From: Bart De Schuymer <bdschuym-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org>
To: David S.Miller <davem-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: ebtables-devel
<ebtables-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
netdev <netdev-VZNHf3L845pBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH] 2.6.3 fix vlan-encapsulated fragmented IP traffic
Date: Sun, 29 Feb 2004 19:14:53 +0100 [thread overview]
Message-ID: <200402291914.53578.bdschuym@pandora.be> (raw)
Hi Dave,
When vlan-tagged fragmented IP traffic passes the bridging firewall and
ip_conntrack is loaded and iptables sees this IP traffic, an oops can
occur when trying to fragment the defragmented packets. This only
happens in the slow_path of ip_fragment().
The problem was reported, diagnosed and fixed by Adam Osuchowski and
Tomasz Dubinski.
When ip_fragment() is fragmenting an IP packet that's encapsulated, it has
to make sure there is enough head room for the encapsulating header.
The patch below fixes it. I saw no other way than to add some code to
ip_fragment(), but this extra code is located in the slow_path so it's
hardly ever executed.
cheers,
Bart
--- linux-2.6.3/include/linux/netfilter_bridge.h.save Sun Feb 29 17:13:44 2004
+++ linux-2.6.3/include/linux/netfilter_bridge.h Sun Feb 29 17:43:55 2004
@@ -88,6 +88,20 @@ void nf_bridge_save_header(struct sk_buf
memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
}
+/* This is called by the IP fragmenting code and it ensures there is
+ * enough room for the encapsulating header (if there is one). */
+static inline
+int nf_bridge_pad(struct sk_buff *skb)
+{
+ if (skb->protocol == __constant_htons(ETH_P_IP))
+ return 0;
+ if (skb->nf_bridge) {
+ if (skb->protocol == __constant_htons(ETH_P_8021Q))
+ return 4;
+ }
+ return 0;
+}
+
struct bridge_skb_cb {
union {
__u32 ipv4;
--- linux-2.6.3/net/ipv4/ip_output.c.save Sun Feb 29 16:30:05 2004
+++ linux-2.6.3/net/ipv4/ip_output.c Sun Feb 29 19:11:35 2004
@@ -80,6 +80,7 @@
#include <net/inetpeer.h>
#include <linux/igmp.h>
#include <linux/netfilter_ipv4.h>
+#include <linux/netfilter_bridge.h>
#include <linux/mroute.h>
#include <linux/netlink.h>
@@ -442,7 +443,7 @@ int ip_fragment(struct sk_buff *skb, int
int ptr;
struct net_device *dev;
struct sk_buff *skb2;
- unsigned int mtu, hlen, left, len;
+ unsigned int mtu, hlen, left, len, ll_rs;
int offset;
int not_last_frag;
struct rtable *rt = (struct rtable*)skb->dst;
@@ -563,6 +564,14 @@ slow_path:
left = skb->len - hlen; /* Space per frame */
ptr = raw + hlen; /* Where to start from */
+#ifdef CONFIG_BRIDGE_NETFILTER
+ /* for bridged IP traffic encapsulated inside f.e. a vlan header,
+ * we need to make room for the encapsulating header */
+ ll_rs = LL_RESERVED_SPACE(rt->u.dst.dev + nf_bridge_pad(skb));
+ mtu -= nf_bridge_pad(skb);
+#else
+ ll_rs = LL_RESERVED_SPACE(rt->u.dst.dev);
+#endif
/*
* Fragment the datagram.
*/
@@ -588,7 +597,7 @@ slow_path:
* Allocate buffer.
*/
- if ((skb2 = alloc_skb(len+hlen+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) {
+ if ((skb2 = alloc_skb(len+hlen+ll_rs, GFP_ATOMIC)) == NULL) {
NETDEBUG(printk(KERN_INFO "IP: frag: no memory for new fragment!\n"));
err = -ENOMEM;
goto fail;
@@ -599,7 +608,7 @@ slow_path:
*/
ip_copy_metadata(skb2, skb);
- skb_reserve(skb2, LL_RESERVED_SPACE(rt->u.dst.dev));
+ skb_reserve(skb2, ll_rs);
skb_put(skb2, len + hlen);
skb2->nh.raw = skb2->data;
skb2->h.raw = skb2->data + hlen;
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
next reply other threads:[~2004-02-29 18:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-29 18:14 Bart De Schuymer [this message]
2004-03-01 5:54 ` [PATCH] 2.6.3 fix vlan-encapsulated fragmented IP traffic David S. Miller
[not found] ` <20040229215421.0ca987e8.davem-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2004-03-01 7:06 ` Bart De Schuymer
2004-03-01 8:35 ` David S. Miller
[not found] ` <20040301003525.522d6db2.davem-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2004-03-01 18:47 ` Bart De Schuymer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200402291914.53578.bdschuym@pandora.be \
--to=bdschuym-lpo8gxj9n8azioh1ieqzka@public.gmane.org \
--cc=davem-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=ebtables-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=netdev-VZNHf3L845pBDgjK7y7TUQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).