Merge branch 'pass_net_through_output_path'
authorDavid S. Miller <davem@davemloft.net>
Thu, 8 Oct 2015 11:27:13 +0000 (04:27 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Oct 2015 11:27:13 +0000 (04:27 -0700)
Eric W. Biederman says:

====================
net: Pass net through the output path v2

This is the next installment of my work to pass struct net through the
output path so the code does not need to guess how to figure out which
network namespace it is in, and ultimately routes can have output
devices in another network namespace.

The first patch in this series is a fix for a bug that came in when sk
was passed through the functions in the output path, and as such is
probably a candidate for net.  At the same time my later patches depend
on it so sending the fix separately would be confusing.

The second patch in this series is another fix that for an issue that
came in when sk was passed through the output path.  I don't think it
needs a backport as I don't think anyone uses the path where the code
was incorrect.

The rest of the patchset focuses on the path from xxx_local_out to
dst_output and in the end succeeds in passing sock_net(sk) from the
socket a packet locally originates on to the dst->output function.

Given the size reduction in the code I think this counts as a cleanup as
much as feature work.

There remain a number of helper functions (like ip option processing) to
take care of before the network stack can support destination devices in
other network namespaces but with this set of changes the backbone of
the work is done.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
43 files changed:
drivers/net/ipvlan/ipvlan_core.c
drivers/net/ppp/pptp.c
drivers/net/vrf.c
include/net/dst.h
include/net/dst_ops.h
include/net/ip.h
include/net/ip6_tunnel.h
include/net/ipv6.h
include/net/lwtunnel.h
include/net/xfrm.h
net/core/dst.c
net/core/lwtunnel.c
net/decnet/dn_nsp_out.c
net/decnet/dn_route.c
net/ipv4/igmp.c
net/ipv4/ip_forward.c
net/ipv4/ip_output.c
net/ipv4/ip_tunnel_core.c
net/ipv4/ip_vti.c
net/ipv4/ipmr.c
net/ipv4/netfilter/ipt_SYNPROXY.c
net/ipv4/netfilter/nf_dup_ipv4.c
net/ipv4/netfilter/nf_reject_ipv4.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/xfrm4_output.c
net/ipv6/ila.c
net/ipv6/ip6_output.c
net/ipv6/ip6_vti.c
net/ipv6/ip6mr.c
net/ipv6/mcast.c
net/ipv6/ndisc.c
net/ipv6/netfilter/ip6t_SYNPROXY.c
net/ipv6/netfilter/nf_dup_ipv6.c
net/ipv6/netfilter/nf_reject_ipv6.c
net/ipv6/output_core.c
net/ipv6/raw.c
net/ipv6/route.c
net/ipv6/xfrm6_output.c
net/mpls/mpls_iptunnel.c
net/netfilter/ipvs/ip_vs_xmit.c
net/xfrm/xfrm_output.c
net/xfrm/xfrm_policy.c

index 207f62e8de9a93415cc76eb5fd75f987b3de53b6..24f8dbcf854f08a5c274e0894431b1ef45703784 100644 (file)
@@ -344,6 +344,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
 {
        const struct iphdr *ip4h = ip_hdr(skb);
        struct net_device *dev = skb->dev;
+       struct net *net = dev_net(dev);
        struct rtable *rt;
        int err, ret = NET_XMIT_DROP;
        struct flowi4 fl4 = {
@@ -354,7 +355,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
                .saddr = ip4h->saddr,
        };
 
-       rt = ip_route_output_flow(dev_net(dev), &fl4, NULL);
+       rt = ip_route_output_flow(net, &fl4, NULL);
        if (IS_ERR(rt))
                goto err;
 
@@ -364,7 +365,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
        }
        skb_dst_drop(skb);
        skb_dst_set(skb, &rt->dst);
-       err = ip_local_out(skb);
+       err = ip_local_out(net, skb->sk, skb);
        if (unlikely(net_xmit_eval(err)))
                dev->stats.tx_errors++;
        else
@@ -381,6 +382,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
 {
        const struct ipv6hdr *ip6h = ipv6_hdr(skb);
        struct net_device *dev = skb->dev;
+       struct net *net = dev_net(dev);
        struct dst_entry *dst;
        int err, ret = NET_XMIT_DROP;
        struct flowi6 fl6 = {
@@ -393,7 +395,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
                .flowi6_proto = ip6h->nexthdr,
        };
 
-       dst = ip6_route_output(dev_net(dev), NULL, &fl6);
+       dst = ip6_route_output(net, NULL, &fl6);
        if (dst->error) {
                ret = dst->error;
                dst_release(dst);
@@ -401,7 +403,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
        }
        skb_dst_drop(skb);
        skb_dst_set(skb, dst);
-       err = ip6_local_out(skb);
+       err = ip6_local_out(net, skb->sk, skb);
        if (unlikely(net_xmit_eval(err)))
                dev->stats.tx_errors++;
        else
index 686f37daa262b180f5efed77152335e62364b4ef..fc69e41d09506e96b38f067fa05175bd680fa36b 100644 (file)
@@ -169,6 +169,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 {
        struct sock *sk = (struct sock *) chan->private;
        struct pppox_sock *po = pppox_sk(sk);
+       struct net *net = sock_net(sk);
        struct pptp_opt *opt = &po->proto.pptp;
        struct pptp_gre_header *hdr;
        unsigned int header_len = sizeof(*hdr);
@@ -187,7 +188,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
        if (sk_pppox(po)->sk_state & PPPOX_DEAD)
                goto tx_error;
 
-       rt = ip_route_output_ports(sock_net(sk), &fl4, NULL,
+       rt = ip_route_output_ports(net, &fl4, NULL,
                                   opt->dst_addr.sin_addr.s_addr,
                                   opt->src_addr.sin_addr.s_addr,
                                   0, 0, IPPROTO_GRE,
@@ -279,10 +280,10 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
        nf_reset(skb);
 
        skb->ip_summed = CHECKSUM_NONE;
-       ip_select_ident(sock_net(sk), skb, NULL);
+       ip_select_ident(net, skb, NULL);
        ip_send_check(iph);
 
-       ip_local_out(skb);
+       ip_local_out(net, skb->sk, skb);
        return 1;
 
 tx_error:
index 64499766e00f64255ece98727d382064e621e909..191579aeab1695957e272d54adf630eb57f7ae14 100644 (file)
@@ -74,9 +74,9 @@ static struct dst_entry *vrf_ip_check(struct dst_entry *dst, u32 cookie)
        return dst;
 }
 
-static int vrf_ip_local_out(struct sk_buff *skb)
+static int vrf_ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       return ip_local_out(skb);
+       return ip_local_out(net, sk, skb);
 }
 
 static unsigned int vrf_v4_mtu(const struct dst_entry *dst)
@@ -222,7 +222,7 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
                                               RT_SCOPE_LINK);
        }
 
-       ret = ip_local_out(skb);
+       ret = ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
        if (unlikely(net_xmit_eval(ret)))
                vrf_dev->stats.tx_errors++;
        else
@@ -312,10 +312,9 @@ err:
        return ret;
 }
 
