Skip to contentSkip to conversation

conntrack doesn't always work when a bridge is used

DISCUSSION Damien Thébault 2 participants 21 messages Dec 19, 2007 – Jan 11, 2008 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hello,

I sent the quoted mail to linux-net with my problem yesterday, but I did a git bisect today and I got the following output :

Quoted 10 lines

2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8 is first bad commit commit 2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8

Author: Patrick McHardy <[email protected]>
Date:   Wed Dec 13 16:54:25 2006 -0800

[NETFILTER]: bridge-netfilter: remove deferred hooks

Remove the deferred hooks and all related code as scheduled in feature-removal-schedule.

Quoted 6 lines
:040000 040000 c49ea947455937566b6129991dde5e86f2453aae 6611736ce5c0fcde7627494b66b9ea94e37ea42e M      Documentation
:040000 040000 d0dd0700fe68f98b52687be3a0c31d73f7b15b81 f8ddf15a0389c5f5b7f2c11d7d0db039a660e1d5 M      include
:040000 040000 dafccf7ff8657be9adca6b28dbd365cdd6c01ca5 3eeb1cb4b16cc5cb698ab559b47ea6b0991d4d3a M      net

With exactly this version, the behaviour is similar with what I see with 2.6.23 and 2.6.24-rc5 (see below).

The original mail :

Quoted 183 lines · Damien Thébault

Hello,

I was trying to use a setup with nat and bridge, but conntrack doesn't work properly (at first I tried rtsp, but since it's an external patch with some modifications, I used ftp for my tests).
I removed everything but the minimal setup to report this bug :

A) one ftp client, on 192.168.1.0/24 (192.168.1.50 or 192.168.1.5 or 192.168.1.150 or 192.168.1.15, see below)
B) one router doing nat
b1) one interface is on 192.168.1.0/24 with the ftp client (192.168.1.70) b2) the other interface is on 192.168.2.0/24 with the ftp server
(192.168.2.70 or 192.168.2.7, see below)
C) one ftp server, on 192.168.2.0/24 (192.168.2.50)

To do my tests, I used only one physical interface on the router, configured with two ip addresses. This interface is either a real interface or a bridge on top of only this same real interface, for exemple :
ifconfig eth0 192.168.1.70 up
ifconfig eth0:0 192.168.2.70 up
or :
ifconfig eth0:0 down
brctl addbr br0
brctl addif br0 eth0
ifconfig eth0 0.0.0.0 up
ifconfig br0 192.168.1.70 up
ifconfig br0:0 192.168.2.70 up

the following netfilter configuration is used :
iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -j MASQUERADE

I tried this once with three computers, and the today with only two computers. But to do this two-computers setup, I had to add another rule to do the trick :
iptables -t nat -A PREROUTING -d 192.168.2.250 -j DNAT --to-destination 192.168.2.50
And I connect from the computer with both 192.168.1.50 and 192.168.2.50 to the ftp server 192.168.2.250, the route for 192.168.2.0/24 goes via the router, is natted and comes back. The behaviour is the same with three distinct computers or with this, so it's not really interesting here.

What I'm seeing, is that when the bridge is used, and when the output ip address of the router is longer or smaller than the ip address of the client, then conntrack doesn't work!
The good address is present after nat_ftp ("wan"-side ip address of ther router), everything seems to work well but the incoming connexion from port 20 is not forwarded (RST is replied to the SYN). If the bridge is not used, or if the two ip addresses have the same length, then it works as expected.

The kernel used on the router is 2.6.24-rc5-git5, and active ftp is used. I collected /proc/net/nf_conntrack on each try, if something else is needed, I'll get what is needed (the packets captures with wireshark look ok in every case, but maybe someone will need them?).

1) without a bridge
* 192.168.1.50 -> 192.168.1.70 [ nat ] 192.168.2.7 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.7
sport=20 dport=51956 packets=5 bytes=334 src=192.168.1.50 dst=192.168.2.250 sport=51956 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.50
dst=192.168.2.250 sport=52709 dport=21 packets=11 bytes=635 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=52709 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2

* 192.168.1.50 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.50
dst=192.168.2.250 sport=52747 dport=21 packets=11 bytes=634 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=52747 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=43608 packets=5 bytes=334 src=192.168.1.50 dst=192.168.2.250 sport=43608 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1

* 192.168.1.5 -> 192.168.1.70 [ nat ] 192.168.2.7 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 117 TIME_WAIT src=192.168.2.50 dst=192.168.2.7
sport=20 dport=41758 packets=5 bytes=334 src=192.168.1.5 dst=192.168.2.250 sport=41758 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1
ipv4 2 tcp 6 431997 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=47397 dport=21 packets=11 bytes=633 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=47397 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2

* 192.168.1.5 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=53851 dport=21 packets=11 bytes=634 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=53851 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=51600 packets=5 bytes=334 src=192.168.1.5 dst=192.168.2.250 sport=51600 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1

* 192.168.1.150-> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.150
dst=192.168.2.250 sport=41108 dport=21 packets=11 bytes=636 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=41108 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=35479 packets=5 bytes=334 src=192.168.1.150 dst=192.168.2.250 sport=35479 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1

* 192.168.1.15 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=46819 packets=5 bytes=334 src=192.168.1.15 dst=192.168.2.250 sport=46819 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.15
dst=192.168.2.250 sport=44839 dport=21 packets=11 bytes=635 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=44839 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2

2) with a bridge
* 192.168.1.50 -> 192.168.1.70 [ nat ] 192.168.2.7 -> 192.168.2.50
ftp doesn't work
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.50
dst=192.168.2.250 sport=56140 dport=21 packets=13 bytes=796 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=56140 packets=13 bytes=1109 [ASSURED] mark=0 secmark=0 use=1

