[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <785698dcf3e1f62e6fbe5b85a42d9704a3a48793.1651071843.git.asml.silence@gmail.com>
Date: Thu, 28 Apr 2022 11:56:36 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: netdev@...r.kernel.org, "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
linux-kernel@...r.kernel.org,
Pavel Begunkov <asml.silence@...il.com>
Subject: [PATCH net-next 05/11] udp/ipv6: optimise udpv6_sendmsg() daddr checks
All paths taking udpv6_sendmsg() to the ipv6_addr_v4mapped() check set a
non zero daddr, we can safely kill the NULL check just before it.
Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---
net/ipv6/udp.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 78ce5fc53b59..1f05e165eb17 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1383,19 +1383,18 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
daddr = &sk->sk_v6_daddr;
}
- if (daddr) {
- if (ipv6_addr_v4mapped(daddr)) {
- struct sockaddr_in sin;
- sin.sin_family = AF_INET;
- sin.sin_port = sin6 ? sin6->sin6_port : inet->inet_dport;
- sin.sin_addr.s_addr = daddr->s6_addr32[3];
- msg->msg_name = &sin;
- msg->msg_namelen = sizeof(sin);
+ if (ipv6_addr_v4mapped(daddr)) {
+ struct sockaddr_in sin;
+
+ sin.sin_family = AF_INET;
+ sin.sin_port = sin6 ? sin6->sin6_port : inet->inet_dport;
+ sin.sin_addr.s_addr = daddr->s6_addr32[3];
+ msg->msg_name = &sin;
+ msg->msg_namelen = sizeof(sin);
do_udp_sendmsg:
- if (__ipv6_only_sock(sk))
- return -ENETUNREACH;
- return udp_sendmsg(sk, msg, len);
- }
+ if (__ipv6_only_sock(sk))
+ return -ENETUNREACH;
+ return udp_sendmsg(sk, msg, len);
}
ulen += sizeof(struct udphdr);
--
2.36.0
Powered by blists - more mailing lists