Skip to content

Commit

Permalink
net/sched: cls_flower: validate ct_state for invalid and reply flags
Browse files Browse the repository at this point in the history
Add invalid and reply flags validate in the fl_validate_ct_state.
This makes the checking complete if compared to ovs'
validate_ct_state().

Signed-off-by: wenxu <wenxu@ucloud.cn>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Link: https://lore.kernel.org/r/1614064315-364-1-git-send-email-wenxu@ucloud.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
wenxu authored and Jakub Kicinski committed Feb 23, 2021
1 parent f3f9be9 commit 3aed8b6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/sched/cls_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,21 @@ static int fl_validate_ct_state(u16 state, struct nlattr *tb,
return -EINVAL;
}

if (state & TCA_FLOWER_KEY_CT_FLAGS_INVALID &&
state & ~(TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
TCA_FLOWER_KEY_CT_FLAGS_INVALID)) {
NL_SET_ERR_MSG_ATTR(extack, tb,
"when inv is set, only trk may be set");
return -EINVAL;
}

if (state & TCA_FLOWER_KEY_CT_FLAGS_NEW &&
state & TCA_FLOWER_KEY_CT_FLAGS_REPLY) {
NL_SET_ERR_MSG_ATTR(extack, tb,
"new and rpl are mutually exclusive");
return -EINVAL;
}

return 0;
}

Expand Down

0 comments on commit 3aed8b6

Please sign in to comment.