Skip to contentSkip to conversation

flow_dissector, cls_flower: Add support for multiple MPLS Label Stack Entries

PATCH Superseded Guillaume Nault 2 participants 6 messages May 20, 2020 – May 21, 2020

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover flow_dissector, cls_flower: Add support for multiple MPLS Label Stack Entries

Currently, the flow dissector and the Flower classifier can only handle the first entry of an MPLS label stack. This patch series generalises the code to allow parsing and matching the labels that follow.

Patch 1 extends the flow dissector to parse MPLS LSEs until the Bottom Of Stack bit is reached. The number of parsed LSEs is capped at FLOW_DIS_MPLS_MAX (arbitrarily set to 7).

Patch 2 extends Flower. It defines new netlink attributes, which are independent from the previous MPLS ones. Mixing the old and the new attributes in a same filter is not allowed. For backward compatibility, the old attributes are used when dumping filters that don't require the new ones.

Guillaume Nault (2):
flow_dissector: Parse multiple MPLS Label Stack Entries
cls_flower: Support filtering on multiple MPLS Label Stack Entries

 include/net/flow_dissector.h |  14 +-
 include/uapi/linux/pkt_cls.h |  23 +++
 net/core/flow_dissector.c    |  49 ++++--
 net/sched/cls_flower.c       | 295 +++++++++++++++++++++++++++++++++--
 4 files changed, 347 insertions(+), 34 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH 1/2 flow_dissector: Parse multiple MPLS Label Stack Entries

The current MPLS dissector only parses the first MPLS Label Stack Entry (second LSE can be parsed too, but only to set a key_id).

This patch adds the possibility to parse several LSEs by making __skb_flow_dissect_mpls() return FLOW_DISSECT_RET_PROTO_AGAIN as long as the Bottom Of Stack bit hasn't been seen, up to a maximum of FLOW_DIS_MPLS_MAX entries.

FLOW_DIS_MPLS_MAX is arbitrarily set to 7. This should be enough for many practical purposes, without wasting too much space.

To record the parsed values, flow_dissector_key_mpls is modified to store an array of stack entries, instead of just the values of the first one. A bit field, "used_lses", is also added to keep track of the LSEs that have been set. The objective is to avoid defining a new FLOW_DISSECTOR_KEY_MPLS_XX for each level of the MPLS stack.

TC flower, which is the only user of FLOW_DISSECTOR_KEY_MPLS, is adapted for the new struct flow_dissector_key_mpls layout. Matching on several MPLS Label Stack Entries will be added in the next patch.

Finally, the behaviour of the FLOW_DISSECTOR_KEY_MPLS_ENTROPY key is slightly modified. Instead of recording the first Entropy Label, it now records the last one. This shouldn't have any consequences since there doesn't seem to have any user of FLOW_DISSECTOR_KEY_MPLS_ENTROPY in the tree. We'd probably better do a hash of all parsed MPLS labels instead (excluding reserved labels) anyway. That'd give better entropy and would probably also simplify the code. But that's not the purpose of this patch, so I'm keeping that as a future exercise.

---
 include/net/flow_dissector.h | 14 +++++++++-
 net/core/flow_dissector.c    | 49 ++++++++++++++++++++++-----------
 net/sched/cls_flower.c       | 52 +++++++++++++++++++++++++-----------
 3 files changed, 82 insertions(+), 33 deletions(-)
include/net/flow_dissector.h +13 -1
index 628383915827..4fb1a69c6ecf 100644
@@ -59,13 +59,25 @@ struct flow_dissector_key_vlan {
 	__be16	vlan_tpid;
 };
 
