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

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 @@ static int vrf_finish_output(struct sock *sk, struct sk_buff *skb) ...@@ -298,14 +298,15 @@ static int vrf_finish_output(struct sock *sk, struct sk_buff *skb)
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 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) ...@@ -308,8 +309,8 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
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 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb) ...@@ -394,7 +394,7 @@ static int br_nf_pre_routing_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_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 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb) ...@@ -414,7 +414,7 @@ static int br_nf_pre_routing_finish(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);
...@@ -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 @@ static int dn_nsp_rx_packet(struct sock *sk2, struct sk_buff *skb) ...@@ -814,8 +814,8 @@ static int dn_nsp_rx_packet(struct sock *sk2, struct sk_buff *skb)
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,
arp_xmit_finish);
} }
EXPORT_SYMBOL(arp_xmit); EXPORT_SYMBOL(arp_xmit);
...@@ -897,8 +898,9 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -897,8 +898,9 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,
memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb)); memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
return NF_HOOK(NFPROTO_ARP, NF_ARP_IN, NULL, skb, return NF_HOOK(NFPROTO_ARP, NF_ARP_IN,
dev, NULL, arp_process); dev_net(dev), NULL, skb, dev, NULL,
arp_process);
consumeskb: consumeskb:
consume_skb(skb); consume_skb(skb);
......
...@@ -146,8 +146,9 @@ int ip_forward(struct sk_buff *skb) ...@@ -146,8 +146,9 @@ int ip_forward(struct sk_buff *skb)
skb->priority = rt_tos2priority(iph->tos); skb->priority = rt_tos2priority(iph->tos);
return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, NULL, skb, return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
skb->dev, rt->dst.dev, ip_forward_finish); net, NULL, skb, skb->dev, rt->dst.dev,
ip_forward_finish);
sr_failed: sr_failed:
/* /*
......
...@@ -254,8 +254,8 @@ int ip_local_deliver(struct sk_buff *skb) ...@@ -254,8 +254,8 @@ int ip_local_deliver(struct sk_buff *skb)
return 0; return 0;
} }
return NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_IN, NULL, skb, return NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_IN,
skb->dev, NULL, dev_net(skb->dev), NULL, skb, skb->dev, NULL,
ip_local_deliver_finish); ip_local_deliver_finish);
} }
...@@ -453,8 +453,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, ...@@ -453,8 +453,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
/* Must drop socket now because of tproxy. */ /* Must drop socket now because of tproxy. */
skb_orphan(skb); skb_orphan(skb);
return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, NULL, skb, return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
dev, NULL, net, NULL, skb, dev, NULL,
ip_rcv_finish); ip_rcv_finish);
csum_error: csum_error:
......
...@@ -97,12 +97,14 @@ EXPORT_SYMBOL(ip_send_check); ...@@ -97,12 +97,14 @@ EXPORT_SYMBOL(ip_send_check);
static int __ip_local_out_sk(struct sock *sk, struct sk_buff *skb) static int __ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
{ {
struct net *net = dev_net(skb_dst(skb)->dev);
struct iphdr *iph = ip_hdr(skb); struct iphdr *iph = ip_hdr(skb);
iph->tot_len = htons(skb->len); iph->tot_len = htons(skb->len);
ip_send_check(iph); ip_send_check(iph);
return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb, NULL, return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
skb_dst(skb)->dev, dst_output); net, sk, skb, NULL, skb_dst(skb)->dev,
dst_output);
} }
int __ip_local_out(struct sk_buff *skb) int __ip_local_out(struct sk_buff *skb)
...@@ -322,7 +324,7 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb) ...@@ -322,7 +324,7 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
if (newskb) if (newskb)
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
sk, newskb, NULL, newskb->dev, net, sk, newskb, NULL, newskb->dev,
dev_loopback_xmit); dev_loopback_xmit);
} }
...@@ -337,12 +339,14 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb) ...@@ -337,12 +339,14 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
if (rt->rt_flags&RTCF_BROADCAST) { if (rt->rt_flags&RTCF_BROADCAST) {
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
if (newskb) if (newskb)
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, newskb, NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
NULL, newskb->dev, dev_loopback_xmit); net, sk, newskb, NULL, newskb->dev,
dev_loopback_xmit);
} }
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb, NULL, return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
skb->dev, ip_finish_output, net, sk, skb, NULL, skb->dev,
ip_finish_output,
!(IPCB(skb)->flags & IPSKB_REROUTED)); !(IPCB(skb)->flags & IPSKB_REROUTED));
} }
...@@ -356,8 +360,8 @@ int ip_output(struct sock *sk, struct sk_buff *skb) ...@@ -356,8 +360,8 @@ int ip_output(struct sock *sk, struct sk_buff *skb)
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,
ip_finish_output, ip_finish_output,
!(IPCB(skb)->flags & IPSKB_REROUTED)); !(IPCB(skb)->flags & IPSKB_REROUTED));
} }
......
...@@ -1788,8 +1788,8 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt, ...@@ -1788,8 +1788,8 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
* not mrouter) cannot join to more than one interface - it will * not mrouter) cannot join to more than one interface - it will
* result in receiving multiple packets. * result in receiving multiple packets.
*/ */
NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, NULL, skb, NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
skb->dev, dev, net, NULL, skb, skb->dev, dev,
ipmr_forward_finish); ipmr_forward_finish);
return; return;
......
...@@ -411,8 +411,9 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4, ...@@ -411,8 +411,9 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
icmp_out_count(net, ((struct icmphdr *) icmp_out_count(net, ((struct icmphdr *)
skb_transport_header(skb))->type); skb_transport_header(skb))->type);
err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb, err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
NULL, rt->dst.dev, dst_output); net, sk, skb, NULL, rt->dst.dev,
dst_output);
if (err > 0) if (err > 0)
err = net_xmit_errno(err); err = net_xmit_errno(err);
if (err) if (err)
......
...@@ -52,8 +52,8 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async) ...@@ -52,8 +52,8 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async)
iph->tot_len = htons(skb->len); iph->tot_len = htons(skb->len);
ip_send_check(iph); ip_send_check(iph);
NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, NULL, skb, NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
skb->dev, NULL, dev_net(skb->dev), NULL, skb, skb->dev, NULL,
xfrm4_rcv_encap_finish); xfrm4_rcv_encap_finish);
return 0; return 0;
} }
......
...@@ -96,8 +96,10 @@ static int __xfrm4_output(struct sock *sk, struct sk_buff *skb) ...@@ -96,8 +96,10 @@ static int __xfrm4_output(struct sock *sk, struct sk_buff *skb)
int xfrm4_output(struct sock *sk, struct sk_buff *skb) int xfrm4_output(struct sock *sk, struct sk_buff *skb)
{ {
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb, struct net *net = dev_net(skb_dst(skb)->dev);
NULL, skb_dst(skb)->dev, __xfrm4_output, return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
net, sk, skb, NULL, skb_dst(skb)->dev,
__xfrm4_output,
!(IPCB(skb)->flags & IPSKB_REROUTED)); !(IPCB(skb)->flags & IPSKB_REROUTED));
} }
......
...@@ -183,8 +183,8 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt ...@@ -183,8 +183,8 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
/* Must drop socket now because of tproxy. */ /* Must drop socket now because of tproxy. */
skb_orphan(skb); skb_orphan(skb);
return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, NULL, skb, return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
dev, NULL, net, NULL, skb, dev, NULL,
ip6_rcv_finish); ip6_rcv_finish);
err: err:
IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INHDRERRORS); IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INHDRERRORS);
...@@ -278,8 +278,8 @@ static int ip6_input_finish(struct sock *sk, struct sk_buff *skb) ...@@ -278,8 +278,8 @@ static int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
int ip6_input(struct sk_buff *skb) int ip6_input(struct sk_buff *skb)
{ {
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN, NULL, skb, return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
skb->dev, NULL, dev_net(skb->dev), NULL, skb, skb->dev, NULL,
ip6_input_finish); ip6_input_finish);
} }
......
...@@ -83,7 +83,7 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb) ...@@ -83,7 +83,7 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
*/ */
if (newskb) if (newskb)
NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING,
sk, newskb, NULL, newskb->dev, net, sk, newskb, NULL, newskb->dev,
dev_loopback_xmit); dev_loopback_xmit);
if (ipv6_hdr(skb)->hop_limit == 0) { if (ipv6_hdr(skb)->hop_limit == 0) {
...@@ -142,8 +142,8 @@ int ip6_output(struct sock *sk, struct sk_buff *skb) ...@@ -142,8 +142,8 @@ int ip6_output(struct sock *sk, struct sk_buff *skb)
return 0; return 0;
} }
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, sk, skb, return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
NULL, dev, net, sk, skb, NULL, dev,
ip6_finish_output, ip6_finish_output,
!(IP6CB(skb)->flags & IP6SKB_REROUTED)); !(IP6CB(skb)->flags & IP6SKB_REROUTED));
} }
...@@ -223,8 +223,9 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, ...@@ -223,8 +223,9 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) { if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) {
IP6_UPD_PO_STATS(net, ip6_dst_idev(skb_dst(skb)), IP6_UPD_PO_STATS(net, ip6_dst_idev(skb_dst(skb)),
IPSTATS_MIB_OUT, skb->len); IPSTATS_MIB_OUT, skb->len);
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb, return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
NULL, dst->dev, dst_output); net, sk, skb, NULL, dst->dev,
dst_output);
} }
skb->dev = dst->dev; skb->dev = dst->dev;
...@@ -511,8 +512,8 @@ int ip6_forward(struct sk_buff *skb) ...@@ -511,8 +512,8 @@ int ip6_forward(struct sk_buff *skb)
IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, NULL, skb, return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
skb->dev, dst->dev, net, NULL, skb, skb->dev, dst->dev,
ip6_forward_finish); ip6_forward_finish);
error: error:
......
...@@ -2064,8 +2064,8 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, ...@@ -2064,8 +2064,8 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
IP6CB(skb)->flags |= IP6SKB_FORWARDED; IP6CB(skb)->flags |= IP6SKB_FORWARDED;
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, NULL, skb, return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
skb->dev, dev, net, NULL, skb, skb->dev, dev,
ip6mr_forward2_finish); ip6mr_forward2_finish);
out_free: out_free:
......
...@@ -1645,7 +1645,7 @@ static void mld_sendpack(struct sk_buff *skb) ...@@ -1645,7 +1645,7 @@ static void mld_sendpack(struct sk_buff *skb)
payload_len = skb->len; payload_len = skb->len;
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
net->ipv6.igmp_sk, skb, NULL, skb->dev, net, net->ipv6.igmp_sk, skb, NULL, skb->dev,
dst_output); dst_output);
out: out:
if (!err) { if (!err) {
...@@ -2008,8 +2008,9 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) ...@@ -2008,8 +2008,9 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
} }
skb_dst_set(skb, dst); skb_dst_set(skb, dst);
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb, err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
NULL, skb->dev, dst_output); net, sk, skb, NULL, skb->dev,
dst_output);
out: out:
if (!err) { if (!err) {
ICMP6MSGOUT_INC_STATS(net, idev, type); ICMP6MSGOUT_INC_STATS(net, idev, type);
......
...@@ -463,8 +463,8 @@ static void ndisc_send_skb(struct sk_buff *skb, ...@@ -463,8 +463,8 @@ static void ndisc_send_skb(struct sk_buff *skb,
idev = __in6_dev_get(dst->dev); idev = __in6_dev_get(dst->dev);
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len); IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len);
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb, err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
NULL, dst->dev, net, sk, skb, NULL, dst->dev,
dst_output); dst_output);
if (!err) { if (!err) {
ICMP6MSGOUT_INC_STATS(net, idev, type); ICMP6MSGOUT_INC_STATS(net, idev, type);
......
...@@ -74,7 +74,7 @@ static unsigned int ipv6_defrag(const struct nf_hook_ops *ops, ...@@ -74,7 +74,7 @@ static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
nf_ct_frag6_consume_orig(reasm); nf_ct_frag6_consume_orig(reasm);
NF_HOOK_THRESH(NFPROTO_IPV6, ops->hooknum, state->sk, reasm, NF_HOOK_THRESH(NFPROTO_IPV6, ops->hooknum, state->net, state->sk, reasm,
state->in, state->out, state->in, state->out,
state->okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1); state->okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1);
......
...@@ -140,6 +140,7 @@ EXPORT_SYMBOL(ip6_dst_hoplimit); ...@@ -140,6 +140,7 @@ EXPORT_SYMBOL(ip6_dst_hoplimit);
static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb) static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
{ {
struct net *net = dev_net(skb_dst(skb)->dev);
int len; int len;
len = skb->len - sizeof(struct ipv6hdr); len = skb->len - sizeof(struct ipv6hdr);
...@@ -148,8 +149,9 @@ static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb) ...@@ -148,8 +149,9 @@ static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
ipv6_hdr(skb)->payload_len = htons(len); ipv6_hdr(skb)->payload_len = htons(len);
IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr); IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb, return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
NULL, skb_dst(skb)->dev, dst_output); net, sk, skb, NULL, skb_dst(skb)->dev,
dst_output);
} }
int __ip6_local_out(struct sk_buff *skb) int __ip6_local_out(struct sk_buff *skb)
......
...@@ -654,7 +654,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, ...@@ -654,7 +654,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
goto error_fault; goto error_fault;
IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len); IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len);
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb, err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, sk, skb,
NULL, rt->dst.dev, dst_output); NULL, rt->dst.dev, dst_output);
if (err > 0) if (err > 0)
err = net_xmit_errno(err); err = net_xmit_errno(err);
......
...@@ -42,8 +42,8 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async) ...@@ -42,8 +42,8 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
ipv6_hdr(skb)->payload_len = htons(skb->len); ipv6_hdr(skb)->payload_len = htons(skb->len);
__skb_push(skb, skb->data - skb_network_header(skb)); __skb_push(skb, skb->data - skb_network_header(skb));
NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, NULL, skb, NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
skb->dev, NULL, dev_net(skb->dev), NULL, skb, skb->dev, NULL,
ip6_rcv_finish); ip6_rcv_finish);
return -1; return -1;
} }
......
...@@ -168,7 +168,9 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb) ...@@ -168,7 +168,9 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb)
int xfrm6_output(struct sock *sk, struct sk_buff *skb) int xfrm6_output(struct sock *sk, struct sk_buff *skb)
{ {
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, sk, skb, struct net *net = dev_net(skb_dst(skb)->dev);
NULL, skb_dst(skb)->dev, __xfrm6_output, return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
net, sk, skb, NULL, skb_dst(skb)->dev,
__xfrm6_output,
!(IP6CB(skb)->flags & IP6SKB_REROUTED)); !(IP6CB(skb)->flags & IP6SKB_REROUTED));
} }
...@@ -573,7 +573,7 @@ static inline int ip_vs_nat_send_or_cont(int pf, struct sk_buff *skb, ...@@ -573,7 +573,7 @@ static inline int ip_vs_nat_send_or_cont(int pf, struct sk_buff *skb,
skb_forward_csum(skb); skb_forward_csum(skb);
if (!skb->sk) if (!skb->sk)
skb_sender_cpu_clear(skb); skb_sender_cpu_clear(skb);
NF_HOOK(pf, NF_INET_LOCAL_OUT, NULL, skb, NF_HOOK(pf, NF_INET_LOCAL_OUT, ip_vs_conn_net(cp), NULL, skb,
NULL, skb_dst(skb)->dev, dst_output); NULL, skb_dst(skb)->dev, dst_output);
} else } else
ret = NF_ACCEPT; ret = NF_ACCEPT;
...@@ -595,7 +595,7 @@ static inline int ip_vs_send_or_cont(int pf, struct sk_buff *skb, ...@@ -595,7 +595,7 @@ static inline int ip_vs_send_or_cont(int pf, struct sk_buff *skb,
skb_forward_csum(skb); skb_forward_csum(skb);
if (!skb->sk) if (!skb->sk)
skb_sender_cpu_clear(skb); skb_sender_cpu_clear(skb);
NF_HOOK(pf, NF_INET_LOCAL_OUT, NULL, skb, NF_HOOK(pf, NF_INET_LOCAL_OUT, ip_vs_conn_net(cp), NULL, skb,
NULL, skb_dst(skb)->dev, dst_output); NULL, skb_dst(skb)->dev, dst_output);
} else } else
ret = NF_ACCEPT; ret = NF_ACCEPT;
......
...@@ -131,6 +131,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err) ...@@ -131,6 +131,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
int xfrm_output_resume(struct sk_buff *skb, int err) int xfrm_output_resume(struct sk_buff *skb, int err)
{ {
struct net *net = xs_net(skb_dst(skb)->xfrm);
while (likely((err = xfrm_output_one(skb, err)) == 0)) { while (likely((err = xfrm_output_one(skb, err)) == 0)) {
nf_reset(skb); nf_reset(skb);
...@@ -142,7 +143,7 @@ int xfrm_output_resume(struct sk_buff *skb, int err) ...@@ -142,7 +143,7 @@ int xfrm_output_resume(struct sk_buff *skb, int err)
return dst_output(skb->sk, skb); return dst_output(skb->sk, skb);
err = nf_hook(skb_dst(skb)->ops->family, err = nf_hook(skb_dst(skb)->ops->family,
NF_INET_POST_ROUTING, skb->sk, skb, NF_INET_POST_ROUTING, net, skb->sk, skb,
NULL, skb_dst(skb)->dev, xfrm_output2); NULL, skb_dst(skb)->dev, xfrm_output2);
if (unlikely(err != 1)) if (unlikely(err != 1))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment