How to set tos to 0

Radek Krejča radek.krejca at starnet.cz
Wed Aug 10 14:23:54 UTC 2016


> On 31 Jul 2016, at 19:46, Radek Krejča wrote:
> > I need to set TOS to 0 and remark it with rules.
> >
> > I am trying to use scrub to set tos to 0, but I have problem:
> >
> > scrub all fragment reassemble no-df set-tos 0
> >
> > give Illegal value
> >
> > but scrub all fragment reassemble no-df set-tos 1
> > is working.
> >
> > I am trying 0x00, 0x0 and still the same.
> >
> > How can I set TOS to 0?
> >
> I think you may have found a bug.
> 
> Can you give this patch a try?
> 
> diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
> index e0cfa3d..980976e 100644
> --- a/sbin/pfctl/parse.y
> +++ b/sbin/pfctl/parse.y
> @@ -3593,8 +3593,8 @@ tos       : STRING                        {
>                          else if ($1[0] == '0' && $1[1] == 'x')
>                                  $$ = strtoul($1, NULL, 16);
>                          else
> -                               $$ = 0;         /* flag bad argument */
> -                       if (!$$ || $$ > 255) {
> +                               $$ = 256;               /* flag bad
> argument */
> +                       if ($$ < 0 || $$ > 255) {
>                                  yyerror("illegal tos value %s", $1);
>                                  free($1);
>                                  YYERROR;
> @@ -3603,7 +3603,7 @@ tos       : STRING                        {
>                  }
>                  | NUMBER                        {
>                          $$ = $1;
> -                       if (!$$ || $$ > 255) {
> +                       if ($$ < 0 || $$ > 255) {
>                                  yyerror("illegal tos value %s", $1);
>                                  YYERROR;
>                          }
> 

Hello Kristof,

this patch seems to be working.

I will post bugreport.

Thank you
Radek


More information about the freebsd-pf mailing list