-static int vrf_output(struct sock *sk, struct sk_buff *skb)
+static int vrf_output(struct net *net, 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(net, IPSTATS_MIB_OUT, skb->len);
 
index 779206c15f8bae0b86e5b3536ca256ba4eee2802..1279f9b09791ace6885b0dd67c2c28d578b6cd8e 100644 (file)
@@ -45,7 +45,7 @@ struct dst_entry {
        void                    *__pad1;
 #endif
        int                     (*input)(struct sk_buff *);
-       int                     (*output)(struct sock *sk, struct sk_buff *skb);
+       int                     (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 
        unsigned short          flags;
 #define DST_HOST               0x0001
@@ -365,10 +365,10 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
        __skb_tunnel_rx(skb, dev, net);
 }
 
-int dst_discard_sk(struct sock *sk, struct sk_buff *skb);
+int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 static inline int dst_discard(struct sk_buff *skb)
 {
-       return dst_discard_sk(skb->sk, skb);
+       return dst_discard_out(&init_net, skb->sk, skb);
 }
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref,
                int initial_obsolete, unsigned short flags);
@@ -454,13 +454,9 @@ static inline void dst_set_expires(struct dst_entry *dst, int timeout)
 }
 
 /* Output packet to network from transport.  */
-static inline int dst_output(struct sock *sk, struct sk_buff *skb)
+static inline int dst_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       return skb_dst(skb)->output(sk, skb);
-}
-static inline int dst_output_okfn(struct net *net, struct sock *sk, struct sk_buff *skb)
-{
-       return dst_output(sk, skb);
+       return skb_dst(skb)->output(net, sk, skb);
 }
 
 /* Input packet from network to transport.  */
index d64253914a6ab6406d92becb4c44fbdec8af17e2..a0d443ca16fcca26b4925d477265935f5bdaf5bc 100644 (file)
@@ -9,6 +9,7 @@ struct kmem_cachep;
 struct net_device;
 struct sk_buff;
 struct sock;
+struct net;
 
 struct dst_ops {
        unsigned short          family;
@@ -28,7 +29,7 @@ struct dst_ops {
                                               struct sk_buff *skb, u32 mtu);
        void                    (*redirect)(struct dst_entry *dst, struct sock *sk,
                                            struct sk_buff *skb);
-       int                     (*local_out)(struct sk_buff *skb);
+       int                     (*local_out)(struct net *net, struct sock *sk, struct sk_buff *skb);
        struct neighbour *      (*neigh_lookup)(const struct dst_entry *dst,
                                                struct sk_buff *skb,
                                                const void *daddr);
index dd06ab3669f9d4d38ea1e7cb8e0053516943566c..3c904a28d5e5a0091c5aeb86432be8ea9365a2e1 100644 (file)
@@ -107,17 +107,13 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
           struct net_device *orig_dev);
 int ip_local_deliver(struct sk_buff *skb);
 int ip_mr_input(struct sk_buff *skb);
-int ip_output(struct sock *sk, struct sk_buff *skb);
-int ip_mc_output(struct sock *sk, struct sk_buff *skb);
+int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb);
+int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
                   int (*output)(struct net *, struct sock *, struct sk_buff *));
 void ip_send_check(struct iphdr *ip);
-int __ip_local_out(struct sk_buff *skb);
-int ip_local_out_sk(struct sock *sk, struct sk_buff *skb);
-static inline int ip_local_out(struct sk_buff *skb)
-{
-       return ip_local_out_sk(skb->sk, skb);
-}
+int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
+int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 
 int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
 void ip_init(void);
index fa915fa0f703dc03d21ae51b50cbd11c7fb74561..aaee6fa02cf1d2a756eb6b97559501c47af1c635 100644 (file)
@@ -87,7 +87,7 @@ static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
        int pkt_len, err;
 
        pkt_len = skb->len - skb_inner_network_offset(skb);
-       err = ip6_local_out_sk(sk, skb);
+       err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
 
        if (net_xmit_eval(err) == 0) {
                struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
index 3dde042bcd3fc4db7efe95207a4c7b0708e1aed2..e1a10b0ac0b027189732372e2c0040e5ea8350f2 100644 (file)
@@ -860,14 +860,13 @@ struct dst_entry *ip6_blackhole_route(struct net *net,
  *     skb processing functions
  */
 
-int ip6_output(struct sock *sk, struct sk_buff *skb);
+int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 int ip6_forward(struct sk_buff *skb);
 int ip6_input(struct sk_buff *skb);
 int ip6_mc_input(struct sk_buff *skb);
 
-int __ip6_local_out(struct sk_buff *skb);
-int ip6_local_out_sk(struct sock *sk, struct sk_buff *skb);
-int ip6_local_out(struct sk_buff *skb);
+int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
+int ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 
 /*
  *     Extension header (options) processing
index fce0e35e74d075cd77f23a84efc6c36885c93ba9..66350ce3e955330c167dd8ffbb5dc1abfb02a6eb 100644 (file)
@@ -18,7 +18,7 @@ struct lwtunnel_state {
        __u16           type;
        __u16           flags;
        atomic_t        refcnt;
-       int             (*orig_output)(struct sock *sk, struct sk_buff *skb);
+       int             (*orig_output)(struct net *net, struct sock *sk, struct sk_buff *skb);
        int             (*orig_input)(struct sk_buff *);
        int             len;
        __u8            data[0];
@@ -28,7 +28,7 @@ struct lwtunnel_encap_ops {
        int (*build_state)(struct net_device *dev, struct nlattr *encap,
                           unsigned int family, const void *cfg,
                           struct lwtunnel_state **ts);
-       int (*output)(struct sock *sk, struct sk_buff *skb);
+       int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
        int (*input)(struct sk_buff *skb);
        int (*fill_encap)(struct sk_buff *skb,
                          struct lwtunnel_state *lwtstate);
@@ -88,7 +88,7 @@ int lwtunnel_fill_encap(struct sk_buff *skb,
 int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate);
 struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len);
 int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b);
-int lwtunnel_output(struct sock *sk, struct sk_buff *skb);
+int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 int lwtunnel_input(struct sk_buff *skb);
 
 #else
@@ -160,7 +160,7 @@ static inline int lwtunnel_cmp_encap(struct lwtunnel_state *a,
        return 0;
 }
 
-static inline int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
+static inline int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        return -EOPNOTSUPP;
 }
index fd176106909a8111177250d70e684fa67e6f3f02..4a9c21f9b4ea189075901a3f2c8c12ec6814f5fe 100644 (file)
@@ -333,7 +333,7 @@ struct xfrm_state_afinfo {
                                                const xfrm_address_t *saddr);
        int                     (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
        int                     (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
-       int                     (*output)(struct sock *sk, struct sk_buff *skb);
+       int                     (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
        int                     (*output_finish)(struct sock *sk, struct sk_buff *skb);
        int                     (*extract_input)(struct xfrm_state *x,
                                                 struct sk_buff *skb);
@@ -1527,7 +1527,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
 
 int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
 int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
-int xfrm4_output(struct sock *sk, struct sk_buff *skb);
+int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb);
 int xfrm4_rcv_cb(struct sk_buff *skb, u8 protocol, int err);
 int xfrm4_protocol_register(struct xfrm4_protocol *handler, unsigned char protocol);
@@ -1552,7 +1552,7 @@ __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr);
 __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr);
 int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
 int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
-int xfrm6_output(struct sock *sk, struct sk_buff *skb);
+int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
 int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb);
 int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
                          u8 **prevhdr);
index 0771c8cb9307c8c1b8edd3742fda766db5e59a97..2a1818065e126d4645076f391e4dd689051e9d43 100644 (file)
@@ -144,12 +144,12 @@ loop:
        mutex_unlock(&dst_gc_mutex);
 }
 
-int dst_discard_sk(struct sock *sk, struct sk_buff *skb)
+int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        kfree_skb(skb);
        return 0;
 }
-EXPORT_SYMBOL(dst_discard_sk);
+EXPORT_SYMBOL(dst_discard_out);
 
 const u32 dst_default_metrics[RTAX_MAX + 1] = {
        /* This initializer is needed to force linker to place this variable
@@ -177,7 +177,7 @@ void dst_init(struct dst_entry *dst, struct dst_ops *ops,
        dst->xfrm = NULL;
 #endif
        dst->input = dst_discard;
-       dst->output = dst_discard_sk;
+       dst->output = dst_discard_out;
        dst->error = 0;
        dst->obsolete = initial_obsolete;
        dst->header_len = 0;
@@ -224,7 +224,7 @@ static void ___dst_free(struct dst_entry *dst)
         */
        if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) {
                dst->input = dst_discard;
-               dst->output = dst_discard_sk;
+               dst->output = dst_discard_out;
        }
        dst->obsolete = DST_OBSOLETE_DEAD;
 }
@@ -352,7 +352,7 @@ static struct dst_ops md_dst_ops = {
        .family =               AF_UNSPEC,
 };
 
-static int dst_md_discard_sk(struct sock *sk, struct sk_buff *skb)
+static int dst_md_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        WARN_ONCE(1, "Attempting to call output on metadata dst\n");
        kfree_skb(skb);
@@ -375,7 +375,7 @@ static void __metadata_dst_init(struct metadata_dst *md_dst, u8 optslen)
                 DST_METADATA | DST_NOCACHE | DST_NOCOUNT);
 
        dst->input = dst_md_discard;
-       dst->output = dst_md_discard_sk;
+       dst->output = dst_md_discard_out;
 
        memset(dst + 1, 0, sizeof(*md_dst) + optslen - sizeof(*dst));
 }
