On Fri, Jul 28, 2017 at 06:13:50PM +1000, Jonathan Gray wrote:
> 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.
> 

makes sense, ok

Reyk

> Index: brconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/brconfig.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 brconfig.c
> --- brconfig.c        7 Jun 2017 16:47:29 -0000       1.15
> +++ brconfig.c        28 Jul 2017 08:04:00 -0000
> @@ -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 
>               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
> 

-- 

Reply via email to