Commit 11036bd7 authored by Asbjørn Sloth Tønnesen's avatar Asbjørn Sloth Tønnesen Committed by Jakub Kicinski

net/sched: cls_flower: rework TCA_FLOWER_KEY_ENC_FLAGS usage

This patch changes how TCA_FLOWER_KEY_ENC_FLAGS is used, so that
it is used with TCA_FLOWER_KEY_FLAGS_* flags, in the same way as
TCA_FLOWER_KEY_FLAGS is currently used.

Where TCA_FLOWER_KEY_FLAGS uses {key,mask}->control.flags, then
TCA_FLOWER_KEY_ENC_FLAGS now uses {key,mask}->enc_control.flags,
therefore {key,mask}->enc_flags is now unused.

As the generic fl_set_key_flags/fl_dump_key_flags() is used with
encap set to true, then fl_{set,dump}_key_enc_flags() is removed.

This breaks unreleased userspace API (net-next since 2024-06-04).
Signed-off-by: default avatarAsbjørn Sloth Tønnesen <ast@fiberby.net>
Tested-by: default avatarDavide Caratti <dcaratti@redhat.com>
Reviewed-by: default avatarDavide Caratti <dcaratti@redhat.com>
Link: https://patch.msgid.link/20240713021911.1631517-10-ast@fiberby.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 988f8723
...@@ -554,8 +554,8 @@ enum { ...@@ -554,8 +554,8 @@ enum {
TCA_FLOWER_KEY_SPI, /* be32 */ TCA_FLOWER_KEY_SPI, /* be32 */
TCA_FLOWER_KEY_SPI_MASK, /* be32 */ TCA_FLOWER_KEY_SPI_MASK, /* be32 */
TCA_FLOWER_KEY_ENC_FLAGS, /* u32 */ TCA_FLOWER_KEY_ENC_FLAGS, /* be32 */
TCA_FLOWER_KEY_ENC_FLAGS_MASK, /* u32 */ TCA_FLOWER_KEY_ENC_FLAGS_MASK, /* be32 */
__TCA_FLOWER_MAX, __TCA_FLOWER_MAX,
}; };
......
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
(TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT | \ (TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT | \
TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST) TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST)
#define TUNNEL_FLAGS_PRESENT (\ #define TCA_FLOWER_KEY_ENC_FLAGS_POLICY_MASK \
_BITUL(IP_TUNNEL_CSUM_BIT) | \ (TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM | \
_BITUL(IP_TUNNEL_DONT_FRAGMENT_BIT) | \ TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT | \
_BITUL(IP_TUNNEL_OAM_BIT) | \ TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM | \
_BITUL(IP_TUNNEL_CRIT_OPT_BIT)) TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT)
struct fl_flow_key { struct fl_flow_key {
struct flow_dissector_key_meta meta; struct flow_dissector_key_meta meta;
...@@ -745,10 +745,10 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = { ...@@ -745,10 +745,10 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
[TCA_FLOWER_KEY_SPI_MASK] = { .type = NLA_U32 }, [TCA_FLOWER_KEY_SPI_MASK] = { .type = NLA_U32 },
[TCA_FLOWER_L2_MISS] = NLA_POLICY_MAX(NLA_U8, 1), [TCA_FLOWER_L2_MISS] = NLA_POLICY_MAX(NLA_U8, 1),
[TCA_FLOWER_KEY_CFM] = { .type = NLA_NESTED }, [TCA_FLOWER_KEY_CFM] = { .type = NLA_NESTED },
[TCA_FLOWER_KEY_ENC_FLAGS] = NLA_POLICY_MASK(NLA_U32, [TCA_FLOWER_KEY_ENC_FLAGS] = NLA_POLICY_MASK(NLA_BE32,
TUNNEL_FLAGS_PRESENT), TCA_FLOWER_KEY_ENC_FLAGS_POLICY_MASK),
[TCA_FLOWER_KEY_ENC_FLAGS_MASK] = NLA_POLICY_MASK(NLA_U32, [TCA_FLOWER_KEY_ENC_FLAGS_MASK] = NLA_POLICY_MASK(NLA_BE32,
TUNNEL_FLAGS_PRESENT), TCA_FLOWER_KEY_ENC_FLAGS_POLICY_MASK),
}; };
static const struct nla_policy static const struct nla_policy
...@@ -1866,21 +1866,6 @@ static int fl_set_key_cfm(struct nlattr **tb, ...@@ -1866,21 +1866,6 @@ static int fl_set_key_cfm(struct nlattr **tb,
return 0; return 0;
} }
static int fl_set_key_enc_flags(struct nlattr **tb, u32 *flags_key,
u32 *flags_mask, struct netlink_ext_ack *extack)
{
/* mask is mandatory for flags */
if (NL_REQ_ATTR_CHECK(extack, NULL, tb, TCA_FLOWER_KEY_ENC_FLAGS_MASK)) {
NL_SET_ERR_MSG(extack, "missing enc_flags mask");
return -EINVAL;
}
*flags_key = nla_get_u32(tb[TCA_FLOWER_KEY_ENC_FLAGS]);
*flags_mask = nla_get_u32(tb[TCA_FLOWER_KEY_ENC_FLAGS_MASK]);
return 0;
}
static int fl_set_key(struct net *net, struct nlattr **tb, static int fl_set_key(struct net *net, struct nlattr **tb,
struct fl_flow_key *key, struct fl_flow_key *mask, struct fl_flow_key *key, struct fl_flow_key *mask,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
...@@ -2123,8 +2108,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb, ...@@ -2123,8 +2108,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
} }
if (tb[TCA_FLOWER_KEY_ENC_FLAGS]) if (tb[TCA_FLOWER_KEY_ENC_FLAGS])
ret = fl_set_key_enc_flags(tb, &key->enc_flags.flags, ret = fl_set_key_flags(tb, true, &key->enc_control.flags,
&mask->enc_flags.flags, extack); &mask->enc_control.flags, extack);
return ret; return ret;
} }
...@@ -3381,22 +3366,6 @@ static int fl_dump_key_cfm(struct sk_buff *skb, ...@@ -3381,22 +3366,6 @@ static int fl_dump_key_cfm(struct sk_buff *skb,
return err; return err;
} }
static int fl_dump_key_enc_flags(struct sk_buff *skb,
struct flow_dissector_key_enc_flags *key,
struct flow_dissector_key_enc_flags *mask)
{
if (!memchr_inv(mask, 0, sizeof(*mask)))
return 0;
if (nla_put_u32(skb, TCA_FLOWER_KEY_ENC_FLAGS, key->flags))
return -EMSGSIZE;
if (nla_put_u32(skb, TCA_FLOWER_KEY_ENC_FLAGS_MASK, mask->flags))
return -EMSGSIZE;
return 0;
}
static int fl_dump_key_options(struct sk_buff *skb, int enc_opt_type, static int fl_dump_key_options(struct sk_buff *skb, int enc_opt_type,
struct flow_dissector_key_enc_opts *enc_opts) struct flow_dissector_key_enc_opts *enc_opts)
{ {
...@@ -3699,7 +3668,8 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net, ...@@ -3699,7 +3668,8 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
if (fl_dump_key_cfm(skb, &key->cfm, &mask->cfm)) if (fl_dump_key_cfm(skb, &key->cfm, &mask->cfm))
goto nla_put_failure; goto nla_put_failure;
if (fl_dump_key_enc_flags(skb, &key->enc_flags, &mask->enc_flags)) if (fl_dump_key_flags(skb, true, key->enc_control.flags,
mask->enc_control.flags))
goto nla_put_failure; goto nla_put_failure;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment