Re: ifconfig compiler warnings

2019-10-23 Thread Theo de Raadt
Looks great to me.

Alexander Bluhm  wrote:

> On Thu, Oct 17, 2019 at 04:23:32PM +0200, Alexander Bluhm wrote:
> > There are more warnings, but the diff is long enough already.
> 
> Here is the next part to fix ifconfig warnings.  The global variable
> "name" is the interface name.  Sometimes it is passed as parameter,
> sometimes it is accessed directly.  Parameter name changes, sometimes
> "name" is used for something else.
> 
> - Call the global interface variable "ifname".
> - Do not pass it around, just use it globally.
> - Do not use "ifname" for anything else.
> 
> ok?
> 
> bluhm
> 
> Index: sbin/ifconfig/brconfig.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/brconfig.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 brconfig.c
> --- sbin/ifconfig/brconfig.c  17 Oct 2019 18:37:38 -  1.23
> +++ sbin/ifconfig/brconfig.c  22 Oct 2019 20:26:38 -
> @@ -56,7 +56,7 @@ void bridge_list(char *);
>  void bridge_cfg(const char *);
>  void bridge_badrule(int, char **, int);
>  void bridge_showrule(struct ifbrlreq *);
> -int is_switch(char *);
> +int is_switch(void);
>  int bridge_arprule(struct ifbrlreq *, int *, char ***);
> 
>  #define  IFBAFBITS   "\020\1STATIC"
> @@ -200,13 +200,13 @@ addlocal(const char *ifsname, int d)
>   errx(1, "only vether can be local interface");
> 
>   /* Add local */
> - strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name));
> + strlcpy(breq.ifbr_name, ifname, sizeof(breq.ifbr_name));
>   strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname));
>   if (ioctl(sock, SIOCBRDGADDL, (caddr_t)) == -1) {
>   if (errno == EEXIST)
>   return;
>   else
> - err(1, "%s: ioctl SIOCBRDGADDL %s", name, ifsname);
> + err(1, "%s: ioctl SIOCBRDGADDL %s", ifname, ifsname);
>   }
>  }
> 
> @@ -215,15 +215,15 @@ bridge_ifsetflag(const char *ifsname, u_
>  {
>   struct ifbreq req;
> 
> - strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
> + strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
>   if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
> - err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
> + err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", ifname, ifsname);
> 
>   req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK;
> 
>   if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
> - err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
> + err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", ifname, ifsname);
>  }
> 
>  void
> @@ -231,16 +231,16 @@ bridge_ifclrflag(const char *ifsname, u_
>  {
>   struct ifbreq req;
> 
> - strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
> + strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
> 
>   if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
> - err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
> + err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", ifname, ifsname);
> 
>   req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK);
> 
>   if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
> - err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
> + err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", ifname, ifsname);
>  }
> 
>  void
> @@ -248,10 +248,10 @@ bridge_flushall(const char *val, int p)
>  {
>   struct ifbreq req;
> 
> - strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
> + strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
>   req.ifbr_ifsflags = IFBF_FLUSHALL;
>   if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
> - err(1, "%s", name);
> + err(1, "%s", ifname);
>  }
> 
>  void
> @@ -259,10 +259,10 @@ bridge_flush(const char *val, int p)
>  {
>   struct ifbreq req;
> 
> - strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
> + strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
>   req.ifbr_ifsflags = IFBF_FLUSHDYN;
>   if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
> - err(1, "%s", name);
> + err(1, "%s", ifname);
>  }
> 
>  void
> @@ -274,11 +274,11 @@ bridge_cfg(const char *delim)
>   u_int8_t lladdr[ETHER_ADDR_LEN];
>   u_int16_t bprio;
> 
> - strlcpy(ifbp.ifbop_name, name, sizeof(ifbp.ifbop_name));
> + strlcpy(ifbp.ifbop_name, ifname, sizeof(ifbp.ifbop_name));
>   if (ioctl(sock, SIOCBRDGGPARAM, (caddr_t)) == -1) {
>   if (errno == ENOTTY)
>   return;
> - err(1, "%s SIOCBRDGGPARAM", name);
> + err(1, "%s SIOCBRDGGPARAM", ifname);
>   }
> 
>   printf("%s", delim);
> @@ -322,11 +322,11 @@ bridge_list(char *delim)
>   if (inb == NULL)
>   err(1, "malloc");
>   bifc.ifbic_buf = 

Re: ifconfig compiler warnings

2019-10-23 Thread Alexander Bluhm
On Thu, Oct 17, 2019 at 04:23:32PM +0200, Alexander Bluhm wrote:
> There are more warnings, but the diff is long enough already.

Here is the next part to fix ifconfig warnings.  The global variable
"name" is the interface name.  Sometimes it is passed as parameter,
sometimes it is accessed directly.  Parameter name changes, sometimes
"name" is used for something else.

- Call the global interface variable "ifname".
- Do not pass it around, just use it globally.
- Do not use "ifname" for anything else.

ok?

bluhm

Index: sbin/ifconfig/brconfig.c
===
RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/brconfig.c,v
retrieving revision 1.23
diff -u -p -r1.23 brconfig.c
--- sbin/ifconfig/brconfig.c17 Oct 2019 18:37:38 -  1.23
+++ sbin/ifconfig/brconfig.c22 Oct 2019 20:26:38 -
@@ -56,7 +56,7 @@ void bridge_list(char *);
 void bridge_cfg(const char *);
 void bridge_badrule(int, char **, int);
 void bridge_showrule(struct ifbrlreq *);
-int is_switch(char *);
+int is_switch(void);
 int bridge_arprule(struct ifbrlreq *, int *, char ***);

 #defineIFBAFBITS   "\020\1STATIC"
@@ -200,13 +200,13 @@ addlocal(const char *ifsname, int d)
errx(1, "only vether can be local interface");

/* Add local */
-   strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name));
+   strlcpy(breq.ifbr_name, ifname, sizeof(breq.ifbr_name));
strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname));
if (ioctl(sock, SIOCBRDGADDL, (caddr_t)) == -1) {
if (errno == EEXIST)
return;
else
-   err(1, "%s: ioctl SIOCBRDGADDL %s", name, ifsname);
+   err(1, "%s: ioctl SIOCBRDGADDL %s", ifname, ifsname);
}
 }

