diff mbox series

[net-next] net/sched: cls_flower: validate ct_state for invalid and reply flags

Message ID 1613974190-12108-1-git-send-email-wenxu@ucloud.cn (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/sched: cls_flower: validate ct_state for invalid and reply flags | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 3 maintainers not CCed: jiri@resnulli.us davem@davemloft.net xiyou.wangcong@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 88 this patch: 88
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 88 this patch: 88
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

wenxu Feb. 22, 2021, 6:09 a.m. UTC
From: wenxu <wenxu@ucloud.cn>

Add invalid and reply flags validate in the fl_validate_ct_state.

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 net/sched/cls_flower.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Marcelo Ricardo Leitner Feb. 22, 2021, 12:12 p.m. UTC | #1
On Mon, Feb 22, 2021 at 02:09:50PM +0800, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
> 
> Add invalid and reply flags validate in the fl_validate_ct_state.

This makes the checking complete if compared to ovs'
validate_ct_state().

...
> +	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 also be set");

The message is missing the verb:
+				    "when inv is set, only trk may also be set");

Other than this, LGTM.

> +		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
>
diff mbox series

Patch

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 2409e52..18430db 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -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 also 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;
 }