diff mbox series

[net-next,v2,01/10] net/sched: flower: refactor tunnel flag definitions

Message ID 20240705133348.728901-2-ast@fiberby.net (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series flower: rework TCA_FLOWER_KEY_ENC_FLAGS usage | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 869 this patch: 869
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 933 this patch: 933
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5902 this patch: 5902
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 44 this patch: 44
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-06--00-00 (tests: 693)

Commit Message

Asbjørn Sloth Tønnesen July 5, 2024, 1:33 p.m. UTC
Redefine the flower control flags as an enum, so they are
included in BTF info.

Make the kernel-side enum a more explicit superset of
TCA_FLOWER_KEY_FLAGS_*, new flags still need to be added to
both enums, but at least the bit position only has to be
defined once.

FLOW_DIS_ENCAPSULATION is never set for mask, so it can't be
exposed to userspace in an unsupported flags mask error message,
so it will be placed one bit position above the last uAPI flag.

Suggested-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
 include/net/flow_dissector.h | 14 +++++++++++---
 include/uapi/linux/pkt_cls.h |  3 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Asbjørn Sloth Tønnesen July 8, 2024, 11:11 a.m. UTC | #1
On 7/5/24 1:33 PM, Asbjørn Sloth Tønnesen wrote:
 > net/sched: flower: refactor tunnel flag definitions

Should have been: "net/sched: flower: refactor control flag definitions"

After the split, tunnel control flags are first introduced in the next patch.

I will properly do a new spin tomorrow.

Davide, I think David Ahern would be happy [1] if you could post a new iproute2 patch,
since the kernel patches should preferably hit net-next this week (due to uAPI breakage).

[1] https://lore.kernel.org/c83bb901-686e-4507-b4b1-020ae86d2381@kernel.org/
Davide Caratti July 8, 2024, 12:07 p.m. UTC | #2
hello,

On Mon, Jul 8, 2024 at 1:12 PM Asbjørn Sloth Tønnesen <ast@fiberby.net> wrote:
>

[...]

> Davide, I think David Ahern would be happy [1] if you could post a new iproute2 patch,
> since the kernel patches should preferably hit net-next this week (due to uAPI breakage).

I will send an updated patch (don't use "matches" + add missing man
page + rename keywords [1])  in the next hours.
thanks,
Asbjørn Sloth Tønnesen July 8, 2024, 12:38 p.m. UTC | #3
Hi Davide,

On 7/8/24 12:07 PM, Davide Caratti wrote:
> On Mon, Jul 8, 2024 at 1:12 PM Asbjørn Sloth Tønnesen<ast@fiberby.net>  wrote:
> [...]
> 
>> Davide, I think David Ahern would be happy [1] if you could post a new iproute2 patch,
>> since the kernel patches should preferably hit net-next this week (due to uAPI breakage).
> I will send an updated patch (don't use "matches" + add missing man
> page + rename keywords [1])  in the next hours.

Great.

>> Nit: I would prefix all of these with "tun_".
> "tun_" or just "tun" ? please note that each flag can have a "no"
> prefix, so is it better
> 
> notuncsum
> notundf
> notunoam
> notuncrit
> 
> or
> 
> notun_csum
> notun_df
> notun_oam
> notun_crit
> 
> ?
> 
> (I'm for not using the underscore - but I'm open to ideas: please let me know)

I'm fine with no underscores, alternatively recognizing both "no" and "no_" prefixes.
diff mbox series

Patch

diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
index 3e47e123934d4..c3fce070b9129 100644
--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -7,6 +7,7 @@ 
 #include <linux/siphash.h>
 #include <linux/string.h>
 #include <uapi/linux/if_ether.h>
+#include <uapi/linux/pkt_cls.h>
 
 struct bpf_prog;
 struct net;
@@ -24,9 +25,16 @@  struct flow_dissector_key_control {
 	u32	flags;
 };
 
-#define FLOW_DIS_IS_FRAGMENT	BIT(0)
-#define FLOW_DIS_FIRST_FRAG	BIT(1)
-#define FLOW_DIS_ENCAPSULATION	BIT(2)
+/* The control flags are kept in sync with TCA_FLOWER_KEY_FLAGS_*, as those
+ * flags are exposed to userspace in some error paths, ie. unsupported flags.
+ */
+enum flow_dissector_ctrl_flags {
+	FLOW_DIS_IS_FRAGMENT		= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT,
+	FLOW_DIS_FIRST_FRAG		= TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST,
+
+	/* These flags are internal to the kernel */
+	FLOW_DIS_ENCAPSULATION		= (TCA_FLOWER_KEY_FLAGS_MAX << 1),
+};
 
 enum flow_dissect_ret {
 	FLOW_DISSECT_RET_OUT_GOOD,
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index b6d38f5fd7c05..12db276f0c11e 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -677,8 +677,11 @@  enum {
 enum {
 	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
 	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
+	__TCA_FLOWER_KEY_FLAGS_MAX,
 };
 
+#define TCA_FLOWER_KEY_FLAGS_MAX (__TCA_FLOWER_KEY_FLAGS_MAX - 1)
+
 enum {
 	TCA_FLOWER_KEY_CFM_OPT_UNSPEC,
 	TCA_FLOWER_KEY_CFM_MD_LEVEL,