summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2008-05-09 02:52:15 +0000
committermarkus <markus@openbsd.org>2008-05-09 02:52:15 +0000
commit338fceb4a95edb6498c1dac3afa93de1693c71fb (patch)
tree79d42f919f93236f2e27fcb5dc1069139c483854 /sys/netinet
parentdivert packets to local socket without modifying the ip header; (diff)
downloadwireguard-openbsd-338fceb4a95edb6498c1dac3afa93de1693c71fb.tar.xz
wireguard-openbsd-338fceb4a95edb6498c1dac3afa93de1693c71fb.zip
Add SO_BINDANY socket option from BSD/OS.
The option allows a socket to be bound to addresses which are not local to the machine. In order to receive packets for these addresses SO_BINDANY needs to be combined with matching outgoing pf(4) divert rules, see pf.conf(5). ok beck@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_pcb.c5
-rw-r--r--sys/netinet/raw_ip.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index e3e8d58bdfa..58702c81a36 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.95 2008/05/09 02:44:54 markus Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.96 2008/05/09 02:52:15 markus Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -284,7 +284,8 @@ in_pcbbind(v, nam)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (sin->sin_addr.s_addr != INADDR_ANY) {
sin->sin_port = 0; /* yech... */
- if (in_iawithaddr(sin->sin_addr, NULL) == 0)
+ if (!(so->so_options & SO_BINDANY) &&
+ in_iawithaddr(sin->sin_addr, NULL) == 0)
return (EADDRNOTAVAIL);
}
if (lport) {
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 3b621e57678..1b45549be3c 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.42 2008/05/09 02:44:54 markus Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.43 2008/05/09 02:52:15 markus Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -408,7 +408,8 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
((addr->sin_family != AF_INET) &&
(addr->sin_family != AF_IMPLINK)) ||
(addr->sin_addr.s_addr &&
- ifa_ifwithaddr(sintosa(addr)) == 0)) {
+ (!(so->so_options & SO_BINDANY) &&
+ in_iawithaddr(addr->sin_addr, NULL) == 0))) {
error = EADDRNOTAVAIL;
break;
}