Skip to content

Commit ede2059

Browse files
ebiedermdavem330
authored andcommitted
dst: Pass net into dst->output
The network namespace is already passed into dst_output pass it into dst->output lwt->output and friends. Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 33224b1 commit ede2059

File tree

18 files changed

+45
-53
lines changed

18 files changed

+45
-53
lines changed

drivers/net/vrf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,9 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
312312
return ret;
313313
}
314314

315-
static int vrf_output(struct sock *sk, struct sk_buff *skb)
315+
static int vrf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
316316
{
317317
struct net_device *dev = skb_dst(skb)->dev;
318-
struct net *net = dev_net(dev);
319318

320319
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
321320

include/net/dst.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct dst_entry {
4545
void *__pad1;
4646
#endif
4747
int (*input)(struct sk_buff *);
48-
int (*output)(struct sock *sk, struct sk_buff *skb);
48+
int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
4949

5050
unsigned short flags;
5151
#define DST_HOST 0x0001
@@ -365,10 +365,10 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
365365
__skb_tunnel_rx(skb, dev, net);
366366
}
367367

368-
int dst_discard_sk(struct sock *sk, struct sk_buff *skb);
368+
int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
369369
static inline int dst_discard(struct sk_buff *skb)
370370
{
371-
return dst_discard_sk(skb->sk, skb);
371+
return dst_discard_out(&init_net, skb->sk, skb);
372372
}
373373
void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref,
374374
int initial_obsolete, unsigned short flags);
@@ -456,7 +456,7 @@ static inline void dst_set_expires(struct dst_entry *dst, int timeout)
456456
/* Output packet to network from transport. */
457457
static inline int dst_output(struct net *net, struct sock *sk, struct sk_buff *skb)
458458
{
459-
return skb_dst(skb)->output(sk, skb);
459+
return skb_dst(skb)->output(net, sk, skb);
460460
}
461461

462462
/* Input packet from network to transport. */

include/net/ip.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
107107
struct net_device *orig_dev);
108108
int ip_local_deliver(struct sk_buff *skb);
109109
int ip_mr_input(struct sk_buff *skb);
110-
int ip_output(struct sock *sk, struct sk_buff *skb);
111-
int ip_mc_output(struct sock *sk, struct sk_buff *skb);
110+
int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb);
111+
int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb);
112112
int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
113113
int (*output)(struct net *, struct sock *, struct sk_buff *));
114114
void ip_send_check(struct iphdr *ip);

include/net/ipv6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ struct dst_entry *ip6_blackhole_route(struct net *net,
860860
* skb processing functions
861861
*/
862862

863-
int ip6_output(struct sock *sk, struct sk_buff *skb);
863+
int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
864864
int ip6_forward(struct sk_buff *skb);
865865
int ip6_input(struct sk_buff *skb);
866866
int ip6_mc_input(struct sk_buff *skb);

include/net/lwtunnel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct lwtunnel_state {
1818
__u16 type;
1919
__u16 flags;
2020
atomic_t refcnt;
21-
int (*orig_output)(struct sock *sk, struct sk_buff *skb);
21+
int (*orig_output)(struct net *net, struct sock *sk, struct sk_buff *skb);
2222
int (*orig_input)(struct sk_buff *);
2323
int len;
2424
__u8 data[0];
@@ -28,7 +28,7 @@ struct lwtunnel_encap_ops {
2828
int (*build_state)(struct net_device *dev, struct nlattr *encap,
2929
unsigned int family, const void *cfg,
3030
struct lwtunnel_state **ts);
31-
int (*output)(struct sock *sk, struct sk_buff *skb);
31+
int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
3232
int (*input)(struct sk_buff *skb);
3333
int (*fill_encap)(struct sk_buff *skb,
3434
struct lwtunnel_state *lwtstate);
@@ -88,7 +88,7 @@ int lwtunnel_fill_encap(struct sk_buff *skb,
8888
int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate);
8989
struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len);
9090
int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b);
91-
int lwtunnel_output(struct sock *sk, struct sk_buff *skb);
91+
int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb);
9292
int lwtunnel_input(struct sk_buff *skb);
9393

9494
#else
@@ -160,7 +160,7 @@ static inline int lwtunnel_cmp_encap(struct lwtunnel_state *a,
160160
return 0;
161161
}
162162

163-
static inline int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
163+
static inline int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
164164
{
165165
return -EOPNOTSUPP;
166166
}

include/net/xfrm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ struct xfrm_state_afinfo {
333333
const xfrm_address_t *saddr);
334334
int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
335335
int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
336-
int (*output)(struct sock *sk, struct sk_buff *skb);
336+
int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
337337
int (*output_finish)(struct sock *sk, struct sk_buff *skb);
338338
int (*extract_input)(struct xfrm_state *x,
339339
struct sk_buff *skb);
@@ -1527,7 +1527,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
15271527

15281528
int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
15291529
int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1530-
int xfrm4_output(struct sock *sk, struct sk_buff *skb);
1530+
int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb);
15311531
int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb);
15321532
int xfrm4_rcv_cb(struct sk_buff *skb, u8 protocol, int err);
15331533
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);
15521552
__be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr);
15531553
int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
15541554
int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1555-
int xfrm6_output(struct sock *sk, struct sk_buff *skb);
1555+
int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
15561556
int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb);
15571557
int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
15581558
u8 **prevhdr);

net/core/dst.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ static void dst_gc_task(struct work_struct *work)
144144
mutex_unlock(&dst_gc_mutex);
145145
}
146146

147-
int dst_discard_sk(struct sock *sk, struct sk_buff *skb)
147+
int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
148148
{
149149
kfree_skb(skb);
150150
return 0;
151151
}
152-
EXPORT_SYMBOL(dst_discard_sk);
152+
EXPORT_SYMBOL(dst_discard_out);
153153

154154
const u32 dst_default_metrics[RTAX_MAX + 1] = {
155155
/* 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,
177177
dst->xfrm = NULL;
178178
#endif
179179
dst->input = dst_discard;
180-
dst->output = dst_discard_sk;
180+
dst->output = dst_discard_out;
181181
dst->error = 0;
182182
dst->obsolete = initial_obsolete;
183183
dst->header_len = 0;
@@ -224,7 +224,7 @@ static void ___dst_free(struct dst_entry *dst)
224224
*/
225225
if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) {
226226
dst->input = dst_discard;
227-
dst->output = dst_discard_sk;
227+
dst->output = dst_discard_out;
228228
}
229229
dst->obsolete = DST_OBSOLETE_DEAD;
230230
}
@@ -352,7 +352,7 @@ static struct dst_ops md_dst_ops = {
352352
.family = AF_UNSPEC,
353353
};
354354

355-
static int dst_md_discard_sk(struct sock *sk, struct sk_buff *skb)
355+
static int dst_md_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
356356
{
357357
WARN_ONCE(1, "Attempting to call output on metadata dst\n");
358358
kfree_skb(skb);
@@ -375,7 +375,7 @@ static void __metadata_dst_init(struct metadata_dst *md_dst, u8 optslen)
375375
DST_METADATA | DST_NOCACHE | DST_NOCOUNT);
376376

377377
dst->input = dst_md_discard;
378-
dst->output = dst_md_discard_sk;
378+
dst->output = dst_md_discard_out;
379379

380380
memset(dst + 1, 0, sizeof(*md_dst) + optslen - sizeof(*dst));
381381
}
@@ -430,7 +430,7 @@ static void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
430430

431431
if (!unregister) {
432432
dst->input = dst_discard;
433-
dst->output = dst_discard_sk;
433+
dst->output = dst_discard_out;
434434
} else {
435435
dst->dev = dev_net(dst->dev)->loopback_dev;
436436
dev_hold(dst->dev);

net/core/lwtunnel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b)
180180
}
181181
EXPORT_SYMBOL(lwtunnel_cmp_encap);
182182

183-
int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
183+
int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
184184
{
185185
struct dst_entry *dst = skb_dst(skb);
186186
const struct lwtunnel_encap_ops *ops;
@@ -199,7 +199,7 @@ int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
199199
rcu_read_lock();
200200
ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
201201
if (likely(ops && ops->output))
202-
ret = ops->output(sk, skb);
202+
ret = ops->output(net, sk, skb);
203203
rcu_read_unlock();
204204

205205
if (ret == -EOPNOTSUPP)

net/decnet/dn_route.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
744744
return NET_RX_DROP;
745745
}
746746

747-
static int dn_output(struct sock *sk, struct sk_buff *skb)
747+
static int dn_output(struct net *net, struct sock *sk, struct sk_buff *skb)
748748
{
749749
struct dst_entry *dst = skb_dst(skb);
750750
struct dn_route *rt = (struct dn_route *)dst;
@@ -832,7 +832,7 @@ static int dn_forward(struct sk_buff *skb)
832832
* Used to catch bugs. This should never normally get
833833
* called.
834834
*/
835-
static int dn_rt_bug_sk(struct sock *sk, struct sk_buff *skb)
835+
static int dn_rt_bug_out(struct net *net, struct sock *sk, struct sk_buff *skb)
836836
{
837837
struct dn_skb_cb *cb = DN_SKB_CB(skb);
838838

@@ -1469,7 +1469,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
14691469

14701470
rt->n = neigh;
14711471
rt->dst.lastuse = jiffies;
1472-
rt->dst.output = dn_rt_bug_sk;
1472+
rt->dst.output = dn_rt_bug_out;
14731473
switch (res.type) {
14741474
case RTN_UNICAST:
14751475
rt->dst.input = dn_forward;

net/ipv4/ip_output.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
284284
return ip_finish_output2(net, sk, skb);
285285
}
286286

287-
int ip_mc_output(struct sock *sk, struct sk_buff *skb)
287+
int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb)
288288
{
289289
struct rtable *rt = skb_rtable(skb);
290290
struct net_device *dev = rt->dst.dev;
291-
struct net *net = dev_net(dev);
292291

293292
/*
294293
* If the indicated interface is up and running, send the packet.
@@ -347,10 +346,9 @@ int ip_mc_output(struct sock *sk, struct sk_buff *skb)
347346
!(IPCB(skb)->flags & IPSKB_REROUTED));
348347
}
349348

350-
int ip_output(struct sock *sk, struct sk_buff *skb)
349+
int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
351350
{
352351
struct net_device *dev = skb_dst(skb)->dev;
353-
struct net *net = dev_net(dev);
354352

355353
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
356354

net/ipv4/route.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ static void ipv4_link_failure(struct sk_buff *skb)
11521152
dst_set_expires(&rt->dst, 0);
11531153
}
11541154

1155-
static int ip_rt_bug(struct sock *sk, struct sk_buff *skb)
1155+
static int ip_rt_bug(struct net *net, struct sock *sk, struct sk_buff *skb)
11561156
{
11571157
pr_debug("%s: %pI4 -> %pI4, %s\n",
11581158
__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
23032303

23042304
new->__use = 1;
23052305
new->input = dst_discard;
2306-
new->output = dst_discard_sk;
2306+
new->output = dst_discard_out;
23072307

23082308
new->dev = ort->dst.dev;
23092309
if (new->dev)

net/ipv4/xfrm4_output.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
9494
return x->outer_mode->afinfo->output_finish(sk, skb);
9595
}
9696

97-
int xfrm4_output(struct sock *sk, struct sk_buff *skb)
97+
int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
9898
{
99-
struct net *net = dev_net(skb_dst(skb)->dev);
100-
10199
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
102100
net, sk, skb, NULL, skb_dst(skb)->dev,
103101
__xfrm4_output,

net/ipv6/ila.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static void update_ipv6_locator(struct sk_buff *skb, struct ila_params *p)
9191
*(__be64 *)&ip6h->daddr = p->locator;
9292
}
9393

94-
static int ila_output(struct sock *sk, struct sk_buff *skb)
94+
static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
9595
{
9696
struct dst_entry *dst = skb_dst(skb);
9797

@@ -100,7 +100,7 @@ static int ila_output(struct sock *sk, struct sk_buff *skb)
100100

101101
update_ipv6_locator(skb, ila_params_lwtunnel(dst->lwtstate));
102102

103-
return dst->lwtstate->orig_output(sk, skb);
103+
return dst->lwtstate->orig_output(net, sk, skb);
104104

105105
drop:
106106
kfree_skb(skb);

net/ipv6/ip6_output.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
130130
return ip6_finish_output2(net, sk, skb);
131131
}
132132

133-
int ip6_output(struct sock *sk, struct sk_buff *skb)
133+
int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
134134
{
135135
struct net_device *dev = skb_dst(skb)->dev;
136136
struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
137-
struct net *net = dev_net(dev);
138137

139138
if (unlikely(idev->cnf.disable_ipv6)) {
140139
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);

net/ipv6/route.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ static void ip6_dst_ifdown(struct dst_entry *,
8686
static int ip6_dst_gc(struct dst_ops *ops);
8787

8888
static int ip6_pkt_discard(struct sk_buff *skb);
89-
static int ip6_pkt_discard_out(struct sock *sk, struct sk_buff *skb);
89+
static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
9090
static int ip6_pkt_prohibit(struct sk_buff *skb);
91-
static int ip6_pkt_prohibit_out(struct sock *sk, struct sk_buff *skb);
91+
static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb);
9292
static void ip6_link_failure(struct sk_buff *skb);
9393
static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
9494
struct sk_buff *skb, u32 mtu);
@@ -308,7 +308,7 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
308308
.obsolete = DST_OBSOLETE_FORCE_CHK,
309309
.error = -EINVAL,
310310
.input = dst_discard,
311-
.output = dst_discard_sk,
311+
.output = dst_discard_out,
312312
},
313313
.rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
314314
.rt6i_protocol = RTPROT_KERNEL,
@@ -1195,7 +1195,7 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
11951195

11961196
new->__use = 1;
11971197
new->input = dst_discard;
1198-
new->output = dst_discard_sk;
1198+
new->output = dst_discard_out;
11991199

12001200
if (dst_metrics_read_only(&ort->dst))
12011201
new->_metrics = ort->dst._metrics;
@@ -1853,7 +1853,7 @@ int ip6_route_info_create(struct fib6_config *cfg, struct rt6_info **rt_ret)
18531853
switch (cfg->fc_type) {
18541854
case RTN_BLACKHOLE:
18551855
rt->dst.error = -EINVAL;
1856-
rt->dst.output = dst_discard_sk;
1856+
rt->dst.output = dst_discard_out;
18571857
rt->dst.input = dst_discard;
18581858
break;
18591859
case RTN_PROHIBIT:
@@ -2446,7 +2446,7 @@ static int ip6_pkt_discard(struct sk_buff *skb)
24462446
return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES);
24472447
}
24482448

2449-
static int ip6_pkt_discard_out(struct sock *sk, struct sk_buff *skb)
2449+
static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb)
24502450
{
24512451
skb->dev = skb_dst(skb)->dev;
24522452
return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES);
@@ -2457,7 +2457,7 @@ static int ip6_pkt_prohibit(struct sk_buff *skb)
24572457
return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES);
24582458
}
24592459

2460-
static int ip6_pkt_prohibit_out(struct sock *sk, struct sk_buff *skb)
2460+
static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb)
24612461
{
24622462
skb->dev = skb_dst(skb)->dev;
24632463
return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);

net/ipv6/xfrm6_output.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
173173
return x->outer_mode->afinfo->output_finish(sk, skb);
174174
}
175175

176-
int xfrm6_output(struct sock *sk, struct sk_buff *skb)
176+
int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
177177
{
178-
struct net *net = dev_net(skb_dst(skb)->dev);
179-
180178
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
181179
net, sk, skb, NULL, skb_dst(skb)->dev,
182180
__xfrm6_output,

net/mpls/mpls_iptunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static unsigned int mpls_encap_size(struct mpls_iptunnel_encap *en)
3737
return en->labels * sizeof(struct mpls_shim_hdr);
3838
}
3939

40-
int mpls_output(struct sock *sk, struct sk_buff *skb)
40+
int mpls_output(struct net *net, struct sock *sk, struct sk_buff *skb)
4141
{
4242
struct mpls_iptunnel_encap *tun_encap_info;
4343
struct mpls_shim_hdr *hdr;

0 commit comments

Comments
 (0)