Skip to content

Commit 6700c27

Browse files
committed
net: Pass optional SKB and SK arguments to dst_ops->{update_pmtu,redirect}()
This will be used so that we can compose a full flow key. Even though we have a route in this context, we need more. In the future the routes will be without destination address, source address, etc. keying. One ipv4 route will cover entire subnets, etc. In this environment we have to have a way to possess persistent storage for redirects and PMTU information. This persistent storage will exist in the FIB tables, and that's why we'll need to be able to rebuild a full lookup flow key here. Using that flow key will do a fib_lookup() and create/update the persistent entry. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 02f3d4c commit 6700c27

File tree

21 files changed

+71
-49
lines changed

21 files changed

+71
-49
lines changed

drivers/infiniband/ulp/ipoib/ipoib_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
13971397
int e = skb_queue_empty(&priv->cm.skb_queue);
13981398

13991399
if (skb_dst(skb))
1400-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
1400+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
14011401

14021402
skb_queue_tail(&priv->cm.skb_queue, skb);
14031403
if (e)

include/net/dst_ops.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ struct dst_ops {
2424
struct net_device *dev, int how);
2525
struct dst_entry * (*negative_advice)(struct dst_entry *);
2626
void (*link_failure)(struct sk_buff *);
27-
void (*update_pmtu)(struct dst_entry *dst, u32 mtu);
28-
void (*redirect)(struct dst_entry *dst, struct sk_buff *skb);
27+
void (*update_pmtu)(struct dst_entry *dst, struct sock *sk,
28+
struct sk_buff *skb, u32 mtu);
29+
void (*redirect)(struct dst_entry *dst, struct sock *sk,
30+
struct sk_buff *skb);
2931
int (*local_out)(struct sk_buff *skb);
3032
struct neighbour * (*neigh_lookup)(const struct dst_entry *dst,
3133
struct sk_buff *skb,

net/bridge/br_netfilter.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb)
111111
pppoe_proto(skb) == htons(PPP_IPV6) && \
112112
brnf_filter_pppoe_tagged)
113113

114-
static void fake_update_pmtu(struct dst_entry *dst, u32 mtu)
114+
static void fake_update_pmtu(struct dst_entry *dst, struct sock *sk,
115+
struct sk_buff *skb, u32 mtu)
115116
{
116117
}
117118

118-
static void fake_redirect(struct dst_entry *dst, struct sk_buff *skb)
119+
static void fake_redirect(struct dst_entry *dst, struct sock *sk,
120+
struct sk_buff *skb)
119121
{
120122
}
121123

net/dccp/ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void dccp_do_redirect(struct sk_buff *skb, struct sock *sk)
193193
struct dst_entry *dst = __sk_dst_check(sk, 0);
194194

195195
if (dst)
196-
dst->ops->redirect(dst, skb);
196+
dst->ops->redirect(dst, sk, skb);
197197
}
198198

199199
/*

net/dccp/ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
134134
struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
135135

136136
if (dst)
137-
dst->ops->redirect(dst, skb);
137+
dst->ops->redirect(dst, sk, skb);
138138
}
139139

140140
if (type == ICMPV6_PKT_TOOBIG) {

net/decnet/dn_route.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ static void dn_dst_destroy(struct dst_entry *);
117117
static void dn_dst_ifdown(struct dst_entry *, struct net_device *dev, int how);
118118
static struct dst_entry *dn_dst_negative_advice(struct dst_entry *);
119119
static void dn_dst_link_failure(struct sk_buff *);
120-
static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu);
121-
static void dn_dst_redirect(struct dst_entry *dst, struct sk_buff *skb);
120+
static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk,
121+
struct sk_buff *skb , u32 mtu);
122+
static void dn_dst_redirect(struct dst_entry *dst, struct sock *sk,
123+
struct sk_buff *skb);
122124
static struct neighbour *dn_dst_neigh_lookup(const struct dst_entry *dst,
123125
struct sk_buff *skb,
124126
const void *daddr);
@@ -266,7 +268,8 @@ static int dn_dst_gc(struct dst_ops *ops)
266268
* We update both the mtu and the advertised mss (i.e. the segment size we
267269
* advertise to the other end).
268270
*/
269-
static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
271+
static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk,
272+
struct sk_buff *skb, u32 mtu)
270273
{
271274
struct dn_route *rt = (struct dn_route *) dst;
272275
struct neighbour *n = rt->n;
@@ -294,7 +297,8 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
294297
}
295298
}
296299

