Fix constructing of setdscp opcode with tablearg keyword.

setdscp's argument can have zero value that conflicts with IP_FW_TARG value.
Always set high-order bit if parser doesn't find tablearg keyword.

MFC after:	3 days
This commit is contained in:
Andrey V. Elsukov 2016-08-08 18:10:30 +00:00
parent 2af16ec8f2
commit 78724b5251
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303842

View File

@ -3957,15 +3957,19 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
NEED1("missing DSCP code"); NEED1("missing DSCP code");
if (_substrcmp(*av, "tablearg") == 0) { if (_substrcmp(*av, "tablearg") == 0) {
action->arg1 = IP_FW_TARG; action->arg1 = IP_FW_TARG;
} else if (isalpha(*av[0])) { } else {
if ((code = match_token(f_ipdscp, *av)) == -1) if (isalpha(*av[0])) {
errx(EX_DATAERR, "Unknown DSCP code"); if ((code = match_token(f_ipdscp, *av)) == -1)
action->arg1 = code; errx(EX_DATAERR, "Unknown DSCP code");
} else action->arg1 = code;
action->arg1 = strtoul(*av, NULL, 10); } else
/* Add high-order bit to DSCP to make room for tablearg */ action->arg1 = strtoul(*av, NULL, 10);
if (action->arg1 != IP_FW_TARG) /*
* Add high-order bit to DSCP to make room
* for tablearg
*/
action->arg1 |= 0x8000; action->arg1 |= 0x8000;
}
av++; av++;
break; break;
} }