summaryrefslogtreecommitdiffstats
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2009-06-01 10:30:00 +0000
committerpjd <pjd@FreeBSD.org>2009-06-01 10:30:00 +0000
commit5243d2d206ac372ee679c11bde715a4a4f2f93fd (patch)
treece73855429371a51ef92709203be008be66b6119 /sys/netinet/raw_ip.c
parenteb2d64c1bdd4159506f34e57ff8df73c843b7500 (diff)
downloadFreeBSD-src-5243d2d206ac372ee679c11bde715a4a4f2f93fd.zip
FreeBSD-src-5243d2d206ac372ee679c11bde715a4a4f2f93fd.tar.gz
- Rename IP_NONLOCALOK IP socket option to IP_BINDANY, to be more consistent
with OpenBSD (and BSD/OS originally). We can't easly do it SOL_SOCKET option as there is no more space for more SOL_SOCKET options, but this option also fits better as an IP socket option, it seems. - Implement this functionality also for IPv6 and RAW IP sockets. - Always compile it in (don't use additional kernel options). - Remove sysctl to turn this functionality on and off. - Introduce new privilege - PRIV_NETINET_BINDANY, which allows to use this functionality (currently only unjail root can use it). Discussed with: julian, adrian, jhb, rwatson, kmacy
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 695a9cb..080ab09 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -853,15 +853,16 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
if (error != 0)
return (error);
+ inp = sotoinpcb(so);
+ KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
+
if (TAILQ_EMPTY(&V_ifnet) ||
(addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
(addr->sin_addr.s_addr &&
- ifa_ifwithaddr((struct sockaddr *)addr) == 0))
+ (inp->inp_flags & INP_BINDANY) == 0 &&
+ ifa_ifwithaddr((struct sockaddr *)addr) == NULL))
return (EADDRNOTAVAIL);
- inp = sotoinpcb(so);
- KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
-
INP_INFO_WLOCK(&V_ripcbinfo);
INP_WLOCK(inp);
rip_delhash(inp);
OpenPOWER on IntegriCloud