Commit 29a26a56 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller
Browse files

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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 04eb4489
...@@ -298,14 +298,15 @@ err: ...@@ -298,14 +298,15 @@ err:
static int vrf_output(struct sock *sk, struct sk_buff *skb) static int vrf_output(struct sock *sk, struct sk_buff *skb)
{ {
struct net_device *dev = skb_dst(skb)->dev; struct net_device *dev = skb_dst(skb)->dev;
struct net *net = dev_net(dev);
IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUT, skb->len); IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
skb->dev = dev; skb->dev = dev;
skb->protocol = htons(ETH_P_IP); skb->protocol = htons(ETH_P_IP);
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb, return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
NULL, dev, net, sk, skb, NULL, dev,
vrf_finish_output, vrf_finish_output,
!(IPCB(skb)->flags & IPSKB_REROUTED)); !(IPCB(skb)->flags & IPSKB_REROUTED));
} }
......
...@@ -190,12 +190,11 @@ static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook, ...@@ -190,12 +190,11 @@ static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
return 1; return 1;
} }
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk, static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
struct sk_buff *skb, struct net_device *indev, struct sock *sk, struct sk_buff *skb,
struct net_device *outdev, struct net_device *indev, struct net_device *outdev,
int (*okfn)(struct sock *, struct sk_buff *)) int (*okfn)(struct sock *, struct sk_buff *))
{ {
struct net *net = dev_net(indev ? indev : outdev);
return nf_hook_thresh(pf, hook, net, sk, skb, indev, outdev, okfn, INT_MIN); return nf_hook_thresh(pf, hook, net, sk, skb, indev, outdev, okfn, INT_MIN);
} }
...@@ -217,12 +216,11 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk, ...@@ -217,12 +216,11 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
*/ */
static inline int static inline int
NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk, NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
struct sk_buff *skb, struct net_device *in, struct sk_buff *skb, struct net_device *in,
struct net_device *out, struct net_device *out,
int (*okfn)(struct sock *, struct sk_buff *), int thresh) int (*okfn)(struct sock *, struct sk_buff *), int thresh)
{ {
struct net *net = dev_net(in ? in : out);
int ret = nf_hook_thresh(pf, hook, net, sk, skb, in, out, okfn, thresh); int ret = nf_hook_thresh(pf, hook, net, sk, skb, in, out, okfn, thresh);
if (ret == 1) if (ret == 1)
ret = okfn(sk, skb); ret = okfn(sk, skb);
...@@ -230,11 +228,10 @@ NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk, ...@@ -230,11 +228,10 @@ NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk,
} }
static inline int static inline int
NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk, NF_HOOK_COND(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
struct sk_buff *skb, struct net_device *in, struct net_device *out, struct sk_buff *skb, struct net_device *in, struct net_device *out,
int (*okfn)(struct sock *, struct sk_buff *), bool cond) int (*okfn)(struct sock *, struct sk_buff *), bool cond)
{ {
struct net *net = dev_net(in ? in : out);
int ret; int ret;
if (!cond || if (!cond ||
...@@ -244,11 +241,11 @@ NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk, ...@@ -244,11 +241,11 @@ NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk,
} }
static inline int static inline int
NF_HOOK(uint8_t pf, unsigned int hook, struct sock *sk, struct sk_buff *skb, NF_HOOK(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, struct sk_buff *skb,
struct net_device *in, struct net_device *out, struct net_device *in, struct net_device *out,
int (*okfn)(struct sock *, struct sk_buff *)) int (*okfn)(struct sock *, struct sk_buff *))
{ {
return NF_HOOK_THRESH(pf, hook, sk, skb, in, out, okfn, INT_MIN); return NF_HOOK_THRESH(pf, hook, net, sk, skb, in, out, okfn, INT_MIN);
} }
/* Call setsockopt() */ /* Call setsockopt() */
...@@ -348,11 +345,11 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family) ...@@ -348,11 +345,11 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
} }
#else /* !CONFIG_NETFILTER */ #else /* !CONFIG_NETFILTER */
#define NF_HOOK(pf, hook, sk, skb, indev, outdev, okfn) (okfn)(sk, skb) #define NF_HOOK(pf, hook, net, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
#define NF_HOOK_COND(pf, hook, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb) #define NF_HOOK_COND(pf, hook, net, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk, static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
struct sk_buff *skb, struct net_device *indev, struct sock *sk, struct sk_buff *skb,
struct net_device *outdev, struct net_device *indev, struct net_device *outdev,
int (*okfn)(struct sock *, struct sk_buff *)) int (*okfn)(struct sock *, struct sk_buff *))
{ {
return 1; return 1;
......
...@@ -67,8 +67,9 @@ EXPORT_SYMBOL_GPL(br_dev_queue_push_xmit); ...@@ -67,8 +67,9 @@ EXPORT_SYMBOL_GPL(br_dev_queue_push_xmit);
int br_forward_finish(struct sock *sk, struct sk_buff *skb) int br_forward_finish(struct sock *sk, struct sk_buff *skb)
{ {
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, sk, skb, struct net *net = dev_net(skb->dev);
NULL, skb->dev, return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING,
net, sk, skb, NULL, skb->dev,
br_dev_queue_push_xmit); br_dev_queue_push_xmit);
} }
...@@ -92,8 +93,8 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) ...@@ -92,8 +93,8 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
return; return;
} }
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb, NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
NULL, skb->dev, dev_net(skb->dev), NULL, skb,NULL, skb->dev,
br_forward_finish); br_forward_finish);
} }
...@@ -114,8 +115,8 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb) ...@@ -114,8 +115,8 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
skb->dev = to->dev; skb->dev = to->dev;
skb_forward_csum(skb); skb_forward_csum(skb);
NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, NULL, skb, NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD,
indev, skb->dev, dev_net(indev), NULL, skb, indev, skb->dev,
br_forward_finish); br_forward_finish);
} }
......
...@@ -60,8 +60,8 @@ static int br_pass_frame_up(struct sk_buff *skb) ...@@ -60,8 +60,8 @@ static int br_pass_frame_up(struct sk_buff *skb)
if (!skb) if (!skb)
return NET_RX_DROP; return NET_RX_DROP;
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, NULL, skb, return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
indev, NULL, dev_net(indev), NULL, skb, indev, NULL,
br_netif_receive_skb); br_netif_receive_skb);
} }
...@@ -283,8 +283,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) ...@@ -283,8 +283,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
} }
/* Deliver packet to local host only */ /* Deliver packet to local host only */
if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, NULL, skb, if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
skb->dev, NULL, br_handle_local_finish)) { dev_net(skb->dev), NULL, skb, skb->dev, NULL,
br_handle_local_finish)) {
return RX_HANDLER_CONSUMED; /* consumed by filter */ return RX_HANDLER_CONSUMED; /* consumed by filter */
} else { } else {
*pskb = skb; *pskb = skb;
...@@ -308,8 +309,8 @@ forward: ...@@ -308,8 +309,8 @@ forward:
if (ether_addr_equal(p->br->dev->dev_addr, dest)) if (ether_addr_equal(p->br->dev->dev_addr, dest))
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, NULL, skb, NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING,
skb->dev, NULL, dev_net(skb->dev), NULL, skb, skb->dev, NULL,
br_handle_frame_finish); br_handle_frame_finish);
break; break;
default: default:
......
...@@ -829,8 +829,8 @@ static void __br_multicast_send_query(struct net_bridge *br, ...@@ -829,8 +829,8 @@ static void __br_multicast_send_query(struct net_bridge *br,
if (port) { if (port) {
skb->dev = port->dev; skb->dev = port->dev;
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb, NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
NULL, skb->dev, dev_net(port->dev), NULL, skb, NULL, skb->dev,
br_dev_queue_push_xmit); br_dev_queue_push_xmit);
} else { } else {
br_multicast_select_own_querier(br, ip, skb); br_multicast_select_own_querier(br, ip, skb);
......
...@@ -394,7 +394,7 @@ bridged_dnat: ...@@ -394,7 +394,7 @@ bridged_dnat:
nf_bridge_push_encap_header(skb); nf_bridge_push_encap_header(skb);
NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_HOOK_THRESH(NFPROTO_BRIDGE,
NF_BR_PRE_ROUTING, NF_BR_PRE_ROUTING,
sk, skb, skb->dev, NULL, net, sk, skb, skb->dev, NULL,
br_nf_pre_routing_finish_bridge, br_nf_pre_routing_finish_bridge,
1); 1);
return 0; return 0;
...@@ -414,7 +414,7 @@ bridged_dnat: ...@@ -414,7 +414,7 @@ bridged_dnat:
skb->dev = nf_bridge->physindev; skb->dev = nf_bridge->physindev;
nf_bridge_update_protocol(skb); nf_bridge_update_protocol(skb);
nf_bridge_push_encap_header(skb); nf_bridge_push_encap_header(skb);
NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, sk, skb, NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, net, sk, skb,
skb->dev, NULL, skb->dev, NULL,
br_handle_frame_finish, 1); br_handle_frame_finish, 1);
...@@ -512,7 +512,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops, ...@@ -512,7 +512,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
skb->protocol = htons(ETH_P_IP); skb->protocol = htons(ETH_P_IP);
NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->sk, skb, NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
skb->dev, NULL, skb->dev, NULL,
br_nf_pre_routing_finish); br_nf_pre_routing_finish);
...@@ -539,6 +539,7 @@ static unsigned int br_nf_local_in(const struct nf_hook_ops *ops, ...@@ -539,6 +539,7 @@ static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb) static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
{ {
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
struct net *net = dev_net(skb->dev);
struct net_device *in; struct net_device *in;
if (!IS_ARP(skb) && !IS_VLAN_ARP(skb)) { if (!IS_ARP(skb) && !IS_VLAN_ARP(skb)) {
...@@ -560,7 +561,7 @@ static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb) ...@@ -560,7 +561,7 @@ static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
} }
nf_bridge_push_encap_header(skb); nf_bridge_push_encap_header(skb);
NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, sk, skb, NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, net, sk, skb,
in, skb->dev, br_forward_finish, 1); in, skb->dev, br_forward_finish, 1);
return 0; return 0;
} }
...@@ -627,7 +628,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops, ...@@ -627,7 +628,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
else else
skb->protocol = htons(ETH_P_IPV6); skb->protocol = htons(ETH_P_IPV6);
NF_HOOK(pf, NF_INET_FORWARD, NULL, skb, NF_HOOK(pf, NF_INET_FORWARD, state->net, NULL, skb,
brnf_get_logical_dev(skb, state->in), brnf_get_logical_dev(skb, state->in),
parent, br_nf_forward_finish); parent, br_nf_forward_finish);
...@@ -662,7 +663,7 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops, ...@@ -662,7 +663,7 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
return NF_ACCEPT; return NF_ACCEPT;
} }
*d = state->in; *d = state->in;
NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, state->sk, skb, NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, state->net, state->sk, skb,
state->in, state->out, br_nf_forward_finish); state->in, state->out, br_nf_forward_finish);
return NF_STOLEN; return NF_STOLEN;
...@@ -842,7 +843,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops, ...@@ -842,7 +843,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
else else
skb->protocol = htons(ETH_P_IPV6); skb->protocol = htons(ETH_P_IPV6);
NF_HOOK(pf, NF_INET_POST_ROUTING, state->sk, skb, NF_HOOK(pf, NF_INET_POST_ROUTING, state->net, state->sk, skb,
NULL, realoutdev, NULL, realoutdev,
br_nf_dev_queue_xmit); br_nf_dev_queue_xmit);
......
...@@ -166,6 +166,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb) ...@@ -166,6 +166,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
struct rtable *rt; struct rtable *rt;
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
struct net *net = dev_net(dev);
const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops(); const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops();
nf_bridge->frag_max_size = IP6CB(skb)->frag_max_size; nf_bridge->frag_max_size = IP6CB(skb)->frag_max_size;
...@@ -189,7 +190,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb) ...@@ -189,7 +190,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
nf_bridge_update_protocol(skb); nf_bridge_update_protocol(skb);
nf_bridge_push_encap_header(skb); nf_bridge_push_encap_header(skb);
NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING,
sk, skb, skb->dev, NULL, net, sk, skb, skb->dev, NULL,
br_nf_pre_routing_finish_bridge, br_nf_pre_routing_finish_bridge,
1); 1);
return 0; return 0;
...@@ -208,7 +209,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb) ...@@ -208,7 +209,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
skb->dev = nf_bridge->physindev; skb->dev = nf_bridge->physindev;
nf_bridge_update_protocol(skb); nf_bridge_update_protocol(skb);
nf_bridge_push_encap_header(skb); nf_bridge_push_encap_header(skb);
NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, sk, skb, NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, net, sk, skb,
skb->dev, NULL, skb->dev, NULL,
br_handle_frame_finish, 1); br_handle_frame_finish, 1);
...@@ -237,7 +238,7 @@ unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops, ...@@ -237,7 +238,7 @@ unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr; nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr;
skb->protocol = htons(ETH_P_IPV6); skb->protocol = htons(ETH_P_IPV6);
NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, state->sk, skb, NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
skb->dev, NULL, skb->dev, NULL,
br_nf_pre_routing_finish_ipv6); br_nf_pre_routing_finish_ipv6);
......
...@@ -59,8 +59,8 @@ static void br_send_bpdu(struct net_bridge_port *p, ...@@ -59,8 +59,8 @@ static void br_send_bpdu(struct net_bridge_port *p,
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb, NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
NULL, skb->dev, dev_net(p->dev), NULL, skb, NULL, skb->dev,
br_send_bpdu_finish); br_send_bpdu_finish);
} }
......
...@@ -246,8 +246,9 @@ static int dn_long_output(struct neighbour *neigh, struct sock *sk, ...@@ -246,8 +246,9 @@ static int dn_long_output(struct neighbour *neigh, struct sock *sk,
skb_reset_network_header(skb); skb_reset_network_header(skb);
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
NULL, neigh->dev, dn_neigh_output_packet); &init_net, sk, skb, NULL, neigh->dev,
dn_neigh_output_packet);
} }
/* /*
...@@ -286,8 +287,9 @@ static int dn_short_output(struct neighbour *neigh, struct sock *sk, ...@@ -286,8 +287,9 @@ static int dn_short_output(struct neighbour *neigh, struct sock *sk,
skb_reset_network_header(skb); skb_reset_network_header(skb);
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
NULL, neigh->dev, dn_neigh_output_packet); &init_net, sk, skb, NULL, neigh->dev,
dn_neigh_output_packet);
} }
/* /*
...@@ -327,8 +329,9 @@ static int dn_phase3_output(struct neighbour *neigh, struct sock *sk, ...@@ -327,8 +329,9 @@ static int dn_phase3_output(struct neighbour *neigh, struct sock *sk,
skb_reset_network_header(skb); skb_reset_network_header(skb);
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
NULL, neigh->dev, dn_neigh_output_packet); &init_net, sk, skb, NULL, neigh->dev,
dn_neigh_output_packet);
} }
int dn_to_neigh_output(struct sock *sk, struct sk_buff *skb) int dn_to_neigh_output(struct sock *sk, struct sk_buff *skb)
......
...@@ -814,8 +814,8 @@ free_out: ...@@ -814,8 +814,8 @@ free_out:
int dn_nsp_rx(struct sk_buff *skb) int dn_nsp_rx(struct sk_buff *skb)
{ {
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_IN, NULL, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_IN,
skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_nsp_rx_packet); dn_nsp_rx_packet);
} }
......
...@@ -573,8 +573,8 @@ static int dn_route_rx_long(struct sk_buff *skb) ...@@ -573,8 +573,8 @@ static int dn_route_rx_long(struct sk_buff *skb)
ptr++; ptr++;
cb->hops = *ptr++; /* Visit Count */ cb->hops = *ptr++; /* Visit Count */
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING, NULL, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING,
skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_route_rx_packet); dn_route_rx_packet);
drop_it: drop_it:
...@@ -601,8 +601,8 @@ static int dn_route_rx_short(struct sk_buff *skb) ...@@ -601,8 +601,8 @@ static int dn_route_rx_short(struct sk_buff *skb)
ptr += 2; ptr += 2;
cb->hops = *ptr & 0x3f; cb->hops = *ptr & 0x3f;
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING, NULL, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING,
skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_route_rx_packet); dn_route_rx_packet);
drop_it: drop_it:
...@@ -706,22 +706,22 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type ...@@ -706,22 +706,22 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
switch (flags & DN_RT_CNTL_MSK) { switch (flags & DN_RT_CNTL_MSK) {
case DN_RT_PKT_HELO: case DN_RT_PKT_HELO:
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
NULL, skb, skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_route_ptp_hello); dn_route_ptp_hello);
case DN_RT_PKT_L1RT: case DN_RT_PKT_L1RT:
case DN_RT_PKT_L2RT: case DN_RT_PKT_L2RT:
return NF_HOOK(NFPROTO_DECNET, NF_DN_ROUTE, return NF_HOOK(NFPROTO_DECNET, NF_DN_ROUTE,
NULL, skb, skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_route_discard); dn_route_discard);
case DN_RT_PKT_ERTH: case DN_RT_PKT_ERTH:
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
NULL, skb, skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_neigh_router_hello); dn_neigh_router_hello);
case DN_RT_PKT_EEDH: case DN_RT_PKT_EEDH:
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
NULL, skb, skb->dev, NULL, &init_net, NULL, skb, skb->dev, NULL,
dn_neigh_endnode_hello); dn_neigh_endnode_hello);
} }
} else { } else {
...@@ -770,8 +770,8 @@ static int dn_output(struct sock *sk, struct sk_buff *skb) ...@@ -770,8 +770,8 @@ static int dn_output(struct sock *sk, struct sk_buff *skb)
cb->rt_flags |= DN_RT_F_IE; cb->rt_flags |= DN_RT_F_IE;
cb->hops = 0; cb->hops = 0;
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_OUT, sk, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_OUT,
NULL, dev, &init_net, sk, skb, NULL, dev,
dn_to_neigh_output); dn_to_neigh_output);
error: error:
...@@ -819,8 +819,8 @@ static int dn_forward(struct sk_buff *skb) ...@@ -819,8 +819,8 @@ static int dn_forward(struct sk_buff *skb)
if (rt->rt_flags & RTCF_DOREDIRECT) if (rt->rt_flags & RTCF_DOREDIRECT)
cb->rt_flags |= DN_RT_F_IE; cb->rt_flags |= DN_RT_F_IE;
return NF_HOOK(NFPROTO_DECNET, NF_DN_FORWARD, NULL, skb, return NF_HOOK(NFPROTO_DECNET, NF_DN_FORWARD,
dev, skb->dev, &init_net, NULL, skb, dev, skb->dev,
dn_to_neigh_output); dn_to_neigh_output);
drop: drop:
......
...@@ -632,8 +632,9 @@ static int arp_xmit_finish(struct sock *sk, struct sk_buff *skb) ...@@ -632,8 +632,9 @@ static int arp_xmit_finish(struct sock *sk, struct sk_buff *skb)
void arp_xmit(struct sk_buff *skb) void arp_xmit(struct sk_buff *skb)
{ {
/* Send it off, maybe filter it using firewalling first. */ /* Send it off, maybe filter it using firewalling first. */
NF_HOOK(NFPROTO_ARP, NF_ARP_OUT, NULL, skb, NF_HOOK(NFPROTO_ARP, NF_ARP_OUT,
NULL, skb->dev, arp_xmit_finish); dev_net(skb->dev), NULL, skb, NULL, skb->dev,