mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
Merge branch 'nf_hook_netns'
Eric W. Biederman says: ==================== Passing net through the netfilter hooks My primary goal with this patchset and it's follow ups is to cleanup the network routing paths so that we do not look at the output device to derive the network namespace. My plan is to pass the network namespace of the transmitting socket through the output path, to replace code that looks at the output network device today. Once that is done we can have routes with output devices outside of the current network namespace. Which should allow reception and transmission of packets in network namespaces to be as fast as normal packet reception and transmission with early demux disabled, because it will same code path. Once skb_dst(skb)->dev is a little better under control I think it will also be possible to use rcu to cleanup the ancient hack that sets dst->dev to loopback_dev when a network device is removed. The work to get there is a series of code cleanups. I am starting with passing net into the netfilter hooks and into the functions that are called after the netfilter hooks. This removes from netfilter the need to guess which network namespace it is working on. To get there I perform a series of minor prep patches so the big changes at the end are possible to audit without getting lost in the noise. In particular I have a lot of patches computing net into a local variable and then using it through out the function. So this patchset encompases removing dead code, sorting out the _sk functions that were added last time someone pushed a prototype change through the post netfilter functions. Cleaning up individual functions use of the network namespace. Passing net into the netfilter hooks. Passing net into the post netfilter functions. Using state->net in the netfilter code where it is available and trivially usable. Pablo, Dave I don't know whose tree this makes more sense to go through. I am assuming at least initially Pablos as netfilter is involved. From what I have seen there will be a lot of back and forth between the netfilter code paths and the routing code paths. The patches are also available (against 4.3-rc1) at: git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/net-next.git master ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
bbe8373138
67 changed files with 379 additions and 358 deletions
|
@ -253,7 +253,7 @@ static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||
}
|
||||
|
||||
/* modelled after ip_finish_output2 */
|
||||
static int vrf_finish_output(struct sock *sk, struct sk_buff *skb)
|
||||
static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct rtable *rt = (struct rtable *)dst;
|
||||
|
@ -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)
|
||||
{
|
||||
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->protocol = htons(ETH_P_IP);
|
||||
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb,
|
||||
NULL, dev,
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
|
||||
net, sk, skb, NULL, dev,
|
||||
vrf_finish_output,
|
||||
!(IPCB(skb)->flags & IPSKB_REROUTED));
|
||||
}
|
||||
|
|
|
@ -2212,12 +2212,8 @@ int dev_open(struct net_device *dev);
|
|||
int dev_close(struct net_device *dev);
|
||||
int dev_close_many(struct list_head *head, bool unlink);
|
||||
void dev_disable_lro(struct net_device *dev);
|
||||
int dev_loopback_xmit(struct sock *sk, struct sk_buff *newskb);
|
||||
int dev_queue_xmit_sk(struct sock *sk, struct sk_buff *skb);
|
||||
static inline int dev_queue_xmit(struct sk_buff *skb)
|
||||
{
|
||||
return dev_queue_xmit_sk(skb->sk, skb);
|
||||
}
|
||||
int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
|
||||
int dev_queue_xmit(struct sk_buff *skb);
|
||||
int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv);
|
||||
int register_netdevice(struct net_device *dev);
|
||||
void unregister_netdevice_queue(struct net_device *dev, struct list_head *head);
|
||||
|
@ -2989,11 +2985,7 @@ static inline void dev_consume_skb_any(struct sk_buff *skb)
|
|||
|
||||
int netif_rx(struct sk_buff *skb);
|
||||
int netif_rx_ni(struct sk_buff *skb);
|
||||
int netif_receive_skb_sk(struct sock *sk, struct sk_buff *skb);
|
||||
static inline int netif_receive_skb(struct sk_buff *skb)
|
||||
{
|
||||
return netif_receive_skb_sk(skb->sk, skb);
|
||||
}
|
||||
int netif_receive_skb(struct sk_buff *skb);
|
||||
gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb);
|
||||
void napi_gro_flush(struct napi_struct *napi, bool flush_old);
|
||||
struct sk_buff *napi_get_frags(struct napi_struct *napi);
|
||||
|
|
|
@ -54,8 +54,9 @@ struct nf_hook_state {
|
|||
struct net_device *in;
|
||||
struct net_device *out;
|
||||
struct sock *sk;
|
||||
struct net *net;
|
||||
struct list_head *hook_list;
|
||||
int (*okfn)(struct sock *, struct sk_buff *);
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *);
|
||||
};
|
||||
|
||||
static inline void nf_hook_state_init(struct nf_hook_state *p,
|
||||
|
@ -65,7 +66,8 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
|
|||
struct net_device *indev,
|
||||
struct net_device *outdev,
|
||||
struct sock *sk,
|
||||
int (*okfn)(struct sock *, struct sk_buff *))
|
||||
struct net *net,
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *))
|
||||
{
|
||||
p->hook = hook;
|
||||
p->thresh = thresh;
|
||||
|
@ -73,6 +75,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
|
|||
p->in = indev;
|
||||
p->out = outdev;
|
||||
p->sk = sk;
|
||||
p->net = net;
|
||||
p->hook_list = hook_list;
|
||||
p->okfn = okfn;
|
||||
}
|
||||
|
@ -167,32 +170,32 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
|
|||
* value indicates the packet has been consumed by the hook.
|
||||
*/
|
||||
static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
|
||||
struct net *net,
|
||||
struct sock *sk,
|
||||
struct sk_buff *skb,
|
||||
struct net_device *indev,
|
||||
struct net_device *outdev,
|
||||
int (*okfn)(struct sock *, struct sk_buff *),
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *),
|
||||
int thresh)
|
||||
{
|
||||
struct net *net = dev_net(indev ? indev : outdev);
|
||||
struct list_head *hook_list = &net->nf.hooks[pf][hook];
|
||||
|
||||
if (nf_hook_list_active(hook_list, pf, hook)) {
|
||||
struct nf_hook_state state;
|
||||
|
||||
nf_hook_state_init(&state, hook_list, hook, thresh,
|
||||
pf, indev, outdev, sk, okfn);
|
||||
pf, indev, outdev, sk, net, okfn);
|
||||
return nf_hook_slow(skb, &state);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
|
||||
struct sk_buff *skb, struct net_device *indev,
|
||||
struct net_device *outdev,
|
||||
int (*okfn)(struct sock *, struct sk_buff *))
|
||||
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
|
||||
struct sock *sk, struct sk_buff *skb,
|
||||
struct net_device *indev, struct net_device *outdev,
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *))
|
||||
{
|
||||
return nf_hook_thresh(pf, hook, sk, skb, indev, outdev, okfn, INT_MIN);
|
||||
return nf_hook_thresh(pf, hook, net, sk, skb, indev, outdev, okfn, INT_MIN);
|
||||
}
|
||||
|
||||
/* Activate hook; either okfn or kfree_skb called, unless a hook
|
||||
|
@ -213,36 +216,38 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
|
|||
*/
|
||||
|
||||
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 net_device *out,
|
||||
int (*okfn)(struct sock *, struct sk_buff *), int thresh)
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *),
|
||||
int thresh)
|
||||
{
|
||||
int ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, thresh);
|
||||
int ret = nf_hook_thresh(pf, hook, net, sk, skb, in, out, okfn, thresh);
|
||||
if (ret == 1)
|
||||
ret = okfn(sk, skb);
|
||||
ret = okfn(net, sk, skb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
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,
|
||||
int (*okfn)(struct sock *, struct sk_buff *), bool cond)
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *),
|
||||
bool cond)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!cond ||
|
||||
((ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, INT_MIN)) == 1))
|
||||
ret = okfn(sk, skb);
|
||||
((ret = nf_hook_thresh(pf, hook, net, sk, skb, in, out, okfn, INT_MIN)) == 1))
|
||||
ret = okfn(net, sk, skb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
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,
|
||||
int (*okfn)(struct sock *, struct sk_buff *))
|
||||
int (*okfn)(struct net *, 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() */
|
||||
|
@ -342,21 +347,12 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
|
|||
}
|
||||
|
||||
#else /* !CONFIG_NETFILTER */
|
||||
#define NF_HOOK(pf, hook, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
|
||||
#define NF_HOOK_COND(pf, hook, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
|
||||
static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
|
||||
struct sock *sk,
|
||||
struct sk_buff *skb,
|
||||
struct net_device *indev,
|
||||
struct net_device *outdev,
|
||||
int (*okfn)(struct sock *sk, struct sk_buff *), int thresh)
|
||||
{
|
||||
return okfn(sk, skb);
|
||||
}
|
||||
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
|
||||
struct sk_buff *skb, struct net_device *indev,
|
||||
struct net_device *outdev,
|
||||
int (*okfn)(struct sock *, struct sk_buff *))
|
||||
#define NF_HOOK(pf, hook, net, sk, skb, indev, outdev, okfn) (okfn)(net, sk, skb)
|
||||
#define NF_HOOK_COND(pf, hook, net, sk, skb, indev, outdev, okfn, cond) (okfn)(net, sk, skb)
|
||||
static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
|
||||
struct sock *sk, struct sk_buff *skb,
|
||||
struct net_device *indev, struct net_device *outdev,
|
||||
int (*okfn)(struct net *, struct sock *, struct sk_buff *))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ enum nf_br_hook_priorities {
|
|||
|
||||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
||||
|
||||
int br_handle_frame_finish(struct sock *sk, struct sk_buff *skb);
|
||||
int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
static inline void br_drop_fake_rtable(struct sk_buff *skb)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ static inline int nf_hook_ingress(struct sk_buff *skb)
|
|||
|
||||
nf_hook_state_init(&state, &skb->dev->nf_hooks_ingress,
|
||||
NF_NETDEV_INGRESS, INT_MIN, NFPROTO_NETDEV, NULL,
|
||||
skb->dev, NULL, NULL);
|
||||
skb->dev, NULL, dev_net(skb->dev), NULL);
|
||||
return nf_hook_slow(skb, &state);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ struct dn_neigh {
|
|||
|
||||
void dn_neigh_init(void);
|
||||
void dn_neigh_cleanup(void);
|
||||
int dn_neigh_router_hello(struct sock *sk, struct sk_buff *skb);
|
||||
int dn_neigh_endnode_hello(struct sock *sk, struct sk_buff *skb);
|
||||
int dn_neigh_router_hello(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
int dn_neigh_endnode_hello(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
void dn_neigh_pointopoint_hello(struct sk_buff *skb);
|
||||
int dn_neigh_elist(struct net_device *dev, unsigned char *ptr, int n);
|
||||
int dn_to_neigh_output(struct sock *sk, struct sk_buff *skb);
|
||||
int dn_to_neigh_output(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
extern struct neigh_table dn_neigh_table;
|
||||
|
||||
|
|
|
@ -454,13 +454,13 @@ static inline void dst_set_expires(struct dst_entry *dst, int timeout)
|
|||
}
|
||||
|
||||
/* Output packet to network from transport. */
|
||||
static inline int dst_output_sk(struct sock *sk, struct sk_buff *skb)
|
||||
static inline int dst_output(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return skb_dst(skb)->output(sk, skb);
|
||||
}
|
||||
static inline int dst_output(struct sk_buff *skb)
|
||||
static inline int dst_output_okfn(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return dst_output_sk(skb->sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
|
||||
/* Input packet from network to transport. */
|
||||
|
|
|
@ -807,7 +807,7 @@ static inline u8 ip6_tclass(__be32 flowinfo)
|
|||
int ipv6_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
struct packet_type *pt, struct net_device *orig_dev);
|
||||
|
||||
int ip6_rcv_finish(struct sock *sk, struct sk_buff *skb);
|
||||
int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
/*
|
||||
* upper-layer output functions
|
||||
|
|
|
@ -31,7 +31,7 @@ static inline void nf_bridge_push_encap_header(struct sk_buff *skb)
|
|||
skb->network_header -= len;
|
||||
}
|
||||
|
||||
int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb);
|
||||
int br_nf_pre_routing_finish_bridge(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
|
||||
{
|
||||
|
|
|
@ -296,8 +296,6 @@ struct xfrm_policy_afinfo {
|
|||
struct flowi *fl,
|
||||
int reverse);
|
||||
int (*get_tos)(const struct flowi *fl);
|
||||
void (*init_dst)(struct net *net,
|
||||
struct xfrm_dst *dst);
|
||||
int (*init_path)(struct xfrm_dst *path,
|
||||
struct dst_entry *dst,
|
||||
int nfheader_len);
|
||||
|
|
|
@ -35,7 +35,7 @@ static inline int should_deliver(const struct net_bridge_port *p,
|
|||
p->state == BR_STATE_FORWARDING;
|
||||
}
|
||||
|
||||
int br_dev_queue_push_xmit(struct sock *sk, struct sk_buff *skb)
|
||||
int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
if (!is_skb_forwardable(skb->dev, skb))
|
||||
goto drop;
|
||||
|
@ -65,10 +65,10 @@ int br_dev_queue_push_xmit(struct sock *sk, struct sk_buff *skb)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(br_dev_queue_push_xmit);
|
||||
|
||||
int br_forward_finish(struct sock *sk, struct sk_buff *skb)
|
||||
int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, sk, skb,
|
||||
NULL, skb->dev,
|
||||
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING,
|
||||
net, sk, skb, NULL, skb->dev,
|
||||
br_dev_queue_push_xmit);
|
||||
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
|
|||
return;
|
||||
}
|
||||
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb,
|
||||
NULL, skb->dev,
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
|
||||
dev_net(skb->dev), NULL, skb,NULL, skb->dev,
|
||||
br_forward_finish);
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,8 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
|
|||
skb->dev = to->dev;
|
||||
skb_forward_csum(skb);
|
||||
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, NULL, skb,
|
||||
indev, skb->dev,
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD,
|
||||
dev_net(indev), NULL, skb, indev, skb->dev,
|
||||
br_forward_finish);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
br_should_route_hook_t __rcu *br_should_route_hook __read_mostly;
|
||||
EXPORT_SYMBOL(br_should_route_hook);
|
||||
|
||||
static int
|
||||
br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return netif_receive_skb(skb);
|
||||
}
|
||||
|
||||
static int br_pass_frame_up(struct sk_buff *skb)
|
||||
{
|
||||
struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev;
|
||||
|
@ -55,9 +61,9 @@ static int br_pass_frame_up(struct sk_buff *skb)
|
|||
if (!skb)
|
||||
return NET_RX_DROP;
|
||||
|
||||
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, NULL, skb,
|
||||
indev, NULL,
|
||||
netif_receive_skb_sk);
|
||||
return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
|
||||
dev_net(indev), NULL, skb, indev, NULL,
|
||||
br_netif_receive_skb);
|
||||
}
|
||||
|
||||
static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br,
|
||||
|
@ -120,7 +126,7 @@ static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br,
|
|||
}
|
||||
|
||||
/* note: already called with rcu_read_lock */
|
||||
int br_handle_frame_finish(struct sock *sk, struct sk_buff *skb)
|
||||
int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
const unsigned char *dest = eth_hdr(skb)->h_dest;
|
||||
struct net_bridge_port *p = br_port_get_rcu(skb->dev);
|
||||
|
@ -208,7 +214,7 @@ int br_handle_frame_finish(struct sock *sk, struct sk_buff *skb)
|
|||
EXPORT_SYMBOL_GPL(br_handle_frame_finish);
|
||||
|
||||
/* note: already called with rcu_read_lock */
|
||||
static int br_handle_local_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net_bridge_port *p = br_port_get_rcu(skb->dev);
|
||||
u16 vid = 0;
|
||||
|
@ -278,8 +284,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
|
|||
}
|
||||
|
||||
/* Deliver packet to local host only */
|
||||
if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, NULL, skb,
|
||||
skb->dev, NULL, br_handle_local_finish)) {
|
||||
if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
br_handle_local_finish)) {
|
||||
return RX_HANDLER_CONSUMED; /* consumed by filter */
|
||||
} else {
|
||||
*pskb = skb;
|
||||
|
@ -303,8 +310,8 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
|
|||
if (ether_addr_equal(p->br->dev->dev_addr, dest))
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
br_handle_frame_finish);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -829,8 +829,8 @@ static void __br_multicast_send_query(struct net_bridge *br,
|
|||
|
||||
if (port) {
|
||||
skb->dev = port->dev;
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb,
|
||||
NULL, skb->dev,
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
|
||||
dev_net(port->dev), NULL, skb, NULL, skb->dev,
|
||||
br_dev_queue_push_xmit);
|
||||
} else {
|
||||
br_multicast_select_own_querier(br, ip, skb);
|
||||
|
|
|
@ -256,7 +256,7 @@ void nf_bridge_update_protocol(struct sk_buff *skb)
|
|||
* don't, we use the neighbour framework to find out. In both cases, we make
|
||||
* sure that br_handle_frame_finish() is called afterwards.
|
||||
*/
|
||||
int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb)
|
||||
int br_nf_pre_routing_finish_bridge(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct neighbour *neigh;
|
||||
struct dst_entry *dst;
|
||||
|
@ -273,7 +273,7 @@ int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb)
|
|||
if (neigh->hh.hh_len) {
|
||||
neigh_hh_bridge(&neigh->hh, skb);
|
||||
skb->dev = nf_bridge->physindev;
|
||||
ret = br_handle_frame_finish(sk, skb);
|
||||
ret = br_handle_frame_finish(net, sk, skb);
|
||||
} else {
|
||||
/* the neighbour function below overwrites the complete
|
||||
* MAC header, so we save the Ethernet source address and
|
||||
|
@ -342,7 +342,7 @@ br_nf_ipv4_daddr_was_changed(const struct sk_buff *skb,
|
|||
* device, we proceed as if ip_route_input() succeeded. If it differs from the
|
||||
* logical bridge port or if ip_route_output_key() fails we drop the packet.
|
||||
*/
|
||||
static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net_device *dev = skb->dev;
|
||||
struct iphdr *iph = ip_hdr(skb);
|
||||
|
@ -371,7 +371,7 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
|||
if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
|
||||
goto free_skb;
|
||||
|
||||
rt = ip_route_output(dev_net(dev), iph->daddr, 0,
|
||||
rt = ip_route_output(net, iph->daddr, 0,
|
||||
RT_TOS(iph->tos), 0);
|
||||
if (!IS_ERR(rt)) {
|
||||
/* - Bridged-and-DNAT'ed traffic doesn't
|
||||
|
@ -393,7 +393,7 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
|||
nf_bridge_push_encap_header(skb);
|
||||
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,
|
||||
1);
|
||||
return 0;
|
||||
|
@ -413,7 +413,7 @@ static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
|
|||
skb->dev = nf_bridge->physindev;
|
||||
nf_bridge_update_protocol(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,
|
||||
br_handle_frame_finish, 1);
|
||||
|
||||
|
@ -511,7 +511,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
|
|||
|
||||
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,
|
||||
br_nf_pre_routing_finish);
|
||||
|
||||
|
@ -535,7 +535,7 @@ static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
|
|||
}
|
||||
|
||||
/* PF_BRIDGE/FORWARD *************************************************/
|
||||
static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
||||
struct net_device *in;
|
||||
|
@ -559,7 +559,7 @@ static int br_nf_forward_finish(struct sock *sk, struct sk_buff *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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
|
|||
else
|
||||
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),
|
||||
parent, br_nf_forward_finish);
|
||||
|
||||
|
@ -661,14 +661,14 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
|
|||
return NF_ACCEPT;
|
||||
}
|
||||
*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);
|
||||
|
||||
return NF_STOLEN;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) || IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
||||
static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_nf_push_frag_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct brnf_frag_data *data;
|
||||
int err;
|
||||
|
@ -690,23 +690,27 @@ static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
|
|||
__skb_push(skb, data->encap_size);
|
||||
|
||||
nf_bridge_info_free(skb);
|
||||
return br_dev_queue_push_xmit(sk, skb);
|
||||
return br_dev_queue_push_xmit(net, sk, skb);
|
||||
}
|
||||
static int br_nf_push_frag_xmit_sk(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
return br_nf_push_frag_xmit(net, sk, skb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
|
||||
static int br_nf_ip_fragment(struct sock *sk, struct sk_buff *skb,
|
||||
int (*output)(struct sock *, struct sk_buff *))
|
||||
static int
|
||||
br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
|
||||
int (*output)(struct sock *, struct sk_buff *))
|
||||
{
|
||||
unsigned int mtu = ip_skb_dst_mtu(skb);
|
||||
struct iphdr *iph = ip_hdr(skb);
|
||||
struct rtable *rt = skb_rtable(skb);
|
||||
struct net_device *dev = rt->dst.dev;
|
||||
|
||||
if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
|
||||
(IPCB(skb)->frag_max_size &&
|
||||
IPCB(skb)->frag_max_size > mtu))) {
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
||||
kfree_skb(skb);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
@ -722,7 +726,7 @@ static unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_nf_dev_queue_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct nf_bridge_info *nf_bridge;
|
||||
unsigned int mtu_reserved;
|
||||
|
@ -731,7 +735,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
if (skb_is_gso(skb) || skb->len + mtu_reserved <= skb->dev->mtu) {
|
||||
nf_bridge_info_free(skb);
|
||||
return br_dev_queue_push_xmit(sk, skb);
|
||||
return br_dev_queue_push_xmit(net, sk, skb);
|
||||
}
|
||||
|
||||
nf_bridge = nf_bridge_info_get(skb);
|
||||
|
@ -760,7 +764,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|||
skb_copy_from_linear_data_offset(skb, -data->size, data->mac,
|
||||
data->size);
|
||||
|
||||
return br_nf_ip_fragment(sk, skb, br_nf_push_frag_xmit);
|
||||
return br_nf_ip_fragment(net, sk, skb, br_nf_push_frag_xmit_sk);
|
||||
}
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
||||
|
@ -783,14 +787,14 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
|
|||
data->size);
|
||||
|
||||
if (v6ops)
|
||||
return v6ops->fragment(sk, skb, br_nf_push_frag_xmit);
|
||||
return v6ops->fragment(sk, skb, br_nf_push_frag_xmit_sk);
|
||||
|
||||
kfree_skb(skb);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
#endif
|
||||
nf_bridge_info_free(skb);
|
||||
return br_dev_queue_push_xmit(sk, skb);
|
||||
return br_dev_queue_push_xmit(net, sk, skb);
|
||||
drop:
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
|
@ -836,7 +840,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
|
|||
else
|
||||
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,
|
||||
br_nf_dev_queue_xmit);
|
||||
|
||||
|
@ -880,7 +884,7 @@ static void br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
|
|||
skb->dev = nf_bridge->physindev;
|
||||
|
||||
nf_bridge->physoutdev = NULL;
|
||||
br_handle_frame_finish(NULL, skb);
|
||||
br_handle_frame_finish(dev_net(skb->dev), NULL, skb);
|
||||
}
|
||||
|
||||
static int br_nf_dev_xmit(struct sk_buff *skb)
|
||||
|
|
|
@ -161,7 +161,7 @@ br_nf_ipv6_daddr_was_changed(const struct sk_buff *skb,
|
|||
* for br_nf_pre_routing_finish(), same logic is used here but
|
||||
* equivalent IPv6 function ip6_route_input() called indirectly.
|
||||
*/
|
||||
static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
|
||||
static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
||||
struct rtable *rt;
|
||||
|
@ -189,7 +189,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
|
|||
nf_bridge_update_protocol(skb);
|
||||
nf_bridge_push_encap_header(skb);
|
||||
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,
|
||||
1);
|
||||
return 0;
|
||||
|
@ -208,7 +208,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sock *sk, struct sk_buff *skb)
|
|||
skb->dev = nf_bridge->physindev;
|
||||
nf_bridge_update_protocol(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,
|
||||
br_handle_frame_finish, 1);
|
||||
|
||||
|
@ -237,7 +237,7 @@ unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
|
|||
nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr;
|
||||
|
||||
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,
|
||||
br_nf_pre_routing_finish_ipv6);
|
||||
|
||||
|
|
|
@ -413,10 +413,10 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
|
|||
|
||||
/* br_forward.c */
|
||||
void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb);
|
||||
int br_dev_queue_push_xmit(struct sock *sk, struct sk_buff *skb);
|
||||
int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
void br_forward(const struct net_bridge_port *to,
|
||||
struct sk_buff *skb, struct sk_buff *skb0);
|
||||
int br_forward_finish(struct sock *sk, struct sk_buff *skb);
|
||||
int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb, bool unicast);
|
||||
void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
|
||||
struct sk_buff *skb2, bool unicast);
|
||||
|
@ -434,7 +434,7 @@ void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
|
|||
void br_manage_promisc(struct net_bridge *br);
|
||||
|
||||
/* br_input.c */
|
||||
int br_handle_frame_finish(struct sock *sk, struct sk_buff *skb);
|
||||
int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
rx_handler_result_t br_handle_frame(struct sk_buff **pskb);
|
||||
|
||||
static inline bool br_rx_handler_check_rcu(const struct net_device *dev)
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
|
||||
#define LLC_RESERVE sizeof(struct llc_pdu_un)
|
||||
|
||||
static int br_send_bpdu_finish(struct net *net, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
return dev_queue_xmit(skb);
|
||||
}
|
||||
|
||||
static void br_send_bpdu(struct net_bridge_port *p,
|
||||
const unsigned char *data, int length)
|
||||
{
|
||||
|
@ -54,9 +60,9 @@ static void br_send_bpdu(struct net_bridge_port *p,
|
|||
|
||||
skb_reset_mac_header(skb);
|
||||
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, NULL, skb,
|
||||
NULL, skb->dev,
|
||||
dev_queue_xmit_sk);
|
||||
NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
|
||||
dev_net(p->dev), NULL, skb, NULL, skb->dev,
|
||||
br_send_bpdu_finish);
|
||||
}
|
||||
|
||||
static inline void br_set_ticks(unsigned char *dest, int j)
|
||||
|
|
|
@ -61,7 +61,7 @@ ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
|||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(ops->hooknum, skb, state->in, state->out,
|
||||
dev_net(state->in)->xt.frame_filter);
|
||||
state->net->xt.frame_filter);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
|
@ -69,7 +69,7 @@ ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
|||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(ops->hooknum, skb, state->in, state->out,
|
||||
dev_net(state->out)->xt.frame_filter);
|
||||
state->net->xt.frame_filter);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
|
||||
|
|
|
@ -61,7 +61,7 @@ ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
|||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(ops->hooknum, skb, state->in, state->out,
|
||||
dev_net(state->in)->xt.frame_nat);
|
||||
state->net->xt.frame_nat);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
|
@ -69,7 +69,7 @@ ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
|||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(ops->hooknum, skb, state->in, state->out,
|
||||
dev_net(state->out)->xt.frame_nat);
|
||||
state->net->xt.frame_nat);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
|
||||
|
|
|
@ -2915,9 +2915,11 @@ EXPORT_SYMBOL(xmit_recursion);
|
|||
|
||||
/**
|
||||
* dev_loopback_xmit - loop back @skb
|
||||
* @net: network namespace this loopback is happening in
|
||||
* @sk: sk needed to be a netfilter okfn
|
||||
* @skb: buffer to transmit
|
||||
*/
|
||||
int dev_loopback_xmit(struct sock *sk, struct sk_buff *skb)
|
||||
int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
skb_reset_mac_header(skb);
|
||||
__skb_pull(skb, skb_network_offset(skb));
|
||||
|
@ -3143,11 +3145,11 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int dev_queue_xmit_sk(struct sock *sk, struct sk_buff *skb)
|
||||
int dev_queue_xmit(struct sk_buff *skb)
|
||||
{
|
||||
return __dev_queue_xmit(skb, NULL);
|
||||
}
|
||||
EXPORT_SYMBOL(dev_queue_xmit_sk);
|
||||
EXPORT_SYMBOL(dev_queue_xmit);
|
||||
|
||||
int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv)
|
||||
{
|
||||
|
@ -3982,13 +3984,13 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
|
|||
* NET_RX_SUCCESS: no congestion
|
||||
* NET_RX_DROP: packet was dropped
|
||||
*/
|
||||
int netif_receive_skb_sk(struct sock *sk, struct sk_buff *skb)
|
||||
int netif_receive_skb(struct sk_buff *skb)
|
||||
{
|
||||
trace_netif_receive_skb_entry(skb);
|
||||
|
||||
return netif_receive_skb_internal(skb);
|
||||
}
|
||||
EXPORT_SYMBOL(netif_receive_skb_sk);
|
||||
EXPORT_SYMBOL(netif_receive_skb);
|
||||
|
||||
/* Network device is going away, flush any packets still pending
|
||||
* Called with irqs disabled.
|
||||
|
|
|
@ -194,7 +194,7 @@ static int dn_neigh_output(struct neighbour *neigh, struct sk_buff *skb)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int dn_neigh_output_packet(struct sock *sk, struct sk_buff *skb)
|
||||
static int dn_neigh_output_packet(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct dn_route *rt = (struct dn_route *)dst;
|
||||
|
@ -246,8 +246,9 @@ static int dn_long_output(struct neighbour *neigh, struct sock *sk,
|
|||
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb,
|
||||
NULL, neigh->dev, dn_neigh_output_packet);
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
|
||||
&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,
|
|||
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb,
|
||||
NULL, neigh->dev, dn_neigh_output_packet);
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
|
||||
&init_net, sk, skb, NULL, neigh->dev,
|
||||
dn_neigh_output_packet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -327,11 +329,12 @@ static int dn_phase3_output(struct neighbour *neigh, struct sock *sk,
|
|||
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, sk, skb,
|
||||
NULL, neigh->dev, dn_neigh_output_packet);
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING,
|
||||
&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 net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct dn_route *rt = (struct dn_route *) dst;
|
||||
|
@ -375,7 +378,7 @@ void dn_neigh_pointopoint_hello(struct sk_buff *skb)
|
|||
/*
|
||||
* Ethernet router hello message received
|
||||
*/
|
||||
int dn_neigh_router_hello(struct sock *sk, struct sk_buff *skb)
|
||||
int dn_neigh_router_hello(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct rtnode_hello_message *msg = (struct rtnode_hello_message *)skb->data;
|
||||
|
||||
|
@ -437,7 +440,7 @@ int dn_neigh_router_hello(struct sock *sk, struct sk_buff *skb)
|
|||
/*
|
||||
* Endnode hello message received
|
||||
*/
|
||||
int dn_neigh_endnode_hello(struct sock *sk, struct sk_buff *skb)
|
||||
int dn_neigh_endnode_hello(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct endnode_hello_message *msg = (struct endnode_hello_message *)skb->data;
|
||||
struct neighbour *neigh;
|
||||
|
|
|
@ -714,7 +714,8 @@ static int dn_nsp_no_socket(struct sk_buff *skb, unsigned short reason)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int dn_nsp_rx_packet(struct sock *sk2, struct sk_buff *skb)
|
||||
static int dn_nsp_rx_packet(struct net *net, struct sock *sk2,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct dn_skb_cb *cb = DN_SKB_CB(skb);
|
||||
struct sock *sk = NULL;
|
||||
|
@ -814,8 +815,8 @@ static int dn_nsp_rx_packet(struct sock *sk2, struct sk_buff *skb)
|
|||
|
||||
int dn_nsp_rx(struct sk_buff *skb)
|
||||
{
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_IN, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_IN,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_nsp_rx_packet);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ static void dn_nsp_send(struct sk_buff *skb)
|
|||
if (dst) {
|
||||
try_again:
|
||||
skb_dst_set(skb, dst);
|
||||
dst_output(skb);
|
||||
dst_output(skb->sk, skb);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
|
|||
* associations.
|
||||
*/
|
||||
skb_dst_set(skb, dst_clone(dst));
|
||||
dst_output(skb);
|
||||
dst_output(skb->sk, skb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ static int dn_return_long(struct sk_buff *skb)
|
|||
*
|
||||
* Returns: result of input function if route is found, error code otherwise
|
||||
*/
|
||||
static int dn_route_rx_packet(struct sock *sk, struct sk_buff *skb)
|
||||
static int dn_route_rx_packet(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct dn_skb_cb *cb;
|
||||
int err;
|
||||
|
@ -573,8 +573,8 @@ static int dn_route_rx_long(struct sk_buff *skb)
|
|||
ptr++;
|
||||
cb->hops = *ptr++; /* Visit Count */
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_route_rx_packet);
|
||||
|
||||
drop_it:
|
||||
|
@ -601,8 +601,8 @@ static int dn_route_rx_short(struct sk_buff *skb)
|
|||
ptr += 2;
|
||||
cb->hops = *ptr & 0x3f;
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_PRE_ROUTING,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_route_rx_packet);
|
||||
|
||||
drop_it:
|
||||
|
@ -610,7 +610,7 @@ static int dn_route_rx_short(struct sk_buff *skb)
|
|||
return NET_RX_DROP;
|
||||
}
|
||||
|
||||
static int dn_route_discard(struct sock *sk, struct sk_buff *skb)
|
||||
static int dn_route_discard(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
/*
|
||||
* I know we drop the packet here, but thats considered success in
|
||||
|
@ -620,7 +620,7 @@ static int dn_route_discard(struct sock *sk, struct sk_buff *skb)
|
|||
return NET_RX_SUCCESS;
|
||||
}
|
||||
|
||||
static int dn_route_ptp_hello(struct sock *sk, struct sk_buff *skb)
|
||||
static int dn_route_ptp_hello(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
dn_dev_hello(skb);
|
||||
dn_neigh_pointopoint_hello(skb);
|
||||
|
@ -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) {
|
||||
case DN_RT_PKT_HELO:
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
|
||||
NULL, skb, skb->dev, NULL,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_route_ptp_hello);
|
||||
|
||||
case DN_RT_PKT_L1RT:
|
||||
case DN_RT_PKT_L2RT:
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_ROUTE,
|
||||
NULL, skb, skb->dev, NULL,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_route_discard);
|
||||
case DN_RT_PKT_ERTH:
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
|
||||
NULL, skb, skb->dev, NULL,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_neigh_router_hello);
|
||||
|
||||
case DN_RT_PKT_EEDH:
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO,
|
||||
NULL, skb, skb->dev, NULL,
|
||||
&init_net, NULL, skb, skb->dev, NULL,
|
||||
dn_neigh_endnode_hello);
|
||||
}
|
||||
} else {
|
||||
|
@ -770,8 +770,8 @@ static int dn_output(struct sock *sk, struct sk_buff *skb)
|
|||
cb->rt_flags |= DN_RT_F_IE;
|
||||
cb->hops = 0;
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_OUT, sk, skb,
|
||||
NULL, dev,
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_LOCAL_OUT,
|
||||
&init_net, sk, skb, NULL, dev,
|
||||
dn_to_neigh_output);
|
||||
|
||||
error:
|
||||
|
@ -819,8 +819,8 @@ static int dn_forward(struct sk_buff *skb)
|
|||
if (rt->rt_flags & RTCF_DOREDIRECT)
|
||||
cb->rt_flags |= DN_RT_F_IE;
|
||||
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_FORWARD, NULL, skb,
|
||||
dev, skb->dev,
|
||||
return NF_HOOK(NFPROTO_DECNET, NF_DN_FORWARD,
|
||||
&init_net, NULL, skb, dev, skb->dev,
|
||||
dn_to_neigh_output);
|
||||
|
||||
drop:
|
||||
|
|
|
@ -621,14 +621,20 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
|
|||
}
|
||||
EXPORT_SYMBOL(arp_create);
|
||||
|
||||
static int arp_xmit_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return dev_queue_xmit(skb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send an arp packet.
|
||||
*/
|
||||
void arp_xmit(struct sk_buff *skb)
|
||||
{
|
||||
/* Send it off, maybe filter it using firewalling first. */
|
||||
NF_HOOK(NFPROTO_ARP, NF_ARP_OUT, NULL, skb,
|
||||
NULL, skb->dev, dev_queue_xmit_sk);
|
||||
NF_HOOK(NFPROTO_ARP, NF_ARP_OUT,
|
||||
dev_net(skb->dev), NULL, skb, NULL, skb->dev,
|
||||
arp_xmit_finish);
|
||||
}
|
||||
EXPORT_SYMBOL(arp_xmit);
|
||||
|
||||
|
@ -636,7 +642,7 @@ EXPORT_SYMBOL(arp_xmit);
|
|||
* Process an arp request.
|
||||
*/
|
||||
|
||||
static int arp_process(struct sock *sk, struct sk_buff *skb)
|
||||
static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net_device *dev = skb->dev;
|
||||
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
||||
|
@ -648,7 +654,6 @@ static int arp_process(struct sock *sk, struct sk_buff *skb)
|
|||
u16 dev_type = dev->type;
|
||||
int addr_type;
|
||||
struct neighbour *n;
|
||||
struct net *net = dev_net(dev);
|
||||
bool is_garp = false;
|
||||
|
||||
/* arp_rcv below verifies the ARP header and verifies the device
|
||||
|
@ -859,7 +864,7 @@ static int arp_process(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
static void parp_redo(struct sk_buff *skb)
|
||||
{
|
||||
arp_process(NULL, skb);
|
||||
arp_process(dev_net(skb->dev), NULL, skb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -892,8 +897,9 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,
|
|||
|
||||
memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
|
||||
|
||||
return NF_HOOK(NFPROTO_ARP, NF_ARP_IN, NULL, skb,
|
||||
dev, NULL, arp_process);
|
||||
return NF_HOOK(NFPROTO_ARP, NF_ARP_IN,
|
||||
dev_net(dev), NULL, skb, dev, NULL,
|
||||
arp_process);
|
||||
|
||||
consumeskb:
|
||||
consume_skb(skb);
|
||||
|
|
|
@ -61,18 +61,18 @@ static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
|
|||
}
|
||||
|
||||
|
||||
static int ip_forward_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct ip_options *opt = &(IPCB(skb)->opt);
|
||||
|
||||
IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP_ADD_STATS_BH(net, IPSTATS_MIB_OUTOCTETS, skb->len);
|
||||
|
||||
if (unlikely(opt->optlen))
|
||||
ip_forward_options(skb);
|
||||
|
||||
skb_sender_cpu_clear(skb);
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
|
||||
int ip_forward(struct sk_buff *skb)
|
||||
|
@ -81,6 +81,7 @@ int ip_forward(struct sk_buff *skb)
|
|||
struct iphdr *iph; /* Our header */
|
||||
struct rtable *rt; /* Route we use */
|
||||
struct ip_options *opt = &(IPCB(skb)->opt);
|
||||
struct net *net;
|
||||
|
||||
/* that should never happen */
|
||||
if (skb->pkt_type != PACKET_HOST)
|
||||
|
@ -99,6 +100,7 @@ int ip_forward(struct sk_buff *skb)
|
|||
return NET_RX_SUCCESS;
|
||||
|
||||
skb_forward_csum(skb);
|
||||
net = dev_net(skb->dev);
|
||||
|
||||
/*
|
||||
* According to the RFC, we must first decrease the TTL field. If
|
||||
|
@ -119,7 +121,7 @@ int ip_forward(struct sk_buff *skb)
|
|||
IPCB(skb)->flags |= IPSKB_FORWARDED;
|
||||
mtu = ip_dst_mtu_maybe_forward(&rt->dst, true);
|
||||
if (ip_exceeds_mtu(skb, mtu)) {
|
||||
IP_INC_STATS(dev_net(rt->dst.dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
||||
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
|
||||
htonl(mtu));
|
||||
goto drop;
|
||||
|
@ -143,8 +145,9 @@ int ip_forward(struct sk_buff *skb)
|
|||
|
||||
skb->priority = rt_tos2priority(iph->tos);
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, NULL, skb,
|
||||
skb->dev, rt->dst.dev, ip_forward_finish);
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
|
||||
net, NULL, skb, skb->dev, rt->dst.dev,
|
||||
ip_forward_finish);
|
||||
|
||||
sr_failed:
|
||||
/*
|
||||
|
@ -155,7 +158,7 @@ int ip_forward(struct sk_buff *skb)
|
|||
|
||||
too_many_hops:
|
||||
/* Tell the sender its packet died... */
|
||||
IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_INHDRERRORS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_INHDRERRORS);
|
||||
icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
|
||||
drop:
|
||||
kfree_skb(skb);
|
||||
|
|
|
@ -188,10 +188,8 @@ bool ip_call_ra_chain(struct sk_buff *skb)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip_local_deliver_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net *net = dev_net(skb->dev);
|
||||
|
||||
__skb_pull(skb, skb_network_header_len(skb));
|
||||
|
||||
rcu_read_lock();
|
||||
|
@ -254,8 +252,8 @@ int ip_local_deliver(struct sk_buff *skb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_IN, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_IN,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
ip_local_deliver_finish);
|
||||
}
|
||||
|
||||
|
@ -311,7 +309,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb)
|
|||
int sysctl_ip_early_demux __read_mostly = 1;
|
||||
EXPORT_SYMBOL(sysctl_ip_early_demux);
|
||||
|
||||
static int ip_rcv_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
const struct iphdr *iph = ip_hdr(skb);
|
||||
struct rtable *rt;
|
||||
|
@ -337,8 +335,7 @@ static int ip_rcv_finish(struct sock *sk, struct sk_buff *skb)
|
|||
iph->tos, skb->dev);
|
||||
if (unlikely(err)) {
|
||||
if (err == -EXDEV)
|
||||
NET_INC_STATS_BH(dev_net(skb->dev),
|
||||
LINUX_MIB_IPRPFILTER);
|
||||
NET_INC_STATS_BH(net, LINUX_MIB_IPRPFILTER);
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
|
@ -359,11 +356,9 @@ static int ip_rcv_finish(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
rt = skb_rtable(skb);
|
||||
if (rt->rt_type == RTN_MULTICAST) {
|
||||
IP_UPD_PO_STATS_BH(dev_net(rt->dst.dev), IPSTATS_MIB_INMCAST,
|
||||
skb->len);
|
||||
IP_UPD_PO_STATS_BH(net, IPSTATS_MIB_INMCAST, skb->len);
|
||||
} else if (rt->rt_type == RTN_BROADCAST)
|
||||
IP_UPD_PO_STATS_BH(dev_net(rt->dst.dev), IPSTATS_MIB_INBCAST,
|
||||
skb->len);
|
||||
IP_UPD_PO_STATS_BH(net, IPSTATS_MIB_INBCAST, skb->len);
|
||||
|
||||
return dst_input(skb);
|
||||
|
||||
|
@ -378,6 +373,7 @@ static int ip_rcv_finish(struct sock *sk, struct sk_buff *skb)
|
|||
int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
|
||||
{
|
||||
const struct iphdr *iph;
|
||||
struct net *net;
|
||||
u32 len;
|
||||
|
||||
/* When the interface is in promisc. mode, drop all the crap
|
||||
|
@ -387,11 +383,12 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
|||
goto drop;
|
||||
|
||||
|
||||
IP_UPD_PO_STATS_BH(dev_net(dev), IPSTATS_MIB_IN, skb->len);
|
||||
net = dev_net(dev);
|
||||
IP_UPD_PO_STATS_BH(net, IPSTATS_MIB_IN, skb->len);
|
||||
|
||||
skb = skb_share_check(skb, GFP_ATOMIC);
|
||||
if (!skb) {
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_INDISCARDS);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -417,7 +414,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
|||
BUILD_BUG_ON(IPSTATS_MIB_ECT1PKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_ECT_1);
|
||||
BUILD_BUG_ON(IPSTATS_MIB_ECT0PKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_ECT_0);
|
||||
BUILD_BUG_ON(IPSTATS_MIB_CEPKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_CE);
|
||||
IP_ADD_STATS_BH(dev_net(dev),
|
||||
IP_ADD_STATS_BH(net,
|
||||
IPSTATS_MIB_NOECTPKTS + (iph->tos & INET_ECN_MASK),
|
||||
max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
|
||||
|
||||
|
@ -431,7 +428,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
|||
|
||||
len = ntohs(iph->tot_len);
|
||||
if (skb->len < len) {
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INTRUNCATEDPKTS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_INTRUNCATEDPKTS);
|
||||
goto drop;
|
||||
} else if (len < (iph->ihl*4))
|
||||
goto inhdr_error;
|
||||
|
@ -441,7 +438,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
|||
* Note this now means skb->len holds ntohs(iph->tot_len).
|
||||
*/
|
||||
if (pskb_trim_rcsum(skb, len)) {
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_INDISCARDS);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
|
@ -453,14 +450,14 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
|
|||
/* Must drop socket now because of tproxy. */
|
||||
skb_orphan(skb);
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, NULL, skb,
|
||||
dev, NULL,
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
|
||||
net, NULL, skb, dev, NULL,
|
||||
ip_rcv_finish);
|
||||
|
||||
csum_error:
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_CSUMERRORS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_CSUMERRORS);
|
||||
inhdr_error:
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_INHDRERRORS);
|
||||
drop:
|
||||
kfree_skb(skb);
|
||||
out:
|
||||
|
|
|
@ -97,12 +97,14 @@ EXPORT_SYMBOL(ip_send_check);
|
|||
|
||||
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);
|
||||
|
||||
iph->tot_len = htons(skb->len);
|
||||
ip_send_check(iph);
|
||||
return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb, NULL,
|
||||
skb_dst(skb)->dev, dst_output_sk);
|
||||
return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, skb_dst(skb)->dev,
|
||||
dst_output_okfn);
|
||||
}
|
||||
|
||||
int __ip_local_out(struct sk_buff *skb)
|
||||
|
@ -116,7 +118,7 @@ int ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
err = __ip_local_out(skb);
|
||||
if (likely(err == 1))
|
||||
err = dst_output_sk(sk, skb);
|
||||
err = dst_output(sk, skb);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -177,14 +179,15 @@ static int ip_finish_output2(struct sock *sk, struct sk_buff *skb)
|
|||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct rtable *rt = (struct rtable *)dst;
|
||||
struct net_device *dev = dst->dev;
|
||||
struct net *net = dev_net(dev);
|
||||
unsigned int hh_len = LL_RESERVED_SPACE(dev);
|
||||
struct neighbour *neigh;
|
||||
u32 nexthop;
|
||||
|
||||
if (rt->rt_type == RTN_MULTICAST) {
|
||||
IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUTMCAST, skb->len);
|
||||
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len);
|
||||
} else if (rt->rt_type == RTN_BROADCAST)
|
||||
IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUTBCAST, skb->len);
|
||||
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTBCAST, skb->len);
|
||||
|
||||
/* Be paranoid, rather than too clever. */
|
||||
if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
|
||||
|
@ -263,7 +266,7 @@ static int ip_finish_output_gso(struct sock *sk, struct sk_buff *skb,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int ip_finish_output(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
unsigned int mtu;
|
||||
|
||||
|
@ -271,7 +274,7 @@ static int ip_finish_output(struct sock *sk, struct sk_buff *skb)
|
|||
/* Policy lookup after SNAT yielded a new policy */
|
||||
if (skb_dst(skb)->xfrm) {
|
||||
IPCB(skb)->flags |= IPSKB_REROUTED;
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
#endif
|
||||
mtu = ip_skb_dst_mtu(skb);
|
||||
|
@ -288,11 +291,12 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
|
|||
{
|
||||
struct rtable *rt = skb_rtable(skb);
|
||||
struct net_device *dev = rt->dst.dev;
|
||||
struct net *net = dev_net(dev);
|
||||
|
||||
/*
|
||||
* If the indicated interface is up and running, send the packet.
|
||||
*/
|
||||
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->protocol = htons(ETH_P_IP);
|
||||
|
@ -320,7 +324,7 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
|
|||
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
|
||||
if (newskb)
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
|
||||
sk, newskb, NULL, newskb->dev,
|
||||
net, sk, newskb, NULL, newskb->dev,
|
||||
dev_loopback_xmit);
|
||||
}
|
||||
|
||||
|
@ -335,26 +339,29 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
|
|||
if (rt->rt_flags&RTCF_BROADCAST) {
|
||||
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
|
||||
if (newskb)
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, newskb,
|
||||
NULL, newskb->dev, dev_loopback_xmit);
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
|
||||
net, sk, newskb, NULL, newskb->dev,
|
||||
dev_loopback_xmit);
|
||||
}
|
||||
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb, NULL,
|
||||
skb->dev, ip_finish_output,
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
|
||||
net, sk, skb, NULL, skb->dev,
|
||||
ip_finish_output,
|
||||
!(IPCB(skb)->flags & IPSKB_REROUTED));
|
||||
}
|
||||
|
||||
int ip_output(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
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->protocol = htons(ETH_P_IP);
|
||||
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb,
|
||||
NULL, dev,
|
||||
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
|
||||
net, sk, skb, NULL, dev,
|
||||
ip_finish_output,
|
||||
!(IPCB(skb)->flags & IPSKB_REROUTED));
|
||||
}
|
||||
|
@ -498,10 +505,9 @@ static int ip_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
if (unlikely(!skb->ignore_df ||
|
||||
(IPCB(skb)->frag_max_size &&
|
||||
IPCB(skb)->frag_max_size > mtu))) {
|
||||
struct rtable *rt = skb_rtable(skb);
|
||||
struct net_device *dev = rt->dst.dev;
|
||||
struct net *net = dev_net(skb_rtable(skb)->dst.dev);
|
||||
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
||||
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
|
||||
htonl(mtu));
|
||||
kfree_skb(skb);
|
||||
|
@ -529,9 +535,11 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
int offset;
|
||||
__be16 not_last_frag;
|
||||
struct rtable *rt = skb_rtable(skb);
|
||||
struct net *net;
|
||||
int err = 0;
|
||||
|
||||
dev = rt->dst.dev;
|
||||
net = dev_net(dev);
|
||||
|
||||
/*
|
||||
* Point into the IP datagram header.
|
||||
|
@ -624,7 +632,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
err = output(sk, skb);
|
||||
|
||||
if (!err)
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGCREATES);
|
||||
if (err || !frag)
|
||||
break;
|
||||
|
||||
|
@ -634,7 +642,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
}
|
||||
|
||||
if (err == 0) {
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGOKS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -643,7 +651,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
kfree_skb(frag);
|
||||
frag = skb;
|
||||
}
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
||||
return err;
|
||||
|
||||
slow_path_clean:
|
||||
|
@ -765,15 +773,15 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
|
|||
if (err)
|
||||
goto fail;
|
||||
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGCREATES);
|
||||
}
|
||||
consume_skb(skb);
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGOKS);
|
||||
return err;
|
||||
|
||||
fail:
|
||||
kfree_skb(skb);
|
||||
IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(ip_do_fragment);
|
||||
|
|
|
@ -197,7 +197,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
|
|||
skb_dst_set(skb, dst);
|
||||
skb->dev = skb_dst(skb)->dev;
|
||||
|
||||
err = dst_output(skb);
|
||||
err = dst_output(skb->sk, skb);
|
||||
if (net_xmit_eval(err) == 0)
|
||||
err = skb->len;
|
||||
iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
|
||||
|
|
|
@ -1678,17 +1678,18 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
|
|||
nf_reset(skb);
|
||||
}
|
||||
|
||||
static inline int ipmr_forward_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static inline int ipmr_forward_finish(struct net *net, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct ip_options *opt = &(IPCB(skb)->opt);
|
||||
|
||||
IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP_ADD_STATS_BH(net, IPSTATS_MIB_OUTOCTETS, skb->len);
|
||||
|
||||
if (unlikely(opt->optlen))
|
||||
ip_forward_options(skb);
|
||||
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1745,7 +1746,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
|
|||
* to blackhole.
|
||||
*/
|
||||
|
||||
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
|
||||
IP_INC_STATS_BH(net, IPSTATS_MIB_FRAGFAILS);
|
||||
ip_rt_put(rt);
|
||||
goto out_free;
|
||||
}
|
||||
|
@ -1787,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
|
||||
* result in receiving multiple packets.
|
||||
*/
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, NULL, skb,
|
||||
skb->dev, dev,
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
|
||||
net, NULL, skb, skb->dev, dev,
|
||||
ipmr_forward_finish);
|
||||
return;
|
||||
|
||||
|
|
|
@ -30,10 +30,8 @@ static unsigned int
|
|||
arptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net = dev_net(state->in ? state->in : state->out);
|
||||
|
||||
return arpt_do_table(skb, ops->hooknum, state,
|
||||
net->ipv4.arptable_filter);
|
||||
state->net->ipv4.arptable_filter);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *arpfilter_ops __read_mostly;
|
||||
|
|
|
@ -246,7 +246,8 @@ get_chainname_rulenum(const struct ipt_entry *s, const struct ipt_entry *e,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void trace_packet(const struct sk_buff *skb,
|
||||
static void trace_packet(struct net *net,
|
||||
const struct sk_buff *skb,
|
||||
unsigned int hook,
|
||||
const struct net_device *in,
|
||||
const struct net_device *out,
|
||||
|
@ -258,7 +259,6 @@ static void trace_packet(const struct sk_buff *skb,
|
|||
const char *hookname, *chainname, *comment;
|
||||
const struct ipt_entry *iter;
|
||||
unsigned int rulenum = 0;
|
||||
struct net *net = dev_net(in ? in : out);
|
||||
|
||||
root = get_entry(private->entries, private->hook_entry[hook]);
|
||||
|
||||
|
@ -378,8 +378,8 @@ ipt_do_table(struct sk_buff *skb,
|
|||
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
|
||||
/* The packet is traced: log it */
|
||||
if (unlikely(skb->nf_trace))
|
||||
trace_packet(skb, hook, state->in, state->out,
|
||||
table->name, private, e);
|
||||
trace_packet(state->net, skb, hook, state->in,
|
||||
state->out, table->name, private, e);
|
||||
#endif
|
||||
/* Standard target? */
|
||||
if (!t->u.kernel.target->target) {
|
||||
|
|
|
@ -514,7 +514,7 @@ arp_mangle(const struct nf_hook_ops *ops,
|
|||
struct arphdr *arp = arp_hdr(skb);
|
||||
struct arp_payload *payload;
|
||||
struct clusterip_config *c;
|
||||
struct net *net = dev_net(state->in ? state->in : state->out);
|
||||
struct net *net = state->net;
|
||||
|
||||
/* we don't care about non-ethernet and non-ipv4 ARP */
|
||||
if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
|
||||
|
|
|
@ -303,7 +303,7 @@ static unsigned int ipv4_synproxy_hook(const struct nf_hook_ops *ops,
|
|||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *nhs)
|
||||
{
|
||||
struct synproxy_net *snet = synproxy_pernet(dev_net(nhs->in ? : nhs->out));
|
||||
struct synproxy_net *snet = synproxy_pernet(nhs->net);
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct;
|
||||
struct nf_conn_synproxy *synproxy;
|
||||
|
|
|
@ -36,16 +36,14 @@ static unsigned int
|
|||
iptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net;
|
||||
|
||||
if (ops->hooknum == NF_INET_LOCAL_OUT &&
|
||||
(skb->len < sizeof(struct iphdr) ||
|
||||
ip_hdrlen(skb) < sizeof(struct iphdr)))
|
||||
/* root is playing with raw sockets. */
|
||||
return NF_ACCEPT;
|
||||
|
||||
net = dev_net(state->in ? state->in : state->out);
|
||||
return ipt_do_table(skb, ops->hooknum, state, net->ipv4.iptable_filter);
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv4.iptable_filter);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *filter_ops __read_mostly;
|
||||
|
|
|
@ -39,7 +39,6 @@ static const struct xt_table packet_mangler = {
|
|||
static unsigned int
|
||||
ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
|
||||
{
|
||||
struct net_device *out = state->out;
|
||||
unsigned int ret;
|
||||
const struct iphdr *iph;
|
||||
u_int8_t tos;
|
||||
|
@ -60,7 +59,7 @@ ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
|
|||
tos = iph->tos;
|
||||
|
||||
ret = ipt_do_table(skb, NF_INET_LOCAL_OUT, state,
|
||||
dev_net(out)->ipv4.iptable_mangle);
|
||||
state->net->ipv4.iptable_mangle);
|
||||
/* Reroute for ANY change. */
|
||||
if (ret != NF_DROP && ret != NF_STOLEN) {
|
||||
iph = ip_hdr(skb);
|
||||
|
@ -88,10 +87,10 @@ iptable_mangle_hook(const struct nf_hook_ops *ops,
|
|||
return ipt_mangle_out(skb, state);
|
||||
if (ops->hooknum == NF_INET_POST_ROUTING)
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
dev_net(state->out)->ipv4.iptable_mangle);
|
||||
state->net->ipv4.iptable_mangle);
|
||||
/* PREROUTING/INPUT/FORWARD: */
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
dev_net(state->in)->ipv4.iptable_mangle);
|
||||
state->net->ipv4.iptable_mangle);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *mangle_ops __read_mostly;
|
||||
|
|
|
@ -33,9 +33,8 @@ static unsigned int iptable_nat_do_chain(const struct nf_hook_ops *ops,
|
|||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct)
|
||||
{
|
||||
struct net *net = nf_ct_net(ct);
|
||||
|
||||
return ipt_do_table(skb, ops->hooknum, state, net->ipv4.nat_table);
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv4.nat_table);
|
||||
}
|
||||
|
||||
static unsigned int iptable_nat_ipv4_fn(const struct nf_hook_ops *ops,
|
||||
|
|
|
@ -23,16 +23,14 @@ static unsigned int
|
|||
iptable_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net;
|
||||
|
||||
if (ops->hooknum == NF_INET_LOCAL_OUT &&
|
||||
(skb->len < sizeof(struct iphdr) ||
|
||||
ip_hdrlen(skb) < sizeof(struct iphdr)))
|
||||
/* root is playing with raw sockets. */
|
||||
return NF_ACCEPT;
|
||||
|
||||
net = dev_net(state->in ? state->in : state->out);
|
||||
return ipt_do_table(skb, ops->hooknum, state, net->ipv4.iptable_raw);
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv4.iptable_raw);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *rawtable_ops __read_mostly;
|
||||
|
|
|
@ -40,17 +40,14 @@ static unsigned int
|
|||
iptable_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net;
|
||||
|
||||
if (ops->hooknum == NF_INET_LOCAL_OUT &&
|
||||
(skb->len < sizeof(struct iphdr) ||
|
||||
ip_hdrlen(skb) < sizeof(struct iphdr)))
|
||||
/* Somebody is playing with raw sockets. */
|
||||
return NF_ACCEPT;
|
||||
|
||||
net = dev_net(state->in ? state->in : state->out);
|
||||
return ipt_do_table(skb, ops->hooknum, state,
|
||||
net->ipv4.iptable_security);
|
||||
state->net->ipv4.iptable_security);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *sectbl_ops __read_mostly;
|
||||
|
|
|
@ -147,7 +147,7 @@ static unsigned int ipv4_conntrack_in(const struct nf_hook_ops *ops,
|
|||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_conntrack_in(dev_net(state->in), PF_INET, ops->hooknum, skb);
|
||||
return nf_conntrack_in(state->net, PF_INET, ops->hooknum, skb);
|
||||
}
|
||||
|
||||
static unsigned int ipv4_conntrack_local(const struct nf_hook_ops *ops,
|
||||
|
@ -158,7 +158,7 @@ static unsigned int ipv4_conntrack_local(const struct nf_hook_ops *ops,
|
|||
if (skb->len < sizeof(struct iphdr) ||
|
||||
ip_hdrlen(skb) < sizeof(struct iphdr))
|
||||
return NF_ACCEPT;
|
||||
return nf_conntrack_in(dev_net(state->out), PF_INET, ops->hooknum, skb);
|
||||
return nf_conntrack_in(state->net, PF_INET, ops->hooknum, skb);
|
||||
}
|
||||
|
||||
/* Connection tracking may drop packets, but never alters them, so
|
||||
|
|
|
@ -411,8 +411,9 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
|
|||
icmp_out_count(net, ((struct icmphdr *)
|
||||
skb_transport_header(skb))->type);
|
||||
|
||||
err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, rt->dst.dev, dst_output_sk);
|
||||
err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, rt->dst.dev,
|
||||
dst_output_okfn);
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err)
|
||||
|
|
|
@ -22,7 +22,8 @@ int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb)
|
|||
return xfrm4_extract_header(skb);
|
||||
}
|
||||
|
||||
static inline int xfrm4_rcv_encap_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static inline int xfrm4_rcv_encap_finish(struct net *net, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
if (!skb_dst(skb)) {
|
||||
const struct iphdr *iph = ip_hdr(skb);
|
||||
|
@ -52,8 +53,8 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async)
|
|||
iph->tot_len = htons(skb->len);
|
||||
ip_send_check(iph);
|
||||
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
xfrm4_rcv_encap_finish);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -80,14 +80,14 @@ int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb)
|
|||
return xfrm_output(sk, skb);
|
||||
}
|
||||
|
||||
static int __xfrm4_output(struct sock *sk, struct sk_buff *skb)
|
||||
static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct xfrm_state *x = skb_dst(skb)->xfrm;
|
||||
|
||||
#ifdef CONFIG_NETFILTER
|
||||
if (!x) {
|
||||
IPCB(skb)->flags |= IPSKB_REROUTED;
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -96,8 +96,11 @@ static 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,
|
||||
NULL, skb_dst(skb)->dev, __xfrm4_output,
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include <net/inet_ecn.h>
|
||||
#include <net/dst_metadata.h>
|
||||
|
||||
int ip6_rcv_finish(struct sock *sk, struct sk_buff *skb)
|
||||
int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
|
||||
const struct inet6_protocol *ipprot;
|
||||
|
@ -109,7 +109,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
|
|||
if (hdr->version != 6)
|
||||
goto err;
|
||||
|
||||
IP6_ADD_STATS_BH(dev_net(dev), idev,
|
||||
IP6_ADD_STATS_BH(net, idev,
|
||||
IPSTATS_MIB_NOECTPKTS +
|
||||
(ipv6_get_dsfield(hdr) & INET_ECN_MASK),
|
||||
max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
|
||||
|
@ -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. */
|
||||
skb_orphan(skb);
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, NULL, skb,
|
||||
dev, NULL,
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
|
||||
net, NULL, skb, dev, NULL,
|
||||
ip6_rcv_finish);
|
||||
err:
|
||||
IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INHDRERRORS);
|
||||
|
@ -199,9 +199,8 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
|
|||
*/
|
||||
|
||||
|
||||
static int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
const struct inet6_protocol *ipprot;
|
||||
struct inet6_dev *idev;
|
||||
unsigned int nhoff;
|
||||
|
@ -278,8 +277,8 @@ static int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
int ip6_input(struct sk_buff *skb)
|
||||
{
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
ip6_input_finish);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
|
|||
{
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct net_device *dev = dst->dev;
|
||||
struct net *net = dev_net(dev);
|
||||
struct neighbour *neigh;
|
||||
struct in6_addr *nexthop;
|
||||
int ret;
|
||||
|
@ -71,7 +72,7 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
|
|||
struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
|
||||
|
||||
if (!(dev->flags & IFF_LOOPBACK) && sk_mc_loop(sk) &&
|
||||
((mroute6_socket(dev_net(dev), skb) &&
|
||||
((mroute6_socket(net, skb) &&
|
||||
!(IP6CB(skb)->flags & IP6SKB_FORWARDED)) ||
|
||||
ipv6_chk_mcast_addr(dev, &ipv6_hdr(skb)->daddr,
|
||||
&ipv6_hdr(skb)->saddr))) {
|
||||
|
@ -82,19 +83,18 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
|
|||
*/
|
||||
if (newskb)
|
||||
NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING,
|
||||
sk, newskb, NULL, newskb->dev,
|
||||
net, sk, newskb, NULL, newskb->dev,
|
||||
dev_loopback_xmit);
|
||||
|
||||
if (ipv6_hdr(skb)->hop_limit == 0) {
|
||||
IP6_INC_STATS(dev_net(dev), idev,
|
||||
IP6_INC_STATS(net, idev,
|
||||
IPSTATS_MIB_OUTDISCARDS);
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IP6_UPD_PO_STATS(dev_net(dev), idev, IPSTATS_MIB_OUTMCAST,
|
||||
skb->len);
|
||||
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUTMCAST, skb->len);
|
||||
|
||||
if (IPV6_ADDR_MC_SCOPE(&ipv6_hdr(skb)->daddr) <=
|
||||
IPV6_ADDR_SCOPE_NODELOCAL &&
|
||||
|
@ -116,13 +116,12 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
|
|||
}
|
||||
rcu_read_unlock_bh();
|
||||
|
||||
IP6_INC_STATS(dev_net(dst->dev),
|
||||
ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
|
||||
IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
|
||||
kfree_skb(skb);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int ip6_finish_output(struct sock *sk, struct sk_buff *skb)
|
||||
static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) ||
|
||||
dst_allfrag(skb_dst(skb)) ||
|
||||
|
@ -136,15 +135,16 @@ int ip6_output(struct sock *sk, struct sk_buff *skb)
|
|||
{
|
||||
struct net_device *dev = skb_dst(skb)->dev;
|
||||
struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
|
||||
struct net *net = dev_net(dev);
|
||||
|
||||
if (unlikely(idev->cnf.disable_ipv6)) {
|
||||
IP6_INC_STATS(dev_net(dev), idev,
|
||||
IPSTATS_MIB_OUTDISCARDS);
|
||||
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, sk, skb,
|
||||
NULL, dev,
|
||||
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
|
||||
net, sk, skb, NULL, dev,
|
||||
ip6_finish_output,
|
||||
!(IP6CB(skb)->flags & IP6SKB_REROUTED));
|
||||
}
|
||||
|
@ -224,8 +224,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)) {
|
||||
IP6_UPD_PO_STATS(net, ip6_dst_idev(skb_dst(skb)),
|
||||
IPSTATS_MIB_OUT, skb->len);
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, dst->dev, dst_output_sk);
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, dst->dev,
|
||||
dst_output_okfn);
|
||||
}
|
||||
|
||||
skb->dev = dst->dev;
|
||||
|
@ -317,10 +318,11 @@ static int ip6_forward_proxy_check(struct sk_buff *skb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int ip6_forward_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static inline int ip6_forward_finish(struct net *net, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
skb_sender_cpu_clear(skb);
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
|
||||
static unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
|
||||
|
@ -512,8 +514,8 @@ int ip6_forward(struct sk_buff *skb)
|
|||
|
||||
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);
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, NULL, skb,
|
||||
skb->dev, dst->dev,
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
|
||||
net, NULL, skb, skb->dev, dst->dev,
|
||||
ip6_forward_finish);
|
||||
|
||||
error:
|
||||
|
|
|
@ -482,7 +482,7 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
|
|||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
err = dst_output(skb);
|
||||
err = dst_output(skb->sk, skb);
|
||||
if (net_xmit_eval(err) == 0) {
|
||||
struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
|
||||
|
||||
|
|
|
@ -1985,13 +1985,13 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
static inline int ip6mr_forward2_finish(struct sock *sk, struct sk_buff *skb)
|
||||
static inline int ip6mr_forward2_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
IP6_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)),
|
||||
IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
|
||||
IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP6_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)),
|
||||
IP6_ADD_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
|
||||
IPSTATS_MIB_OUTOCTETS, skb->len);
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2063,8 +2063,8 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
|
|||
|
||||
IP6CB(skb)->flags |= IP6SKB_FORWARDED;
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, NULL, skb,
|
||||
skb->dev, dev,
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
|
||||
net, NULL, skb, skb->dev, dev,
|
||||
ip6mr_forward2_finish);
|
||||
|
||||
out_free:
|
||||
|
|
|
@ -1645,8 +1645,8 @@ static void mld_sendpack(struct sk_buff *skb)
|
|||
payload_len = skb->len;
|
||||
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net->ipv6.igmp_sk, skb, NULL, skb->dev,
|
||||
dst_output_sk);
|
||||
net, net->ipv6.igmp_sk, skb, NULL, skb->dev,
|
||||
dst_output_okfn);
|
||||
out:
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, ICMPV6_MLD2_REPORT);
|
||||
|
@ -2008,8 +2008,9 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
|
|||
}
|
||||
|
||||
skb_dst_set(skb, dst);
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, skb->dev, dst_output_sk);
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, skb->dev,
|
||||
dst_output_okfn);
|
||||
out:
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, type);
|
||||
|
|
|
@ -463,9 +463,9 @@ static void ndisc_send_skb(struct sk_buff *skb,
|
|||
idev = __in6_dev_get(dst->dev);
|
||||
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len);
|
||||
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, dst->dev,
|
||||
dst_output_sk);
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, dst->dev,
|
||||
dst_output_okfn);
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, type);
|
||||
ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
|
||||
|
|
|
@ -275,7 +275,8 @@ get_chainname_rulenum(const struct ip6t_entry *s, const struct ip6t_entry *e,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void trace_packet(const struct sk_buff *skb,
|
||||
static void trace_packet(struct net *net,
|
||||
const struct sk_buff *skb,
|
||||
unsigned int hook,
|
||||
const struct net_device *in,
|
||||
const struct net_device *out,
|
||||
|
@ -287,7 +288,6 @@ static void trace_packet(const struct sk_buff *skb,
|
|||
const char *hookname, *chainname, *comment;
|
||||
const struct ip6t_entry *iter;
|
||||
unsigned int rulenum = 0;
|
||||
struct net *net = dev_net(in ? in : out);
|
||||
|
||||
root = get_entry(private->entries, private->hook_entry[hook]);
|
||||
|
||||
|
@ -401,8 +401,8 @@ ip6t_do_table(struct sk_buff *skb,
|
|||
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
|
||||
/* The packet is traced: log it */
|
||||
if (unlikely(skb->nf_trace))
|
||||
trace_packet(skb, hook, state->in, state->out,
|
||||
table->name, private, e);
|
||||
trace_packet(state->net, skb, hook, state->in,
|
||||
state->out, table->name, private, e);
|
||||
#endif
|
||||
/* Standard target? */
|
||||
if (!t->u.kernel.target->target) {
|
||||
|
|
|
@ -320,7 +320,7 @@ static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops,
|
|||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *nhs)
|
||||
{
|
||||
struct synproxy_net *snet = synproxy_pernet(dev_net(nhs->in ? : nhs->out));
|
||||
struct synproxy_net *snet = synproxy_pernet(nhs->net);
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct;
|
||||
struct nf_conn_synproxy *synproxy;
|
||||
|
|
|
@ -35,9 +35,8 @@ static unsigned int
|
|||
ip6table_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net = dev_net(state->in ? state->in : state->out);
|
||||
|
||||
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_filter);
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv6.ip6table_filter);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *filter_ops __read_mostly;
|
||||
|
|
|
@ -58,7 +58,7 @@ ip6t_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
|
|||
flowlabel = *((u_int32_t *)ipv6_hdr(skb));
|
||||
|
||||
ret = ip6t_do_table(skb, NF_INET_LOCAL_OUT, state,
|
||||
dev_net(state->out)->ipv6.ip6table_mangle);
|
||||
state->net->ipv6.ip6table_mangle);
|
||||
|
||||
if (ret != NF_DROP && ret != NF_STOLEN &&
|
||||
(!ipv6_addr_equal(&ipv6_hdr(skb)->saddr, &saddr) ||
|
||||
|
@ -83,10 +83,10 @@ ip6table_mangle_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
|||
return ip6t_mangle_out(skb, state);
|
||||
if (ops->hooknum == NF_INET_POST_ROUTING)
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
dev_net(state->out)->ipv6.ip6table_mangle);
|
||||
state->net->ipv6.ip6table_mangle);
|
||||
/* INPUT/FORWARD */
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
dev_net(state->in)->ipv6.ip6table_mangle);
|
||||
state->net->ipv6.ip6table_mangle);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *mangle_ops __read_mostly;
|
||||
|
|
|
@ -35,9 +35,8 @@ static unsigned int ip6table_nat_do_chain(const struct nf_hook_ops *ops,
|
|||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct)
|
||||
{
|
||||
struct net *net = nf_ct_net(ct);
|
||||
|
||||
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_nat);
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv6.ip6table_nat);
|
||||
}
|
||||
|
||||
static unsigned int ip6table_nat_fn(const struct nf_hook_ops *ops,
|
||||
|
|
|
@ -22,9 +22,8 @@ static unsigned int
|
|||
ip6table_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net = dev_net(state->in ? state->in : state->out);
|
||||
|
||||
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_raw);
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
state->net->ipv6.ip6table_raw);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *rawtable_ops __read_mostly;
|
||||
|
|
|
@ -39,10 +39,8 @@ static unsigned int
|
|||
ip6table_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
const struct net *net = dev_net(state->in ? state->in : state->out);
|
||||
|
||||
return ip6t_do_table(skb, ops->hooknum, state,
|
||||
net->ipv6.ip6table_security);
|
||||
state->net->ipv6.ip6table_security);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops *sectbl_ops __read_mostly;
|
||||
|
|
|
@ -169,7 +169,7 @@ static unsigned int ipv6_conntrack_in(const struct nf_hook_ops *ops,
|
|||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_conntrack_in(dev_net(state->in), PF_INET6, ops->hooknum, skb);
|
||||
return nf_conntrack_in(state->net, PF_INET6, ops->hooknum, skb);
|
||||
}
|
||||
|
||||
static unsigned int ipv6_conntrack_local(const struct nf_hook_ops *ops,
|
||||
|
@ -181,7 +181,7 @@ static unsigned int ipv6_conntrack_local(const struct nf_hook_ops *ops,
|
|||
net_notice_ratelimited("ipv6_conntrack_local: packet too short\n");
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
return nf_conntrack_in(dev_net(state->out), PF_INET6, ops->hooknum, skb);
|
||||
return nf_conntrack_in(state->net, PF_INET6, ops->hooknum, skb);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = {
|
||||
|
|
|
@ -74,7 +74,7 @@ static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
|
|||
|
||||
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->okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1);
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ EXPORT_SYMBOL(ip6_dst_hoplimit);
|
|||
|
||||
static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
int len;
|
||||
|
||||
len = skb->len - sizeof(struct ipv6hdr);
|
||||
|
@ -148,8 +149,9 @@ static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
|
|||
ipv6_hdr(skb)->payload_len = htons(len);
|
||||
IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
|
||||
|
||||
return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, skb_dst(skb)->dev, dst_output_sk);
|
||||
return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, skb_dst(skb)->dev,
|
||||
dst_output_okfn);
|
||||
}
|
||||
|
||||
int __ip6_local_out(struct sk_buff *skb)
|
||||
|
@ -164,7 +166,7 @@ int ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
|
|||
|
||||
err = __ip6_local_out_sk(sk, skb);
|
||||
if (likely(err == 1))
|
||||
err = dst_output_sk(sk, skb);
|
||||
err = dst_output(sk, skb);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -614,6 +614,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
|
|||
unsigned int flags)
|
||||
{
|
||||
struct ipv6_pinfo *np = inet6_sk(sk);
|
||||
struct net *net = sock_net(sk);
|
||||
struct ipv6hdr *iph;
|
||||
struct sk_buff *skb;
|
||||
int err;
|
||||
|
@ -652,9 +653,9 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
|
|||
if (err)
|
||||
goto error_fault;
|
||||
|
||||
IP6_UPD_PO_STATS(sock_net(sk), rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len);
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, sk, skb,
|
||||
NULL, rt->dst.dev, dst_output_sk);
|
||||
IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len);
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, sk, skb,
|
||||
NULL, rt->dst.dev, dst_output_okfn);
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err)
|
||||
|
@ -666,7 +667,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
|
|||
err = -EFAULT;
|
||||
kfree_skb(skb);
|
||||
error:
|
||||
IP6_INC_STATS(sock_net(sk), rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
|
||||
IP6_INC_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
|
||||
if (err == -ENOBUFS && !np->recverr)
|
||||
err = 0;
|
||||
return err;
|
||||
|
|
|
@ -42,8 +42,8 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
|
|||
ipv6_hdr(skb)->payload_len = htons(skb->len);
|
||||
__skb_push(skb, skb->data - skb_network_header(skb));
|
||||
|
||||
NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, NULL, skb,
|
||||
skb->dev, NULL,
|
||||
NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
|
||||
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
|
||||
ip6_rcv_finish);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb)
|
|||
return xfrm_output(sk, skb);
|
||||
}
|
||||
|
||||
static int __xfrm6_output(struct sock *sk, struct sk_buff *skb)
|
||||
static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
struct xfrm_state *x = dst->xfrm;
|
||||
|
@ -140,7 +140,7 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb)
|
|||
#ifdef CONFIG_NETFILTER
|
||||
if (!x) {
|
||||
IP6CB(skb)->flags |= IP6SKB_REROUTED;
|
||||
return dst_output_sk(sk, skb);
|
||||
return dst_output(sk, skb);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -168,7 +168,10 @@ static 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,
|
||||
NULL, skb_dst(skb)->dev, __xfrm6_output,
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -573,8 +573,8 @@ static inline int ip_vs_nat_send_or_cont(int pf, struct sk_buff *skb,
|
|||
skb_forward_csum(skb);
|
||||
if (!skb->sk)
|
||||
skb_sender_cpu_clear(skb);
|
||||
NF_HOOK(pf, NF_INET_LOCAL_OUT, NULL, skb,
|
||||
NULL, skb_dst(skb)->dev, dst_output_sk);
|
||||
NF_HOOK(pf, NF_INET_LOCAL_OUT, ip_vs_conn_net(cp), NULL, skb,
|
||||
NULL, skb_dst(skb)->dev, dst_output_okfn);
|
||||
} else
|
||||
ret = NF_ACCEPT;
|
||||
|
||||
|
@ -595,8 +595,8 @@ static inline int ip_vs_send_or_cont(int pf, struct sk_buff *skb,
|
|||
skb_forward_csum(skb);
|
||||
if (!skb->sk)
|
||||
skb_sender_cpu_clear(skb);
|
||||
NF_HOOK(pf, NF_INET_LOCAL_OUT, NULL, skb,
|
||||
NULL, skb_dst(skb)->dev, dst_output_sk);
|
||||
NF_HOOK(pf, NF_INET_LOCAL_OUT, ip_vs_conn_net(cp), NULL, skb,
|
||||
NULL, skb_dst(skb)->dev, dst_output_okfn);
|
||||
} else
|
||||
ret = NF_ACCEPT;
|
||||
return ret;
|
||||
|
|
|
@ -215,7 +215,7 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
|
|||
case NF_ACCEPT:
|
||||
case NF_STOP:
|
||||
local_bh_disable();
|
||||
entry->state.okfn(entry->state.sk, skb);
|
||||
entry->state.okfn(entry->state.net, entry->state.sk, skb);
|
||||
local_bh_enable();
|
||||
break;
|
||||
case NF_QUEUE:
|
||||
|
|
|
@ -670,8 +670,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
|
|||
struct nfqnl_instance *queue;
|
||||
struct sk_buff *skb, *segs;
|
||||
int err = -ENOBUFS;
|
||||
struct net *net = dev_net(entry->state.in ?
|
||||
entry->state.in : entry->state.out);
|
||||
struct net *net = entry->state.net;
|
||||
struct nfnl_queue_net *q = nfnl_queue_pernet(net);
|
||||
|
||||
/* rcu_read_lock()ed by nf_hook_slow() */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <net/dst.h>
|
||||
#include <net/xfrm.h>
|
||||
|
||||
static int xfrm_output2(struct sock *sk, struct sk_buff *skb);
|
||||
static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
static int xfrm_skb_check_space(struct sk_buff *skb)
|
||||
{
|
||||
|
@ -131,6 +131,8 @@ static int xfrm_output_one(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)) {
|
||||
nf_reset(skb);
|
||||
|
||||
|
@ -139,10 +141,10 @@ int xfrm_output_resume(struct sk_buff *skb, int err)
|
|||
goto out;
|
||||
|
||||
if (!skb_dst(skb)->xfrm)
|
||||
return dst_output(skb);
|
||||
return dst_output(skb->sk, skb);
|
||||
|
||||
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);
|
||||
if (unlikely(err != 1))
|
||||
goto out;
|
||||
|
@ -156,12 +158,12 @@ int xfrm_output_resume(struct sk_buff *skb, int err)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(xfrm_output_resume);
|
||||
|
||||
static int xfrm_output2(struct sock *sk, struct sk_buff *skb)
|
||||
static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
return xfrm_output_resume(skb, 1);
|
||||
}
|
||||
|
||||
static int xfrm_output_gso(struct sock *sk, struct sk_buff *skb)
|
||||
static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct sk_buff *segs;
|
||||
|
||||
|
@ -177,7 +179,7 @@ static int xfrm_output_gso(struct sock *sk, struct sk_buff *skb)
|
|||
int err;
|
||||
|
||||
segs->next = NULL;
|
||||
err = xfrm_output2(sk, segs);
|
||||
err = xfrm_output2(net, sk, segs);
|
||||
|
||||
if (unlikely(err)) {
|
||||
kfree_skb_list(nskb);
|
||||
|
@ -196,7 +198,7 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
|
|||
int err;
|
||||
|
||||
if (skb_is_gso(skb))
|
||||
return xfrm_output_gso(sk, skb);
|
||||
return xfrm_output_gso(net, sk, skb);
|
||||
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL) {
|
||||
err = skb_checksum_help(skb);
|
||||
|
@ -207,7 +209,7 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
|
|||
}
|
||||
}
|
||||
|
||||
return xfrm_output2(sk, skb);
|
||||
return xfrm_output2(net, sk, skb);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xfrm_output);
|
||||
|
||||
|
|
|
@ -1583,8 +1583,6 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family)
|
|||
|
||||
memset(dst + 1, 0, sizeof(*xdst) - sizeof(*dst));
|
||||
xdst->flo.ops = &xfrm_bundle_fc_ops;
|
||||
if (afinfo->init_dst)
|
||||
afinfo->init_dst(net, xdst);
|
||||
} else
|
||||
xdst = ERR_PTR(-ENOBUFS);
|
||||
|
||||
|
@ -1947,7 +1945,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
|
|||
skb_dst_drop(skb);
|
||||
skb_dst_set(skb, dst);
|
||||
|
||||
dst_output(skb);
|
||||
dst_output(skb->sk, skb);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
Loading…
Reference in a new issue