Skip to content

Commit bd085ef

Browse files
liuhangbindavem330
authored andcommitted
net: add bool confirm_neigh parameter for dst_ops.update_pmtu
The MTU update code is supposed to be invoked in response to real networking events that update the PMTU. In IPv6 PMTU update function __ip6_rt_update_pmtu() we called dst_confirm_neigh() to update neighbor confirmed time. But for tunnel code, it will call pmtu before xmit, like: - tnl_update_pmtu() - skb_dst_update_pmtu() - ip6_rt_update_pmtu() - __ip6_rt_update_pmtu() - dst_confirm_neigh() If the tunnel remote dst mac address changed and we still do the neigh confirm, we will not be able to update neigh cache and ping6 remote will failed. So for this ip_tunnel_xmit() case, _EVEN_ if the MTU is changed, we should not be invoking dst_confirm_neigh() as we have no evidence of successful two-way communication at this point. On the other hand it is also important to keep the neigh reachability fresh for TCP flows, so we cannot remove this dst_confirm_neigh() call. To fix the issue, we have to add a new bool parameter for dst_ops.update_pmtu to choose whether we should do neigh update or not. I will add the parameter in this patch and set all the callers to true to comply with the previous way, and fix the tunnel code one by one on later patches. v5: No change. v4: No change. v3: Do not remove dst_confirm_neigh, but add a new bool parameter in dst_ops.update_pmtu to control whether we should do neighbor confirm. Also split the big patch to small ones for each area. v2: Remove dst_confirm_neigh in __ip6_rt_update_pmtu. Suggested-by: David Miller <davem@davemloft.net> Reviewed-by: Guillaume Nault <gnault@redhat.com> Acked-by: David Ahern <dsahern@gmail.com> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ff43ae4 commit bd085ef

14 files changed

Lines changed: 42 additions & 25 deletions

File tree

‎drivers/net/gtp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,
540540
mtu = dst_mtu(&rt->dst);
541541
}
542542

543-
rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu);
543+
rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu, true);
544544

545545
if (!skb_is_gso(skb) && (iph->frag_off & htons(IP_DF)) &&
546546
mtu < ntohs(iph->tot_len)) {

‎include/net/dst.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static inline void skb_dst_update_pmtu(struct sk_buff *skb, u32 mtu)
516516
struct dst_entry *dst = skb_dst(skb);
517517

518518
if (dst && dst->ops->update_pmtu)
519-
dst->ops->update_pmtu(dst, NULL, skb, mtu);
519+
dst->ops->update_pmtu(dst, NULL, skb, mtu, true);
520520
}
521521

522522
static inline void skb_tunnel_check_pmtu(struct sk_buff *skb,

‎include/net/dst_ops.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ struct dst_ops {
2727
struct dst_entry * (*negative_advice)(struct dst_entry *);
2828
void (*link_failure)(struct sk_buff *);
2929
void (*update_pmtu)(struct dst_entry *dst, struct sock *sk,
30-
struct sk_buff *skb, u32 mtu);
30+
struct sk_buff *skb, u32 mtu,
31+
bool confirm_neigh);
3132
void (*redirect)(struct dst_entry *dst, struct sock *sk,
3233
struct sk_buff *skb);
3334
int (*local_out)(struct net *net, struct sock *sk, struct sk_buff *skb);

‎net/bridge/br_nf_core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#endif
2323

2424
static void fake_update_pmtu(struct dst_entry *dst, struct sock *sk,
25-
struct sk_buff *skb, u32 mtu)
25+
struct sk_buff *skb, u32 mtu,
26+
bool confirm_neigh)
2627
{
2728
}
2829