* 192.168.1.50 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431997 ESTABLISHED src=192.168.1.50
dst=192.168.2.250 sport=34334 dport=21 packets=11 bytes=635 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=34334 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=59124 packets=5 bytes=334 src=192.168.1.50 dst=192.168.2.250 sport=59124 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1

* 192.168.1.5 -> 192.168.1.70 [ nat ] 192.168.2.7 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 116 TIME_WAIT src=192.168.2.50 dst=192.168.2.7
sport=20 dport=36148 packets=5 bytes=334 src=192.168.1.5 dst=192.168.2.250 sport=36148 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1
ipv4 2 tcp 6 431996 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=46925 dport=21 packets=11 bytes=633 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=46925 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2

* 192.168.1.5 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp doesn't work
/proc/net/nf_conntrack :
ipv4 2 tcp 6 59 CLOSE_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=60875 packets=4 bytes=282 src=192.168.1.5 dst=192.168.2.250 sport=60875 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1
ipv4 2 tcp 6 431999 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=48877 dport=21 packets=12 bytes=687 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=48877 packets=9 bytes=939 [ASSURED] mark=0 secmark=0 use=2

* 192.168.1.150-> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp doesn't work
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431999 ESTABLISHED src=192.168.1.150
dst=192.168.2.250 sport=33847 dport=21 packets=14 bytes=878 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=33847 packets=14 bytes=1173 [ASSURED] mark=0 secmark=0 use=1

Quoted 12 lines

* 192.168.1.15 -> 192.168.1.70 [ nat ] 192.168.2.70 -> 192.168.2.50
ftp works
/proc/net/nf_conntrack :
ipv4 2 tcp 6 431998 ESTABLISHED src=192.168.1.15
dst=192.168.2.250 sport=46792 dport=21 packets=11 bytes=633 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=46792 packets=8 bytes=880 [ASSURED] mark=0 secmark=0 use=2
ipv4 2 tcp 6 118 TIME_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=56576 packets=5 bytes=334 src=192.168.1.15 dst=192.168.2.250 sport=56576 dport=20 packets=3 bytes=164 [ASSURED] mark=0 secmark=0 use=1

--
Damien Thébault
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 18 lines · Damien Thébault

Hello,

I sent the quoted mail to linux-net with my problem yesterday, but I did a git bisect today and I got the following output :

Quoted 13 lines

2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8 is first bad commit commit 2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8

Author: Patrick McHardy <[email protected]>
Date:   Wed Dec 13 16:54:25 2006 -0800

[NETFILTER]: bridge-netfilter: remove deferred hooks

Remove the deferred hooks and all related code as scheduled in feature-removal-schedule.

Quoted 6 lines
Quoted 3 lines
:040000 040000 c49ea947455937566b6129991dde5e86f2453aae 6611736ce5c0fcde7627494b66b9ea94e37ea42e M      Documentation
:040000 040000 d0dd0700fe68f98b52687be3a0c31d73f7b15b81 f8ddf15a0389c5f5b7f2c11d7d0db039a660e1d5 M      include
:040000 040000 dafccf7ff8657be9adca6b28dbd365cdd6c01ca5 3eeb1cb4b16cc5cb698ab559b47ea6b0991d4d3a M      net

With exactly this version, the behaviour is similar with what I see with 2.6.23 and 2.6.24-rc5 (see below).

Could you capture the conntrack events of the non-working case with (run in parallel):

conntrack -E
conntrack -E expect

#3 lore raw
Quoted 7 lines · Patrick McHardy

Could you capture the conntrack events of the non-working case with (run in parallel):

conntrack -E
conntrack -E expect

Sure, here it is :

conntrack -E :

    [NEW] tcp      6 120 SYN_SENT src=192.168.1.5 dst=192.168.2.250

sport=45090 dport=21 [UNREPLIED] src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090
[UPDATE] tcp 6 60 SYN_RECV src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]

    [NEW] tcp      6 120 SYN_SENT src=127.0.0.1 dst=127.0.0.1

sport=47496 dport=631 [UNREPLIED] src=127.0.0.1 dst=127.0.0.1 sport=631 dport=47496
[UPDATE] tcp 6 120 CLOSE src=127.0.0.1 dst=127.0.0.1 sport=47496
dport=631 src=127.0.0.1 dst=127.0.0.1 sport=631 dport=47496
[DESTROY] tcp 6 src=127.0.0.1 dst=127.0.0.1 sport=47496 dport=631
packets=1 bytes=60 src=127.0.0.1 dst=127.0.0.1 sport=631 dport=47496 packets=0 bytes=0

    [NEW] tcp      6 120 SYN_SENT src=192.168.2.50 dst=192.168.2.70

sport=20 dport=33344 [UNREPLIED] src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20
[UPDATE] tcp 6 60 SYN_RECV src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.2.50
dst=192.168.2.70 sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 120 FIN_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 60 CLOSE_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 10 CLOSE src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 120 FIN_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 60 CLOSE_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 30 LAST_ACK src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 120 TIME_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 10 CLOSE src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]

    [NEW] unknown  2 600 src=192.168.1.1 dst=224.0.0.1 [UNREPLIED]

src=224.0.0.1 dst=192.168.1.1
[DESTROY] tcp 6 src=192.168.2.50 dst=192.168.2.70 sport=20
dport=33344 packets=4 bytes=559 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 packets=4 bytes=216
[DESTROY] tcp 6 src=192.168.1.5 dst=192.168.2.250 sport=45090
dport=21 packets=17 bytes=916 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 packets=12 bytes=1162

conntrack -E expect :

300 proto=6 src=192.168.2.50 dst=192.168.2.70 sport=0 dport=33344