@@ -430,7 +430,7 @@ static void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 
        if (!unregister) {
                dst->input = dst_discard;
-               dst->output = dst_discard_sk;
+               dst->output = dst_discard_out;
        } else {
                dst->dev = dev_net(dst->dev)->loopback_dev;
                dev_hold(dst->dev);
index dfb1a9ca08354fef353bf274415528d2d4ca269a..299cfc24d88832c3580450fcd824ae7b4fdd10c1 100644 (file)
@@ -180,7 +180,7 @@ int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b)
 }
 EXPORT_SYMBOL(lwtunnel_cmp_encap);
 
-int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
+int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct dst_entry *dst = skb_dst(skb);
        const struct lwtunnel_encap_ops *ops;
@@ -199,7 +199,7 @@ int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
        rcu_read_lock();
        ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
        if (likely(ops && ops->output))
-               ret = ops->output(sk, skb);
+               ret = ops->output(net, sk, skb);
        rcu_read_unlock();
 
        if (ret == -EOPNOTSUPP)
index 4b02dd300f5072f97e25aea310e6dea67d26cfee..849805e7af523a0f1159c5e3b6914a4ccd99b353 100644 (file)
@@ -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->sk, skb);
+               dst_output(&init_net, 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->sk, skb);
+       dst_output(&init_net, skb->sk, skb);
 }
 
 
index e930321e2c1de264000eba75fa0a13a60cd821cc..27fce283117babac70b4be2ca77c82eef5badf0c 100644 (file)
@@ -744,7 +744,7 @@ out:
        return NET_RX_DROP;
 }
 
-static int dn_output(struct sock *sk, struct sk_buff *skb)
+static int dn_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;
@@ -832,7 +832,7 @@ drop:
  * Used to catch bugs. This should never normally get
  * called.
  */
-static int dn_rt_bug_sk(struct sock *sk, struct sk_buff *skb)
+static int dn_rt_bug_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
 
@@ -1469,7 +1469,7 @@ make_route:
 
        rt->n = neigh;
        rt->dst.lastuse = jiffies;
-       rt->dst.output = dn_rt_bug_sk;
+       rt->dst.output = dn_rt_bug_out;
        switch (res.type) {
        case RTN_UNICAST:
                rt->dst.input = dn_forward;
index de6d4c8ba600edccd9f467b5fab9f1c00a6f7151..64aaf3522a59f30672689f7309987606773ccb0c 100644 (file)
@@ -397,7 +397,7 @@ static int igmpv3_sendpack(struct sk_buff *skb)
 
        pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen);
 
-       return ip_local_out(skb);
+       return ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
 }
 
 static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
@@ -739,7 +739,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
        ih->group = group;
        ih->csum = ip_compute_csum((void *)ih, sizeof(struct igmphdr));
 
-       return ip_local_out(skb);
+       return ip_local_out(net, skb->sk, skb);
 }
 
 static void igmp_gq_timer_expire(unsigned long data)
index d66cfb35ba74681f0a4cecb76f2bb72d9389efe9..da0d7ce85844a9ed0732883ac363ab2de62f3a9b 100644 (file)
@@ -72,7 +72,7 @@ static int ip_forward_finish(struct net *net, struct sock *sk, struct sk_buff *s
                ip_forward_options(skb);
 
        skb_sender_cpu_clear(skb);
-       return dst_output(sk, skb);
+       return dst_output(net, sk, skb);
 }
 
 int ip_forward(struct sk_buff *skb)
index 911ea739049a69e98cedd6590a0a8616b4285ab5..67404e1fe7d40fe5121f7405d738bea40fe70942 100644 (file)
@@ -96,34 +96,28 @@ void ip_send_check(struct iphdr *iph)
 }
 EXPORT_SYMBOL(ip_send_check);
 
-static int __ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
+int __ip_local_out(struct net *net, 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,
                       net, sk, skb, NULL, skb_dst(skb)->dev,
-                      dst_output_okfn);
+                      dst_output);
 }
 
-int __ip_local_out(struct sk_buff *skb)
-{
-       return __ip_local_out_sk(skb->sk, skb);
-}
-
-int ip_local_out_sk(struct sock *sk, struct sk_buff *skb)
+int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        int err;
 
-       err = __ip_local_out(skb);
+       err = __ip_local_out(net, sk, skb);
        if (likely(err == 1))
-               err = dst_output(sk, skb);
+               err = dst_output(net, sk, skb);
 
        return err;
 }
-EXPORT_SYMBOL_GPL(ip_local_out_sk);
+EXPORT_SYMBOL_GPL(ip_local_out);
 
 static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
 {
@@ -143,6 +137,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
 {
        struct inet_sock *inet = inet_sk(sk);
        struct rtable *rt = skb_rtable(skb);
+       struct net *net = sock_net(sk);
        struct iphdr *iph;
 
        /* Build the IP header. */
@@ -161,7 +156,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
                iph->id = 0;
        } else {
                iph->frag_off = 0;
-               __ip_select_ident(sock_net(sk), iph, 1);
+               __ip_select_ident(net, iph, 1);
        }
 
        if (opt && opt->opt.optlen) {
@@ -173,7 +168,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
        skb->mark = sk->sk_mark;
 
        /* Send it out. */
-       return ip_local_out(skb);
+       return ip_local_out(net, skb->sk, skb);
 }
 EXPORT_SYMBOL_GPL(ip_build_and_send_pkt);
 
@@ -276,7 +271,7 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
        /* Policy lookup after SNAT yielded a new policy */
        if (skb_dst(skb)->xfrm) {
                IPCB(skb)->flags |= IPSKB_REROUTED;
-               return dst_output(sk, skb);
+               return dst_output(net, sk, skb);
        }
 #endif
        mtu = ip_skb_dst_mtu(skb);
@@ -289,11 +284,10 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
        return ip_finish_output2(net, sk, skb);
 }
 