‎net/decnet/dn_route.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ static void dn_dst_ifdown(struct dst_entry *, struct net_device *dev, int how);
110110
static struct dst_entry *dn_dst_negative_advice(struct dst_entry *);
111111
static void dn_dst_link_failure(struct sk_buff *);
112112
static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk,
113-
struct sk_buff *skb , u32 mtu);
113+
struct sk_buff *skb , u32 mtu,
114+
bool confirm_neigh);
114115
static void dn_dst_redirect(struct dst_entry *dst, struct sock *sk,
115116
struct sk_buff *skb);
116117
static struct neighbour *dn_dst_neigh_lookup(const struct dst_entry *dst,
@@ -251,7 +252,8 @@ static int dn_dst_gc(struct dst_ops *ops)
251252
* advertise to the other end).
252253
*/
253254
static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk,
254-
struct sk_buff *skb, u32 mtu)
255+
struct sk_buff *skb, u32 mtu,
256+
bool confirm_neigh)
255257
{
256258
struct dn_route *rt = (struct dn_route *) dst;
257259
struct neighbour *n = rt->n;

‎net/ipv4/inet_connection_sock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu)
10861086
if (!dst)
10871087
goto out;
10881088
}
1089-
dst->ops->update_pmtu(dst, sk, NULL, mtu);
1089+
dst->ops->update_pmtu(dst, sk, NULL, mtu, true);
10901090

10911091
dst = __sk_dst_check(sk, 0);
10921092
if (!dst)

‎net/ipv4/route.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst);
139139
static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
140140
static void ipv4_link_failure(struct sk_buff *skb);
141141
static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
142-
struct sk_buff *skb, u32 mtu);
142+
struct sk_buff *skb, u32 mtu,
143+
bool confirm_neigh);
143144
static void ip_do_redirect(struct dst_entry *dst, struct sock *sk,
144145
struct sk_buff *skb);
145146
static void ipv4_dst_destroy(struct dst_entry *dst);
@@ -1043,7 +1044,8 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
10431044
}
10441045

10451046
static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
1046-
struct sk_buff *skb, u32 mtu)
1047+
struct sk_buff *skb, u32 mtu,
1048+
bool confirm_neigh)
10471049
{
10481050
struct rtable *rt = (struct rtable *) dst;
10491051
struct flowi4 fl4;
@@ -2687,7 +2689,8 @@ static unsigned int ipv4_blackhole_mtu(const struct dst_entry *dst)
26872689
}
26882690

26892691
static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk,
2690-
struct sk_buff *skb, u32 mtu)
2692+
struct sk_buff *skb, u32 mtu,
2693+
bool confirm_neigh)
26912694
{
26922695
}
26932696

‎net/ipv4/xfrm4_policy.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
100100
}
101101

102102
static void xfrm4_update_pmtu(struct dst_entry *dst, struct sock *sk,
103-
struct sk_buff *skb, u32 mtu)
103+
struct sk_buff *skb, u32 mtu,
104+
bool confirm_neigh)
104105
{
105106
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
106107
struct dst_entry *path = xdst->route;
107108

108-
path->ops->update_pmtu(path, sk, skb, mtu);
109+
path->ops->update_pmtu(path, sk, skb, mtu, confirm_neigh);
109110
}
110111

111112
static void xfrm4_redirect(struct dst_entry *dst, struct sock *sk,

‎net/ipv6/inet6_connection_sock.c‎

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

147147
if (IS_ERR(dst))
148148
return NULL;
149-
dst->ops->update_pmtu(dst, sk, NULL, mtu);
149+
dst->ops->update_pmtu(dst, sk, NULL, mtu, true);
150150

151151
dst = inet6_csk_route_socket(sk, &fl6);
152152
return IS_ERR(dst) ? NULL : dst;

‎net/ipv6/ip6_gre.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
10401040

10411041
/* TooBig packet may have updated dst->dev's mtu */
10421042
if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu)
1043-
dst->ops->update_pmtu(dst, NULL, skb, dst->dev->mtu);
1043+
dst->ops->update_pmtu(dst, NULL, skb, dst->dev->mtu, true);
10441044

10451045
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
10461046
NEXTHDR_GRE);

0 commit comments

Comments
 (0)