diff options
author | kn <kn@cvs.openbsd.org> | 2020-08-05 06:12:44 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2020-08-05 06:12:44 +0000 |
commit | 24f6d8940f3d40d16a3b3bf12b7e97e9a83cd436 (patch) | |
tree | 80a4dffd29652ba784494066ca71cd0aa4673fa8 /sbin | |
parent | 325c0022f8cf2ee11b87d4901c45121113c84f37 (diff) |
Merge switch_status() into bridge_status()
This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).
OK dlg
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/brconfig.c | 32 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 3 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.h | 3 |
3 files changed, 15 insertions, 23 deletions
diff --git a/sbin/ifconfig/brconfig.c b/sbin/ifconfig/brconfig.c index 1d11598ef5d..470e36f0571 100644 --- a/sbin/ifconfig/brconfig.c +++ b/sbin/ifconfig/brconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.c,v 1.26 2020/07/29 12:13:28 kn Exp $ */ +/* $OpenBSD: brconfig.c,v 1.27 2020/08/05 06:12:43 kn Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -54,6 +54,7 @@ void bridge_ifclrflag(const char *, u_int32_t); void bridge_list(char *); void bridge_cfg(const char *); +void switch_cfg(const char *); void bridge_badrule(int, char **, int); void bridge_showrule(struct ifbrlreq *); int is_switch(void); @@ -778,17 +779,24 @@ void bridge_status(void) { struct ifbrparam bp1, bp2; + int isswitch = is_switch(); - if (!is_bridge() || is_switch()) + if (!is_bridge()) return; - bridge_cfg("\t"); + if (isswitch) + switch_cfg("\t"); + else + bridge_cfg("\t"); bridge_list("\t"); if (aflag && !ifaliases) return; + if (isswitch) + return; + strlcpy(bp1.ifbrp_name, ifname, sizeof(bp1.ifbrp_name)); if (ioctl(sock, SIOCBRDGGCACHE, (caddr_t)&bp1) == -1) return; @@ -1146,8 +1154,8 @@ is_switch() return (1); } -static void -switch_cfg(char *delim) +void +switch_cfg(const char *delim) { struct ifbrparam bp; @@ -1171,20 +1179,6 @@ switch_cfg(char *delim) } void -switch_status(void) -{ - if (!is_switch()) - return; - - switch_cfg("\t"); - - bridge_list("\t"); - - if (aflag && !ifaliases) - return; -} - -void switch_datapathid(const char *arg, int d) { struct ifbrparam bp; diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index cc314b7a44f..3286c5e12b6 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.424 2020/07/03 17:42:50 florian Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.425 2020/08/05 06:12:43 kn Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -3507,7 +3507,6 @@ status(int link, struct sockaddr_dl *sdl, int ls) phys_status(0); #ifndef SMALL bridge_status(); - switch_status(); #endif } diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 1d5b9ccff10..17555761d59 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.h,v 1.2 2019/10/24 18:54:10 bluhm Exp $ */ +/* $OpenBSD: ifconfig.h,v 1.3 2020/08/05 06:12:43 kn Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -69,7 +69,6 @@ void bridge_flushrule(const char *, int); int is_bridge(void); void bridge_status(void); int bridge_rule(int, char **, int); -void switch_status(void); void switch_datapathid(const char *, int); void switch_portno(const char *, const char *); |