Signature · 1 line
Damien Thebault
#4 lore raw
Quoted 9 lines · Damien Thébault
Quoted 6 lines · Patrick McHardy

Could you capture the conntrack events of the non-working case with (run in parallel):

conntrack -E
conntrack -E expect

Sure, here it is :

That actually looks like it works properly.

New control connection:

Quoted 9 lines
    [NEW] tcp      6 120 SYN_SENT src=192.168.1.5 dst=192.168.2.250

sport=45090 dport=21 [UNREPLIED] src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090
[UPDATE] tcp 6 60 SYN_RECV src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.1.5
dst=192.168.2.250 sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]

New expectation for data connection:

Quoted 3 lines

conntrack -E expect :

300 proto=6 src=192.168.2.50 dst=192.168.2.70 sport=0 dport=33344

New data connection machting expectation, both source and destination properly NATed:

Quoted 10 lines
    [NEW] tcp      6 120 SYN_SENT src=192.168.2.50 dst=192.168.2.70

sport=20 dport=33344 [UNREPLIED] src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20
[UPDATE] tcp 6 60 SYN_RECV src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.2.50
dst=192.168.2.70 sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 120 FIN_WAIT src=192.168.2.50 dst=192.168.2.70

Quoted 8 lines

sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 60 CLOSE_WAIT src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]
[UPDATE] tcp 6 10 CLOSE src=192.168.2.50 dst=192.168.2.70
sport=20 dport=33344 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 [ASSURED]

Data connection closed

Quoted 7 lines

[UPDATE] tcp 6 120 FIN_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 60 CLOSE_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 30 LAST_ACK src=192.168.1.5 dst=192.168.2.250

Quoted 8 lines

sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 120 TIME_WAIT src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]
[UPDATE] tcp 6 10 CLOSE src=192.168.1.5 dst=192.168.2.250
sport=45090 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 [ASSURED]

Control connection closed

Quoted 7 lines

[DESTROY] tcp 6 src=192.168.2.50 dst=192.168.2.70 sport=20
dport=33344 packets=4 bytes=559 src=192.168.1.5 dst=192.168.2.250 sport=33344 dport=20 packets=4 bytes=216

[DESTROY] tcp 6 src=192.168.1.5 dst=192.168.2.250 sport=45090
dport=21 packets=17 bytes=916 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=45090 packets=12 bytes=1162

Both connections destroyed
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 17 lines · Patrick McHardy

That actually looks like it works properly.

New control connection:

[...]

New expectation for data connection:

[...]

New data connection machting expectation, both source and destination properly NATed:

[...]

Data connection closed

Quoted 8 lines

[...]

Control connection closed

[...]

Both connections destroyed

Yes, when I'm using ip addresses with the same length, the conntrack -E output is similar, and it's working.
But if I change the router's "wan"-side ip address to be longer or shorter than the client's ip address, then it's non-working again.

I don't think it's something in the configuration : the results are present on two different computers, one being a x86 little endian debian laptop where I did the bisect, the other being an arm xscale big endian board with a custom distro (nothing funny here, just kernel, drivers, busybox and some utilities).

Well, I'm sorry, I don't want to bother anyone, but those are really the results I'm seeing.

Signature · 1 line
Damien Thebault
#6 lore raw
Quoted 5 lines · Damien Thébault

Yes, when I'm using ip addresses with the same length, the conntrack -E output is similar, and it's working.
But if I change the router's "wan"-side ip address to be longer or shorter than the client's ip address, then it's non-working again.

Quoted 8 lines

I don't think it's something in the configuration : the results are present on two different computers, one being a x86 little endian debian laptop where I did the bisect, the other being an arm xscale big endian board with a custom distro (nothing funny here, just kernel, drivers, busybox and some utilities).

Well, I'm sorry, I don't want to bother anyone, but those are really the results I'm seeing.

Don't worry. I was just wondering because I asked for the output of the *non-working* case :) Please post that and I'll look into it. -
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 4 lines · Patrick McHardy

Don't worry. I was just wondering because I asked for the output of the *non-working* case :) Please post that and I'll look into it.

The fact is that this was the output of the non working case, they are similar. I'm attaching the four files I just made, with both the working and the non-working case.
(I didn't wait the [DESTROY])

Signature · 1 line
Damien Thebault
    [NEW] tcp      6 120 SYN_SENT src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 [UNREPLIED] src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126
 [UPDATE] tcp      6 60 SYN_RECV src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126
 [UPDATE] tcp      6 432000 ESTABLISHED src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126 [ASSURED]
    [NEW] tcp      6 120 SYN_SENT src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 [UNREPLIED] src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20
 [UPDATE] tcp      6 60 SYN_RECV src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20
 [UPDATE] tcp      6 432000 ESTABLISHED src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20 [ASSURED]
 [UPDATE] tcp      6 120 FIN_WAIT src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20 [ASSURED]
 [UPDATE] tcp      6 60 CLOSE_WAIT src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20 [ASSURED]
 [UPDATE] tcp      6 10 CLOSE src=192.168.2.50 dst=192.168.2.70 sport=20 dport=58132 src=192.168.1.5 dst=192.168.2.250 sport=58132 dport=20 [ASSURED]
 [UPDATE] tcp      6 120 FIN_WAIT src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126 [ASSURED]
 [UPDATE] tcp      6 60 CLOSE_WAIT src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126 [ASSURED]
 [UPDATE] tcp      6 30 LAST_ACK src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126 [ASSURED]
 [UPDATE] tcp      6 10 CLOSE src=192.168.1.5 dst=192.168.2.250 sport=55126 dport=21 src=192.168.2.50 dst=192.168.2.70 sport=21 dport=55126 [ASSURED]
300 proto=6 src=192.168.2.50 dst=192.168.2.70 sport=0 dport=58132
Now closing conntrack event dumping...
    [NEW] tcp      6 120 SYN_SENT src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 [UNREPLIED] src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137
 [UPDATE] tcp      6 60 SYN_RECV src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137
 [UPDATE] tcp      6 432000 ESTABLISHED src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137 [ASSURED]
    [NEW] tcp      6 120 SYN_SENT src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 [UNREPLIED] src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20
 [UPDATE] tcp      6 60 SYN_RECV src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20
 [UPDATE] tcp      6 431999 ESTABLISHED src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20 [ASSURED]
 [UPDATE] tcp      6 120 FIN_WAIT src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20 [ASSURED]
 [UPDATE] tcp      6 60 CLOSE_WAIT src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20 [ASSURED]
 [UPDATE] tcp      6 30 LAST_ACK src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20 [ASSURED]
 [UPDATE] tcp      6 120 TIME_WAIT src=192.168.2.50 dst=192.168.2.7 sport=20 dport=44357 src=192.168.1.5 dst=192.168.2.250 sport=44357 dport=20 [ASSURED]
 [UPDATE] tcp      6 120 FIN_WAIT src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137 [ASSURED]
 [UPDATE] tcp      6 30 LAST_ACK src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137 [ASSURED]
 [UPDATE] tcp      6 120 TIME_WAIT src=192.168.1.5 dst=192.168.2.250 sport=55137 dport=21 src=192.168.2.50 dst=192.168.2.7 sport=21 dport=55137 [ASSURED]

300 proto=6 src=192.168.2.50 dst=192.168.2.7 sport=0 dport=44357 Now closing conntrack event dumping...

#8 lore raw
Quoted 8 lines · Damien Thébault
Quoted 3 lines · Patrick McHardy

Don't worry. I was just wondering because I asked for the output of the *non-working* case :) Please post that and I'll look into it.

The fact is that this was the output of the non working case, they are similar. I'm attaching the four files I just made, with both the working and the non-working case.

Thanks. Could you also post a tcpdump and enable conntrack logging by doing "echo 255 >/proc/sys/net/netfilter/nf_conntrack_log_invalid" and post the output of that, if any (you also need to load ipt_LOG in case you're not using some other logging backend).
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 6 lines · Patrick McHardy

Thanks. Could you also post a tcpdump and enable conntrack logging by doing "echo 255 >/proc/sys/net/netfilter/nf_conntrack_log_invalid" and post the output of that, if any (you also need to load ipt_LOG in case you're not using some other logging backend).

I captured three times. The first time ("bad1" files), the reply is coming back, but the ftp client doesn't seem to handle it. The second time ("bad2" files), there is a problem with sequence numbers. And then the last time ("good" files), it's ok.

I had sequence number errors without the previous bridge patch which get merged in net-2.6. So I'll try again with the net-2.6 kernel.

Signature · 1 line
Damien Thebault
#10 lore raw
Quoted 4 lines · Damien Thébault

I had sequence number errors without the previous bridge patch which get merged in net-2.6. So I'll try again with the net-2.6 kernel.

Ok I tried and it's the same behaviour.
Oh and last time I forgot to tell, but I'm not seeing anything in the kernel log.
(I checked that the LOG target was working by adding a rule with iptables on INPUT and trying to connect to this port, the packet was present in the kernel log)

Signature · 5 lines
Damien Thebault
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
In reply to Damien Thébault
Quoted 7 lines · Damien Thébault
Quoted 5 lines · Patrick McHardy

Thanks. Could you also post a tcpdump and enable conntrack logging by doing "echo 255 >/proc/sys/net/netfilter/nf_conntrack_log_invalid" and post the output of that, if any (you also need to load ipt_LOG in case you're not using some other logging backend).

Quoted 7 lines

I captured three times. The first time ("bad1" files), the reply is coming back, but the ftp client doesn't seem to handle it. The second time ("bad2" files), there is a problem with sequence numbers. And then the last time ("good" files), it's ok.

I had sequence number errors without the previous bridge patch which get merged in net-2.6. So I'll try again with the net-2.6 kernel.

Yes, the captures show the effects from the double POSTROUTING invocation. Could you send me captures from the current net-2.6 tree?

#12 lore raw
Quoted 6 lines · Patrick McHardy
Quoted 6 lines

I captured three times. The first time ("bad1" files), the reply is coming back, but the ftp client doesn't seem to handle it. The second time ("bad2" files), there is a problem with sequence numbers. And then the last time ("good" files), it's ok.

Quoted 8 lines
Quoted 2 lines

I had sequence number errors without the previous bridge patch which get merged in net-2.6. So I'll try again with the net-2.6 kernel.

Yes, the captures show the effects from the double POSTROUTING invocation. Could you send me captures from the current net-2.6 tree?

Sure, here they are.
(I used David Miller's net-2.6.25 at 75fa3253609430f28da005da494ce5ad3b5c78a1 )

Signature · 1 line
Damien Thebault
#13 lore raw
Quoted 9 lines · Damien Thébault
Quoted 4 lines · Patrick McHardy

Yes, the captures show the effects from the double POSTROUTING invocation. Could you send me captures from the current net-2.6 tree?

Sure, here they are.
(I used David Miller's net-2.6.25 at 75fa3253609430f28da005da494ce5ad3b5c78a1 )

Thanks. They still show the double POST_ROUTING effects (the retransmitted \0a), but I can't figure out why this would be happening. Please add TRACE rules in both directions for the FTP control traffic and post the output. This will allow to verify that we're indeed dealing with double hook invocations and not some other bug:

modprobe ipt_LOG
iptables -t raw -A OUTPUT -p tcp --dport 21 -j TRACE iptables -t raw -A OUTPUT -p tcp --sport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --dport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --sport 21 -j TRACE

Thanks.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw

2008/1/2 Damien Thébault <[email protected]>:

Quoted 14 lines · Patrick McHardy
Quoted 13 lines

Thanks. They still show the double POST_ROUTING effects (the retransmitted \0a), but I can't figure out why this would be happening. Please add TRACE rules in both directions for the FTP control traffic and post the output. This will allow to verify that we're indeed dealing with double hook invocations and not some other bug:

modprobe ipt_LOG
iptables -t raw -A OUTPUT -p tcp --dport 21 -j TRACE iptables -t raw -A OUTPUT -p tcp --sport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --dport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --sport 21 -j TRACE

Quoted 7 lines
Quoted 2 lines

Thanks.

I captured those files with "tail -n 0 -f /var/log/messages". The first setup (trace1.log) is the "working" one.

Regards.

I tried to use the patch I created earlier (the one adding the hooks again). I said it worked but it does not everytime.

By the way, Patrick, what do you think about this bug? Maybe I shouldn't rely on bridges but it's a useful feature sometimes.

Regards.

Signature · 5 lines
Damien Thebault
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw
Quoted 16 lines · Damien Thébault

2008/1/2 Damien Thébault <[email protected]>:

Quoted 8 lines · Patrick McHardy
Quoted 7 lines

Thanks. They still show the double POST_ROUTING effects (the retransmitted \0a), but I can't figure out why this would be happening. Please add TRACE rules in both directions for the FTP control traffic and post the output. This will allow to verify that we're indeed dealing with double hook invocations and not some other bug:

Quoted 6 lines
Quoted 6 lines

modprobe ipt_LOG
iptables -t raw -A OUTPUT -p tcp --dport 21 -j TRACE iptables -t raw -A OUTPUT -p tcp --sport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --dport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --sport 21 -j TRACE

Quoted 6 lines

I tried to use the patch I created earlier (the one adding the hooks again). I said it worked but it does not everytime.

By the way, Patrick, what do you think about this bug? Maybe I shouldn't rely on bridges but it's a useful feature sometimes.

No, this should work properly. I just tried to reproduce it, but I only get a single POSTROUTING invocation. I tried with real bridged traffic, traffic routed between two different bridge devices and traffic routed between a bridge device and a normal ethernet device, but everything seems to work correctly.

Could you send me the commands you're using to configure your setup and everything (routing, iptables, ...) that could be related?

#17 lore raw
Quoted 13 lines · Patrick McHardy
Quoted 4 lines · Damien Thébault

By the way, Patrick, what do you think about this bug? Maybe I shouldn't rely on bridges but it's a useful feature sometimes.

No, this should work properly. I just tried to reproduce it, but I only get a single POSTROUTING invocation. I tried with real bridged traffic, traffic routed between two different bridge devices and traffic routed between a bridge device and a normal ethernet device, but everything seems to work correctly.

Quoted 4 lines

Could you send me the commands you're using to configure your setup and everything (routing, iptables, ...) that could be related?

On the router, I'm using this script :

ifconfig eth0 0.0.0.0 up
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 192.168.1.70 up
ifconfig br0:0 192.168.2.70 up
iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -j MASQUERADE iptables -t nat -A PREROUTING -d 192.168.2.250 -j DNAT --to-destination 192.168.2.50
modprobe nf_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward

And for logging :

modprobe ipt_LOG
iptables -t raw -A OUTPUT -p tcp --dport 21 -j TRACE iptables -t raw -A OUTPUT -p tcp --sport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --dport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --sport 21 -j TRACE

I only have one interface (eth0), that's why I use br0 and br0:0, so the wireshark captures show each packet twice, input on br0 and output on br0:0 (or input on br0:0 and output on br0) when capturing on eth0.

On the ftp client/server :

ifconfig eth2 192.168.1.50
ifconfig eth2:0 192.168.2.50
ip route del 192.168.2.0/24
ip route add 192.168.2.0/24 dev eth2 via 192.168.1.70

And then I try to connect to 192.168.2.250, this will use the router 192.168.1.70 on eth2, wille be DNATted to 192.168.2.50 and will come back on eth2:0 on the ftp server.

Like the router captures, we have eth2 and eth2:0 together when capturing on eth2.

This configuration will work fine, but if I run any of this on the router, it will not work well anymore :

ifconfig br0:0 192.168.2.7 up

or

ifconfig br0:0 192.168.2.170 up

I don't think I'm using anything else.

Signature · 1 line
Damien Thebault
#18 lore raw
Quoted 57 lines · Damien Thébault
Quoted 7 lines · Patrick McHardy

No, this should work properly. I just tried to reproduce it, but I only get a single POSTROUTING invocation. I tried with real bridged traffic, traffic routed between two different bridge devices and traffic routed between a bridge device and a normal ethernet device, but everything seems to work correctly.

Quoted 5 lines

Could you send me the commands you're using to configure your setup and everything (routing, iptables, ...) that could be related?

On the router, I'm using this script :

ifconfig eth0 0.0.0.0 up
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 192.168.1.70 up
ifconfig br0:0 192.168.2.70 up
iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -j MASQUERADE iptables -t nat -A PREROUTING -d 192.168.2.250 -j DNAT --to-destination 192.168.2.50
modprobe nf_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward

And for logging :

modprobe ipt_LOG
iptables -t raw -A OUTPUT -p tcp --dport 21 -j TRACE iptables -t raw -A OUTPUT -p tcp --sport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --dport 21 -j TRACE iptables -t raw -A PREROUTING -p tcp --sport 21 -j TRACE

I only have one interface (eth0), that's why I use br0 and br0:0, so the wireshark captures show each packet twice, input on br0 and output on br0:0 (or input on br0:0 and output on br0) when capturing on eth0.

On the ftp client/server :

ifconfig eth2 192.168.1.50
ifconfig eth2:0 192.168.2.50
ip route del 192.168.2.0/24
ip route add 192.168.2.0/24 dev eth2 via 192.168.1.70

And then I try to connect to 192.168.2.250, this will use the router 192.168.1.70 on eth2, wille be DNATted to 192.168.2.50 and will come back on eth2:0 on the ftp server.

Like the router captures, we have eth2 and eth2:0 together when capturing on eth2.

This configuration will work fine, but if I run any of this on the router, it will not work well anymore :

Quoted 8 lines

ifconfig br0:0 192.168.2.7 up

or

ifconfig br0:0 192.168.2.170 up

I don't think I'm using anything else.

Thanks. Its the DNAT rule thats causing this, the bridge netfilter code calls dst_output directly for bridged dnated frames, causing these hook invocations:

PREROUTING
dst_output() POSTROUTING
FORWARD
POSTROUTING

which is obviously broken. I'll see if I can come up with a fix for this.

-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#19 lore raw
Quoted 17 lines · Patrick McHardy
Quoted 10 lines · Damien Thébault

On the router, I'm using this script :

ifconfig eth0 0.0.0.0 up
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 192.168.1.70 up
ifconfig br0:0 192.168.2.70 up
iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -j MASQUERADE iptables -t nat -A PREROUTING -d 192.168.2.250 -j DNAT --to-destination 192.168.2.50

Thanks. Its the DNAT rule thats causing this, the bridge netfilter code calls dst_output directly for bridged dnated frames, causing these hook invocations:

Quoted 7 lines

PREROUTING
dst_output() POSTROUTING
FORWARD
POSTROUTING

which is obviously broken. I'll see if I can come up with a fix for this.

It appears this has always been broken. Could you test this patch please?

The bridge code only calls dst_output to get a new destination MAC address for the DNATed packet when the new destination is reachable on the same bridge, so this patch simply hands the packet to the neighbour output function without going through the IP stack.

net/bridge/br_netfilter.c +9 -4
index c1757c7..362fe89 100644
@@ -285,12 +285,17 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
 	skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
 
 	skb->dev = bridge_parent(skb->dev);
-	if (!skb->dev)
-		kfree_skb(skb);
-	else {
+	if (skb->dev) {
+		struct dst_entry *dst = skb->dst;
+
 		nf_bridge_pull_encap_header(skb);
-		skb->dst->output(skb);
+
+		if (dst->hh)
+			return neigh_hh_output(dst->hh, skb);
+		else if (dst->neighbour)
+			return dst->neighbour->output(skb);
 	}
+	kfree_skb(skb);
 	return 0;
 }
 
#20 lore raw
Quoted 53 lines · Patrick McHardy
Quoted 17 lines · Patrick McHardy
Quoted 10 lines · Damien Thébault

On the router, I'm using this script :

ifconfig eth0 0.0.0.0 up
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 192.168.1.70 up
ifconfig br0:0 192.168.2.70 up
iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -j MASQUERADE iptables -t nat -A PREROUTING -d 192.168.2.250 -j DNAT --to-destination 192.168.2.50

Thanks. Its the DNAT rule thats causing this, the bridge netfilter code calls dst_output directly for bridged dnated frames, causing these hook invocations:

Quoted 7 lines

PREROUTING
dst_output() POSTROUTING
FORWARD
POSTROUTING

which is obviously broken. I'll see if I can come up with a fix for this.

It appears this has always been broken. Could you test this patch please?

The bridge code only calls dst_output to get a new destination MAC address for the DNATed packet when the new destination is reachable on the same bridge, so this patch simply hands the packet to the neighbour output function without going through the IP stack.

net/bridge/br_netfilter.c +3 -4
index c1757c7..362fe89 100644
@@ -285,12 +285,17 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
        skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
 
        skb->dev = bridge_parent(skb->dev);
-       if (!skb->dev)
-               kfree_skb(skb);
-       else {
+       if (skb->dev) {
+               struct dst_entry *dst = skb->dst;
+
                nf_bridge_pull_encap_header(skb);
-               skb->dst->output(skb);

net/bridge/br_netfilter.c static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) · line 301

Quoted 10 lines
net/bridge/br_netfilter.c +6 -0
+
+               if (dst->hh)
+                       return neigh_hh_output(dst->hh, skb);
+               else if (dst->neighbour)
+                       return dst->neighbour->output(skb);
        }
+       kfree_skb(skb);
        return 0;
 }
 

I confirm that this patch solves the problem with this setup, thanks!

Does this mean that without this patch, DNAT doesn't work (correctly) on a bridge?

Signature · 1 line
Damien Thebault
#21 lore raw
Quoted 22 lines · Damien Thébault
Quoted 22 lines
net/bridge/br_netfilter.c +8 -4
index c1757c7..362fe89 100644
@@ -285,12 +285,17 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
        skb->nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
 
        skb->dev = bridge_parent(skb->dev);
-       if (!skb->dev)
-               kfree_skb(skb);
-       else {
+       if (skb->dev) {
+               struct dst_entry *dst = skb->dst;
+
                nf_bridge_pull_encap_header(skb);
-               skb->dst->output(skb);
+
+               if (dst->hh)
+                       return neigh_hh_output(dst->hh, skb);
+               else if (dst->neighbour)
+                       return dst->neighbour->output(skb);
        }
Quoted 8 lines

net/bridge/br_netfilter.c static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) · line 301

Quoted 6 lines
net/bridge/br_netfilter.c +1 -0
+       kfree_skb(skb);
        return 0;
 }
 

I confirm that this patch solves the problem with this setup, thanks!

Thanks a lot for testing and providing all the data.

Quoted 2 lines

Does this mean that without this patch, DNAT doesn't work (correctly) on a bridge?

DNAT itself works, but the incorrect POSTROUTING hook invocation can break other things like packet mangling by NAT helpers.

#22 lore raw
In reply to Damien Thébault
Quoted 22 lines · Damien Thébault

Hello,

I sent the quoted mail to linux-net with my problem yesterday, but I did a git bisect today and I got the following output :

Quoted 16 lines

2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8 is first bad commit commit 2bf540b73ed5b304e84bb4d4c390d49d1cfa0ef8

Author: Patrick McHardy <[email protected]>
Date:   Wed Dec 13 16:54:25 2006 -0800

[NETFILTER]: bridge-netfilter: remove deferred hooks

Remove the deferred hooks and all related code as scheduled in feature-removal-schedule.

:040000 040000 c49ea947455937566b6129991dde5e86f2453aae 6611736ce5c0fcde7627494b66b9ea94e37ea42e M      Documentation
:040000 040000 d0dd0700fe68f98b52687be3a0c31d73f7b15b81 f8ddf15a0389c5f5b7f2c11d7d0db039a660e1d5 M      include
:040000 040000 dafccf7ff8657be9adca6b28dbd365cdd6c01ca5 3eeb1cb4b16cc5cb698ab559b47ea6b0991d4d3a M      net

This morning I reverted the patch and ported it to work with the net-2.6.25 and 2.6.23 kernels. With it, the behaviour seems to be good again (I didn't test a lot so I don't know if anything else is broken by this).
I don't know yet if it solves my RTSP conntrack problem too.

(Yes I know this is not really the good way to handle this, but since the removal of the deferred hooks before 2.6.20, there was a lot of changes in this area, so I just tried to see if it was working with the current kernel)

I'm attaching the two patchs if anyone needs it.

Signature · 1 line
Damien Thebault
Documentation/feature-removal-schedule.txt +16 -0
index 0ae682b..919f331 100644
@@ -181,6 +181,22 @@ Who:	Nick Piggin <[email protected]>
 
 ---------------------------
 
+What:	Bridge netfilter deferred IPv4/IPv6 output hook calling
+When:	January 2007
+Why:	The deferred output hooks are a layering violation causing unusual
+	and broken behaviour on bridge devices. Examples of things they
+	break include QoS classifation using the MARK or CLASSIFY targets,
+	the IPsec policy match and connection tracking with VLANs on a
+	bridge. Their only use is to enable bridge output port filtering
+	within iptables with the physdev match, which can also be done by
+	combining iptables and ebtables using netfilter marks. Until it
+	will get removed the hook deferral is disabled by default and is
+	only enabled when needed.
+
+Who:	Patrick McHardy <[email protected]>
+
+---------------------------
+
 What:	PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
 When:	October 2008
 Why:	The stacking of class devices makes these values misleading and
include/linux/netfilter_bridge.h +1 -0
index 499aa93..d9487b9 100644
@@ -83,6 +83,7 @@ struct bridge_skb_cb {
 	} daddr;
 };
 
+extern int brnf_deferred_hooks;
 #else
 #define nf_bridge_maybe_copy_header(skb)	(0)
 #define nf_bridge_pad(skb)			(0)
include/linux/netfilter_ipv4.h +3 -1
index 9a10092..b96952a 100644
@@ -36,6 +36,7 @@
 #define NFC_IP_DST_PT		0x0400
 /* Something else about the proto */
 #define NFC_IP_PROTO_UNKNOWN	0x2000
+#endif /* ! __KERNEL__ */
 
 /* IP Hooks */
 /* After promisc drops, checksum checks. */
@@ -49,7 +50,6 @@
 /* Packets about to hit the wire. */
 #define NF_IP_POST_ROUTING	4
 #define NF_IP_NUMHOOKS		5
-#endif /* ! __KERNEL__ */
 
 enum nf_ip_hook_priorities {
 	NF_IP_PRI_FIRST = INT_MIN,
@@ -57,8 +57,10 @@ enum nf_ip_hook_priorities {
 	NF_IP_PRI_RAW = -300,
 	NF_IP_PRI_SELINUX_FIRST = -225,
 	NF_IP_PRI_CONNTRACK = -200,
+	NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
 	NF_IP_PRI_MANGLE = -150,
 	NF_IP_PRI_NAT_DST = -100,
+	NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
 	NF_IP_PRI_FILTER = 0,
 	NF_IP_PRI_NAT_SRC = 100,
 	NF_IP_PRI_SELINUX_LAST = 225,
include/linux/netfilter_ipv6.h +3 -1
index 3475a65..07133c9 100644
@@ -40,6 +40,7 @@
 #define NFC_IP6_DST_PT           0x0400
 /* Something else about the proto */
 #define NFC_IP6_PROTO_UNKNOWN    0x2000
+#endif /* ! __KERNEL__ */
 
 /* IP6 Hooks */
 /* After promisc drops, checksum checks. */
@@ -53,7 +54,6 @@
 /* Packets about to hit the wire. */
 #define NF_IP6_POST_ROUTING	4
 #define NF_IP6_NUMHOOKS		5
-#endif /* ! __KERNEL__ */
 
 
 enum nf_ip6_hook_priorities {
@@ -61,8 +61,10 @@ enum nf_ip6_hook_priorities {
 	NF_IP6_PRI_CONNTRACK_DEFRAG = -400,
 	NF_IP6_PRI_SELINUX_FIRST = -225,
 	NF_IP6_PRI_CONNTRACK = -200,
+	NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
 	NF_IP6_PRI_MANGLE = -150,
 	NF_IP6_PRI_NAT_DST = -100,
+	NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
 	NF_IP6_PRI_FILTER = 0,
 	NF_IP6_PRI_NAT_SRC = 100,
 	NF_IP6_PRI_SELINUX_LAST = 225,
net/bridge/br_netfilter.c +172 -15

236 lines not on this page · raw message

net/netfilter/xt_physdev.c +8 -4
index 678b683..6e7eb9b 100644
@@ -104,16 +104,20 @@ physdev_mt_check(const char *tablename, const void *ip,
 	if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
 	    info->bitmask & ~XT_PHYSDEV_OP_MASK)
 		return false;
-	if (info->bitmask & XT_PHYSDEV_OP_OUT &&
+	if (brnf_deferred_hooks == 0 &&
+	    info->bitmask & XT_PHYSDEV_OP_OUT &&
 	    (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) ||
 	     info->invert & XT_PHYSDEV_OP_BRIDGED) &&
 	    hook_mask & ((1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
 			 (1 << NF_INET_POST_ROUTING))) {
 		printk(KERN_WARNING "physdev match: using --physdev-out in the "
 		       "OUTPUT, FORWARD and POSTROUTING chains for non-bridged "
-		       "traffic is not supported anymore.\n");
-		if (hook_mask & (1 << NF_INET_LOCAL_OUT))
-			return false;
+		       "traffic is deprecated and breaks other things, it will "
+		       "be removed in January 2007. See Documentation/"
+		       "feature-removal-schedule.txt for details. This doesn't "
+		       "affect you in case you're using it for purely bridged "
+		       "traffic.\n");
+		brnf_deferred_hooks = 1;
 	}
 	return true;
 }
Documentation/feature-removal-schedule.txt +16 -0
Index: Documentation/feature-removal-schedule.txt
===================================================================
@@ -154,6 +154,22 @@
 
 ---------------------------
 
+What:	Bridge netfilter deferred IPv4/IPv6 output hook calling
+When:	January 2007
+Why:	The deferred output hooks are a layering violation causing unusual
+	and broken behaviour on bridge devices. Examples of things they
+	break include QoS classifation using the MARK or CLASSIFY targets,
+	the IPsec policy match and connection tracking with VLANs on a
+	bridge. Their only use is to enable bridge output port filtering
+	within iptables with the physdev match, which can also be done by
+	combining iptables and ebtables using netfilter marks. Until it
+	will get removed the hook deferral is disabled by default and is
+	only enabled when needed.
+
+Who:	Patrick McHardy <[email protected]>
+
+---------------------------
+
 What:	PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
 When:	October 2008
 Why:	The stacking of class devices makes these values misleading and
include/linux/netfilter_bridge.h +1 -0
Index: include/linux/netfilter_bridge.h
===================================================================
@@ -82,6 +82,7 @@
 	} daddr;
 };
 
+extern int brnf_deferred_hooks;
 #else
 #define nf_bridge_maybe_copy_header(skb)	(0)
 #define nf_bridge_pad(skb)			(0)
include/linux/netfilter_ipv4.h +2 -0
Index: include/linux/netfilter_ipv4.h
===================================================================
@@ -57,8 +57,10 @@
 	NF_IP_PRI_RAW = -300,
 	NF_IP_PRI_SELINUX_FIRST = -225,
 	NF_IP_PRI_CONNTRACK = -200,
+	NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
 	NF_IP_PRI_MANGLE = -150,
 	NF_IP_PRI_NAT_DST = -100,
+	NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
 	NF_IP_PRI_FILTER = 0,
 	NF_IP_PRI_NAT_SRC = 100,
 	NF_IP_PRI_SELINUX_LAST = 225,
include/linux/netfilter_ipv6.h +2 -0
Index: include/linux/netfilter_ipv6.h
===================================================================
@@ -62,8 +62,10 @@
 	NF_IP6_PRI_CONNTRACK_DEFRAG = -400,
 	NF_IP6_PRI_SELINUX_FIRST = -225,
 	NF_IP6_PRI_CONNTRACK = -200,
+	NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
 	NF_IP6_PRI_MANGLE = -150,
 	NF_IP6_PRI_NAT_DST = -100,
+	NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
 	NF_IP6_PRI_FILTER = 0,
 	NF_IP6_PRI_NAT_SRC = 100,
 	NF_IP6_PRI_SELINUX_LAST = 225,
net/bridge/br_netfilter.c +174 -15

239 lines not on this page · raw message

net/netfilter/xt_physdev.c +8 -4
Index: net/netfilter/xt_physdev.c
===================================================================
@@ -110,16 +110,20 @@
 	if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
 	    info->bitmask & ~XT_PHYSDEV_OP_MASK)
 		return false;
-	if (info->bitmask & XT_PHYSDEV_OP_OUT &&
+	if (brnf_deferred_hooks == 0 &&
+	    info->bitmask & XT_PHYSDEV_OP_OUT &&
 	    (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) ||
 	     info->invert & XT_PHYSDEV_OP_BRIDGED) &&
 	    hook_mask & ((1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
 			 (1 << NF_IP_POST_ROUTING))) {
 		printk(KERN_WARNING "physdev match: using --physdev-out in the "
 		       "OUTPUT, FORWARD and POSTROUTING chains for non-bridged "
-		       "traffic is not supported anymore.\n");
-		if (hook_mask & (1 << NF_IP_LOCAL_OUT))
-			return false;
+		       "traffic is deprecated and breaks other things, it will "
+		       "be removed in January 2007. See Documentation/"
+		       "feature-removal-schedule.txt for details. This doesn't "
+		       "affect you in case you're using it for purely bridged "
+		       "traffic.\n");
+		brnf_deferred_hooks = 1;
 	}
 	return true;
 }