-int ip_mc_output(struct sock *sk, struct sk_buff *skb)
+int ip_mc_output(struct net *net, 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.
@@ -352,10 +346,9 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
                            !(IPCB(skb)->flags & IPSKB_REROUTED));
 }
 
-int ip_output(struct sock *sk, struct sk_buff *skb)
+int ip_output(struct net *net, 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(net, IPSTATS_MIB_OUT, skb->len);
 
@@ -386,6 +379,7 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
 int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
 {
        struct inet_sock *inet = inet_sk(sk);
+       struct net *net = sock_net(sk);
        struct ip_options_rcu *inet_opt;
        struct flowi4 *fl4;
        struct rtable *rt;
@@ -416,7 +410,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
                 * keep trying until route appears or the connection times
                 * itself out.
                 */
-               rt = ip_route_output_ports(sock_net(sk), fl4, sk,
+               rt = ip_route_output_ports(net, fl4, sk,
                                           daddr, inet->inet_saddr,
                                           inet->inet_dport,
                                           inet->inet_sport,
@@ -453,20 +447,20 @@ packet_routed:
                ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
        }
 
-       ip_select_ident_segs(sock_net(sk), skb, sk,
+       ip_select_ident_segs(net, skb, sk,
                             skb_shinfo(skb)->gso_segs ?: 1);
 
        /* TODO : should we use skb->sk here instead of sk ? */
        skb->priority = sk->sk_priority;
        skb->mark = sk->sk_mark;
 
-       res = ip_local_out(skb);
+       res = ip_local_out(net, sk, skb);
        rcu_read_unlock();
        return res;
 
 no_route:
        rcu_read_unlock();
-       IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
+       IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
        kfree_skb(skb);
        return -EHOSTUNREACH;
 }
@@ -1440,7 +1434,7 @@ int ip_send_skb(struct net *net, struct sk_buff *skb)
 {
        int err;
 
-       err = ip_local_out(skb);
+       err = ip_local_out(net, skb->sk, skb);
        if (err) {
                if (err > 0)
                        err = net_xmit_errno(err);
index 84dce6a92f93bec35158b392477c536d6f2f1529..6cb9009c3d96785e566a3cb2cd065860e05980e1 100644 (file)
@@ -53,6 +53,7 @@ int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
                  __u8 tos, __u8 ttl, __be16 df, bool xnet)
 {
        int pkt_len = skb->len - skb_inner_network_offset(skb);
+       struct net *net = dev_net(rt->dst.dev);
        struct iphdr *iph;
        int err;
 
@@ -76,10 +77,9 @@ int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
        iph->daddr      =       dst;
        iph->saddr      =       src;
        iph->ttl        =       ttl;
-       __ip_select_ident(dev_net(rt->dst.dev), iph,
-                         skb_shinfo(skb)->gso_segs ?: 1);
+       __ip_select_ident(net, iph, skb_shinfo(skb)->gso_segs ?: 1);
 
-       err = ip_local_out_sk(sk, skb);
+       err = ip_local_out(net, sk, skb);
        if (unlikely(net_xmit_eval(err)))
                pkt_len = 0;
        return pkt_len;
index 3b87ec5178f986ad17f53d23fcd8e01402fe13a4..4d8f0b6987777ab6c096fadbce538c53cbcad24b 100644 (file)
@@ -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->sk, skb);
+       err = dst_output(tunnel->net, skb->sk, skb);
        if (net_xmit_eval(err) == 0)
                err = skb->len;
        iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
index cfcb996ec51bac6843ae3f513e6a7ba2f3da3610..fc42525d86943a384d1f8d052d7649b69ba401b4 100644 (file)
@@ -1689,7 +1689,7 @@ static inline int ipmr_forward_finish(struct net *net, struct sock *sk,
        if (unlikely(opt->optlen))
                ip_forward_options(skb);
 
-       return dst_output(sk, skb);
+       return dst_output(net, sk, skb);
 }
 
 /*
index 6a6e762ab27f18f9b5924c84895f60ea490da79e..f1a8df8ecc1f344d58aa834fb7230b12e0fa1bc2 100644 (file)
@@ -63,7 +63,7 @@ synproxy_send_tcp(const struct synproxy_net *snet,
                nf_conntrack_get(nfct);
        }
 
-       ip_local_out(nskb);
+       ip_local_out(net, nskb->sk, nskb);
        return;
 
 free_nskb:
index ce2a59e5c6659ab8dda663e89d63c703702efccb..ceb187308120675c6f5d51000e5e7112a48b3670 100644 (file)
@@ -92,7 +92,7 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
 
        if (nf_dup_ipv4_route(net, skb, gw, oif)) {
                __this_cpu_write(nf_skb_duplicated, true);
-               ip_local_out(skb);
+               ip_local_out(net, skb->sk, skb);
                __this_cpu_write(nf_skb_duplicated, false);
        } else {
                kfree_skb(skb);
index 2f5e925d3264c50e9bf1a54dbd2fbada25d16906..c747b2d9eb7703388762c71a7222a567e2ce5cde 100644 (file)
@@ -157,7 +157,7 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)
                dev_queue_xmit(nskb);
        } else
 #endif
-               ip_local_out(nskb);
+               ip_local_out(net, nskb->sk, nskb);
 
        return;
 
index 09a07e8b2f35463b2bd9f390c42c90f2bd931e09..8c0d0bdc2a7c59ad44752f2d378a07d505753a8b 100644 (file)
@@ -413,7 +413,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
 
        err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
                      net, sk, skb, NULL, rt->dst.dev,
-                     dst_output_okfn);
+                     dst_output);
        if (err > 0)
                err = net_xmit_errno(err);
        if (err)
index bf1486bd7e811d64d5c4a69173dfa9c64a877456..4be5ff08f98d266153eaeea1f01605946def415b 100644 (file)
@@ -1152,7 +1152,7 @@ static void ipv4_link_failure(struct sk_buff *skb)
                dst_set_expires(&rt->dst, 0);
 }
 
-static int ip_rt_bug(struct sock *sk, struct sk_buff *skb)
+static int ip_rt_bug(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        pr_debug("%s: %pI4 -> %pI4, %s\n",
                 __func__, &ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
@@ -2303,7 +2303,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
 
                new->__use = 1;
                new->input = dst_discard;
-               new->output = dst_discard_sk;
+               new->output = dst_discard_out;
 
                new->dev = ort->dst.dev;
                if (new->dev)
index cd6be736e19fcb06aa68f42e07eb51c5ce2c10d2..9f298d0dc9a1ccc3ac53dd205be8b90e56cc866b 100644 (file)
@@ -87,17 +87,15 @@ static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 #ifdef CONFIG_NETFILTER
        if (!x) {
                IPCB(skb)->flags |= IPSKB_REROUTED;
-               return dst_output(sk, skb);
+               return dst_output(net, sk, skb);
        }
 #endif
 
        return x->outer_mode->afinfo->output_finish(sk, skb);
 }
 
-int xfrm4_output(struct sock *sk, struct sk_buff *skb)
+int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       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,
index 678d2df4b8d93915185bd14ca7fa8cf9931472e4..1a6852e1ac69e408de22e8df9131188542ad649a 100644 (file)
@@ -91,7 +91,7 @@ static void update_ipv6_locator(struct sk_buff *skb, struct ila_params *p)
        *(__be64 *)&ip6h->daddr = p->locator;
 }
 
-static int ila_output(struct sock *sk, struct sk_buff *skb)
+static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct dst_entry *dst = skb_dst(skb);
 
@@ -100,7 +100,7 @@ static int ila_output(struct sock *sk, struct sk_buff *skb)
 
        update_ipv6_locator(skb, ila_params_lwtunnel(dst->lwtstate));
 
-       return dst->lwtstate->orig_output(sk, skb);
+       return dst->lwtstate->orig_output(net, sk, skb);
 
 drop:
        kfree_skb(skb);
index caf7d14a1bdda66df36ed5d610519ddcdd9c67fb..32583b507c2ee7613cf9d27030d476d602d866bc 100644 (file)
@@ -130,11 +130,10 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
                return ip6_finish_output2(net, sk, skb);
 }
 
-int ip6_output(struct sock *sk, struct sk_buff *skb)
+int ip6_output(struct net *net, 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(net, idev, IPSTATS_MIB_OUTDISCARDS);
@@ -233,7 +232,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
                 */
                return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
                               net, (struct sock *)sk, skb, NULL, dst->dev,
-                              dst_output_okfn);
+                              dst_output);
        }
 
        skb->dev = dst->dev;
@@ -333,7 +332,7 @@ 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);
+       return dst_output(net, sk, skb);
 }
 
 static unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
