Skip to contentSkip to conversation

2.6.12: connection tracking broken?

DISCUSSION Chris Rankin 13 participants 40 messages Jun 18, 2005 – Jun 28, 2005

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi,

I have just tried upgrading my firewall to 2.6.12, but neither of the following rules in my FORWARD table was allowing return traffic:

1109 814K ACCEPT all -- ppp0 br0 anywhere anywhere ctstate
RELATED,ESTABLISHED
11M 13G ACCEPT all -- ppp0 br0 anywhere anywhere state
RELATED,ESTABLISHED

I have currently returned to using 2.6.11.11, where the identical configuration works fine. br0 is a bridge device containing two e100 devices, and ppp0 is my PPPoE DSL link. I am using iptables 1.3.1.

Cheers,
Chris

___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

#1 lore raw
Quoted 4 lines

Hi,

I have just tried upgrading my firewall to 2.6.12, but neither of the following rules in my FORWARD table was allowing return traffic:

You forget about INPUT and OUTPUT. If you drop everything in INPUT, there's nothing to FORWARD.

Quoted 8 lines

1109 814K ACCEPT all -- ppp0 br0 anywhere anywhere ctstate
RELATED,ESTABLISHED
11M 13G ACCEPT all -- ppp0 br0 anywhere anywhere state
RELATED,ESTABLISHED

I have currently returned to using 2.6.11.11, where the identical configuration works fine. br0 is a bridge device containing two e100 devices, and ppp0 is my PPPoE DSL link. I am using iptables 1.3.1.

Jan Engelhardt

Signature · 2 lines
| Gesellschaft fuer Wissenschaftliche Datenverarbeitung Goettingen,
| Am Fassberg, 37077 Goettingen, www.gwdg.de
#2 lore raw
Quoted 5 lines · Jan Engelhardt
Quoted 2 lines

I have just tried upgrading my firewall to 2.6.12, but neither of the following rules in my FORWARD table was allowing return traffic:

You forget about INPUT and OUTPUT. If you drop everything in INPUT, there's nothing to FORWARD.

No. INPUT/OUTPUT rules have nothing to do with FORWARDed traffic, since a packet is either locally destined (INPUT), locally originated (OUTPUT) or being forwarded (FORWARD).

Quoted 8 lines
Quoted 8 lines

1109 814K ACCEPT all -- ppp0 br0 anywhere anywhere ctstate
RELATED,ESTABLISHED
11M 13G ACCEPT all -- ppp0 br0 anywhere anywhere state
RELATED,ESTABLISHED

I have currently returned to using 2.6.11.11, where the identical configuration works fine. br0 is a bridge device containing two e100 devices, and ppp0 is my PPPoE DSL link. I am using iptables 1.3.1.

Did you have /proc/sys/net/ipv4/ip_forward turned on?

Signature · 2 lines
[ Tobias DiPasquale ]
0x636f6465736c696e67657240676d61696c2e636f6d
#3 lore raw
Quoted 1 line · --- Tobias DiPasquale

Did you have /proc/sys/net/ipv4/ip_forward turned on?

Yes, because otherwise it wouldn't work in 2.6.11.11 either. My userspace environment is identical between 2.6.12 an 2.6.11.11, but the RELATED and ESTABLISHED packets aren't forwarded across the bridge in 2.6.12.

And no, I haven't tried recompiling my userspace iptables tools. Why would this make any difference? "iptables -L -v" reports exactly what I expect to see.

Cheers,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

#4 lore raw
In reply to Jan Engelhardt
Quoted 2 lines · Jan Engelhardt

You forget about INPUT and OUTPUT. If you drop everything in INPUT, there's nothing to FORWARD.

he was talking about iptables, not ipchains.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#5 lore raw
In reply to Chris Rankin
Quoted 2 lines

I have just tried upgrading my firewall to 2.6.12, but neither of the following rules in my FORWARD table was allowing return traffic:

This seems to happen only if you use bridge interfaces, as you said it is something related to connection tracking otherwise netfilter seems to work ok.

I have sent this right now to the bridge list, I'm copying it here so that more info is available about this bug.

---------------------------------------------------------------------------
Hi!

As noted by Chris Rankin on a mail to netfilter-devel and to the linux-kernel mailing list (subject: 2.6.12: connection tracking broken?), there is a problem with the connection tracking of iptables when one of the interfaces is a bridge.

