aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/arp.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-09-15 21:04:16 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-17 20:18:37 -0400
commit29a26a56803855a79dbd028cd61abee56237d6e5 (patch)
tree89fb3a95216d44417577e218a967ede09d676922 /net/ipv4/arp.c
parent04eb44890e5bb3cc855e5c0f18a05eb7311364b7 (diff)
netfilter: Pass struct net into the netfilter hooks
Pass a network namespace parameter into the netfilter hooks. At the call site of the netfilter hooks the path a packet is taking through the network stack is well known which allows the network namespace to be easily and reliabily. This allows the replacement of magic code like "dev_net(state->in?:state->out)" that appears at the start of most netfilter hooks with "state->net". In almost all cases the network namespace passed in is derived from the first network device passed in, guaranteeing those paths will not see any changes in practice. The exceptions are: xfrm/xfrm_output.c:xfrm_output_resume() xs_net(skb_dst(skb)->xfrm) ipvs/ip_vs_xmit.c:ip_vs_nat_send_or_cont() ip_vs_conn_net(cp) ipvs/ip_vs_xmit.c:ip_vs_send_or_cont() ip_vs_conn_net(cp) ipv4/raw.c:raw_send_hdrinc() sock_net(sk) ipv6/ip6_output.c:ip6_xmit() sock_net(sk) ipv6/ndisc.c:ndisc_send_skb() dev_net(skb->dev) not dev_net(dst->dev) ipv6/raw.c:raw6_send_hdrinc() sock_net(sk) br_netfilter_hooks.c:br_nf_pre_routing_finish() dev_net(skb->dev) before skb->dev is set to nf_bridge->physindev In all cases these exceptions seem to be a better expression for the network namespace the packet is being processed in then the historic "dev_net(in?in:out)". I am documenting them in case something odd pops up and someone starts trying to track down what happened. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/arp.c')
-rw-r--r--net/ipv4/arp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3632e98eb0f9..ae71e9ade5f9 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -632,8 +632,9 @@ static int arp_xmit_finish(struct sock *sk, struct sk_buff *skb)
632void arp_xmit(struct sk_buff *skb) 632void arp_xmit(struct sk_buff *skb)
633{ 633{
634 /* Send it off, maybe filter it using firewalling first. */ 634 /* Send it off, maybe filter it using firewalling first. */
635 NF_HOOK(NFPROTO_ARP, NF_ARP_OUT, NULL, skb, 635 NF_HOOK(NFPROTO_ARP, NF_ARP_OUT,
636 NULL, skb->dev, arp_xmit_finish); 636 dev_net(skb->dev), NULL, skb, NULL, skb->dev,
637 arp_xmit_finish);
637} 638}
638EXPORT_SYMBOL(arp_xmit); 639EXPORT_SYMBOL(arp_xmit);
639 640
@@ -897,8 +898,9 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,
897 898
898 memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb)); 899 memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
899 900
900 return NF_HOOK(NFPROTO_ARP, NF_ARP_IN, NULL, skb, 901 return NF_HOOK(NFPROTO_ARP, NF_ARP_IN,
901 dev, NULL, arp_process); 902 dev_net(dev), NULL, skb, dev, NULL,
903 arp_process);
902 904
903consumeskb: 905consumeskb:
904 consume_skb(skb); 906 consume_skb(skb);