Fix ip_queue for bridged packets
Subsystems (2)
PATCH 1/1 Fix ip_queue for bridged packets
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
net/ipv4/netfilter/ip_queue.c renamed from net/ipv4/netfilter/ip_queue.c.old +7 -0
@@ -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; }
include/linux/netfilter_bridge.h renamed from include/linux/netfilter_bridge.h.old +16 -0
@@ -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) {
Quoted 9 lines · Bart De Schuymer
Hi Harald,
When
ip_queuecopies an old skbuff to a new one (because the tailroom is too small), it usesskb_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 doingdev_queue_xmit. Whenip_queuedoes 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.
what about ip6_queue.c ? Would you need a similar fix for ipv6 bridging If yes, could you please merge your changes with ip6_queue.c and send me a cumulative patch?
Thanks.
Quoted 2 lines
cheers,
Bart
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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
Quoted 3 lines · Harald Welte
what about
ip6_queue.c? Would you need a similar fix for ipv6 bridging If yes, could you please merge your changes withip6_queue.cand send me a cumulative patch?
IPv6 isn't currently passed to ip6tables, so that code doesn't need fixing.
cheers,
Bart