diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-14 22:18:13 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-14 22:18:13 +0000 |
commit | a31939470420bb6567cc43889e40a1a3fa4357b0 (patch) | |
tree | a2445fabde5fdc427a081691110d9d08065ca70a /sbin/dhclient | |
parent | 710264b751b432437d8f0f064c693498383a04fe (diff) |
When an interface generates an RTM_IFINFO message, it may be as the
result of its LLADDR changing! Check said address and if it differs
from what we think it is, simulate a SIGHUP to restart, getting the
new address and a new lease for it.
Spotted by, fix tested by, and ok beck@
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 15 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index fdbd4b67e2f..a6d584fc404 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.228 2013/02/14 20:39:46 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.229 2013/02/14 22:18:12 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -176,6 +176,7 @@ routehandler(void) struct in_addr a, b; ssize_t n; int linkstat, rslt; + struct hardware hw; struct rt_msghdr *rtm; struct if_msghdr *ifm; struct ifa_msghdr *ifam; @@ -255,6 +256,7 @@ routehandler(void) } goto die; case RTM_IFINFO: + note("Got RTM_IFINFO"); ifm = (struct if_msghdr *)rtm; if (ifm->ifm_index != ifi->index) break; @@ -263,6 +265,13 @@ routehandler(void) goto die; } + memcpy(&hw, &ifi->hw_address, sizeof(hw)); + discover_interface(); + if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) { + quit = SIGHUP; + return; + } + linkstat = LINK_STATE_IS_UP(ifm->ifm_data.ifi_link_state) ? 1 : 0; if (linkstat != ifi->linkstat) { @@ -462,6 +471,10 @@ main(int argc, char *argv[]) /* set up the interface */ discover_interface(); + /* Register the interface... */ + if_register_receive(); + if_register_send(); + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socket_fd) == -1) error("socketpair: %s", strerror(errno)); socket_nonblockmode(socket_fd[0]); diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 64553aea46a..31241325130 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.71 2013/02/13 19:32:52 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.72 2013/02/14 22:18:12 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -97,9 +97,6 @@ discover_interface(void) if (!ifi->ifp) error("%s: not found", ifi->name); - /* Register the interface... */ - if_register_receive(); - if_register_send(); freeifaddrs(ifap); } |