diff options
author | Vincent Bernat <vincent@bernat.im> | 2018-07-31 21:18:11 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-01 18:50:04 +0200 |
commit | 83ba4645152d1177c161750e1064e3a8e7cee19b (patch) | |
tree | 7209c851dda98efb2aa1e7a42ff738d3fe560c38 /net/ipv4/af_inet.c | |
parent | net: change Exar/Neterion menu items to be alphabetical (diff) | |
download | linux-83ba4645152d1177c161750e1064e3a8e7cee19b.tar.xz linux-83ba4645152d1177c161750e1064e3a8e7cee19b.zip |
net: add helpers checking if socket can be bound to nonlocal address
The construction "net->ipv4.sysctl_ip_nonlocal_bind || inet->freebind
|| inet->transparent" is present three times and its IPv6 counterpart
is also present three times. We introduce two small helpers to
characterize these tests uniformly.
Signed-off-by: Vincent Bernat <vincent@bernat.im>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f2a0a3bab6b5..ee707b91d1a7 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -486,8 +486,7 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, * is temporarily down) */ err = -EADDRNOTAVAIL; - if (!net->ipv4.sysctl_ip_nonlocal_bind && - !(inet->freebind || inet->transparent) && + if (!inet_can_nonlocal_bind(net, inet) && addr->sin_addr.s_addr != htonl(INADDR_ANY) && chk_addr_ret != RTN_LOCAL && chk_addr_ret != RTN_MULTICAST && |