297-
static void dn_dst_redirect(struct dst_entry *dst, struct sk_buff *skb)
300+
static void dn_dst_redirect(struct dst_entry *dst, struct sock *sk,
301+
struct sk_buff *skb)
298302
{
299303
}
300304

net/ipv4/inet_connection_sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu)
840840
if (!dst)
841841
goto out;
842842
}
843-
dst->ops->update_pmtu(dst, mtu);
843+
dst->ops->update_pmtu(dst, sk, NULL, mtu);
844844

845845
dst = __sk_dst_check(sk, 0);
846846
if (!dst)

net/ipv4/ip_gre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
833833
mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
834834

835835
if (skb_dst(skb))
836-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
836+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
837837

838838
if (skb->protocol == htons(ETH_P_IP)) {
839839
df |= (old_iph->frag_off&htons(IP_DF));

net/ipv4/ipip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
519519
}
520520

521521
if (skb_dst(skb))
522-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
522+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
523523

524524
if ((old_iph->frag_off & htons(IP_DF)) &&
525525
mtu < ntohs(old_iph->tot_len)) {

net/ipv4/route.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst);
148148
static void ipv4_dst_destroy(struct dst_entry *dst);
149149
static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
150150
static void ipv4_link_failure(struct sk_buff *skb);
151-
static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
152-
static void ip_do_redirect(struct dst_entry *dst, struct sk_buff *skb);
151+
static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
152+
struct sk_buff *skb, u32 mtu);
153+
static void ip_do_redirect(struct dst_entry *dst, struct sock *sk,
154+
struct sk_buff *skb);
153155
static int rt_garbage_collect(struct dst_ops *ops);
154156

155157
static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -1273,7 +1275,7 @@ static void rt_del(unsigned int hash, struct rtable *rt)
12731275
spin_unlock_bh(rt_hash_lock_addr(hash));
12741276
}
12751277

1276-
static void ip_do_redirect(struct dst_entry *dst, struct sk_buff *skb)
1278+
static void ip_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buff *skb)
12771279
{
12781280
__be32 new_gw = icmp_hdr(skb)->un.gateway;
12791281
__be32 old_gw = ip_hdr(skb)->saddr;
@@ -1506,7 +1508,8 @@ out: kfree_skb(skb);
15061508
return 0;
15071509
}
15081510

1509-
static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
1511+
static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
1512+
struct sk_buff *skb, u32 mtu)
15101513
{
15111514
struct rtable *rt = (struct rtable *) dst;
15121515

@@ -1531,7 +1534,7 @@ void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu,
15311534
iph->daddr, iph->saddr, 0, 0);
15321535
rt = __ip_route_output_key(net, &fl4);
15331536
if (!IS_ERR(rt)) {
1534-
ip_rt_update_pmtu(&rt->dst, mtu);
1537+
ip_rt_update_pmtu(&rt->dst, NULL, skb, mtu);
15351538
ip_rt_put(rt);
15361539
}
15371540
}
@@ -1559,7 +1562,7 @@ void ipv4_redirect(struct sk_buff *skb, struct net *net,
15591562
protocol, flow_flags, iph->daddr, iph->saddr, 0, 0);
15601563
rt = __ip_route_output_key(net, &fl4);
15611564
if (!IS_ERR(rt)) {
1562-
ip_do_redirect(&rt->dst, skb);
1565+
ip_do_redirect(&rt->dst, NULL, skb);
15631566
ip_rt_put(rt);
15641567
}
15651568
}
@@ -2587,11 +2590,13 @@ static unsigned int ipv4_blackhole_mtu(const struct dst_entry *dst)
25872590
return mtu ? : dst->dev->mtu;
25882591
}
25892592

2590-
static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu)
2593+
static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk,
2594+
struct sk_buff *skb, u32 mtu)
25912595
{
25922596
}
25932597