On my tests here I have setup a connection between two machines using a real interface (eth0) and then the same setup using a bridge interface (br0) to which that interface had been enslaved:

The setup had modules ipt_LOG, ipt_state, ip_conntrack, iptable_filter and ip_tables loaded, as well as bridge and I loaded a simple set of rules, exactly the same set each time but changing the interface name, I'll just write the setup for br0, but the setup was the same one for eth0 with that little change:

iptables -A INPUT -i br0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -i br0 -j LOG --log-level 7 --log-prefix "NOTESTABLISHED " iptables -A INPUT -i br0 -j DROP

this set of rules with eth0 on them worked ok when I tried to telnet a port on a remote machine (192.168.0.1) from the local machine (192.168.0.2), concretelly the test was a telnet to port 22 where the ssh daemon was listening. However, when I did the same test using the br0 interface, I got this logged:

NOTESTABLISHED IN=br0 OUT= PHYSIN=eth0 MAC=00:50:ba:54:39:8c:00:48:54:6a:58:90:08:00 SRC=192.168.0.1 DST=192.168.0.2 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=22 DPT=48448 WINDOW=5792 RES=0x00 ACK SYN URGP=0

doing a grep for 192.168.0.1 on /proc/net/ip_conntrack* returned nothing, however netstat showed the connection:
tcp 0 1 192.168.0.2:48448 192.168.0.1:22 SYN_SENT

I believe that iptables works ok execept for the connection tracking, but I have not tested this fully.

Machines were I tried this were a Pentium III and an AMD K6II both with kernel 2.6.12, I know this is happening at least from RC5, but at that time I didn't have the time to check and I thought it was due to the kernel bridge firewall being loaded, the tests I did today with 2.6.12 final didn't have the kernel bridge firewall, just normal bridge and normal iptables.

If you need any other info to check this just ask for it.

Regards...

Signature · 1 line
Manty/BestiaTester -> http://manty.net
#6 lore raw
Quoted 2 lines

I have sent this right now to the bridge list, I'm copying it here so that more info is available about this bug.

I have selected patches from 2.6.12 that I thought could be related to this issue, and I have finaly identified this patch...

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=b31e5b1bb53b99dfd5e890aa07e943aff114ae1c

as the patch causing the problem, I have reversed it on my kernel tree and now the firewall is working again.

I have not really looked at what the patch does and how it does that, I have just identified it as the one causing the break of this connection tracking relating to the bridges.

It seems this is affecting more stuff than the connection tracking on bridges, I have a friend also suffering problems relating to the firewall in 2.6.12 and nothing to do with the bridge, but he is not around now so I cannot confirm it is due to this patch also. His problem may be something related to loopback. I'll try to contact him tomorrow and tell him to test with this patch reversed.

Regards...

Signature · 1 line
Manty/BestiaTester -> http://manty.net
#7 lore raw
Quoted 7 lines · Santiago Garcia Mantinan
Quoted 2 lines

I have sent this right now to the bridge list, I'm copying it here so that more info is available about this bug.

I have selected patches from 2.6.12 that I thought could be related to this issue, and I have finaly identified this patch...

Quoted 8 lines

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=b31e5b1bb53b99dfd5e890aa07e943aff114ae1c

as the patch causing the problem, I have reversed it on my kernel tree and now the firewall is working again.

I have not really looked at what the patch does and how it does that, I have just identified it as the one causing the break of this connection tracking relating to the bridges.

The patch drops the conntrack reference when a packet leaves IP to avoid problems with module unload because of indefinitely queued packets. The bridge-netfilter code defers calling of some NF_IP_* hooks to the bridge layer, when the conntrack reference is already gone, so the entry is neither confirmed (enters the hashtable) nor available for use by matches or targets. Reverting the patch is not a good option, I'll look into other possiblities.

Regards
Patrick

#8 lore raw
Quoted 3 lines · Patrick McHardy

The bridge-netfilter code defers calling of some NF_IP_* hooks to the bridge layer, when the conntrack reference is already gone, so the entry

Why does it defer them at all? Shouldn't the fact that the device is bridged be transparent to the IP layer?

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#9 lore raw

From: Herbert Xu <[email protected]>
Date: Mon, 20 Jun 2005 10:05:42 +1000