@@ -215,15 +215,15 @@ bridge_ifsetflag(const char *ifsname, u_
 {
struct ifbreq req;

-   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
+   strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
-   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
+   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", ifname, ifsname);

req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK;

if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
-   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
+   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", ifname, ifsname);
 }

 void
@@ -231,16 +231,16 @@ bridge_ifclrflag(const char *ifsname, u_
 {
struct ifbreq req;

-   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
+   strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));

if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
-   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
+   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", ifname, ifsname);

req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK);

if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
-   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
+   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", ifname, ifsname);
 }

 void
@@ -248,10 +248,10 @@ bridge_flushall(const char *val, int p)
 {
struct ifbreq req;

-   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
+   strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHALL;
if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
-   err(1, "%s", name);
+   err(1, "%s", ifname);
 }

 void
@@ -259,10 +259,10 @@ bridge_flush(const char *val, int p)
 {
struct ifbreq req;

-   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
+   strlcpy(req.ifbr_name, ifname, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHDYN;
if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
-   err(1, "%s", name);
+   err(1, "%s", ifname);
 }

 void
@@ -274,11 +274,11 @@ bridge_cfg(const char *delim)
u_int8_t lladdr[ETHER_ADDR_LEN];
u_int16_t bprio;

-   strlcpy(ifbp.ifbop_name, name, sizeof(ifbp.ifbop_name));
+   strlcpy(ifbp.ifbop_name, ifname, sizeof(ifbp.ifbop_name));
if (ioctl(sock, SIOCBRDGGPARAM, (caddr_t)) == -1) {
if (errno == ENOTTY)
return;
-   err(1, "%s SIOCBRDGGPARAM", name);
+   err(1, "%s SIOCBRDGGPARAM", ifname);
}

printf("%s", delim);
@@ -322,11 +322,11 @@ bridge_list(char *delim)
if (inb == NULL)
err(1, "malloc");
bifc.ifbic_buf = inbuf = inb;
-   strlcpy(bifc.ifbic_name, name, sizeof(bifc.ifbic_name));
+   strlcpy(bifc.ifbic_name, ifname, sizeof(bifc.ifbic_name));

Re: ifconfig compiler warnings

2019-10-18 Thread Sebastian Benoit
Alexander Bluhm(alexander.bl...@gmx.net) on 2019.10.17 16:23:32 +0200:
> Hi,
> 
> I would like to fix some warings in ifconfig when compiled with
> WARNINGS=yes.
> 
> - Move all prototypes and variables used in multiple .c files into
>   common ifconfig.h.  Basically rename brconfig.h to ifconfig.h and
>   also use it for sff.c.
> - Fix missing prototypes.
> - Global variable s is a bad name as it shadows local variables.
>   Call it sock and use it everywhere.
> 
> There are more warnings, but the diff is long enough already.
> 
> ok?

ok

> 
> bluhm
> 
> Index: sbin/ifconfig/brconfig.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/brconfig.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 brconfig.c
> --- sbin/ifconfig/brconfig.c  28 Jun 2019 13:32:44 -  1.22
> +++ sbin/ifconfig/brconfig.c  17 Oct 2019 13:12:51 -
> @@ -47,7 +47,7 @@
>  #include 
>  #include 
> 
> -#include "brconfig.h"
> +#include "ifconfig.h"
> 
>  void bridge_ifsetflag(const char *, u_int32_t);
>  void bridge_ifclrflag(const char *, u_int32_t);
> @@ -202,7 +202,7 @@ addlocal(const char *ifsname, int d)
>   /* Add local */
>   strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name));
>   strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname));
> - if (ioctl(s, SIOCBRDGADDL, (caddr_t)) == -1) {
> + if (ioctl(sock, SIOCBRDGADDL, (caddr_t)) == -1) {
>   if (errno == EEXIST)
>   return;
>   else
> @@ -217,12 +217,12 @@ bridge_ifsetflag(const char *ifsname, u_
> 
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
> - if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
> + if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
>   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
> 
>   req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK;
> 
> - if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
> + if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
>   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
>  }
> 
> @@ -234,12 +234,12 @@ bridge_ifclrflag(const char *ifsname, u_
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
> 
> - if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
> + if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
>   err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
> 
>   req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK);
> 
> - if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
> + if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
>   err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
>  }
> 
> @@ -250,7 +250,7 @@ bridge_flushall(const char *val, int p)
> 
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   req.ifbr_ifsflags = IFBF_FLUSHALL;
> - if (ioctl(s, SIOCBRDGFLUSH, ) == -1)
> + if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
>   err(1, "%s", name);
>  }
> 
> @@ -261,7 +261,7 @@ bridge_flush(const char *val, int p)
> 
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   req.ifbr_ifsflags = IFBF_FLUSHDYN;
> - if (ioctl(s, SIOCBRDGFLUSH, ) == -1)
> + if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
>   err(1, "%s", name);
>  }
> 
> @@ -275,7 +275,7 @@ bridge_cfg(const char *delim)
>   u_int16_t bprio;
> 
>   strlcpy(ifbp.ifbop_name, name, sizeof(ifbp.ifbop_name));
> - if (ioctl(s, SIOCBRDGGPARAM, (caddr_t)) == -1) {
> + if (ioctl(sock, SIOCBRDGGPARAM, (caddr_t)) == -1) {
>   if (errno == ENOTTY)
>   return;
>   err(1, "%s SIOCBRDGGPARAM", name);
> @@ -323,7 +323,7 @@ bridge_list(char *delim)
>   err(1, "malloc");
>   bifc.ifbic_buf = inbuf = inb;
>   strlcpy(bifc.ifbic_name, name, sizeof(bifc.ifbic_name));
> - if (ioctl(s, SIOCBRDGIFS, ) == -1) {
> + if (ioctl(sock, SIOCBRDGIFS, ) == -1) {
>   if (errno == ENOTTY)
>   return;
>   err(1, "%s SIOCBRDGIFS", name);
> @@ -371,7 +371,7 @@ bridge_add(const char *ifn, int d)
> 
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
> - if (ioctl(s, SIOCBRDGADD, ) == -1) {
> + if (ioctl(sock, SIOCBRDGADD, ) == -1) {
>   if (errno == EEXIST)
>   return;
>   err(1, "%s: %s", name, ifn);
> @@ -385,7 +385,7 @@ bridge_delete(const char *ifn, int d)
> 
>   strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
>   strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
> - if (ioctl(s, SIOCBRDGDEL, ) == -1)
> + if (ioctl(sock, SIOCBRDGDEL, ) == -1)
>   err(1, "%s: %s", name, ifn);
>  }
> 
> 

ifconfig compiler warnings

2019-10-17 Thread Alexander Bluhm
Hi,

I would like to fix some warings in ifconfig when compiled with
WARNINGS=yes.

- Move all prototypes and variables used in multiple .c files into
  common ifconfig.h.  Basically rename brconfig.h to ifconfig.h and
  also use it for sff.c.
- Fix missing prototypes.
- Global variable s is a bad name as it shadows local variables.
  Call it sock and use it everywhere.

There are more warnings, but the diff is long enough already.

ok?

bluhm

Index: sbin/ifconfig/brconfig.c
===
RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/brconfig.c,v
retrieving revision 1.22
diff -u -p -r1.22 brconfig.c
--- sbin/ifconfig/brconfig.c28 Jun 2019 13:32:44 -  1.22
+++ sbin/ifconfig/brconfig.c17 Oct 2019 13:12:51 -
@@ -47,7 +47,7 @@
 #include 
 #include 

-#include "brconfig.h"
+#include "ifconfig.h"

 void bridge_ifsetflag(const char *, u_int32_t);
 void bridge_ifclrflag(const char *, u_int32_t);
@@ -202,7 +202,7 @@ addlocal(const char *ifsname, int d)
/* Add local */
strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name));
strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname));
-   if (ioctl(s, SIOCBRDGADDL, (caddr_t)) == -1) {
+   if (ioctl(sock, SIOCBRDGADDL, (caddr_t)) == -1) {
if (errno == EEXIST)
return;
else
@@ -217,12 +217,12 @@ bridge_ifsetflag(const char *ifsname, u_

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
-   if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
+   if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);

req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK;

-   if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
+   if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
 }

@@ -234,12 +234,12 @@ bridge_ifclrflag(const char *ifsname, u_
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));

-   if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
+   if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)) == -1)
err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);