@@ -1692,7 +1691,7 @@ int ip6_send_skb(struct sk_buff *skb)
        struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
        int err;
 
-       err = ip6_local_out(skb);
+       err = ip6_local_out(net, skb->sk, skb);
        if (err) {
                if (err > 0)
                        err = net_xmit_errno(err);
index f96f1c19b4a8842cbc29dbe1288e0d001f34bd7e..0a8610b33d7980e4b1d5290b4266669ddcdc9e0a 100644 (file)
@@ -482,7 +482,7 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
                return -EMSGSIZE;
        }
 
-       err = dst_output(skb->sk, skb);
+       err = dst_output(t->net, skb->sk, skb);
        if (net_xmit_eval(err) == 0) {
                struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
 
index 5e5d16e7ce8532ea9599f6c4b006f4934b0e265e..ad19136086dd5e1ae4e362e3da0f0267fc755b02 100644 (file)
@@ -1991,7 +1991,7 @@ static inline int ip6mr_forward2_finish(struct net *net, struct sock *sk, struct
                         IPSTATS_MIB_OUTFORWDATAGRAMS);
        IP6_ADD_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
                         IPSTATS_MIB_OUTOCTETS, skb->len);
-       return dst_output(sk, skb);
+       return dst_output(net, sk, skb);
 }
 
 /*
index a8bf57ca74d3a171d4a939a7e919760f9e117d7d..124338a39e29cb3e3a5e602fb706486f330fb529 100644 (file)
@@ -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_okfn);
+                     dst_output);
 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_okfn);
+                     dst_output);
 out:
        if (!err) {
                ICMP6MSGOUT_INC_STATS(net, idev, type);
index 7089c305245c81f7aa28af5141f2b64d9812e693..b18012f9f9fcba0b7d1f59b2a156f0d35b28b63a 100644 (file)
@@ -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_okfn);
+                     dst_output);
        if (!err) {
                ICMP6MSGOUT_INC_STATS(net, idev, type);
                ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
index c2356602158a659d751847d9042986b363ab43b6..a10a2a9e9f94129e2d4a92b0c58012eb346485b3 100644 (file)
@@ -76,7 +76,7 @@ synproxy_send_tcp(const struct synproxy_net *snet,
                nf_conntrack_get(nfct);
        }
 
-       ip6_local_out(nskb);
+       ip6_local_out(net, nskb->sk, nskb);
        return;
 
 free_nskb:
index ee0d9a5b16c352d17a89e46d2de6fb1bea76c54e..6989c70ae29f1541e0216d36d58ee142934a83c2 100644 (file)
@@ -68,7 +68,7 @@ void nf_dup_ipv6(struct net *net, struct sk_buff *skb, unsigned int hooknum,
        }
        if (nf_dup_ipv6_route(net, skb, gw, oif)) {
                __this_cpu_write(nf_skb_duplicated, true);
-               ip6_local_out(skb);
+               ip6_local_out(net, skb->sk, skb);
                __this_cpu_write(nf_skb_duplicated, false);
        } else {
                kfree_skb(skb);
index 94b4c6dfb400c90b6c368acb7ecb83649309dce0..7309e475f68b405d040e53069b123663914ffd7b 100644 (file)
@@ -206,7 +206,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
                dev_queue_xmit(nskb);
        } else
 #endif
-               ip6_local_out(nskb);
+               ip6_local_out(net, nskb->sk, nskb);
 }
 EXPORT_SYMBOL_GPL(nf_send_reset6);
 
index e77102c4f8045e881bf3bdf86d43dc5323f6ae31..462f2a76b5c2270dba806e193a4c5bde57e14a39 100644 (file)
@@ -138,9 +138,8 @@ int ip6_dst_hoplimit(struct dst_entry *dst)
 EXPORT_SYMBOL(ip6_dst_hoplimit);
 #endif
 
-static int __ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
+int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       struct net *net = dev_net(skb_dst(skb)->dev);
        int len;
 
        len = skb->len - sizeof(struct ipv6hdr);
@@ -151,29 +150,18 @@ 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_okfn);
-}
-
-int __ip6_local_out(struct sk_buff *skb)
-{
-       return __ip6_local_out_sk(skb->sk, skb);
+                      dst_output);
 }
 EXPORT_SYMBOL_GPL(__ip6_local_out);
 
-int ip6_local_out_sk(struct sock *sk, struct sk_buff *skb)
+int ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        int err;
 
-       err = __ip6_local_out_sk(sk, skb);
+       err = __ip6_local_out(net, sk, skb);
        if (likely(err == 1))
-               err = dst_output(sk, skb);
+               err = dst_output(net, sk, skb);
 
        return err;
 }
-EXPORT_SYMBOL_GPL(ip6_local_out_sk);
-
-int ip6_local_out(struct sk_buff *skb)
-{
-       return ip6_local_out_sk(skb->sk, skb);
-}
 EXPORT_SYMBOL_GPL(ip6_local_out);
index fec0151522a25d0bcd787c0353d23f5aba11c780..dc65ec198f7c3f7ae19176fdaa8752c7fb4e13a5 100644 (file)
@@ -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_okfn);
+                     NULL, rt->dst.dev, dst_output);
        if (err > 0)
                err = net_xmit_errno(err);
        if (err)
index d3d946773a3e8caa3dddbcdaef222b3bb9efa59e..4320ddcac33f59511a8913d1c68c374231c64d3d 100644 (file)
@@ -86,9 +86,9 @@ static void           ip6_dst_ifdown(struct dst_entry *,
 static int              ip6_dst_gc(struct dst_ops *ops);
 
 static int             ip6_pkt_discard(struct sk_buff *skb);
-static int             ip6_pkt_discard_out(struct sock *sk, struct sk_buff *skb);
+static int             ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 static int             ip6_pkt_prohibit(struct sk_buff *skb);
-static int             ip6_pkt_prohibit_out(struct sock *sk, struct sk_buff *skb);
+static int             ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb);
 static void            ip6_link_failure(struct sk_buff *skb);
 static void            ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
                                           struct sk_buff *skb, u32 mtu);
@@ -308,7 +308,7 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
                .obsolete       = DST_OBSOLETE_FORCE_CHK,
                .error          = -EINVAL,
                .input          = dst_discard,
-               .output         = dst_discard_sk,
+               .output         = dst_discard_out,
        },
        .rt6i_flags     = (RTF_REJECT | RTF_NONEXTHOP),
        .rt6i_protocol  = RTPROT_KERNEL,
@@ -1195,7 +1195,7 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
 
                new->__use = 1;
                new->input = dst_discard;
-               new->output = dst_discard_sk;
+               new->output = dst_discard_out;
 
                if (dst_metrics_read_only(&ort->dst))
                        new->_metrics = ort->dst._metrics;
@@ -1853,7 +1853,7 @@ int ip6_route_info_create(struct fib6_config *cfg, struct rt6_info **rt_ret)
                switch (cfg->fc_type) {
                case RTN_BLACKHOLE:
                        rt->dst.error = -EINVAL;
-                       rt->dst.output = dst_discard_sk;
+                       rt->dst.output = dst_discard_out;
                        rt->dst.input = dst_discard;
                        break;
                case RTN_PROHIBIT:
@@ -2446,7 +2446,7 @@ static int ip6_pkt_discard(struct sk_buff *skb)
        return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES);
 }
 
-static int ip6_pkt_discard_out(struct sock *sk, struct sk_buff *skb)
+static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        skb->dev = skb_dst(skb)->dev;
        return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES);
@@ -2457,7 +2457,7 @@ static int ip6_pkt_prohibit(struct sk_buff *skb)
        return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES);
 }
 
-static int ip6_pkt_prohibit_out(struct sock *sk, struct sk_buff *skb)
+static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        skb->dev = skb_dst(skb)->dev;
        return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
index 4cefda009f53299bed8b4ac9008125a67da0fb68..9db067a11b525c4bb026fa1d352c05a591e60124 100644 (file)
@@ -147,7 +147,7 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 #ifdef CONFIG_NETFILTER
        if (!x) {
                IP6CB(skb)->flags |= IP6SKB_REROUTED;
-               return dst_output(sk, skb);
+               return dst_output(net, sk, skb);
        }
 #endif
 
@@ -173,10 +173,8 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
        return x->outer_mode->afinfo->output_finish(sk, skb);
 }
 
-int xfrm6_output(struct sock *sk, struct sk_buff *skb)
+int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       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,
index 21e70bc9af989355521f8fd99ea3bc07730626c8..67591aef9cae6fb203ef802272baad6e5b191000 100644 (file)
@@ -37,7 +37,7 @@ static unsigned int mpls_encap_size(struct mpls_iptunnel_encap *en)
        return en->labels * sizeof(struct mpls_shim_hdr);
 }
 
-int mpls_output(struct sock *sk, struct sk_buff *skb)
+int mpls_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct mpls_iptunnel_encap *tun_encap_info;
        struct mpls_shim_hdr *hdr;
index 77182b9750cdc55a25a1f858367a0ef203f3fd3f..3264cb49b333620d6013cf1f6686f09bf07f9b8a 100644 (file)
@@ -576,7 +576,7 @@ static inline int ip_vs_nat_send_or_cont(int pf, struct sk_buff *skb,
                if (!skb->sk)
                        skb_sender_cpu_clear(skb);
                NF_HOOK(pf, NF_INET_LOCAL_OUT, cp->ipvs->net, NULL, skb,
-                       NULL, skb_dst(skb)->dev, dst_output_okfn);
+                       NULL, skb_dst(skb)->dev, dst_output);
        } else
                ret = NF_ACCEPT;
 
@@ -598,7 +598,7 @@ static inline int ip_vs_send_or_cont(int pf, struct sk_buff *skb,
                if (!skb->sk)
                        skb_sender_cpu_clear(skb);
                NF_HOOK(pf, NF_INET_LOCAL_OUT, cp->ipvs->net, NULL, skb,
-                       NULL, skb_dst(skb)->dev, dst_output_okfn);
+                       NULL, skb_dst(skb)->dev, dst_output);
        } else
                ret = NF_ACCEPT;
        return ret;
@@ -1049,7 +1049,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        ret = ip_vs_tunnel_xmit_prepare(skb, cp);
        if (ret == NF_ACCEPT)
-               ip_local_out(skb);
+               ip_local_out(net, skb->sk, skb);
        else if (ret == NF_DROP)
                kfree_skb(skb);
        rcu_read_unlock();
@@ -1141,7 +1141,7 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        ret = ip_vs_tunnel_xmit_prepare(skb, cp);
        if (ret == NF_ACCEPT)
-               ip6_local_out(skb);
+               ip6_local_out(cp->ipvs->net, skb->sk, skb);
        else if (ret == NF_DROP)
                kfree_skb(skb);
        rcu_read_unlock();
index c48a4b8582bb0970626a8c073b6068d8c5bddc19..cc3676eb6239707909e41c34841abbd4ea8958dd 100644 (file)
@@ -136,12 +136,12 @@ int xfrm_output_resume(struct sk_buff *skb, int err)
        while (likely((err = xfrm_output_one(skb, err)) == 0)) {
                nf_reset(skb);
 
-               err = skb_dst(skb)->ops->local_out(skb);
+               err = skb_dst(skb)->ops->local_out(net, skb->sk, skb);
                if (unlikely(err != 1))
                        goto out;
 
                if (!skb_dst(skb)->xfrm)
-                       return dst_output(skb->sk, skb);
+                       return dst_output(net, skb->sk, skb);
 
                err = nf_hook(skb_dst(skb)->ops->family,
                              NF_INET_POST_ROUTING, net, skb->sk, skb,
index 418daa038edf4444520ebcfb15627d4e0679d402..09bfcbac63bb3f75d909aecd840b63d36b169eec 100644 (file)
@@ -1887,6 +1887,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
        struct sock *sk;
        struct dst_entry *dst;
        struct xfrm_policy *pol = (struct xfrm_policy *)arg;
+       struct net *net = xp_net(pol);
        struct xfrm_policy_queue *pq = &pol->polq;
        struct flowi fl;
        struct sk_buff_head list;
@@ -1903,8 +1904,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
        spin_unlock(&pq->hold_queue.lock);
 
        dst_hold(dst->path);
-       dst = xfrm_lookup(xp_net(pol), dst->path, &fl,
-                         sk, 0);
+       dst = xfrm_lookup(net, dst->path, &fl, sk, 0);
        if (IS_ERR(dst))
                goto purge_queue;
 
@@ -1934,8 +1934,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
 
                xfrm_decode_session(skb, &fl, skb_dst(skb)->ops->family);
                dst_hold(skb_dst(skb)->path);
-               dst = xfrm_lookup(xp_net(pol), skb_dst(skb)->path,
-                                 &fl, skb->sk, 0);
+               dst = xfrm_lookup(net, skb_dst(skb)->path, &fl, skb->sk, 0);
                if (IS_ERR(dst)) {
                        kfree_skb(skb);
                        continue;
@@ -1945,7 +1944,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
                skb_dst_drop(skb);
                skb_dst_set(skb, dst);
 
-               dst_output(skb->sk, skb);
+               dst_output(net, skb->sk, skb);
        }
 
 out:
@@ -1958,7 +1957,7 @@ purge_queue:
        xfrm_pol_put(pol);
 }
 
-static int xdst_queue_output(struct sock *sk, struct sk_buff *skb)
+static int xdst_queue_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        unsigned long sched_next;
        struct dst_entry *dst = skb_dst(skb);