summaryrefslogtreecommitdiffstats
path: root/usr.sbin/arp/arp.c
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2014-03-18 14:18:22 +0000
committermikeb <mikeb@openbsd.org>2014-03-18 14:18:22 +0000
commit140f2ab4e209d8ae8fdae7cf33eef4ba26de87be (patch)
treefb7f7bc4de0b4426ffec800abc52b69b5a88140b /usr.sbin/arp/arp.c
parentzap trailing whitespace; (diff)
downloadwireguard-openbsd-140f2ab4e209d8ae8fdae7cf33eef4ba26de87be.tar.xz
wireguard-openbsd-140f2ab4e209d8ae8fdae7cf33eef4ba26de87be.zip
Put AF_ROUTE socket that arp(8) operates on into the appropriate rdomain.
Previously "arp -V 1 -d 10.0.0.1" would hang forever since while the target rdomain was passed in the rtm, the AF_ROUTE socket was always created in the rdomain 0. Due to the logic in route_input (rtsock.c) route socket's rdomain is compared against the target rdomain of the request and reply is generated only when they match. In our case rdomains were different which cased arp(8) to hang waiting for the reply that would never be sent. ok deraadt
Diffstat (limited to 'usr.sbin/arp/arp.c')
-rw-r--r--usr.sbin/arp/arp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index a4e37b6634d..055b6e8dff7 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arp.c,v 1.55 2014/02/26 20:50:17 claudio Exp $ */
+/* $OpenBSD: arp.c,v 1.56 2014/03/18 14:18:22 mikeb Exp $ */
/* $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */
/*
@@ -238,11 +238,15 @@ file(char *name)
void
getsocket(void)
{
+ socklen_t len = sizeof(rdomain);
+
if (s >= 0)
return;
s = socket(PF_ROUTE, SOCK_RAW, 0);
if (s < 0)
err(1, "socket");
+ if (setsockopt(s, PF_ROUTE, ROUTE_TABLEFILTER, &rdomain, len) < 0)
+ err(1, "ROUTE_TABLEFILTER");
}
struct sockaddr_in so_mask = { 8, 0, 0, { 0xffffffff } };