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

0 commit comments

Comments
 (0)