summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2020-08-25 07:40:48 -0400
committerDavid S. Miller <davem@davemloft.net>2020-08-25 06:20:10 -0700
commit0ce779a9f50108c26541b54c12a0808ba1be103a (patch)
treeca9c4fb10d74c4346125d91877a6c843bb526724 /net
parent0316a211168dd94c4d3b81c91e76fac4f2714544 (diff)
net: Avoid unnecessary inet_addr_type() call when addr is INADDR_ANY
We can avoid unnecessary inet_addr_type() call by check addr against INADDR_ANY first. Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ping.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index cc09d1135ce2..19a947bf0faa 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -310,10 +310,10 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
pr_debug("ping_check_bind_addr(sk=%p,addr=%pI4,port=%d)\n",
sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port));
- chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
-
if (addr->sin_addr.s_addr == htonl(INADDR_ANY))
chk_addr_ret = RTN_LOCAL;
+ else
+ chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
if ((!inet_can_nonlocal_bind(net, isk) &&
chk_addr_ret != RTN_LOCAL) ||