Quoted 7 lines
Quoted 3 lines · Patrick McHardy

The bridge-netfilter code defers calling of some NF_IP_* hooks to the bridge layer, when the conntrack reference is already gone, so the entry

Why does it defer them at all? Shouldn't the fact that the device is bridged be transparent to the IP layer?

The bridge netfilter layer uses netif_rx(skb) at the deepest level in order to avoid too deep stack usage.

This is also why the NF_HOOK*() macros were semantically changed a little bit several months ago.

#10 lore raw
Quoted 8 lines · David S. Miller

From: Herbert Xu <[email protected]>
Date: Mon, 20 Jun 2005 10:05:42 +1000

Quoted 2 lines

Why does it defer them at all? Shouldn't the fact that the device is bridged be transparent to the IP layer?

The bridge netfilter layer uses netif_rx(skb) at the deepest level in order to avoid too deep stack usage.

Sorry, but I don't see the connection between this and deferring NF_IP_* hooks on the transmit path.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#11 lore raw
In reply to Herbert Xu
Quoted 7 lines · Herbert Xu
Quoted 3 lines · Patrick McHardy

The bridge-netfilter code defers calling of some NF_IP_* hooks to the bridge layer, when the conntrack reference is already gone, so the entry

Why does it defer them at all? Shouldn't the fact that the device is bridged be transparent to the IP layer?

I couldn't figure out the reason, it seems to have something to do with setting up device pointers for iptables and ebtables. It looks like the only way to fix this problem without keeping the conntrack reference while packets are queued at the device is to avoid defering the NF_IP_* hooks. Bart, can you explain why the hooks are defered please?

Regards
Patrick

#12 lore raw

Op ma, 20-06-2005 te 04:45 +0200, schreef Patrick McHardy:

Quoted 9 lines · Herbert Xu
Quoted 7 lines
Quoted 3 lines · Patrick McHardy

The bridge-netfilter code defers calling of some NF_IP_* hooks to the bridge layer, when the conntrack reference is already gone, so the entry

Why does it defer them at all? Shouldn't the fact that the device is bridged be transparent to the IP layer?

Quoted 6 lines

I couldn't figure out the reason, it seems to have something to do with setting up device pointers for iptables and ebtables. It looks like the only way to fix this problem without keeping the conntrack reference while packets are queued at the device is to avoid defering the NF_IP_* hooks. Bart, can you explain why the hooks are defered please?

This is done so that iptables knows which bridge port the output device is, using the iptables physdev match.

Can't you release the conntrack reference with a function registered on the POSTROUTING hook with a prio higher than nat POSTROUTING (or something like that)?

cheers,
Bart

#13 lore raw
Quoted 6 lines · Bart De Schuymer

Op ma, 20-06-2005 te 04:45 +0200, schreef Patrick McHardy:

Quoted 1 line

Bart, can you explain why the hooks are defered please?

This is done so that iptables knows which bridge port the output device is, using the iptables physdev match.

In which cases is this necessary? AFAICT the output device is determined in br_handle_frame_finish() for a normally bridged packet.

Quoted 3 lines

Can't you release the conntrack reference with a function registered on the POSTROUTING hook with a prio higher than nat POSTROUTING (or something like that)?

We would have to hold the reference while the packet is queued at the device for the bridge case, which we want to avoid.

Regards
Patrick

#14 lore raw

Op ma, 20-06-2005 te 14:15 +0200, schreef Patrick McHardy:

Quoted 10 lines
Quoted 6 lines · Bart De Schuymer

Op ma, 20-06-2005 te 04:45 +0200, schreef Patrick McHardy:

Quoted 1 line

Bart, can you explain why the hooks are defered please?

This is done so that iptables knows which bridge port the output device is, using the iptables physdev match.

In which cases is this necessary? AFAICT the output device is determined in br_handle_frame_finish() for a normally bridged packet.

When the _routing_ decision sends the packet to br0 (a bridge device), it is unknown which bridge port(s) the packet will be sent out. This is only known after the packet enters the bridge code. Therefore, for iptables to know the bridge port out device, the hooks must be postponed until in the bridge code.

Quoted 6 lines
Quoted 3 lines

Can't you release the conntrack reference with a function registered on the POSTROUTING hook with a prio higher than nat POSTROUTING (or something like that)?

