diff options
author | Phil Sutter <phil@nwl.cc> | 2024-01-24 23:29:46 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2024-02-02 18:26:14 +0100 |
commit | 30a7f11234a81bd2389c7e7224769b1fdd192239 (patch) | |
tree | 7b4a1674937105e49e531f06e49b7309596759a9 /extensions/libebt_stp.c | |
parent | 285406b1d22e3ed0aec30ea0a534ea76211156a9 (diff) |
libxtables: xtoptions: Assert ranges are monotonic increasing
Extensions commonly require the upper range value to be larger or equal
to the lower one. Performing this check in the parser is easier and
covers all extensions at once.
One notable exception is NFQUEUE which requires strict monotonicity.
Hence leave its checks in place.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'extensions/libebt_stp.c')
-rw-r--r-- | extensions/libebt_stp.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/extensions/libebt_stp.c b/extensions/libebt_stp.c index 371fa04c..189e36a5 100644 --- a/extensions/libebt_stp.c +++ b/extensions/libebt_stp.c @@ -139,36 +139,33 @@ static void brstp_parse(struct xt_option_call *cb) cb->val.ethermacmask, ETH_ALEN); break; -#define RANGE_ASSIGN(name, fname, val) { \ +#define RANGE_ASSIGN(fname, val) { \ stpinfo->config.fname##l = val[0]; \ stpinfo->config.fname##u = cb->nvals > 1 ? val[1] : val[0]; \ - if (stpinfo->config.fname##u < stpinfo->config.fname##l) \ - xtables_error(PARAMETER_PROBLEM, \ - "Bad --stp-" name " range"); \ } case O_RPRIO: - RANGE_ASSIGN("root-prio", root_prio, cb->val.u16_range); + RANGE_ASSIGN(root_prio, cb->val.u16_range); break; case O_RCOST: - RANGE_ASSIGN("root-cost", root_cost, cb->val.u32_range); + RANGE_ASSIGN(root_cost, cb->val.u32_range); break; case O_SPRIO: - RANGE_ASSIGN("sender-prio", sender_prio, cb->val.u16_range); + RANGE_ASSIGN(sender_prio, cb->val.u16_range); break; case O_PORT: - RANGE_ASSIGN("port", port, cb->val.u16_range); + RANGE_ASSIGN(port, cb->val.u16_range); break; case O_MSGAGE: - RANGE_ASSIGN("msg-age", msg_age, cb->val.u16_range); + RANGE_ASSIGN(msg_age, cb->val.u16_range); break; case O_MAXAGE: - RANGE_ASSIGN("max-age", max_age, cb->val.u16_range); + RANGE_ASSIGN(max_age, cb->val.u16_range); break; case O_HTIME: - RANGE_ASSIGN("hello-time", hello_time, cb->val.u16_range); + RANGE_ASSIGN(hello_time, cb->val.u16_range); break; case O_FWDD: - RANGE_ASSIGN("forward-delay", forward_delay, cb->val.u16_range); + RANGE_ASSIGN(forward_delay, cb->val.u16_range); break; #undef RANGE_ASSIGN } |