Re: ifconfig(8): fix set switch(4) datapath id

2016-10-17 Thread Reyk Floeter

> Am 17.10.2016 um 14:33 schrieb Rafael Zalamena :
> 
>> On Mon, Oct 17, 2016 at 02:30:41PM +0400, Reyk Floeter wrote:
>> 
>>> Am 17.10.2016 um 14:16 schrieb Rafael Zalamena :
>>> 
>>> There are two inconsistencies with the ifconfig(8) switch(4) configuring:
>>> 1) Datapath ID is an unsigned 64 bit integer, not a signed one;
>> 
>> I think we should use strtonum instead of strtoull here.
> 
> If we use strtonum() we lose the ability to express the datapath id in
> hexadecimal numbers and we'll use only decimals. I think we should keep
> the strtoull().

Makes sense.

So OK for the diff.

Reyk



Re: ifconfig(8): fix set switch(4) datapath id

2016-10-17 Thread Reyk Floeter

> Am 17.10.2016 um 14:16 schrieb Rafael Zalamena :
> 
> There are two inconsistencies with the ifconfig(8) switch(4) configuring:
> 1) Datapath ID is an unsigned 64 bit integer, not a signed one;

I think we should use strtonum instead of strtoull here.

> 2) ifconfig(8) man pages says that the parameter is "datapath" not
>   "datapathid";
> 

Yes, this chunk is OK.

Reyk

> This diff fixes both problems and let us configure the datapath id
> correctly.
> 
> ok?
> 
> 
> Index: brconfig.c
> ===
> RCS file: /home/obsdcvs/src/sbin/ifconfig/brconfig.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 brconfig.c
> --- brconfig.c3 Sep 2016 17:13:48 -1.11
> +++ brconfig.c17 Oct 2016 10:11:25 -
> @@ -1051,7 +1051,7 @@ switch_datapathid(const char *arg, int d
>char *endptr;
> 
>errno = 0;
> -newdpid = strtoll(arg, , 0);
> +newdpid = strtoull(arg, , 0);
>if (arg[0] == '\0' || endptr[0] != '\0' || errno == ERANGE)
>errx(1, "invalid arg for datapath-id: %s", arg);
> 
> Index: ifconfig.c
> ===
> RCS file: /home/obsdcvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.330
> diff -u -p -r1.330 ifconfig.c
> --- ifconfig.c3 Sep 2016 13:46:57 -1.330
> +++ ifconfig.c17 Oct 2016 09:48:33 -
> @@ -517,7 +517,7 @@ const structcmd {
>{ "-roaming",0,0,umb_roaming },
>{ "patch",NEXTARG,0,setpair },
>{ "-patch",1,0,unsetpair },
> -{ "datapathid",NEXTARG,0,switch_datapathid },
> +{ "datapath",NEXTARG,0,switch_datapathid },
>{ "portno",NEXTARG2,0,NULL, switch_portno },
>{ "addlocal",NEXTARG,0,addlocal },
> #else /* SMALL */
> 



ifconfig(8): fix set switch(4) datapath id

2016-10-17 Thread Rafael Zalamena
There are two inconsistencies with the ifconfig(8) switch(4) configuring:
1) Datapath ID is an unsigned 64 bit integer, not a signed one;
2) ifconfig(8) man pages says that the parameter is "datapath" not
   "datapathid";

This diff fixes both problems and let us configure the datapath id
correctly.

ok?


Index: brconfig.c
===
RCS file: /home/obsdcvs/src/sbin/ifconfig/brconfig.c,v
retrieving revision 1.11
diff -u -p -r1.11 brconfig.c
--- brconfig.c  3 Sep 2016 17:13:48 -   1.11
+++ brconfig.c  17 Oct 2016 10:11:25 -
@@ -1051,7 +1051,7 @@ switch_datapathid(const char *arg, int d
char *endptr;
 
errno = 0;
-   newdpid = strtoll(arg, , 0);
+   newdpid = strtoull(arg, , 0);
if (arg[0] == '\0' || endptr[0] != '\0' || errno == ERANGE)
errx(1, "invalid arg for datapath-id: %s", arg);
 
Index: ifconfig.c
===
RCS file: /home/obsdcvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.330
diff -u -p -r1.330 ifconfig.c
--- ifconfig.c  3 Sep 2016 13:46:57 -   1.330
+++ ifconfig.c  17 Oct 2016 09:48:33 -
@@ -517,7 +517,7 @@ const structcmd {
{ "-roaming",   0,  0,  umb_roaming },
{ "patch",  NEXTARG,0,  setpair },
{ "-patch", 1,  0,  unsetpair },
-   { "datapathid", NEXTARG,0,  switch_datapathid },
+   { "datapath",   NEXTARG,0,  switch_datapathid },
{ "portno", NEXTARG2,   0,  NULL, switch_portno },
{ "addlocal",   NEXTARG,0,  addlocal },
 #else /* SMALL */