From 5839c49178882dfed2e98b334aef03c88dfef9a6 Mon Sep 17 00:00:00 2001 From: krw Date: Tue, 27 Jun 2017 13:24:49 +0000 Subject: [PATCH] Nuke get_rdomain() and just snag the interface rdomain from the same ifa we use to get the interface hw address. One less socket() and ioctl()! MIssed cleanup from shift to just watching RTM_IFINFO messages for rdomain switch. --- sbin/dhclient/dhclient.c | 3 +-- sbin/dhclient/dhcpd.h | 3 +-- sbin/dhclient/dispatch.c | 24 +++++------------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 223fc7f1786..4803574ecb9 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.448 2017/06/25 00:38:38 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.449 2017/06/27 13:24:49 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -535,7 +535,6 @@ main(int argc, char *argv[]) } /* Put us into the correct rdomain */ - ifi->rdomain = get_rdomain(ifi->name); if (setrtable(ifi->rdomain) == -1) fatal("setting routing table to %u", ifi->rdomain); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 0c20a0ea824..9094e345db3 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.195 2017/06/24 23:32:57 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.196 2017/06/27 13:24:49 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -210,7 +210,6 @@ void set_timeout( struct interface_info *, time_t, void cancel_timeout(struct interface_info *); void interface_link_forceup(char *); int interface_status(struct interface_info *); -int get_rdomain(char *); void get_hw_address(struct interface_info *); void sendhup(void); diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 89b23cb6815..e38766376e6 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.127 2017/06/24 23:32:57 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.128 2017/06/27 13:24:49 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -77,6 +77,7 @@ get_hw_address(struct interface_info *ifi) { struct ifaddrs *ifap, *ifa; struct sockaddr_dl *sdl; + struct if_data *ifdata; int found; if (getifaddrs(&ifap) != 0) @@ -100,6 +101,9 @@ get_hw_address(struct interface_info *ifi) sdl->sdl_alen != ETHER_ADDR_LEN) continue; + ifdata = ifa->ifa_data; + ifi->rdomain = ifdata->ifi_rdomain; + memcpy(ifi->hw_address.ether_addr_octet, LLADDR(sdl), ETHER_ADDR_LEN); ifi->flags |= IFI_VALID_LLADDR; @@ -289,24 +293,6 @@ cancel_timeout(struct interface_info *ifi) ifi->timeout_func = NULL; } -int -get_rdomain(char *name) -{ - int rv = 0, s; - struct ifreq ifr; - - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) - fatal("get_rdomain socket"); - - memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1) - rv = ifr.ifr_rdomainid; - - close(s); - return rv; -} - /* * Inform the [priv] process a HUP was received. */ -- 2.20.1