req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK);

-   if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
+   if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)) == -1)
err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
 }

@@ -250,7 +250,7 @@ bridge_flushall(const char *val, int p)

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHALL;
-   if (ioctl(s, SIOCBRDGFLUSH, ) == -1)
+   if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
err(1, "%s", name);
 }

@@ -261,7 +261,7 @@ bridge_flush(const char *val, int p)

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHDYN;
-   if (ioctl(s, SIOCBRDGFLUSH, ) == -1)
+   if (ioctl(sock, SIOCBRDGFLUSH, ) == -1)
err(1, "%s", name);
 }

@@ -275,7 +275,7 @@ bridge_cfg(const char *delim)
u_int16_t bprio;

strlcpy(ifbp.ifbop_name, name, sizeof(ifbp.ifbop_name));
-   if (ioctl(s, SIOCBRDGGPARAM, (caddr_t)) == -1) {
+   if (ioctl(sock, SIOCBRDGGPARAM, (caddr_t)) == -1) {
if (errno == ENOTTY)
return;
err(1, "%s SIOCBRDGGPARAM", name);
@@ -323,7 +323,7 @@ bridge_list(char *delim)
err(1, "malloc");
bifc.ifbic_buf = inbuf = inb;
strlcpy(bifc.ifbic_name, name, sizeof(bifc.ifbic_name));
-   if (ioctl(s, SIOCBRDGIFS, ) == -1) {
+   if (ioctl(sock, SIOCBRDGIFS, ) == -1) {
if (errno == ENOTTY)
return;
err(1, "%s SIOCBRDGIFS", name);
@@ -371,7 +371,7 @@ bridge_add(const char *ifn, int d)

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
-   if (ioctl(s, SIOCBRDGADD, ) == -1) {
+   if (ioctl(sock, SIOCBRDGADD, ) == -1) {
if (errno == EEXIST)
return;
err(1, "%s: %s", name, ifn);
@@ -385,7 +385,7 @@ bridge_delete(const char *ifn, int d)

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
-   if (ioctl(s, SIOCBRDGDEL, ) == -1)
+   if (ioctl(sock, SIOCBRDGDEL, ) == -1)
err(1, "%s: %s", name, ifn);
 }

@@ -396,7 +396,7 @@ bridge_addspan(const char *ifn, int d)

strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
-   if