From: Theo Buehler Subject: Re: bgpd: fix various flowspec parser issues To: tech@openbsd.org Date: Mon, 18 May 2026 17:46:54 +0200 On Mon, May 18, 2026 at 01:43:55PM +0200, Claudio Jeker wrote: > This is a collection of fixes to the flowspec bits in parse.y > > - handle PROTO proto_item like PROTO { proto_item }. > - extra semicolon after flags > - The LENGTH spec needs to be adjusted, curflow->type needs to be set > before evaluating lengthspec. > - Twice $$ is used in error checking before $$ was set. Use $1 instead. ok tb > > > -- > :wq Claudio > > Index: parse.y > =================================================================== > RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v > diff -u -p -r1.496 parse.y > --- parse.y 13 May 2026 09:25:11 -0000 1.496 > +++ parse.y 18 May 2026 09:32:46 -0000 > @@ -1221,7 +1221,11 @@ flowspec : FLOWSPEC af { > } > ; > > -proto : PROTO proto_item > +proto : PROTO proto_item { > + curflow->type = FLOWSPEC_TYPE_PROTO; > + if (push_unary_numop(OP_EQ, $2) == -1) > + YYERROR; > + } > | PROTO '{' optnl proto_list optnl '}' > ; > > @@ -1337,11 +1341,11 @@ flowrule : from > } flags > | FRAGMENT { > curflow->type = FLOWSPEC_TYPE_FRAG; > - } flags; > + } flags > | icmpspec > - | LENGTH lengthspec { > + | LENGTH { > curflow->type = FLOWSPEC_TYPE_PKT_LEN; > - } > + } lengthspec > | proto > | TOS tos { > curflow->type = FLOWSPEC_TYPE_DSCP; > @@ -1473,7 +1477,7 @@ tos : STRING { > free($1); > } > | NUMBER { > - if ($$ < 0 || $$ > 255) { > + if ($1 < 0 || $1 > 255) { > yyerror("illegal tos value %lld", $1); > YYERROR; > } > @@ -1504,7 +1508,7 @@ length_item : length { > ; > > length : NUMBER { > - if ($$ < 0 || $$ > USHRT_MAX) { > + if ($1 < 0 || $1 > USHRT_MAX) { > yyerror("illegal ptk length value %lld", $1); > YYERROR; > } >