From ad1b458d74ae3c53db2a805cf6927eb4271b6c71 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Mon, 31 Jul 2017 02:32:12 +0000 Subject: The handling of 'add' used by bridge and switch in ifconfig does not error out if the ioctl returns EEXIST. Do the same for the switch specific 'addlocal' and 'portno' ioctls so netstart won't error out when rerun with the same settings in hostname.switchN. ok reyk@ --- sbin/ifconfig/brconfig.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sbin/ifconfig') diff --git a/sbin/ifconfig/brconfig.c b/sbin/ifconfig/brconfig.c index 12ed5e7e99e..1f240b133ce 100644 --- a/sbin/ifconfig/brconfig.c +++ b/sbin/ifconfig/brconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.c,v 1.15 2017/06/07 16:47:29 naddy Exp $ */ +/* $OpenBSD: brconfig.c,v 1.16 2017/07/31 02:32:11 jsg Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -203,7 +203,7 @@ addlocal(const char *ifsname, int d) strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname)); if (ioctl(s, SIOCBRDGADDL, (caddr_t)&breq) < 0) { if (errno == EEXIST) - errx(1, "%s: local port exists already", name); + return; else err(1, "%s: ioctl SIOCBRDGADDL %s", name, ifsname); } @@ -1076,8 +1076,12 @@ switch_portno(const char *ifname, const char *val) errx(1, "invalid arg for portidx: %s", val); breq.ifbr_portno = newportidx; - if (ioctl(s, SIOCSWSPORTNO, (caddr_t)&breq) < 0) - err(1, "%s", name); + if (ioctl(s, SIOCSWSPORTNO, (caddr_t)&breq) < 0) { + if (errno == EEXIST) + return; + else + err(1, "%s", name); + } } #endif -- cgit v1.2.3