On Sun, Jan 29, 2023 at 02:02:08PM +0000, 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 -0000 1.230
> +++ bgpd.conf.5 29 Jan 2023 13:53:02 -0000
> @@ -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 4200000000 \(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 -0000 1.440
> +++ parse.y 29 Jan 2023 13:53:02 -0000
> @@ -242,7 +242,7 @@ typedef struct {
> %token NE LE GE XRANGE LONGER MAXLEN MAX
> %token <v.string> STRING
> %token <v.number> NUMBER
> -%type <v.number> asnumber as4number as4number_any
> optnumber
> +%type <v.number> asnumber as4number optnumber
> %type <v.number> espah family safi restart origincode
> nettype
> %type <v.number> yesno inout restricted expires enforce
> %type <v.number> 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, &errstr);
> - if (errstr) {
> - yyerror("number %s is %s", $1, errstr);
> - free($1);
> - YYERROR;
> - }
> - uval = strtonum(dot, 0, USHRT_MAX, &errstr);
> - 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, &errstr);
> - if (errstr) {
> - yyerror("number %s is %s", $1, errstr);
> - free($1);
> - YYERROR;
> - }
> - uval = strtonum(dot, 0, USHRT_MAX, &errstr);
> - if (errstr) {
> - yyerror("number %s is %s", dot, errstr);
> - free($1);
> - YYERROR;
> - }
> - free($1);
> - } else {
> - yyerror("AS %s is bad", $1);
> - free($1);
> - YYERROR;
> - }
> - $$ = uval | (uvalh << 16);
> - }
> - | asnumber {
> - $$ = $1;
> - }
> - ;
> -
> string : string STRING {
> if (asprintf(&$$, "%s %s", $1, $2) == -1)
> fatal("string: asprintf");
> @@ -460,8 +396,8 @@ as_set : ASSET STRING '{' optnl {
> free($2);
> }
>
> -as_set_l : as4number_any { add_as_set($1); }
> - | as_set_l comma as4number_any { add_as_set($3); }
> +as_set_l : asnumber { add_as_set($1); }
> + | as_set_l comma asnumber { add_as_set($3); }
>
> prefixset : PREFIXSET STRING '{' optnl {
> if ((curpset = new_prefix_set($2, 0)) == NULL) {
> @@ -575,7 +511,7 @@ expires : /* empty */ {
> $$ = $2;
> }
>
> -roa_set_l : prefixset_item SOURCEAS as4number_any expires {
> +roa_set_l : prefixset_item SOURCEAS asnumber expires {
> if ($1->p.len_min != $1->p.len) {
> yyerror("unsupported prefixlen operation in "
> "roa-set");
> @@ -585,7 +521,7 @@ roa_set_l : prefixset_item SOURCEAS as4n
> add_roa_set($1, $3, $1->p.len_max, $4);
> free($1);
> }
> - | roa_set_l comma prefixset_item SOURCEAS as4number_any expires
> {
> + | roa_set_l comma prefixset_item SOURCEAS asnumber expires
> {
> if ($3->p.len_min != $3->p.len) {
> yyerror("unsupported prefixlen operation in "
> "roa-set");
> @@ -630,14 +566,14 @@ aspa_tas_l : aspa_tas { $$ =
> $1; }
> }
> ;
>
> -aspa_tas : as4number_any {
> +aspa_tas : asnumber {
> if (($$ = calloc(1, sizeof(*$$))) == NULL)
> fatal(NULL);
> $$->as = $1;
> $$->aid = AID_UNSPEC;
> $$->num = 1;
> }
> - | as4number_any family {
> + | asnumber family {
> if (($$ = calloc(1, sizeof(*$$))) == NULL)
> fatal(NULL);
> $$->as = $1;
> @@ -2337,7 +2273,7 @@ filter_as_l : filter_as
> }
> ;
>
> -filter_as : as4number_any {
> +filter_as : asnumber {
> if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> NULL)
> fatal(NULL);
> @@ -2351,7 +2287,7 @@ filter_as : as4number_any {
> fatal(NULL);
> $$->a.flags = AS_FLAG_NEIGHBORAS;
> }
> - | equalityop as4number_any {
> + | equalityop asnumber {
> if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> NULL)
> fatal(NULL);
> @@ -2359,7 +2295,7 @@ filter_as : as4number_any {
> $$->a.as_min = $2;
> $$->a.as_max = $2;
> }
> - | as4number_any binaryop as4number_any {
> + | asnumber binaryop asnumber {
> if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> NULL)
> fatal(NULL);
>
--
:wq Claudio