-struct flow_dissector_key_mpls {
+struct flow_dissector_mpls_lse {
 	u32	mpls_ttl:8,
 		mpls_bos:1,
 		mpls_tc:3,
 		mpls_label:20;
 };
 
+#define FLOW_DIS_MPLS_MAX 7
+struct flow_dissector_key_mpls {
+	struct flow_dissector_mpls_lse ls[FLOW_DIS_MPLS_MAX]; /* Label Stack */
+	u8 used_lses; /* One bit set for each Label Stack Entry in use */
+};
+
+static inline void dissector_set_mpls_lse(struct flow_dissector_key_mpls *mpls,
+					  int lse_index)
+{
+	mpls->used_lses |= 1 << lse_index;
+}
+
 #define FLOW_DIS_TUN_OPTS_MAX 255
 /**
  * struct flow_dissector_key_enc_opts:
net/core/flow_dissector.c +33 -16

93 lines not on this page · raw message

net/sched/cls_flower.c +36 -16

100 lines not on this page · raw message

Signature · 1 line
2.21.1
#2 lore raw

Re: [PATCH net-next 1/2] flow_dissector: Parse multiple MPLS Label Stack Entries

Thank you for the patch! Yet something to improve:

Hi Guillaume,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on net/master sparc-next/master linus/master v5.7-rc6 next-20200519] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Guillaume-Nault/flow_dissector-cls_flower-Add-support-for-multiple-MPLS-Label-Stack-Entries/20200521-052254
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4f65e2f483b6f764c15094d14dd53dda048a4048
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:
drivers/net/ethernet/netronome/nfp/flower/match.c: In function 'nfp_flower_compile_mac':

>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:57: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'

100 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:100:12: note: in expansion of macro 'FIELD_PREP'
100 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
| ^~~~~~~~~~

>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:57: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'

100 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:100:12: note: in expansion of macro 'FIELD_PREP'
100 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
| ^~~~~~~~~~
In file included from drivers/net/ethernet/netronome/nfp/flower/match.c:4:

>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:57: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'

100 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
| ^~
include/linux/bitfield.h:95:20: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); | ^~~~
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:

>> drivers/net/ethernet/netronome/nfp/flower/match.c:101:50: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_tc'

101 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:101:5: note: in expansion of macro 'FIELD_PREP'
101 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
| ^~~~~~~~~~

>> drivers/net/ethernet/netronome/nfp/flower/match.c:101:50: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_tc'

101 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:101:5: note: in expansion of macro 'FIELD_PREP'
101 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
| ^~~~~~~~~~
In file included from drivers/net/ethernet/netronome/nfp/flower/match.c:4:

>> drivers/net/ethernet/netronome/nfp/flower/match.c:101:50: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_tc'

101 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
| ^~
include/linux/bitfield.h:95:20: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); | ^~~~
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:

>> drivers/net/ethernet/netronome/nfp/flower/match.c:102:51: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_bos'

102 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:102:5: note: in expansion of macro 'FIELD_PREP'
102 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
| ^~~~~~~~~~

>> drivers/net/ethernet/netronome/nfp/flower/match.c:102:51: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_bos'

102 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert' 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:102:5: note: in expansion of macro 'FIELD_PREP'
102 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
| ^~~~~~~~~~
In file included from drivers/net/ethernet/netronome/nfp/flower/match.c:4:

>> drivers/net/ethernet/netronome/nfp/flower/match.c:102:51: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_bos'

102 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
| ^~
include/linux/bitfield.h:95:20: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); | ^~~~
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:
drivers/net/ethernet/netronome/nfp/flower/match.c:105:58: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'
105 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:105:12: note: in expansion of macro 'FIELD_PREP'
105 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
| ^~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:105:58: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'
105 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:105:12: note: in expansion of macro 'FIELD_PREP'
105 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
| ^~~~~~~~~~
In file included from drivers/net/ethernet/netronome/nfp/flower/match.c:4:
drivers/net/ethernet/netronome/nfp/flower/match.c:105:58: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'
105 | t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
| ^~
include/linux/bitfield.h:95:20: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); | ^~~~
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:
drivers/net/ethernet/netronome/nfp/flower/match.c:106:51: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_tc'
106 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.mask->mpls_tc) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:106:5: note: in expansion of macro 'FIELD_PREP'
106 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.mask->mpls_tc) |
| ^~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:106:51: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_tc'
106 | FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.mask->mpls_tc) |
| ^~
include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
330 | if (!(condition)) | ^~~~~~~~~
include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? | ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); | ^~~~~~~~~~~~~~~~
drivers/net/ethernet/netronome/nfp/flower/match.c:106:5: note: in expansion of macro 'FIELD_PREP'

vim +100 drivers/net/ethernet/netronome/nfp/flower/match.c

5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   76  
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   77  static void
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   78  nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext,
31c491e56ad1ad John Hurley              2019-12-17   79  		       struct nfp_flower_mac_mpls *msk, struct flow_rule *rule)
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   80  {
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   81  	memset(ext, 0, sizeof(struct nfp_flower_mac_mpls));
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   82  	memset(msk, 0, sizeof(struct nfp_flower_mac_mpls));
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   83  
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   84  	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   85  		struct flow_match_eth_addrs match;
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   86  
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   87  		flow_rule_match_eth_addrs(rule, &match);
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   88  		/* Populate mac frame. */
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   89  		ether_addr_copy(ext->mac_dst, &match.key->dst[0]);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   90  		ether_addr_copy(ext->mac_src, &match.key->src[0]);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   91  		ether_addr_copy(msk->mac_dst, &match.mask->dst[0]);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   92  		ether_addr_copy(msk->mac_src, &match.mask->src[0]);
a7cd39e0c7805a Pieter Jansen van Vuuren 2017-08-25   93  	}
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29   94  
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   95  	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_MPLS)) {
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   96  		struct flow_match_mpls match;
bb055c198d9b2b Pieter Jansen van Vuuren 2017-10-06   97  		u32 t_mpls;
bb055c198d9b2b Pieter Jansen van Vuuren 2017-10-06   98  
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02   99  		flow_rule_match_mpls(rule, &match);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02 @100  		t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.key->mpls_label) |
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02 @101  			 FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.key->mpls_tc) |
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02 @102  			 FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.key->mpls_bos) |
bb055c198d9b2b Pieter Jansen van Vuuren 2017-10-06  103  			 NFP_FLOWER_MASK_MPLS_Q;
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  104  		ext->mpls_lse = cpu_to_be32(t_mpls);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  105  		t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, match.mask->mpls_label) |
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  106  			 FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, match.mask->mpls_tc) |
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  107  			 FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, match.mask->mpls_bos) |
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  108  			 NFP_FLOWER_MASK_MPLS_Q;
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  109  		msk->mpls_lse = cpu_to_be32(t_mpls);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  110  	} else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
a64119415ff248 Pieter Jansen van Vuuren 2018-06-25  111  		/* Check for mpls ether type and set NFP_FLOWER_MASK_MPLS_Q
a64119415ff248 Pieter Jansen van Vuuren 2018-06-25  112  		 * bit, which indicates an mpls ether type but without any
a64119415ff248 Pieter Jansen van Vuuren 2018-06-25  113  		 * mpls fields.
a64119415ff248 Pieter Jansen van Vuuren 2018-06-25  114  		 */
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  115  		struct flow_match_basic match;
a64119415ff248 Pieter Jansen van Vuuren 2018-06-25  116  
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  117  		flow_rule_match_basic(rule, &match);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  118  		if (match.key->n_proto == cpu_to_be16(ETH_P_MPLS_UC) ||
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  119  		    match.key->n_proto == cpu_to_be16(ETH_P_MPLS_MC)) {
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  120  			ext->mpls_lse = cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  121  			msk->mpls_lse = cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q);
8f2566225ae2d6 Pablo Neira Ayuso        2019-02-02  122  		}
bb055c198d9b2b Pieter Jansen van Vuuren 2017-10-06  123  	}
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29  124  }
5571e8c9f2419c Pieter Jansen van Vuuren 2017-06-29  125  

:::::: The code at line 100 was first introduced by commit
:::::: 8f2566225ae2d62d532bb1810ed74fa4bbc5bbdb flow_offload: add flow_rule and flow_match structures and use them

:::::: TO: Pablo Neira Ayuso <[email protected]> :::::: CC: David S. Miller <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH net-next 1/2] flow_dissector: Parse multiple MPLS Label Stack Entries

Quoted 8 lines · kbuild test robot

All errors (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/net/ethernet/netronome/nfp/flower/match.c:4:
drivers/net/ethernet/netronome/nfp/flower/match.c: In function 'nfp_flower_compile_mac':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/netronome/nfp/flower/match.c:100:57: error: 'struct flow_dissector_key_mpls' has no member named 'mpls_label'

Sorry, I didn't realise this was used by NFP.
I'll respin.

#4 lore raw

Re: [PATCH net-next 1/2] flow_dissector: Parse multiple MPLS Label Stack Entries

In reply to Guillaume Nault
Thank you for the patch! Perhaps something to improve:

Hi Guillaume,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master sparc-next/master linus/master v5.7-rc6 next-20200519] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Guillaume-Nault/flow_dissector-cls_flower-Add-support-for-multiple-MPLS-Label-Stack-Entries/20200521-052254
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4f65e2f483b6f764c15094d14dd53dda048a4048
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-193-gb8fad4bc-dirty
        # save the attached .config to linux build tree
        make C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate

sparse warnings: (new ones prefixed by >>)

drivers/net/ethernet/netronome/nfp/flower/match.c:100:26: sparse: sparse: no member 'mpls_label' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:100:26: sparse: sparse: no member 'mpls_label' in struct flow_dissector_key_mpls

>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:26: sparse: sparse: cast from unknown type
   drivers/net/ethernet/netronome/nfp/flower/match.c:101:26: sparse: sparse: no member 'mpls_tc' in struct flow_dissector_key_mpls
   drivers/net/ethernet/netronome/nfp/flower/match.c:101:26: sparse: sparse: no member 'mpls_tc' in struct flow_dissector_key_mpls
   drivers/net/ethernet/netronome/nfp/flower/match.c:101:26: sparse: sparse: cast from unknown type
>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:85: sparse: sparse: incompatible types for operation (|):
>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:85: sparse:    void
>> drivers/net/ethernet/netronome/nfp/flower/match.c:100:85: sparse:    void

drivers/net/ethernet/netronome/nfp/flower/match.c:102:26: sparse: sparse: no member 'mpls_bos' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:102:26: sparse: sparse: no member 'mpls_bos' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:102:26: sparse: sparse: cast from unknown type drivers/net/ethernet/netronome/nfp/flower/match.c:105:26: sparse: sparse: no member 'mpls_label' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:105:26: sparse: sparse: no member 'mpls_label' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:105:26: sparse: sparse: cast from unknown type drivers/net/ethernet/netronome/nfp/flower/match.c:106:26: sparse: sparse: no member 'mpls_tc' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:106:26: sparse: sparse: no member 'mpls_tc' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:106:26: sparse: sparse: cast from unknown type drivers/net/ethernet/netronome/nfp/flower/match.c:105:86: sparse: sparse: incompatible types for operation (|):
drivers/net/ethernet/netronome/nfp/flower/match.c:105:86: sparse: void
drivers/net/ethernet/netronome/nfp/flower/match.c:105:86: sparse: void
drivers/net/ethernet/netronome/nfp/flower/match.c:107:26: sparse: sparse: no member 'mpls_bos' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:107:26: sparse: sparse: no member 'mpls_bos' in struct flow_dissector_key_mpls drivers/net/ethernet/netronome/nfp/flower/match.c:107:26: sparse: sparse: cast from unknown type
--
net/core/flow_dissector.c:256:43: sparse: sparse: restricted __be16 degrades to integer

>> net/core/flow_dissector.c:514:34: sparse: sparse: incorrect type in assignment (different base types) @@    expected restricted __be32 [usertype] keyid @@    got unsignrestricted __be32 [usertype] keyid @@
>> net/core/flow_dissector.c:514:34: sparse:    expected restricted __be32 [usertype] keyid
>> net/core/flow_dissector.c:514:34: sparse:    got unsigned int [assigned] [usertype] label

vim +514 net/core/flow_dissector.c