2594-
static void ipv4_rt_blackhole_redirect(struct dst_entry *dst, struct sk_buff *skb)
2598+
static void ipv4_rt_blackhole_redirect(struct dst_entry *dst, struct sock *sk,
2599+
struct sk_buff *skb)
25952600
{
25962601
}
25972602

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static void do_redirect(struct sk_buff *skb, struct sock *sk)
319319
struct dst_entry *dst = __sk_dst_check(sk, 0);
320320

321321
if (dst)
322-
dst->ops->redirect(dst, skb);
322+
dst->ops->redirect(dst, sk, skb);
323323
}
324324

325325
/*

net/ipv4/xfrm4_policy.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,22 @@ static inline int xfrm4_garbage_collect(struct dst_ops *ops)
194194
return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
195195
}
196196

197-
static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu)
197+
static void xfrm4_update_pmtu(struct dst_entry *dst, struct sock *sk,
198+
struct sk_buff *skb, u32 mtu)
198199
{
199200
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
200201
struct dst_entry *path = xdst->route;
201202

202-
path->ops->update_pmtu(path, mtu);
203+
path->ops->update_pmtu(path, sk, skb, mtu);
203204
}
204205

205-
static void xfrm4_redirect(struct dst_entry *dst, struct sk_buff *skb)
206+
static void xfrm4_redirect(struct dst_entry *dst, struct sock *sk,
207+
struct sk_buff *skb)
206208
{
207209
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
208210
struct dst_entry *path = xdst->route;
209211

210-
path->ops->redirect(path, skb);
212+
path->ops->redirect(path, sk, skb);
211213
}
212214

213215
static void xfrm4_dst_destroy(struct dst_entry *dst)

net/ipv6/inet6_connection_sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu)
269269

270270
if (IS_ERR(dst))
271271
return NULL;
272-
dst->ops->update_pmtu(dst, mtu);
272+
dst->ops->update_pmtu(dst, sk, NULL, mtu);
273273

274274
return inet6_csk_route_socket(sk);
275275
}

net/ipv6/ip6_tunnel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
609609
if (rel_info > dst_mtu(skb_dst(skb2)))
610610
goto out;
611611

612-
skb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), rel_info);
612+
skb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), NULL, skb2, rel_info);
613613
}
614614
if (rel_type == ICMP_REDIRECT)
615-
skb_dst(skb2)->ops->redirect(skb_dst(skb2), skb2);
615+
skb_dst(skb2)->ops->redirect(skb_dst(skb2), NULL, skb2);
616616

617617
icmp_send(skb2, rel_type, rel_code, htonl(rel_info));
618618

@@ -952,7 +952,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
952952
if (mtu < IPV6_MIN_MTU)
953953
mtu = IPV6_MIN_MTU;
954954
if (skb_dst(skb))
955-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
955+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
956956
if (skb->len > mtu) {
957957
*pmtu = mtu;
958958
err = -EMSGSIZE;

net/ipv6/route.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ static int ip6_dst_gc(struct dst_ops *ops);
7878
static int ip6_pkt_discard(struct sk_buff *skb);
7979
static int ip6_pkt_discard_out(struct sk_buff *skb);
8080
static void ip6_link_failure(struct sk_buff *skb);
81-
static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
82-
static void rt6_do_redirect(struct dst_entry *dst, struct sk_buff *skb);
81+
static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
82+
struct sk_buff *skb, u32 mtu);
83+
static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk,
84+
struct sk_buff *skb);
8385

8486
#ifdef CONFIG_IPV6_ROUTE_INFO
8587
static struct rt6_info *rt6_add_route_info(struct net *net,
@@ -187,11 +189,13 @@ static unsigned int ip6_blackhole_mtu(const struct dst_entry *dst)
187189
return mtu ? : dst->dev->mtu;
188190
}
189191

190-
static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu)
192+
static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk,
193+
struct sk_buff *skb, u32 mtu)
191194
{
192195
}
193196

194-
static void ip6_rt_blackhole_redirect(struct dst_entry *dst, struct sk_buff *skb)
197+
static void ip6_rt_blackhole_redirect(struct dst_entry *dst, struct sock *sk,
198+
struct sk_buff *skb)
195199
{
196200
}
197201

@@ -1071,7 +1075,8 @@ static void ip6_link_failure(struct sk_buff *skb)
10711075
}
10721076
}
10731077

1074-
static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
1078+
static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
1079+
struct sk_buff *skb, u32 mtu)
10751080
{
10761081
struct rt6_info *rt6 = (struct rt6_info*)dst;
10771082

@@ -1108,7 +1113,7 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
11081113

11091114
dst = ip6_route_output(net, NULL, &fl6);
11101115
if (!dst->error)
1111-
ip6_rt_update_pmtu(dst, ntohl(mtu));
1116+
ip6_rt_update_pmtu(dst, NULL, skb, ntohl(mtu));
11121117
dst_release(dst);
11131118
}
11141119
EXPORT_SYMBOL_GPL(ip6_update_pmtu);
@@ -1136,7 +1141,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
11361141

11371142
dst = ip6_route_output(net, NULL, &fl6);
11381143
if (!dst->error)
1139-
rt6_do_redirect(dst, skb);
1144+
rt6_do_redirect(dst, NULL, skb);
11401145
dst_release(dst);
11411146
}
11421147
EXPORT_SYMBOL_GPL(ip6_redirect);
@@ -1639,7 +1644,7 @@ static int ip6_route_del(struct fib6_config *cfg)
16391644
return err;
16401645
}
16411646

1642-
static void rt6_do_redirect(struct dst_entry *dst, struct sk_buff *skb)
1647+
static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buff *skb)
16431648
{
16441649
struct net *net = dev_net(skb->dev);
16451650
struct netevent_redirect netevent;

net/ipv6/sit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
807807
}
808808

809809
if (tunnel->parms.iph.daddr && skb_dst(skb))
810-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
810+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
811811

812812
if (skb->len > mtu) {
813813
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
367367
struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
368368

369369
if (dst)
370-
dst->ops->redirect(dst,skb);
370+
dst->ops->redirect(dst, sk, skb);
371371
}
372372

373373
if (type == ICMPV6_PKT_TOOBIG) {

net/ipv6/xfrm6_policy.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,22 @@ static inline int xfrm6_garbage_collect(struct dst_ops *ops)
207207
return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
208208
}
209209

210-
static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu)
210+
static void xfrm6_update_pmtu(struct dst_entry *dst, struct sock *sk,
211+
struct sk_buff *skb, u32 mtu)
211212
{
212213
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
213214
struct dst_entry *path = xdst->route;
214215

215-
path->ops->update_pmtu(path, mtu);
216+
path->ops->update_pmtu(path, sk, skb, mtu);
216217
}
217218

218-
static void xfrm6_redirect(struct dst_entry *dst, struct sk_buff *skb)
219+
static void xfrm6_redirect(struct dst_entry *dst, struct sock *sk,
220+
struct sk_buff *skb)
219221
{
220222
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
221223
struct dst_entry *path = xdst->route;
222224

223-
path->ops->redirect(path, skb);
225+
path->ops->redirect(path, sk, skb);
224226
}
225227

226228
static void xfrm6_dst_destroy(struct dst_entry *dst)

net/netfilter/ipvs/ip_vs_xmit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
797797
goto tx_error_put;
798798
}
799799
if (skb_dst(skb))
800-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
800+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
801801

802802
df |= (old_iph->frag_off & htons(IP_DF));
803803

@@ -913,7 +913,7 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
913913
goto tx_error_put;
914914
}
915915
if (skb_dst(skb))
916-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
916+
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
917917

918918
if (mtu < ntohs(old_iph->payload_len) + sizeof(struct ipv6hdr) &&
919919
!skb_is_gso(skb)) {

net/sctp/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t,
432432
return;
433433
dst = sctp_transport_dst_check(t);
434434
if (dst)
435-
dst->ops->redirect(dst, skb);
435+
dst->ops->redirect(dst, sk, skb);
436436
}
437437

438438
/*

net/sctp/transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void sctp_transport_update_pmtu(struct sock *sk, struct sctp_transport *t, u32 p
249249
t->af_specific->get_dst(t, &t->saddr, &t->fl, sk);
250250

251251
if (dst) {
252-
dst->ops->update_pmtu(dst, pmtu);
252+
dst->ops->update_pmtu(dst, sk, NULL, pmtu);
253253

254254
dst = sctp_transport_dst_check(t);
255255
if (!dst)

0 commit comments

Comments
 (0)