[SRU][F:linux-bluefield][PATCH 3/4] net/sched: cls_flower: validate ct_state for invalid and reply flags

Bodong Wang bodong at nvidia.com
Thu Sep 30 20:51:19 UTC 2021


From: wenxu <wenxu at ucloud.cn>

BugLink: https://bugs.launchpad.net/bugs/1944390

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 at ucloud.cn>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>
Link: https://lore.kernel.org/r/1614064315-364-1-git-send-email-wenxu@ucloud.cn
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(Cherry-picked from upstream commit 3aed8b63336c3f81a4fd72808dcf6197fabbbdb2)
Signed-off-by: Paul Blakey <paulb at nvidia.com>
Signed-off-by: Bodong Wang <bodong at nvidia.com>
---
 net/sched/cls_flower.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index b6e4787..8abe6ec 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -1031,6 +1031,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;
 }
 
-- 
1.8.3.1




More information about the kernel-team mailing list