463
464 static enum flow_dissect_ret
465 __skb_flow_dissect_mpls(const struct sk_buff *skb,
466 struct flow_dissector *flow_dissector,
467 void *target_container, void *data, int nhoff, int hlen,
468 int lse_index, bool *entropy_label)
469 {
470 struct mpls_label *hdr, _hdr;
471 u32 entry, label, bos;
472
473 if (!dissector_uses_key(flow_dissector,
474 FLOW_DISSECTOR_KEY_MPLS_ENTROPY) &&
475 !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS))
476 return FLOW_DISSECT_RET_OUT_GOOD;
477
478 if (lse_index >= FLOW_DIS_MPLS_MAX)
479 return FLOW_DISSECT_RET_OUT_GOOD;
480
481 hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
482 hlen, &_hdr);
483 if (!hdr)
484 return FLOW_DISSECT_RET_OUT_BAD;
485
486 entry = ntohl(hdr->entry);
487 label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT;
488 bos = (entry & MPLS_LS_S_MASK) >> MPLS_LS_S_SHIFT;
489
490 if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_MPLS)) {
491 struct flow_dissector_key_mpls *key_mpls;
492 struct flow_dissector_mpls_lse *lse;
493
494 key_mpls = skb_flow_dissector_target(flow_dissector,
495 FLOW_DISSECTOR_KEY_MPLS,
496 target_container);
497 lse = &key_mpls->ls[lse_index];
498
499 lse->mpls_ttl = (entry & MPLS_LS_TTL_MASK) >> MPLS_LS_TTL_SHIFT;
500 lse->mpls_bos = bos;
501 lse->mpls_tc = (entry & MPLS_LS_TC_MASK) >> MPLS_LS_TC_SHIFT;
502 lse->mpls_label = label;
503 dissector_set_mpls_lse(key_mpls, lse_index);
504 }
505
506 if (*entropy_label &&
507 dissector_uses_key(flow_dissector,
508 FLOW_DISSECTOR_KEY_MPLS_ENTROPY)) {
509 struct flow_dissector_key_keyid *key_keyid;
510
511 key_keyid = skb_flow_dissector_target(flow_dissector,
512 FLOW_DISSECTOR_KEY_MPLS_ENTROPY,
513 target_container);

 > 514			key_keyid->keyid = label;

515 }
516
517 *entropy_label = label == MPLS_LABEL_ENTROPY;
518
519 return bos ? FLOW_DISSECT_RET_OUT_GOOD : FLOW_DISSECT_RET_PROTO_AGAIN;
520 }
521

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw

PATCH 2/2 cls_flower: Support filtering on multiple MPLS Label Stack Entries

In reply to Guillaume Nault

With struct flow_dissector_key_mpls now recording the first FLOW_DIS_MPLS_MAX labels, we can extend Flower to filter on any of these LSEs independently.

In order to avoid creating new netlink attributes for every possible depth, let's define a new TCA_FLOWER_KEY_MPLS_OPTS nested attribute that contains the list of LSEs to match. Each LSE is represented by another attribute, TCA_FLOWER_KEY_MPLS_OPTS_LSE, which then contains the attributes representing the depth and the MPLS fields to match at this depth (label, TTL, etc.).

For each MPLS field, the mask is always set to all-ones, as this is what the original API did. We could allow user configurable masks in the future if there is demand for more flexibility.

The new API also allows to only specify an LSE depth. In that case, Flower only verifies that the MPLS label stack depth is greater or equal to the provided depth (that is, an LSE exists at this depth).

Filters that only match on one (or more) fields of the first LSE are dumped using the old netlink attributes, to avoid confusing user space programs that don't understand the new API.

---
 include/uapi/linux/pkt_cls.h |  23 ++++
 net/sched/cls_flower.c       | 243 ++++++++++++++++++++++++++++++++++-
 2 files changed, 265 insertions(+), 1 deletion(-)
include/uapi/linux/pkt_cls.h +23 -0
index fc672b232437..7576209d96f9 100644
@@ -576,6 +576,8 @@ enum {
 	TCA_FLOWER_KEY_CT_LABELS,	/* u128 */
 	TCA_FLOWER_KEY_CT_LABELS_MASK,	/* u128 */
 
+	TCA_FLOWER_KEY_MPLS_OPTS,
+
 	__TCA_FLOWER_MAX,
 };
 
@@ -640,6 +642,27 @@ enum {
 #define TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX \
 		(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)
 
+enum {
+	TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
+	TCA_FLOWER_KEY_MPLS_OPTS_LSE,
+	__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
+};
+
+#define TCA_FLOWER_KEY_MPLS_OPTS_MAX (__TCA_FLOWER_KEY_MPLS_OPTS_MAX - 1)
+
+enum {
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_UNSPEC,
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH,
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL,
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS,
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_TC,
+	TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL,
+	__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX,
+};
+
+#define TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX \
+		(__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX - 1)
+
 enum {
 	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
 	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
net/sched/cls_flower.c +242 -1

284 lines not on this page · raw message

Signature · 1 line
2.21.1