Skip to content

Commit 427faee

Browse files
vvfedorenkodavem330
authored andcommitted
net: ipv6: introduce ip6_dst_mtu_maybe_forward
Replace ip6_dst_mtu_forward with ip6_dst_mtu_maybe_forward and reuse this code in ip6_mtu. Actually these two functions were almost duplicates, this change will simplify the maintaince of mtu calculation code. Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7c804e9 commit 427faee

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

include/net/ip6_route.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,13 @@ static inline bool rt6_duplicate_nexthop(struct fib6_info *a, struct fib6_info *
316316
!lwtunnel_cmp_encap(nha->fib_nh_lws, nhb->fib_nh_lws);
317317
}
318318

319-
static inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
319+
static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst,
320+
bool forwarding)
320321
{
321322
struct inet6_dev *idev;
322323
unsigned int mtu;
323324

324-
if (dst_metric_locked(dst, RTAX_MTU)) {
325+
if (!forwarding || dst_metric_locked(dst, RTAX_MTU)) {
325326
mtu = dst_metric_raw(dst, RTAX_MTU);
326327
if (mtu)
327328
goto out;

net/ipv6/ip6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ int ip6_forward(struct sk_buff *skb)
607607
}
608608
}
609609

610-
mtu = ip6_dst_mtu_forward(dst);
610+
mtu = ip6_dst_mtu_maybe_forward(dst, true);
611611
if (mtu < IPV6_MIN_MTU)
612612
mtu = IPV6_MIN_MTU;
613613

net/ipv6/route.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,25 +3201,7 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)
32013201

32023202
INDIRECT_CALLABLE_SCOPE unsigned int ip6_mtu(const struct dst_entry *dst)
32033203
{
3204-
struct inet6_dev *idev;
3205-
unsigned int mtu;
3206-
3207-
mtu = dst_metric_raw(dst, RTAX_MTU);
3208-
if (mtu)
3209-
goto out;
3210-
3211-
mtu = IPV6_MIN_MTU;
3212-
3213-
rcu_read_lock();
3214-
idev = __in6_dev_get(dst->dev);
3215-
if (idev)
3216-
mtu = idev->cnf.mtu6;
3217-
rcu_read_unlock();
3218-
3219-
out:
3220-
mtu = min_t(unsigned int, mtu, IP6_MAX_MTU);
3221-
3222-
return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
3204+
return ip6_dst_mtu_maybe_forward(dst, false);
32233205
}
32243206
EXPORT_INDIRECT_CALLABLE(ip6_mtu);
32253207

net/netfilter/nf_flow_table_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int flow_offload_fill_route(struct flow_offload *flow,
9999
flow_tuple->mtu = ip_dst_mtu_maybe_forward(dst, true);
100100
break;
101101
case NFPROTO_IPV6:
102-
flow_tuple->mtu = ip6_dst_mtu_forward(dst);
102+
flow_tuple->mtu = ip6_dst_mtu_maybe_forward(dst, true);
103103
break;
104104
}
105105

0 commit comments

Comments
 (0)