Re: bgpd: remove ASDOT support

2023-01-30 Thread Claudio Jeker
On Sun, Jan 29, 2023 at 02:02:08PM +, Job Snijders wrote:
> ASDOT started out as sort of a joke, but unfortunately gained some
> popularity in the 2010s with the rise of 4-byte ASNs and some people
> thinking "cute, I can write my longish number in a shorter exotic
> notation".
> 
> Then, many operators came to realize that using a '.' (dot) in places
> which used to be simple integers is quite annoying (for example when
> regular expressions also are in play), and more fundamentally: why go
> through the trouble of using a complicated syntax when you can just
> write number itself?

Because in some cases you need 0.42 because that's the only way to enforce
a 4byte ASnum with small ASnumbers.
 
> Perhaps time to bring ASDOT to the gardenshed? :-)

The diff is wrong. You removed too much. as4number and as4number_any are
not the same thing and you broke ROA with source-as 0 with this.
Also there is a lot missing.
 
bgpd already uses ASPLAIN everywhere but accepts ASDOT as well. 
I have nothing against applying the first hunk of bgpd.conf.5 but
the second but should not be removed. Because it documents how to force a
4byte ASnumber encoding for ext-communities. (ext-commuinity encoding is a
nightmare but that is a different story).

> Kind regards,
> 
> Job
> 
> Index: bgpd.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.conf.5,v
> retrieving revision 1.230
> diff -u -p -r1.230 bgpd.conf.5
> --- bgpd.conf.5   24 Jan 2023 14:13:11 -  1.230
> +++ bgpd.conf.5   29 Jan 2023 13:53:02 -
> @@ -127,17 +127,9 @@ for Latin America and the Caribbean
>  for Europe, the Middle East, and parts of Asia
>  .El
>  .Pp
> -The AS numbers 64512 \(en 65534 are designated for private use.
> +The AS numbers 64496 \(en 65534 and 42 \(en 4294967294 are designated
> +for private use.
>  The AS number 23456 is reserved and should not be used.
> -4-byte AS numbers may be specified in either the ASPLAIN format:
> -.Bd -literal -offset indent
> -AS 196618
> -.Ed
> -.Pp
> -or in the older ASDOT format:
> -.Bd -literal -offset indent
> -AS 3.10
> -.Ed
>  .Pp
>  .It Ic connect-retry Ar seconds
>  Set the number of seconds to wait before attempting to re-open
> @@ -1991,7 +1983,7 @@ Communities are encoded as
>  .Ar as-number : Ns Ar local .
>  Four-octet encoding is used if the
>  .Ar as-number
> -is bigger than 65535 or if the AS_DOT encoding is used.
> +is bigger than 65535.
>  IPv4 Address Specific Extended Communities are encoded as
>  .Ar IP : Ns Ar local .
>  Opaque Extended Communities are encoded with a single numeric value.
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> retrieving revision 1.440
> diff -u -p -r1.440 parse.y
> --- parse.y   24 Jan 2023 14:13:11 -  1.440
> +++ parse.y   29 Jan 2023 13:53:02 -
> @@ -242,7 +242,7 @@ typedef struct {
>  %token   NE LE GE XRANGE LONGER MAXLEN MAX
>  %token STRING
>  %token NUMBER
> -%type  asnumber as4number as4number_any 
> optnumber
> +%type  asnumber as4number optnumber
>  %type  espah family safi restart origincode 
> nettype
>  %type  yesno inout restricted expires enforce
>  %type  validity aspa_validity
> @@ -297,39 +297,7 @@ asnumber : NUMBER{
>   }
>   }
>  
> -as4number: STRING{
> - const char  *errstr;
> - char*dot;
> - uint32_t uvalh = 0, uval;
> -
> - if ((dot = strchr($1,'.')) != NULL) {
> - *dot++ = '\0';
> - uvalh = strtonum($1, 0, USHRT_MAX, );
> - if (errstr) {
> - yyerror("number %s is %s", $1, errstr);
> - free($1);
> - YYERROR;
> - }
> - uval = strtonum(dot, 0, USHRT_MAX, );
> - if (errstr) {
> - yyerror("number %s is %s", dot, errstr);
> - free($1);
> - YYERROR;
> - }
> - free($1);
> - } else {
> - yyerror("AS %s is bad", $1);
> - free($1);
> - YYERROR;
> - }
> - if (uvalh == 0 && (uval == AS_TRANS || uval == 0)) {
> - yyerror("AS %u is reserved and may not be used",
> - uval);
> - 

bgpd: remove ASDOT support

2023-01-29 Thread Job Snijders
ASDOT started out as sort of a joke, but unfortunately gained some
popularity in the 2010s with the rise of 4-byte ASNs and some people
thinking "cute, I can write my longish number in a shorter exotic
notation".

Then, many operators came to realize that using a '.' (dot) in places
which used to be simple integers is quite annoying (for example when
regular expressions also are in play), and more fundamentally: why go
through the trouble of using a complicated syntax when you can just
write number itself?

Perhaps time to bring ASDOT to the gardenshed? :-)

Kind regards,

Job

Index: bgpd.conf.5
===
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.conf.5,v
retrieving revision 1.230
diff -u -p -r1.230 bgpd.conf.5
--- bgpd.conf.5 24 Jan 2023 14:13:11 -  1.230
+++ bgpd.conf.5 29 Jan 2023 13:53:02 -
@@ -127,17 +127,9 @@ for Latin America and the Caribbean
 for Europe, the Middle East, and parts of Asia
 .El
 .Pp
-The AS numbers 64512 \(en 65534 are designated for private use.
+The AS numbers 64496 \(en 65534 and 42 \(en 4294967294 are designated
+for private use.
 The AS number 23456 is reserved and should not be used.
-4-byte AS numbers may be specified in either the ASPLAIN format:
-.Bd -literal -offset indent
-AS 196618
-.Ed
-.Pp
-or in the older ASDOT format:
-.Bd -literal -offset indent
-AS 3.10
-.Ed
 .Pp
 .It Ic connect-retry Ar seconds
 Set the number of seconds to wait before attempting to re-open
@@ -1991,7 +1983,7 @@ Communities are encoded as
 .Ar as-number : Ns Ar local .
 Four-octet encoding is used if the
 .Ar as-number
-is bigger than 65535 or if the AS_DOT encoding is used.
+is bigger than 65535.
 IPv4 Address Specific Extended Communities are encoded as
 .Ar IP : Ns Ar local .
 Opaque Extended Communities are encoded with a single numeric value.
Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.440
diff -u -p -r1.440 parse.y
--- parse.y 24 Jan 2023 14:13:11 -  1.440
+++ parse.y 29 Jan 2023 13:53:02 -
@@ -242,7 +242,7 @@ typedef struct {
 %token NE LE GE XRANGE LONGER MAXLEN MAX
 %token   STRING
 %token   NUMBER
-%typeasnumber as4number as4number_any optnumber
+%typeasnumber as4number optnumber
 %typeespah family safi restart origincode nettype
 %typeyesno inout restricted expires enforce
 %typevalidity aspa_validity
@@ -297,39 +297,7 @@ asnumber   : NUMBER{
}
}
 
-as4number  : STRING{
-   const char  *errstr;
-   char*dot;
-   uint32_t uvalh = 0, uval;
-
-   if ((dot = strchr($1,'.')) != NULL) {
-   *dot++ = '\0';
-   uvalh = strtonum($1, 0, USHRT_MAX, );
-   if (errstr) {
-   yyerror("number %s is %s", $1, errstr);
-   free($1);
-   YYERROR;
-   }
-   uval = strtonum(dot, 0, USHRT_MAX, );
-   if (errstr) {
-   yyerror("number %s is %s", dot, errstr);
-   free($1);
-   YYERROR;
-   }
-   free($1);
-   } else {
-   yyerror("AS %s is bad", $1);
-   free($1);
-   YYERROR;
-   }
-   if (uvalh == 0 && (uval == AS_TRANS || uval == 0)) {
-   yyerror("AS %u is reserved and may not be used",
-   uval);
-   YYERROR;
-   }
-   $$ = uval | (uvalh << 16);
-   }
-   | asnumber {
+as4number  : asnumber {
if ($1 == AS_TRANS || $1 == 0) {
yyerror("AS %u is reserved and may not be used",
(uint32_t)$1);
@@ -339,38 +307,6 @@ as4number  : STRING{
}
;
 
-as4number_any  : STRING{
-   const char  *errstr;
-   char*dot;
-   uint32_t uvalh = 0, uval;
-
-   if ((dot = strchr($1,'.')) != NULL) {
-   *dot++ = '\0';
-   uvalh = strtonum($1, 0, USHRT_MAX, );
-