netfilter: Pass net into okfn
This is immediately motivated by the bridge code that chains functions that call into netfilter. Without passing net into the okfns the bridge code would need to guess about the best expression for the network namespace to process packets in. As net is frequently one of the first things computed in continuation functions after netfilter has done it's job passing in the desired network namespace is in many cases a code simplification. To support this change the function dst_output_okfn is introduced to simplify passing dst_output as an okfn. For the moment dst_output_okfn just silently drops the struct net. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
9dff2c966a
commit
0c4b51f005
@@ -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;
|
||||
@@ -199,9 +199,8 @@ drop:
|
||||
*/
|
||||
|
||||
|
||||
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;
|
||||
|
||||
@@ -121,7 +121,7 @@ static int ip6_finish_output2(struct sock *sk, struct sk_buff *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)) ||
|
||||
@@ -225,7 +225,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
|
||||
IPSTATS_MIB_OUT, skb->len);
|
||||
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, dst->dev,
|
||||
dst_output);
|
||||
dst_output_okfn);
|
||||
}
|
||||
|
||||
skb->dev = dst->dev;
|
||||
@@ -317,7 +317,8 @@ 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, skb);
|
||||
|
||||
@@ -1985,9 +1985,8 @@ 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)
|
||||
{
|
||||
struct net *net = dev_net(skb_dst(skb)->dev);
|
||||
IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
|
||||
IPSTATS_MIB_OUTFORWDATAGRAMS);
|
||||
IP6_ADD_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
|
||||
|
||||
@@ -1646,7 +1646,7 @@ static void mld_sendpack(struct sk_buff *skb)
|
||||
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, net->ipv6.igmp_sk, skb, NULL, skb->dev,
|
||||
dst_output);
|
||||
dst_output_okfn);
|
||||
out:
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, ICMPV6_MLD2_REPORT);
|
||||
@@ -2010,7 +2010,7 @@ 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,
|
||||
net, sk, skb, NULL, skb->dev,
|
||||
dst_output);
|
||||
dst_output_okfn);
|
||||
out:
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, type);
|
||||
|
||||
@@ -465,7 +465,7 @@ static void ndisc_send_skb(struct sk_buff *skb,
|
||||
|
||||
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, dst->dev,
|
||||
dst_output);
|
||||
dst_output_okfn);
|
||||
if (!err) {
|
||||
ICMP6MSGOUT_INC_STATS(net, idev, type);
|
||||
ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
|
||||
|
||||
@@ -151,7 +151,7 @@ static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
|
||||
|
||||
return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
|
||||
net, sk, skb, NULL, skb_dst(skb)->dev,
|
||||
dst_output);
|
||||
dst_output_okfn);
|
||||
}
|
||||
|
||||
int __ip6_local_out(struct sk_buff *skb)
|
||||
|
||||
@@ -655,7 +655,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
|
||||
|
||||
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);
|
||||
NULL, rt->dst.dev, dst_output_okfn);
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user