We would have to hold the reference while the packet is queued at the device for the bridge case, which we want to avoid.

Trust me, people will complain if they can no longer use the physdev match for routed packets.
People using a bridging firewall will just have to live with the fact that the reference is held until in the bridge code.

cheers,
Bart

#15 lore raw

The changes were originally made to fix conntrack unload problems with raw sockets. My original patch performed the nf_reset in the socket code, but Patrick suggested moving it to ip_output. The below patch reverts the ip_output changes, and implements the original suggested changes to raw socket handling.

While this is unlikely to be the permanent solution, it will fix the current bridging problems while retaining the raw socket fixes. I'd suggest that this could be included in -stable while researching other solutions.

Phil

net/ipv4/ip_output.c +0 -2
diff -purN linux-orig/net/ipv4/ip_output.c linux-new/net/ipv4/ip_output.c
@@ -196,8 +196,6 @@ static inline int ip_finish_output2(stru
 	nf_debug_ip_finish_output2(skb);
 #endif /*CONFIG_NETFILTER_DEBUG*/
 
-	nf_reset(skb);
-
 	if (hh) {
 		int hh_alen;
 
net/ipv4/netfilter/ip_conntrack_standalone.c +7 -0
diff -purN linux-orig/net/ipv4/netfilter/ip_conntrack_standalone.c linux-new/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -432,6 +432,13 @@ static unsigned int ip_conntrack_defrag(
 				        const struct net_device *out,
 				        int (*okfn)(struct sk_buff *))
 {
+#if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
+	/* Previously seen (loopback)?  Ignore.  Do this before
+           fragment check. */
+	if ((*pskb)->nfct)
+		return NF_ACCEPT;
+#endif
+
 	/* Gather fragments. */
 	if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
 		*pskb = ip_ct_gather_frags(*pskb,
net/packet/af_packet.c +6 -0
diff -purN linux-orig/net/packet/af_packet.c linux-new/net/packet/af_packet.c
@@ -274,6 +274,9 @@ static int packet_rcv_spkt(struct sk_buf
 	dst_release(skb->dst);
 	skb->dst = NULL;
 
+	/* drop conntrack reference */
+	nf_reset(skb);
+
 	spkt = (struct sockaddr_pkt*)skb->cb;
 
 	skb_push(skb, skb->data-skb->mac.raw);
@@ -517,6 +520,9 @@ static int packet_rcv(struct sk_buff *sk
 	dst_release(skb->dst);
 	skb->dst = NULL;
 
+	/* drop conntrack reference */
+	nf_reset(skb);
+
 	spin_lock(&sk->sk_receive_queue.lock);
 	po->stats.tp_packets++;
 	__skb_queue_tail(&sk->sk_receive_queue, skb);
#16 lore raw
Quoted 10 lines · Phil Oester

The changes were originally made to fix conntrack unload problems with raw sockets. My original patch performed the nf_reset in the socket code, but Patrick suggested moving it to ip_output. The below patch reverts the ip_output changes, and implements the original suggested changes to raw socket handling.

While this is unlikely to be the permanent solution, it will fix the current bridging problems while retaining the raw socket fixes. I'd suggest that this could be included in -stable while researching other solutions.

I disagree. We will probably have a final solution within a few days, so I don't think we need to submit "temporary" fixes yet. Your patch actually causes a regression for people not using bringe-netfilter, unplugging a network cable can cause the conntrack module to become unloadable again.

Regards
Patrick

#17 lore raw
In reply to Bart De Schuymer
Quoted 5 lines · Bart De Schuymer

When the _routing_ decision sends the packet to br0 (a bridge device), it is unknown which bridge port(s) the packet will be sent out. This is only known after the packet enters the bridge code. Therefore, for iptables to know the bridge port out device, the hooks must be postponed until in the bridge code.

This seems to be a really bad idea, for a single match that violates layering we need to deal with this inconsistency. It's not just the conntrack reference, with IPsec the packet passed to the defered hooks is totally different from when it was still inside IP, which for example breaks the policy match.

Quoted 2 lines

Trust me, people will complain if they can no longer use the physdev match for routed packets.

I'm sure they will, now that they got used to it. Why can't people match on the bridge port inside ebtables and only match on the device within iptables? Is there a case that can't be handled this way?

Regards
Patrick

#18 lore raw

Op di, 21-06-2005 te 01:22 +0200, schreef Patrick McHardy:

Quoted 5 lines

This seems to be a really bad idea, for a single match that violates layering we need to deal with this inconsistency. It's not just the conntrack reference, with IPsec the packet passed to the defered hooks is totally different from when it was still inside IP, which for example breaks the policy match.

I agree it is annoying.

Quoted 6 lines
Quoted 2 lines

Trust me, people will complain if they can no longer use the physdev match for routed packets.

I'm sure they will, now that they got used to it. Why can't people match on the bridge port inside ebtables and only match on the device within iptables? Is there a case that can't be handled this way?

ebtables doesn't have all the targets/matches that iptables has. Perhaps a rule structure using marking can always be used so that the ACCEPT/DROP can be deferred until inside ebtables, I don't know if that will always be possible though.

Deferring the hooks makes the bridge-nf code alot more complicated, so I would be glad to get rid of it if it is the right thing to do. But backwards compatibility can't be maintained and I'd be surprised if every ruleset that now works will still be possible using an iptables/ebtables scheme.
It has worked fine in the past and I see no reason why to stop making it work now because of some recently found and unrelated referencing problem.
Of course, if the netfilter people decide it should be removed, then so be it.

cheers,
Bart

#19 lore raw
Quoted 5 lines · Bart De Schuymer

Deferring the hooks makes the bridge-nf code alot more complicated, so I would be glad to get rid of it if it is the right thing to do. But backwards compatibility can't be maintained and I'd be surprised if every ruleset that now works will still be possible using an iptables/ebtables scheme.

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

BTW. this line from ip_sabotage_out() looks wrong, it will clear all flags instead of setting the BRNF_DONT_TAKE_PARENT flag (second patch):

                        nf_bridge->mask &= BRNF_DONT_TAKE_PARENT;
net/ipv4/ip_output.c +6 -1
@@ -188,7 +188,12 @@ static inline int ip_finish_output2(stru
 		skb = skb2;
 	}
 
-	nf_reset(skb);
+#ifdef CONFIG_BRIDGE_NETFILTER
+	/* bridge-netfilter defers calling some IP hooks to the bridge layer and
+	 * still needs the conntrack reference */
+	if (skb->nf_bridge == NULL)
+#endif
+		nf_reset(skb);
 
 	if (hh) {
 		int hh_alen;
net/bridge/br_netfilter.c +1 -1
@@ -882,7 +882,7 @@ static unsigned int ip_sabotage_out(unsi
 		 * doesn't use the bridge parent of the indev by using
 		 * the BRNF_DONT_TAKE_PARENT mask. */
 		if (hook == NF_IP_FORWARD && nf_bridge->physindev == NULL) {
-			nf_bridge->mask &= BRNF_DONT_TAKE_PARENT;
+			nf_bridge->mask |= BRNF_DONT_TAKE_PARENT;
 			nf_bridge->physindev = (struct net_device *)in;
 		}
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
#20 lore raw

Op di, 21-06-2005 te 17:16 +0200, schreef Patrick McHardy:

Quoted 6 lines

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

Looks good.
Perhaps a compile time option to disable postponing the hooks would be nice...

Quoted 5 lines

BTW. this line from ip_sabotage_out() looks wrong, it will clear all flags instead of setting the BRNF_DONT_TAKE_PARENT flag (second patch):

                        nf_bridge->mask &= BRNF_DONT_TAKE_PARENT;

Thanks,
Bart

#21 lore raw
Quoted 9 lines · * Bart De Schuymer ([email protected]) wrote:

Op di, 21-06-2005 te 17:16 +0200, schreef Patrick McHardy:

Quoted 6 lines

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

Looks good.

Is this one good for -stable?

thanks,
-chris

maintainer
#22 lore raw

From: Chris Wright <[email protected]>
Subject: Re: 2.6.12: connection tracking broken?
Date: Tue, 21 Jun 2005 14:23:17 -0700

Quoted 9 lines · * Bart De Schuymer ([email protected]) wrote:
Quoted 8 lines

Op di, 21-06-2005 te 17:16 +0200, schreef Patrick McHardy:

Quoted 6 lines

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

Quoted 3 lines
Quoted 1 line

Looks good.

Is this one good for -stable?

We will push it to [email protected] if we deem it should.

I do review the stream going into 2.6.x, and decide if it should be bound for -stable as well, so you never need to inquire about this specifically.

#23 lore raw
Quoted 5 lines · * David S. Miller ([email protected]) wrote:

We will push it to [email protected] if we deem it should.

I do review the stream going into 2.6.x, and decide if it should be bound for -stable as well, so you never need to inquire about this specifically.

Great, much appreciated.

thanks,
-chris

#24 lore raw
In reply to David S. Miller
Quoted 3 lines · David S. Miller
Quoted 1 line

Is this one good for -stable?

We will push it to [email protected] if we deem it should.

I would like to get confirmation from someone affected by this bug, after that I think it should go in -stable. Chris, could you give it a try?

Thanks
Patrick

#25 lore raw
Quoted 3 lines · --- Patrick McHardy

I would like to get confirmation from someone affected by this bug, after that I think it should go in -stable. Chris, could you give it a try?

I trust you're talking about the following patches?

net/ipv4/ip_output.c +6 -1
@@ -188,7 +188,12 @@ static inline int ip_finish_output2(stru
                skb = skb2;
        }
 
-       nf_reset(skb);
+#ifdef CONFIG_BRIDGE_NETFILTER
+       /* bridge-netfilter defers calling some IP hooks to the bridge layer and
+        * still needs the conntrack reference */
+       if (skb->nf_bridge == NULL)
+#endif
+               nf_reset(skb);
 
        if (hh) {
                int hh_alen;
net/bridge/br_netfilter.c +1 -1
@@ -882,7 +882,7 @@ static unsigned int ip_sabotage_out(unsi
                 * doesn't use the bridge parent of the indev by using
                 * the BRNF_DONT_TAKE_PARENT mask. */
                if (hook == NF_IP_FORWARD && nf_bridge->physindev == NULL) {
-                       nf_bridge->mask &= BRNF_DONT_TAKE_PARENT;
+                       nf_bridge->mask |= BRNF_DONT_TAKE_PARENT;
                        nf_bridge->physindev = (struct net_device *)in;
                }
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)

I have just installed them, and my bridging firewall is working again with 2.6.12.

Thanks,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

#26 lore raw
Quoted 1 line · Chris Rankin

I have just installed them, and my bridging firewall is working again with 2.6.12.

Thanks Chris. Dave, did you get the patches or do you want me to send them again?

Regards
Patrick

maintainer
#27 lore raw

From: Patrick McHardy <[email protected]>
Date: Thu, 23 Jun 2005 19:42:38 +0200

Quoted 2 lines

Thanks Chris. Dave, did you get the patches or do you want me to send them again?

I have the patch, can you give me a nice changelog entry for it?

Thanks.

#28 lore raw
Quoted 2 lines · David S. Miller

I have the patch, can you give me a nice changelog entry for it?

Here you go:

In 2.6.12 we started dropping the conntrack reference when a packet leaves the IP layer. This broke connection tracking on a bridge, because bridge-netfilter defers calling some NF_IP_* hooks to the bridge layer for locally generated packets going out a bridge, where the conntrack reference is no longer available. This patch keeps the reference in this case as a temporary solution, long term we will remove the defered hook calling. No attempt is made to drop the reference in the bridge-code when it is no longer needed, tc actions could already have sent the packet anywhere.

Regards
Patrick

maintainer
#29 lore raw

From: Patrick McHardy <[email protected]>
Date: Fri, 24 Jun 2005 10:39:08 +0200

Quoted 9 lines

In 2.6.12 we started dropping the conntrack reference when a packet leaves the IP layer. This broke connection tracking on a bridge, because bridge-netfilter defers calling some NF_IP_* hooks to the bridge layer for locally generated packets going out a bridge, where the conntrack reference is no longer available. This patch keeps the reference in this case as a temporary solution, long term we will remove the defered hook calling. No attempt is made to drop the reference in the bridge-code when it is no longer needed, tc actions could already have sent the packet anywhere.

Patch applied and pushed to [email protected]

Thanks a lot.

#30 lore raw
In reply to Bart De Schuymer
Quoted 10 lines · Bart De Schuymer

Op di, 21-06-2005 te 17:16 +0200, schreef Patrick McHardy:

Quoted 6 lines

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

Looks good.

Thanks.

Quoted 2 lines

Perhaps a compile time option to disable postponing the hooks would be nice...

I think we want to reduce the number of possible paths to ideally one, not make them a compile-time option.

Regards
Patrick

#31 lore raw
In reply to Patrick McHardy
Quoted 7 lines · Patrick McHardy
Quoted 5 lines · Bart De Schuymer

Deferring the hooks makes the bridge-nf code alot more complicated, so I would be glad to get rid of it if it is the right thing to do. But backwards compatibility can't be maintained and I'd be surprised if every ruleset that now works will still be possible using an iptables/ebtables scheme.

Quoted 6 lines

I unfortunately don't see a way to remove it, but we should keep thinking about it. Can you please check if the attached patch is correct? It should exclude all packets handled by bridge-netfilter from having their conntrack reference dropped. I didn't add nf_reset()'s to the bridging code because with tc actions the packets can end up anywhere else anyway, and this will hopefully get fixed right sometime.

I think this patch will be fine for 2.6.12.*.

Longer term though we should obsolete the ipt_physdev module. The rationale there is that this creates a precedence that we can't possibly maintain in a consistent way. For example, we don't have a target that matches by hardware MAC address. If you wanted to do that, you'd hook into the arptables interface rather than deferring iptables after the creation of the hardware header.

This can be done in two stages to minimise pain for people already using it:

1) We rewrite ipt_physdev to do the lookups necessary to get the output physical devices through the bridge layer. Of course this may not be the real output device due to changes in the environment. So this should be accompanied with a warning that users should switch to ebt.

2) We remove the iptables deferring since ipt_physdev will no longer need it.

3) After a set period (say a year or so) we remove ipt_physdev altogether.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#32 lore raw
Quoted 16 lines · Herbert Xu

Longer term though we should obsolete the ipt_physdev module. The rationale there is that this creates a precedence that we can't possibly maintain in a consistent way. For example, we don't have a target that matches by hardware MAC address. If you wanted to do that, you'd hook into the arptables interface rather than deferring iptables after the creation of the hardware header.

This can be done in two stages to minimise pain for people already using it:

1) We rewrite ipt_physdev to do the lookups necessary to get the output physical devices through the bridge layer. Of course this may not be the real output device due to changes in the environment. So this should be accompanied with a warning that users should switch to ebt.

Quoted 4 lines

2) We remove the iptables deferring since ipt_physdev will no longer need it.

3) After a set period (say a year or so) we remove ipt_physdev altogether.

For my local setup it is already a minor PITA that there is no tool combining the functionality of arptables, ebtables and iptables, but I can cope with the help of marking and ipt_physdev. If that doesn't work reliably anymore, I'll be stuck.

Wasn't someone working on a unified framework for *tables? IIRC that would have been pkttables, but Harald(?) said there was not much code there yet.

Regards,
Carl-Daniel

Signature · 1 line
http://www.hailfinger.org/
#33 lore raw
Quoted 8 lines · Carl-Daniel Hailfinger
Quoted 2 lines · Herbert Xu

3) After a set period (say a year or so) we remove ipt_physdev altogether.

For my local setup it is already a minor PITA that there is no tool combining the functionality of arptables, ebtables and iptables, but I can cope with the help of marking and ipt_physdev. If that doesn't work reliably anymore, I'll be stuck.

You would still be able to mark packets in iptables and match on that mark in ebtables, where filtering on the bridge port can be performed.

Quoted 3 lines

Wasn't someone working on a unified framework for *tables? IIRC that would have been pkttables, but Harald(?) said there was not much code there yet.

Not much has changed AFAIK, but pkttables wouldn't change the fact that the bridge port isn't available at the IP layer.

Regards
Patrick

#34 lore raw
In reply to Carl-Daniel Hailfinger

Op do, 23-06-2005 te 02:02 +0200, schreef Carl-Daniel Hailfinger:

Quoted 8 lines

For my local setup it is already a minor PITA that there is no tool combining the functionality of arptables, ebtables and iptables, but I can cope with the help of marking and ipt_physdev. If that doesn't work reliably anymore, I'll be stuck.

Wasn't someone working on a unified framework for *tables? IIRC that would have been pkttables, but Harald(?) said there was not much code there yet.

On my todo list is making the arptables matches usable in ebtables rules. I think it would be very nice if {eb,ip,ip6,arp}tables modules could be used together.

cheers,
Bart

#35 lore raw
In reply to Herbert Xu
Quoted 6 lines · Herbert Xu

Longer term though we should obsolete the ipt_physdev module. The rationale there is that this creates a precedence that we can't possibly maintain in a consistent way. For example, we don't have a target that matches by hardware MAC address. If you wanted to do that, you'd hook into the arptables interface rather than deferring iptables after the creation of the hardware header.

Agreed.

Quoted 7 lines

This can be done in two stages to minimise pain for people already using it:

1) We rewrite ipt_physdev to do the lookups necessary to get the output physical devices through the bridge layer. Of course this may not be the real output device due to changes in the environment. So this should be accompanied with a warning that users should switch to ebt.

IMO without defering the hooks the physdev match becomes pretty useless for locally generated packets. The bridge layer clones packets that are delivered to multiple ports and calls the NF_IP_* hooks for each clone, so each clone can be treated seperately. In the IP layer there is only a single packet, so clones for different ports couldn't be treated seperately anymore and the semantic of the physdev match would need to be changed to match on any bridge port in this case, which would probably break existing rulesets.

Quoted 4 lines

2) We remove the iptables deferring since ipt_physdev will no longer need it.

