mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
ipv6: use dst6_mtu() instead of dst_mtu()
When we expect an IPv6 dst, use dst6_mtu() instead of dst_mtu() to save some code space. Due to current dst6_mtu() implementation, only convert users in IPv6 stack. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260130210303.3888261-7-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
8776c4ef3a
commit
b40f0130a2
6 changed files with 19 additions and 16 deletions
|
|
@ -1057,7 +1057,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
|
|||
/* TooBig packet may have updated dst->dev's mtu */
|
||||
if (!t->parms.collect_md && dst) {
|
||||
mtu = READ_ONCE(dst_dev(dst)->mtu);
|
||||
if (dst_mtu(dst) > mtu)
|
||||
if (dst6_mtu(dst) > mtu)
|
||||
dst->ops->update_pmtu(dst, NULL, skb, mtu, false);
|
||||
}
|
||||
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
|
|||
skb->priority = priority;
|
||||
skb->mark = mark;
|
||||
|
||||
mtu = dst_mtu(dst);
|
||||
mtu = dst6_mtu(dst);
|
||||
if (likely((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb))) {
|
||||
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTREQUESTS);
|
||||
|
||||
|
|
@ -1403,10 +1403,10 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
|
|||
v6_cork->dontfrag = ipc6->dontfrag;
|
||||
if (rt->dst.flags & DST_XFRM_TUNNEL)
|
||||
mtu = READ_ONCE(np->pmtudisc) >= IPV6_PMTUDISC_PROBE ?
|
||||
READ_ONCE(rt->dst.dev->mtu) : dst_mtu(&rt->dst);
|
||||
READ_ONCE(rt->dst.dev->mtu) : dst6_mtu(&rt->dst);
|
||||
else
|
||||
mtu = READ_ONCE(np->pmtudisc) >= IPV6_PMTUDISC_PROBE ?
|
||||
READ_ONCE(rt->dst.dev->mtu) : dst_mtu(xfrm_dst_path(&rt->dst));
|
||||
READ_ONCE(rt->dst.dev->mtu) : dst6_mtu(xfrm_dst_path(&rt->dst));
|
||||
|
||||
frag_size = READ_ONCE(np->frag_size);
|
||||
if (frag_size && frag_size < mtu)
|
||||
|
|
|
|||
|
|
@ -638,7 +638,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
|
||||
/* change mtu on this route */
|
||||
if (rel_type == ICMP_DEST_UNREACH && rel_code == ICMP_FRAG_NEEDED) {
|
||||
if (rel_info > dst_mtu(skb_dst(skb2)))
|
||||
if (rel_info > dst6_mtu(skb_dst(skb2)))
|
||||
goto out;
|
||||
|
||||
skb_dst_update_pmtu_no_confirm(skb2, rel_info);
|
||||
|
|
@ -1187,7 +1187,7 @@ route_lookup:
|
|||
t->parms.name);
|
||||
goto tx_err_dst_release;
|
||||
}
|
||||
mtu = dst_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
|
||||
mtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
|
||||
if (encap_limit >= 0) {
|
||||
max_headroom += 8;
|
||||
mtu -= 8;
|
||||
|
|
|
|||
|
|
@ -1184,7 +1184,7 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
|||
rcu_read_lock();
|
||||
dst = __sk_dst_get(sk);
|
||||
if (dst)
|
||||
val = dst_mtu(dst);
|
||||
val = dst6_mtu(dst);
|
||||
rcu_read_unlock();
|
||||
if (!val)
|
||||
return -ENOTCONN;
|
||||
|
|
@ -1283,7 +1283,7 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
|||
rcu_read_lock();
|
||||
dst = __sk_dst_get(sk);
|
||||
if (dst)
|
||||
mtuinfo.ip6m_mtu = dst_mtu(dst);
|
||||
mtuinfo.ip6m_mtu = dst6_mtu(dst);
|
||||
rcu_read_unlock();
|
||||
if (!mtuinfo.ip6m_mtu)
|
||||
return -ENOTCONN;
|
||||
|
|
|
|||
|
|
@ -2049,6 +2049,8 @@ unlock:
|
|||
static bool rt6_mtu_change_route_allowed(struct inet6_dev *idev,
|
||||
struct rt6_info *rt, int mtu)
|
||||
{
|
||||
u32 dmtu = dst6_mtu(&rt->dst);
|
||||
|
||||
/* If the new MTU is lower than the route PMTU, this new MTU will be the
|
||||
* lowest MTU in the path: always allow updating the route PMTU to
|
||||
* reflect PMTU decreases.
|
||||
|
|
@ -2059,10 +2061,10 @@ static bool rt6_mtu_change_route_allowed(struct inet6_dev *idev,
|
|||
* handle this.
|
||||
*/
|
||||
|
||||
if (dst_mtu(&rt->dst) >= mtu)
|
||||
if (dmtu >= mtu)
|
||||
return true;
|
||||
|
||||
if (dst_mtu(&rt->dst) == idev->cnf.mtu6)
|
||||
if (dmtu == idev->cnf.mtu6)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -2932,7 +2934,7 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
|
|||
|
||||
if (mtu < IPV6_MIN_MTU)
|
||||
return;
|
||||
if (mtu >= dst_mtu(dst))
|
||||
if (mtu >= dst6_mtu(dst))
|
||||
return;
|
||||
|
||||
if (!rt6_cache_allowed_for_pmtu(rt6)) {
|
||||
|
|
@ -3248,7 +3250,7 @@ EXPORT_SYMBOL_GPL(ip6_sk_redirect);
|
|||
|
||||
static unsigned int ip6_default_advmss(const struct dst_entry *dst)
|
||||
{
|
||||
unsigned int mtu = dst_mtu(dst);
|
||||
unsigned int mtu = dst6_mtu(dst);
|
||||
struct net *net;
|
||||
|
||||
mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ failure:
|
|||
static void tcp_v6_mtu_reduced(struct sock *sk)
|
||||
{
|
||||
struct dst_entry *dst;
|
||||
u32 mtu;
|
||||
u32 mtu, dmtu;
|
||||
|
||||
if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))
|
||||
return;
|
||||
|
|
@ -368,8 +368,9 @@ static void tcp_v6_mtu_reduced(struct sock *sk)
|
|||
if (!dst)
|
||||
return;
|
||||
|
||||
if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) {
|
||||
tcp_sync_mss(sk, dst_mtu(dst));
|
||||
dmtu = dst6_mtu(dst);
|
||||
if (inet_csk(sk)->icsk_pmtu_cookie > dmtu) {
|
||||
tcp_sync_mss(sk, dmtu);
|
||||
tcp_simple_retransmit(sk);
|
||||
}
|
||||
}
|
||||
|
|
@ -1467,7 +1468,7 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
|
|||
|
||||
tcp_ca_openreq_child(newsk, dst);
|
||||
|
||||
tcp_sync_mss(newsk, dst_mtu(dst));
|
||||
tcp_sync_mss(newsk, dst6_mtu(dst));
|
||||
newtp->advmss = tcp_mss_clamp(tcp_sk(sk), dst_metric_advmss(dst));
|
||||
|
||||
tcp_initialize_rcv_mss(newsk);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue