aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/neighbour.h
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2010-04-15 06:26:39 -0400
committerPatrick McHardy <kaber@trash.net>2010-04-15 06:26:39 -0400
commite179e6322ac334e21a3c6d669d95bc967e5d0a80 (patch)
treeeee21d4e85ffeed02c6a25a8b224845cb9ed0fd2 /include/net/neighbour.h
parentea2d9b41bd418894d1ee25de1642c3325d71c397 (diff)
netfilter: bridge-netfilter: Fix MAC header handling with IP DNAT
- fix IP DNAT on vlan- or pppoe-encapsulated traffic: The functions neigh_hh_output() or dst->neighbour->output() overwrite the complete Ethernet header, although we only need the destination MAC address. For encapsulated packets, they ended up overwriting the encapsulating header. The new code copies the Ethernet source MAC address and protocol number before calling dst->neighbour->output(). The Ethernet source MAC and protocol number are copied back in place in br_nf_pre_routing_finish_bridge_slow(). This also makes the IP DNAT more transparent because in the old scheme the source MAC of the bridge was copied into the source address in the Ethernet header. We also let skb->protocol equal ETH_P_IP resp. ETH_P_IPV6 during the execution of the PF_INET resp. PF_INET6 hooks. - Speed up IP DNAT by calling neigh_hh_bridge() instead of neigh_hh_output(): if dst->hh is available, we already know the MAC address so we can just copy it. Signed-off-by: Bart De Schuymer <bdschuym@pandora.be> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/net/neighbour.h')
-rw-r--r--include/net/neighbour.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index da1d58be31b7..eb21340a573b 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -299,6 +299,20 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
299 return 0; 299 return 0;
300} 300}
301 301
302#ifdef CONFIG_BRIDGE_NETFILTER
303static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb)
304{
305 unsigned seq, hh_alen;
306
307 do {
308 seq = read_seqbegin(&hh->hh_lock);
309 hh_alen = HH_DATA_ALIGN(ETH_HLEN);
310 memcpy(skb->data - hh_alen, hh->hh_data, ETH_ALEN + hh_alen - ETH_HLEN);
311 } while (read_seqretry(&hh->hh_lock, seq));
312 return 0;
313}
314#endif
315
302static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb) 316static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
303{ 317{
304 unsigned seq; 318 unsigned seq;