3) After a set period (say a year or so) we remove ipt_physdev altogether.

How about we schedule it for removal in a year, keep the workaround until then and then remove the hook defering?

Regards
Patrick

#36 lore raw
Quoted 5 lines · Patrick McHardy
Quoted 2 lines

3) After a set period (say a year or so) we remove ipt_physdev altogether.

How about we schedule it for removal in a year, keep the workaround until then and then remove the hook defering?

That's fine by me.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#37 lore raw
In reply to Herbert Xu

Op do, 23-06-2005 te 07:49 +1000, schreef Herbert Xu:

Quoted 6 lines

Longer term though we should obsolete the ipt_physdev module. The rationale there is that this creates a precedence that we can't possibly maintain in a consistent way. For example, we don't have a target that matches by hardware MAC address. If you wanted to do that, you'd hook into the arptables interface rather than deferring iptables after the creation of the hardware header.

Iptables also sees purely bridged packets and at least for these packets the physdev module is useful and harmless. I think removing physdev alltogether is a bit drastic.

I wonder what flood of messages from angry users the removal of the physdev functionality for routed packets will stirr.

cheers,
Bart

#38 lore raw
Quoted 8 lines · Bart De Schuymer

Op do, 23-06-2005 te 07:49 +1000, schreef Herbert Xu:

