All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix ip_queue for bridged packets
@ 2003-10-25 15:09 Bart De Schuymer
  2003-10-27  8:04 ` David S. Miller
  0 siblings, 1 reply; 14+ messages in thread
From: Bart De Schuymer @ 2003-10-25 15:09 UTC (permalink / raw)
  To: David S.Miller; +Cc: netfilter-devel

Hi Dave,

When ip_queue copies an old skbuff to a new one (because the tailroom is
too small), it uses skb_copy_expand(). This function doesn't copy the
Ethernet header, which is not needed for normal IP traffic. Normally, the
Ethernet header is filled in later before doing dev_queue_xmit.
When ip_queue does this to a bridged IP packet, it has to copy the Ethernet
header, because the Ethernet header is already filled in and won't be filled
in again.
The patch below makes this happen. It puts the code that actually copies the
header inside netfilter_bridge.h, so that it can be reused and altered
without touching other code.

The patch is already approved by Stephen Hemminger (in private mail).
Since Harald Welte excels in silence, I'm sending netfilter stuff directly
to you from now on.

The patch is vs test7 but applies fine vs test8.

cheers,
Bart

--- linux-2.6.0-test7/net/ipv4/netfilter/ip_queue.c.old	2003-10-12 21:23:01.000000000 +0200
+++ linux-2.6.0-test7/net/ipv4/netfilter/ip_queue.c	2003-10-12 22:13:45.000000000 +0200
@@ -21,6 +21,9 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4/ip_queue.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#ifdef CONFIG_BRIDGE_NETFILTER
+#include <linux/netfilter_bridge.h>
+#endif
 #include <linux/netlink.h>
 #include <linux/spinlock.h>
 #include <linux/sysctl.h>
@@ -353,6 +356,10 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, st
 			}
 			if (e->skb->sk)
 				skb_set_owner_w(newskb, e->skb->sk);
+#ifdef CONFIG_BRIDGE_NETFILTER
+			/* bridged packets already have their Ethernet header */
+			br_nf_maybe_copy_header2(newskb, e->skb);
+#endif
 			kfree_skb(e->skb);
 			e->skb = newskb;
 		}
--- linux-2.6.0-test7/include/linux/netfilter_bridge.h.old	2003-10-12 21:44:28.000000000 +0200
+++ linux-2.6.0-test7/include/linux/netfilter_bridge.h	2003-10-12 22:21:16.000000000 +0200
@@ -81,6 +81,22 @@ void nf_bridge_maybe_copy_header(struct 
 	}
 }
 
+/* needed in IP netfilter modules that can copy bridged skbuff's,
+ * but don't copy the Ethernet header by default. */
+static inline
+void nf_bridge_maybe_copy_header2(struct sk_buff *d,
+				  struct sk_buff *s)
+{
+	if (s->nf_bridge) {
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+		if (s->protocol == __constant_htons(ETH_P_8021Q))
+			memcpy(d->data - 18, s->data - 18, 18);
+		else
+#endif
+			memcpy(d->data - 16, s->data - 16, 16);
+	}
+}
+
 static inline
 void nf_bridge_save_header(struct sk_buff *skb)
 {

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] Fix ip_queue for bridged packets
@ 2003-10-12 20:43 Bart De Schuymer
  2003-10-14 10:58 ` Harald Welte
  0 siblings, 1 reply; 14+ messages in thread
From: Bart De Schuymer @ 2003-10-12 20:43 UTC (permalink / raw)
  To: Harald Welte; +Cc: netfilter-devel, Stephen Hemminger

Hi Harald,

When ip_queue copies an old skbuff to a new one (because the tailroom is
too small), it uses skb_copy_expand(). This function doesn't copy the
Ethernet header, which is not needed for normal IP traffic. Normally, the
Ethernet header is filled in later before doing dev_queue_xmit.
When ip_queue does this to a bridged IP packet, it has to copy the Ethernet
header, because the Ethernet header was already filled in earlier and won't
be filled in again.
The patch below makes this happen. It puts the code that actually copies the
header inside netfilter_bridge.h, so that it can be reused and altered
without touching other code.

cheers,
Bart


--- linux-2.6.0-test7/net/ipv4/netfilter/ip_queue.c.old	2003-10-12 21:23:01.000000000 +0200
+++ linux-2.6.0-test7/net/ipv4/netfilter/ip_queue.c	2003-10-12 22:13:45.000000000 +0200
@@ -21,6 +21,9 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4/ip_queue.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#ifdef CONFIG_BRIDGE_NETFILTER
+#include <linux/netfilter_bridge.h>
+#endif
 #include <linux/netlink.h>
 #include <linux/spinlock.h>
 #include <linux/sysctl.h>
@@ -353,6 +356,10 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, st
 			}
 			if (e->skb->sk)
 				skb_set_owner_w(newskb, e->skb->sk);
+#ifdef CONFIG_BRIDGE_NETFILTER
+			/* bridged packets already have their Ethernet header */
+			br_nf_maybe_copy_header2(newskb, e->skb);
+#endif
 			kfree_skb(e->skb);
 			e->skb = newskb;
 		}
--- linux-2.6.0-test7/include/linux/netfilter_bridge.h.old	2003-10-12 21:44:28.000000000 +0200
+++ linux-2.6.0-test7/include/linux/netfilter_bridge.h	2003-10-12 22:21:16.000000000 +0200
@@ -81,6 +81,22 @@ void nf_bridge_maybe_copy_header(struct 
 	}
 }
 
+/* needed in IP netfilter modules that can copy bridged skbuff's,
+ * but don't copy the Ethernet header by default. */
+static inline
+void nf_bridge_maybe_copy_header2(struct sk_buff *d,
+				  struct sk_buff *s)
+{
+	if (s->nf_bridge) {
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+		if (s->protocol == __constant_htons(ETH_P_8021Q))
+			memcpy(d->data - 18, s->data - 18, 18);
+		else
+#endif
+			memcpy(d->data - 16, s->data - 16, 16);
+	}
+}
+
 static inline
 void nf_bridge_save_header(struct sk_buff *skb)
 {

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-10-31 17:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-25 15:09 [PATCH] Fix ip_queue for bridged packets Bart De Schuymer
2003-10-27  8:04 ` David S. Miller
2003-10-27 23:02   ` Bart De Schuymer
2003-10-28 14:02     ` David S. Miller
2003-10-28 14:56     ` David S. Miller
2003-10-29  7:00       ` Bart De Schuymer
2003-10-29 22:25       ` Bart De Schuymer
2003-10-29 22:41         ` David S. Miller
2003-10-28 19:09     ` Scott MacKay
2003-10-31 12:53     ` Scott MacKay
2003-10-31 17:30       ` Bart De Schuymer
  -- strict thread matches above, loose matches on Subject: below --
2003-10-12 20:43 Bart De Schuymer
2003-10-14 10:58 ` Harald Welte
2003-10-15 18:33   ` Bart De Schuymer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.