Skip to content

Commit 6e5c85c

Browse files
Asbjørn Sloth Tønnesenkuba-moo
authored andcommitted
net/sched: flower: refactor control flag definitions
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 <[email protected]> Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]> Reviewed-by: Davide Caratti <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ba7a0f4 commit 6e5c85c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

include/net/flow_dissector.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/siphash.h>
88
#include <linux/string.h>
99
#include <uapi/linux/if_ether.h>
10+
#include <uapi/linux/pkt_cls.h>
1011

1112
struct bpf_prog;
1213
struct net;
@@ -24,9 +25,16 @@ struct flow_dissector_key_control {
2425
u32 flags;
2526
};
2627

27-
#define FLOW_DIS_IS_FRAGMENT BIT(0)
28-
#define FLOW_DIS_FIRST_FRAG BIT(1)
29-
#define FLOW_DIS_ENCAPSULATION BIT(2)
28+
/* The control flags are kept in sync with TCA_FLOWER_KEY_FLAGS_*, as those
29+
* flags are exposed to userspace in some error paths, ie. unsupported flags.
30+
*/
31+
enum flow_dissector_ctrl_flags {
32+
FLOW_DIS_IS_FRAGMENT = TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT,
33+
FLOW_DIS_FIRST_FRAG = TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST,
34+
35+
/* These flags are internal to the kernel */
36+
FLOW_DIS_ENCAPSULATION = (TCA_FLOWER_KEY_FLAGS_MAX << 1),
37+
};
3038

3139
enum flow_dissect_ret {
3240
FLOW_DISSECT_RET_OUT_GOOD,

include/uapi/linux/pkt_cls.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,11 @@ enum {
677677
enum {
678678
TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
679679
TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
680+
__TCA_FLOWER_KEY_FLAGS_MAX,
680681
};
681682

683+
#define TCA_FLOWER_KEY_FLAGS_MAX (__TCA_FLOWER_KEY_FLAGS_MAX - 1)
684+
682685
enum {
683686
TCA_FLOWER_KEY_CFM_OPT_UNSPEC,
684687
TCA_FLOWER_KEY_CFM_MD_LEVEL,

0 commit comments

Comments
 (0)