Skip to content

Commit fcb4bb0

Browse files
Asbjørn Sloth Tønnesenkuba-moo
authored andcommitted
net/sched: cls_flower: prepare fl_{set,dump}_key_flags() for ENC_FLAGS
Prepare fl_set_key_flags/fl_dump_key_flags() for use with TCA_FLOWER_KEY_ENC_FLAGS{,_MASK}. This patch adds an encap argument, similar to fl_set_key_ip/ fl_dump_key_ip(), and determine the flower keys based on the encap argument, and use them in the rest of the two functions. Since these functions are so far, only called with encap set false, then there is no functional change. Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]> Tested-by: Davide Caratti <[email protected]> Reviewed-by: Davide Caratti <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bfda5a6 commit fcb4bb0

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

net/sched/cls_flower.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,19 +1166,28 @@ static void fl_set_key_flag(u32 flower_key, u32 flower_mask,
11661166
}
11671167
}
11681168

1169-
static int fl_set_key_flags(struct nlattr **tb, u32 *flags_key,
1169+
static int fl_set_key_flags(struct nlattr **tb, bool encap, u32 *flags_key,
11701170
u32 *flags_mask, struct netlink_ext_ack *extack)
11711171
{
1172+
int fl_key, fl_mask;
11721173
u32 key, mask;
11731174

1175+
if (encap) {
1176+
fl_key = TCA_FLOWER_KEY_ENC_FLAGS;
1177+
fl_mask = TCA_FLOWER_KEY_ENC_FLAGS_MASK;
1178+
} else {
1179+
fl_key = TCA_FLOWER_KEY_FLAGS;
1180+
fl_mask = TCA_FLOWER_KEY_FLAGS_MASK;
1181+
}
1182+
11741183
/* mask is mandatory for flags */
1175-
if (!tb[TCA_FLOWER_KEY_FLAGS_MASK]) {
1184+
if (NL_REQ_ATTR_CHECK(extack, NULL, tb, fl_mask)) {
11761185
NL_SET_ERR_MSG(extack, "Missing flags mask");
11771186
return -EINVAL;
11781187
}
11791188

1180-
key = be32_to_cpu(nla_get_be32(tb[TCA_FLOWER_KEY_FLAGS]));
1181-
mask = be32_to_cpu(nla_get_be32(tb[TCA_FLOWER_KEY_FLAGS_MASK]));
1189+
key = be32_to_cpu(nla_get_be32(tb[fl_key]));
1190+
mask = be32_to_cpu(nla_get_be32(tb[fl_mask]));
11821191

11831192
*flags_key = 0;
11841193
*flags_mask = 0;
@@ -2086,7 +2095,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
20862095
return ret;
20872096

20882097
if (tb[TCA_FLOWER_KEY_FLAGS]) {
2089-
ret = fl_set_key_flags(tb, &key->control.flags,
2098+
ret = fl_set_key_flags(tb, false, &key->control.flags,
20902099
&mask->control.flags, extack);
20912100
if (ret)
20922101
return ret;
@@ -3084,12 +3093,22 @@ static void fl_get_key_flag(u32 dissector_key, u32 dissector_mask,
30843093
}
30853094
}
30863095

3087-
static int fl_dump_key_flags(struct sk_buff *skb, u32 flags_key, u32 flags_mask)
3096+
static int fl_dump_key_flags(struct sk_buff *skb, bool encap,
3097+
u32 flags_key, u32 flags_mask)
30883098
{
3089-
u32 key, mask;
3099+
int fl_key, fl_mask;
30903100
__be32 _key, _mask;
3101+
u32 key, mask;
30913102
int err;
30923103

3104+
if (encap) {
3105+
fl_key = TCA_FLOWER_KEY_ENC_FLAGS;
3106+
fl_mask = TCA_FLOWER_KEY_ENC_FLAGS_MASK;
3107+
} else {
3108+
fl_key = TCA_FLOWER_KEY_FLAGS;
3109+
fl_mask = TCA_FLOWER_KEY_FLAGS_MASK;
3110+
}
3111+
30933112
if (!memchr_inv(&flags_mask, 0, sizeof(flags_mask)))
30943113
return 0;
30953114

@@ -3105,11 +3124,11 @@ static int fl_dump_key_flags(struct sk_buff *skb, u32 flags_key, u32 flags_mask)
31053124
_key = cpu_to_be32(key);
31063125
_mask = cpu_to_be32(mask);
31073126

3108-
err = nla_put(skb, TCA_FLOWER_KEY_FLAGS, 4, &_key);
3127+
err = nla_put(skb, fl_key, 4, &_key);
31093128
if (err)
31103129
return err;
31113130

3112-
return nla_put(skb, TCA_FLOWER_KEY_FLAGS_MASK, 4, &_mask);
3131+
return nla_put(skb, fl_mask, 4, &_mask);
31133132
}
31143133

31153134
static int fl_dump_key_geneve_opt(struct sk_buff *skb,
@@ -3632,7 +3651,8 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
36323651
if (fl_dump_key_ct(skb, &key->ct, &mask->ct))
36333652
goto nla_put_failure;
36343653

3635-
if (fl_dump_key_flags(skb, key->control.flags, mask->control.flags))
3654+
if (fl_dump_key_flags(skb, false, key->control.flags,
3655+
mask->control.flags))
36363656
goto nla_put_failure;
36373657

36383658
if (fl_dump_key_val(skb, &key->hash.hash, TCA_FLOWER_KEY_HASH,

0 commit comments

Comments
 (0)