Quoted 6 lines

Longer term though we should obsolete the ipt_physdev module. The rationale there is that this creates a precedence that we can't possibly maintain in a consistent way. For example, we don't have a target that matches by hardware MAC address. If you wanted to do that, you'd hook into the arptables interface rather than deferring iptables after the creation of the hardware header.

Quoted 6 lines

Iptables also sees purely bridged packets and at least for these packets the physdev module is useful and harmless. I think removing physdev alltogether is a bit drastic.

I wonder what flood of messages from angry users the removal of the physdev functionality for routed packets will stirr.

I have to agree with Bart. I don't know any bridging-packetfilter setup that doesn't use ipt_physdev in FORWARD :(

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#39 lore raw
Quoted 2 lines · Harald Welte

I have to agree with Bart. I don't know any bridging-packetfilter setup that doesn't use ipt_physdev in FORWARD :(

It shouldn't be a problem to MARK in ebtables and use the marks instead. So far I think we can only remove the support for locally generated packets, but the way bridge-netfilter and ip-netfilter interact causes some more problems and inconsistencies which I would like to look into first. One thing I've noticed is that NF_IP_LOCAL_OUT, NF_IP_FORWARD and NF_IP_POST_ROUTING get called for every clone when packets are delivered to multiple ports, which causes unexpected results with REJECT (many packets sent in response to a single one) and probably others. This could be avoided by only passing packets to the NF_IP_* hooks once, but that would make the physdev match useless.

Another problem is defragmentation, we've added the user argument to ip_defrag to avoid packets from jumping through the stack between different callers. With bridge-netfilter defragmentation in NF_IP_PRE_ROUTING can be reached from both the IP layer and the bridge layer, so packets can still jump (see netfilter bugzilla #339).

I expect there are more problems, I hope I can find some time to look into it this week.

Regards
Patrick