summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2015-01-01 22:53:39 +0000
committerkrw <krw@openbsd.org>2015-01-01 22:53:39 +0000
commit785383f683611524ec1c7c6617529b269b5023e9 (patch)
tree729292845b825e14c1f676d729d1452d9a2d0cf5
parent"The logging of errors SHOULD be restricted to conflicting information (diff)
downloadwireguard-openbsd-785383f683611524ec1c7c6617529b269b5023e9.tar.xz
wireguard-openbsd-785383f683611524ec1c7c6617529b269b5023e9.zip
Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually maintained list of dynamic interface types. '-C' brought to my attention by reyk@, tweaks to install script to use -C in get_ifdevs() from rpe@. ok rpe@ deraadt@
-rw-r--r--distrib/miniroot/install.sub44
-rw-r--r--sbin/ifconfig/ifconfig.c10
2 files changed, 20 insertions, 34 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index b45ad8e0172..3035282cce2 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.803 2014/12/29 17:04:19 deraadt Exp $
+# $OpenBSD: install.sub,v 1.804 2015/01/01 22:53:39 krw Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
# All rights reserved.
@@ -161,9 +161,12 @@ get_cddevs () {
}
get_ifdevs() {
- ifconfig "$@" 2>/dev/null |
- egrep -v '^[[:space:]]|(bridge|enc|gif|gre|lo|pflog|pfsync|ppp|tun)[[:digit:]]+:' |
- sed -n 's/^\(.*\):.*/\1/p'
+ local _if _iflist=$(ifconfig -C)
+
+ for _if in $(ifconfig "$@" 2>/dev/null |
+ sed -n 's/^\([^[:space:]]*\):.*/\1/p'); do
+ isin ${_if%%[0-9]*} $_iflist || echo $_if
+ done
}
get_drive() {
@@ -1125,28 +1128,19 @@ enable_network() {
for hn in /mnt/etc/hostname.*; do
# Strip off prefix to get interface name.
if=${hn#/mnt/etc/hostname.}
- # Check for ifconfig'able interface.
- (ifconfig $if||ifconfig $if create) >/dev/null 2>&1 || continue
- # Don't immediately do interfaces constructed from others.
- # Skip uninteresting devices.
- case ${if%%[0-9]*} in
- trunk) _trunks="$_trunks $hn"
- continue
- ;;
- svlan) _svlans="$_svlans $hn"
- continue
- ;;
- vlan) _vlans="$_vlans $hn"
- continue
- ;;
- bridge|carp|enc|gif|gre|lo|pflog|pfsync|ppp|tun)
- continue
- ;;
- esac
- # Now parse the hostname.* file
- ifstart $hn
+ if isin ${if%%[0-9]*} $(ifconfig -C); then
+ # Dynamic interfaces must be done later.
+ case ${if%%[0-9]*} in
+ trunk) _trunks="$_trunks $hn" ;;
+ svlan) _svlans="$_svlans $hn" ;;
+ vlan) _vlans="$_vlans $hn" ;;
+ esac
+ else
+ # 'real' interfaces (if available) are done now.
+ ifconfig $if >/dev/null 2>&1 && ifstart $hn
+ fi
done
- # Configure any constructed interfaces now that 'real' ones are up.
+ # Configure any dynamic interfaces now that 'real' ones are up.
# ORDER IS IMPORTANT! (see /etc/netstart)
for hn in $_trunks $_svlans $_vlans; do
ifstart $hn
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 74c463aac3a..a32940ec4b5 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.289 2014/11/14 15:09:29 tedu Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.290 2015/01/01 22:53:39 krw Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -581,9 +581,7 @@ main(int argc, char *argv[])
{
const struct afswtch *rafp = NULL;
int create = 0;
-#ifndef SMALL
int Cflag = 0;
-#endif
int gflag = 0;
int i;
int noprint = 0;
@@ -612,12 +610,10 @@ main(int argc, char *argv[])
case 'g':
gflag = 1;
break;
-#ifndef SMALL
case 'C':
Cflag = 1;
nomore = 1;
break;
-#endif
default:
usage(1);
break;
@@ -644,14 +640,12 @@ main(int argc, char *argv[])
rafp = afp;
af = ifr.ifr_addr.sa_family = rafp->af_af;
}
-#ifndef SMALL
if (Cflag) {
if (argc > 0 || aflag)
usage(1);
list_cloners();
exit(0);
}
-#endif
if (gflag) {
if (argc == 0)
printgroupattribs(name);
@@ -1052,7 +1046,6 @@ clone_destroy(const char *addr, int param)
err(1, "SIOCIFDESTROY");
}
-#ifndef SMALL
void
list_cloners(void)
{
@@ -1095,7 +1088,6 @@ list_cloners(void)
putchar('\n');
free(buf);
}
-#endif
#define RIDADDR 0
#define ADDR 1