diff options
author | kn <kn@cvs.openbsd.org> | 2020-07-29 12:13:29 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2020-07-29 12:13:29 +0000 |
commit | cc9aaac7d81d264698c98e7506f9f2a8490cf9a9 (patch) | |
tree | c8fd9aa064897cc0704875c1e917e6249708702a /sbin | |
parent | 4d03bfe896ec57a6f8197e203a3115044b7d9389 (diff) |
Remove redundant bridge checks
bridge_status() and switch_status() do the regular sanity check with
SIOCGIFFLAGS, but both functions also call is_switch() and bridge_status()
also calls is_bridge().
is_bridge() checks SIOCGIFFLAGS again, then both is_*() helpers finally do
driver specific ioctl(2) calls to test whether the given interface is
indeed a bridge(4) or a switch(4).
SIOCGIFFLAGS serves no purpose here and is taken care of in ifconfig.c's
getinfo(), so remove its calls from brconfig.c entirely.
OK dlg
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/brconfig.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/sbin/ifconfig/brconfig.c b/sbin/ifconfig/brconfig.c index e33b73ebf2c..1d11598ef5d 100644 --- a/sbin/ifconfig/brconfig.c +++ b/sbin/ifconfig/brconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.c,v 1.25 2020/01/22 06:24:07 tedu Exp $ */ +/* $OpenBSD: brconfig.c,v 1.26 2020/07/29 12:13:28 kn Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -762,14 +762,8 @@ bridge_holdcnt(const char *value, int d) int is_bridge() { - struct ifreq ifr; struct ifbaconf ifbac; - strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - - if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) - return (0); - ifbac.ifbac_len = 0; strlcpy(ifbac.ifbac_name, ifname, sizeof(ifbac.ifbac_name)); if (ioctl(sock, SIOCBRDGRTS, (caddr_t)&ifbac) == -1) { @@ -783,16 +777,11 @@ is_bridge() void bridge_status(void) { - struct ifreq ifr; struct ifbrparam bp1, bp2; if (!is_bridge() || is_switch()) return; - strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) - return; - bridge_cfg("\t"); bridge_list("\t"); @@ -1184,15 +1173,9 @@ switch_cfg(char *delim) void switch_status(void) { - struct ifreq ifr; - if (!is_switch()) return; - strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) - return; - switch_cfg("\t"); bridge_list("\t"); |