net/ipv4: bind ip_nonlocal_bind to current netns
net.ipv4.ip_nonlocal_bind sysctl was global to all network namespaces. This patch allows to set a different value for each network namespace. Signed-off-by: Vincent Bernat <vincent@bernat.im> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
afddacc3cc
commit
49a601589c
7 changed files with 12 additions and 17 deletions
|
@ -418,10 +418,6 @@ int inet_release(struct socket *sock)
|
|||
}
|
||||
EXPORT_SYMBOL(inet_release);
|
||||
|
||||
/* It is off by default, see below. */
|
||||
int sysctl_ip_nonlocal_bind __read_mostly;
|
||||
EXPORT_SYMBOL(sysctl_ip_nonlocal_bind);
|
||||
|
||||
int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||
{
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
|
||||
|
@ -461,7 +457,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
|||
* is temporarily down)
|
||||
*/
|
||||
err = -EADDRNOTAVAIL;
|
||||
if (!sysctl_ip_nonlocal_bind &&
|
||||
if (!net->ipv4.sysctl_ip_nonlocal_bind &&
|
||||
!(inet->freebind || inet->transparent) &&
|
||||
addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
|
||||
chk_addr_ret != RTN_LOCAL &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue