introduce Geneve options support in TC tunnel key
Subsystems (3)
cover introduce Geneve options support in TC tunnel key
Hi all,
This set adds Geneve options support to the TC tunnel key action. Options TLVs are exposed to userspace using a list of netlink attributes with each option described using attributes for class, type and data.
The series also enhances the tunnel key action to use extended ack.
Simon Horman (3):
net/sched: act_tunnel_key: disambiguate metadata dst error cases net/sched: act_tunnel_key: add extended ack support net/sched: add tunnel option support to act_tunnel_key
include/uapi/linux/tc_act/tc_tunnel_key.h | 26 ++++ net/sched/act_tunnel_key.c | 212 ++++++++++++++++++++++++++++-- 2 files changed, 230 insertions(+), 8 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/3 net/sched: act_tunnel_key: disambiguate metadata dst error cases
Metadata may be NULL for one of two reasons:
* Missing user input
* Failure to allocate the metadata dst
Disambiguate these case by returning -EINVAL for the former and -ENOMEM for the latter rather than -EINVAL for both cases.
This is in preparation for using extended ack to provide more information to users when parsing their input.
--- net/sched/act_tunnel_key.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sched/act_tunnel_key.c +4 -1
@@ -143,10 +143,13 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, metadata =__ipv6_tun_set_dst (&saddr, &daddr,0 ,0 , dst_port,0 , flags, key_id,0 ); + }else { + ret = -EINVAL ; + goto err_out; }if (!metadata) { - ret = -EINVAL ; + ret = -ENOMEM ; goto err_out; }
Signature · 1 line
2.11.0
PATCH 2/3 net/sched: act_tunnel_key: add extended ack support
In reply to Simon HormanAdd extended ack support for the tunnel key action by using NL_SET_ERR_MSG during validation of user input.
--- net/sched/act_tunnel_key.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/sched/act_tunnel_key.c +6 -2
@@ -90,12 +90,14 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,return -EINVAL ; err =nla_parse_nested (tb,TCA_TUNNEL_KEY_MAX , nla, tunnel_key_policy, -NULL ); + extack);if (err <0 )return err; -if (!tb[TCA_TUNNEL_KEY_PARMS ]) +if (!tb[TCA_TUNNEL_KEY_PARMS ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key parameter" );return -EINVAL ; + } parm =nla_data (tb[TCA_TUNNEL_KEY_PARMS ]); exists =tcf_idr_check (tn, parm->index, a, bind);
@@ -107,6 +109,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,break ;case TCA_TUNNEL_KEY_ACT_SET :if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key enc id" ); ret = -EINVAL ; goto err_out; }
@@ -144,6 +147,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,0 , flags, key_id, 0); }else { +NL_SET_ERR_MSG (extack,"Missing both ipv4 and ipv6 enc src and dst" ); ret = -EINVAL ; goto err_out; }
Signature · 1 line
2.11.0
PATCH 3/3 net/sched: add tunnel option support to act_tunnel_key
In reply to Simon HormanAllow setting tunnel options using the act_tunnel_key action.
Options are expressed as class:type:data and multiple options may be listed using a comma delimiter.
# ip link add name geneve0 type geneve dstport 0 external
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 protocol ip parent ffff: \
flower indev eth0 \
ip_proto udp \
action tunnel_key \
set src_ip 10.0.99.192 \
dst_ip 10.0.99.193 \
dst_port 6081 \
id 11 \
geneve_opts 0102:80:00800022,0102:80:00800022 \
action mirred egress redirect dev geneve0--- include/uapi/linux/tc_act/tc_tunnel_key.h | 26 ++++ net/sched/act_tunnel_key.c | 199 +++++++++++++++++++++++++++++- 2 files changed, 220 insertions(+), 5 deletions(-)
include/uapi/linux/tc_act/tc_tunnel_key.h +26 -0
@@ -36,9 +36,35 @@ enum {TCA_TUNNEL_KEY_PAD ,TCA_TUNNEL_KEY_ENC_DST_PORT ,/* be16 */ TCA_TUNNEL_KEY_NO_CSUM ,/* u8 */ +TCA_TUNNEL_KEY_ENC_OPTS ,/* Nested TCA_TUNNEL_KEY_ENC_OPTS_ +* attributes +*/ __TCA_TUNNEL_KEY_MAX, };#define TCA_TUNNEL_KEY_MAX (__TCA_TUNNEL_KEY_MAX - 1) +enum { +TCA_TUNNEL_KEY_ENC_OPTS_UNSPEC , +TCA_TUNNEL_KEY_ENC_OPTS_GENEVE ,/* Nested +* TCA_TUNNEL_KEY_ENC_OPTS_ +* attributes +*/ + __TCA_TUNNEL_KEY_ENC_OPTS_MAX, +}; + +#define TCA_TUNNEL_KEY_ENC_OPTS_MAX (__TCA_TUNNEL_KEY_ENC_OPTS_MAX - 1) + +enum { +TCA_TUNNEL_KEY_ENC_OPT_GENEVE_UNSPEC , +TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS ,/* u16 */ +TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE ,/* u8 */ +TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ,/* 4 to 128 bytes */ + + __TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX, +}; + +#define TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX \ + (__TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX - 1) +#endif
net/sched/act_tunnel_key.c +194 -5
265 lines not on this page · raw message
Signature · 1 line
2.11.0
Quoted 5 lines · Simon Horman
Hi all,
This set adds Geneve options support to the TC tunnel key action. Options TLVs are exposed to userspace using a list of netlink attributes with each option described using attributes for class, type and data.
can you comment re what are the change vs your earlier post (will appreciate an arch link to the thread..)
Quoted 15 lines
The series also enhances the tunnel key action to use extended ack.
Simon Horman (3):
net/sched:act_tunnel_key: disambiguate metadata dst error cases net/sched:act_tunnel_key: add extended ack support net/sched: add tunnel option support toact_tunnel_keyinclude/uapi/linux/tc_act/tc_tunnel_key.h | 26 ++++ net/sched/act_tunnel_key.c | 212 ++++++++++++++++++++++++++++-- 2 files changed, 230 insertions(+), 8 deletions(-)--
2.11.0
Quoted 9 lines · Or Gerlitz
Quoted 5 lines · Simon Horman
Hi all,
This set adds Geneve options support to the TC tunnel key action. Options TLVs are exposed to userspace using a list of netlink attributes with each option described using attributes for class, type and data.
can you comment re what are the change vs your earlier post (will appreciate an arch link to the thread..)
The main change is that the netlink interface exposes netlink attribute for the class, type and data of each option, rather than a single attribute that describes all options as a byte-string.
I believe the previous discussion is here:
https://www.spinics.net/lists/netdev/msg457058.html
Re: [PATCH/RFC 2/3] net/sched: act_tunnel_key: add extended ack support
In reply to Simon Hormannet/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 98
Quoted 3 lines · Simon Horman
net/sched/act_tunnel_key.c +2
-1-if (!tb[TCA_TUNNEL_KEY_PARMS ]) +if (!tb[TCA_TUNNEL_KEY_PARMS ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key parameter" );
"parameters" (it's not just one parameter)
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 112
Quoted 5 lines
net/sched/act_tunnel_key.c +1
-0@@ -107,6 +109,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,break ;case TCA_TUNNEL_KEY_ACT_SET :if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key enc id" );
This is not much helpful to the user. What's "enc"? I guess "Missing tunnel key id" would be enough and better.
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 150
Quoted 5 lines
net/sched/act_tunnel_key.c +1
-0@@ -144,6 +147,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,0 , flags, key_id, 0); }else { +NL_SET_ERR_MSG (extack,"Missing both ipv4 and ipv6 enc src and dst" );
We don't need both but only one of them. And again, "enc" does not have a clear meaning.
"Missing either IPv4 or IPv6 source and destination address"?
In addition, it makes little sense to me to add extacks to just some of the errors in the tunnel_key_init function. Please add extacks to all of them.
Thanks,
Jiri
Re: [PATCH/RFC 3/3] net/sched: add tunnel option support to act_tunnel_key
In reply to Simon HormanQuoted 7 lines · Simon Horman
net/sched/act_tunnel_key.c +7
-0+static int +tunnel_key_copy_geneve_opt (const struct nlattr *nla,int dst_len,void *dst, +struct netlink_ext_ack *extack) +{ +struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX +1 ]; +int err, data_len, opt_len; +u8 *data;
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 90
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+ + err =nla_parse_nested (tb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX , + nla, geneve_opt_policy, extack); +if (err <0 ) +return err; + +if (!tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS ] || + !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE ] || + !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key enc geneve option class, type or data" );
I think it's obvious by now that I don't like the "enc" :-)
Quoted 11 lines
net/sched/act_tunnel_key.c +11
-0+return -EINVAL ; + } + + data =nla_data (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]); + data_len =nla_len (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]); +if (data_len <4 ) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data is less than 4 bytes long" ); +return -ERANGE ; + } +if (data_len %4 ) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data is not a multiple of 4 bytes long" );
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 111
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+return -ERANGE ; + } + + opt_len =sizeof (struct geneve_opt ) + data_len; +if (dst) { +struct geneve_opt *opt = dst; +u16 class; + +if (dst_len < opt_len) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data length is longer than the supplied data" );
I don't understand this error. What can the user do about it? Furthermore, the error is not propagated to the user space (see also below).
Shouldn't this be WARN_ON or something?
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 116
Quoted 5 lines
net/sched/act_tunnel_key.c +5
-0+return -EINVAL ; + } + + class =nla_get_u16 (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS ]); +put_unaligned_be16 (class, &opt->opt_class);
How this can be unaligned, given we check that the option length is a multiple of 4 bytes and the option header is 4 bytes?
Quoted 5 lines
net/sched/act_tunnel_key.c +5
-0+ + opt->type =nla_get_u8 (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE ]); + opt->length = data_len /4 ;/* length is in units of 4 bytes */ + opt->r1 =0 ; + opt->r2 =0 ;
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 131
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+ opt->r3 =0 ; + +memcpy (opt +1 , data, data_len); + } + +return opt_len; +} + +static int tunnel_key_copy_opts (const struct nlattr *nla,u8 *dst, +int dst_len,struct netlink_ext_ack *extack)
Please be consistent with parameter ordering, dst and dst_len are in a different order here and in tunnel_key_copy_geneve_opt.
[...]
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 298
Quoted 8 lines
net/sched/act_tunnel_key.c +4
-0@@ -157,6 +292,11 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, goto err_out; } +if (opts_len) +tunnel_key_opts_set (tb[TCA_TUNNEL_KEY_ENC_OPTS ], + &metadata->u.tun_info, opts_len, + extack);
You need to propagate the error here. The previous validation is not enough as errors while copying to tun_info were not covered.
Quoted 9 lines
net/sched/act_tunnel_key.c +2
-0+ metadata->u.tun_info.mode |=IP_TUNNEL_INFO_TX ;break ;default :@@ -221,6 +361,53 @@ static void tunnel_key_release(struct tc_action *a)kfree_rcu (params, rcu); } +static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 374
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+ const struct ip_tunnel_info *info) +{ +int len = info->options_len; +u8 *src = (u8 *)(info +1 ); + +while (len >0 ) { +struct geneve_opt *opt = (struct geneve_opt *)src; +u16 class; + + class =get_unaligned_be16 (&opt->opt_class);
I don't think this can be unaligned.
net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 385
Quoted 11 lines
net/sched/act_tunnel_key.c +11
-0+if (nla_put_u16 (skb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS , + class) || +nla_put_u8 (skb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE , + opt->type) || +nla_put (skb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA , + opt->length *4 , opt +1 )) +return -EMSGSIZE ; + + len -=sizeof (struct geneve_opt ) + opt->length *4 ; + src +=sizeof (struct geneve_opt ) + opt->length *4 ; + }
All of this needs to be nested in TCA_TUNNEL_KEY_ENC_OPTS_GENEVE.
Quoted 8 lines
net/sched/act_tunnel_key.c +8
-0+ +return 0 ; +} + +static int tunnel_key_opts_dump (struct sk_buff *skb, +const struct ip_tunnel_info *info) +{ +struct nlattr *start;
net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 403
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+int err; + +if (!info->options_len) +return 0 ; + + start =nla_nest_start (skb,TCA_TUNNEL_KEY_ENC_OPTS ); +if (!start) +return -EMSGSIZE ; + + err =tunnel_key_geneve_opts_dump (skb, info);
How do you know it is geneve opts and not some other (future) tunnel type options?
This is actually more fundamental problem with this patch. The metadata_dst options are blindly set to the provided data, yet nowhere we check whether the tunnel type matches. This must be done somehow. We probably need to store the options type in metadata_dst.
Thanks,
Jiri
Re: [PATCH/RFC 2/3] net/sched: act_tunnel_key: add extended ack support
In reply to Jiri BencQuoted 25 lines · Jiri Benc
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 98
Quoted 3 lines · Simon Horman
net/sched/act_tunnel_key.c +2
-1-if (!tb[TCA_TUNNEL_KEY_PARMS ]) +if (!tb[TCA_TUNNEL_KEY_PARMS ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key parameter" );"parameters" (it's not just one parameter)
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 112
Quoted 5 lines
net/sched/act_tunnel_key.c +1
-0@@ -107,6 +109,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,break ;case TCA_TUNNEL_KEY_ACT_SET :if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key enc id" );This is not much helpful to the user. What's "enc"? I guess "Missing tunnel key id" would be enough and better.
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 150
Quoted 5 lines
net/sched/act_tunnel_key.c +1
-0@@ -144,6 +147,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,0 , flags, key_id, 0); }else { +NL_SET_ERR_MSG (extack,"Missing both ipv4 and ipv6 enc src and dst" );We don't need both but only one of them. And again, "enc" does not have a clear meaning.
Quoted 1 line
"Missing either IPv4 or IPv6 source and destination address"?
Sure, I'll work on making the messages clearer.
Quoted 3 lines
In addition, it makes little sense to me to add extacks to just some of the errors in the
tunnel_key_initfunction. Please add extacks to all of them.
At the time I wrote the patch I tried to cover those errors that could result from user-input. I can extend the coverage if that is preferred.
Re: [PATCH/RFC 3/3] net/sched: add tunnel option support to act_tunnel_key
In reply to Jiri BencQuoted 47 lines · Jiri Benc
Quoted 7 lines · Simon Horman
net/sched/act_tunnel_key.c +7
-0+static int +tunnel_key_copy_geneve_opt (const struct nlattr *nla,int dst_len,void *dst, +struct netlink_ext_ack *extack) +{ +struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX +1 ]; +int err, data_len, opt_len; +u8 *data;net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 90
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+ + err =nla_parse_nested (tb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX , + nla, geneve_opt_policy, extack); +if (err <0 ) +return err; + +if (!tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS ] || + !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE ] || + !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]) { +NL_SET_ERR_MSG (extack,"Missing tunnel key enc geneve option class, type or data" );I think it's obvious by now that I don't like the "enc" :-)
Quoted 11 lines
net/sched/act_tunnel_key.c +11
-0+return -EINVAL ; + } + + data =nla_data (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]); + data_len =nla_len (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA ]); +if (data_len <4 ) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data is less than 4 bytes long" ); +return -ERANGE ; + } +if (data_len %4 ) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data is not a multiple of 4 bytes long" );net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 111
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+return -ERANGE ; + } + + opt_len =sizeof (struct geneve_opt ) + data_len; +if (dst) { +struct geneve_opt *opt = dst; +u16 class; + +if (dst_len < opt_len) { +NL_SET_ERR_MSG (extack,"Tunnel key enc geneve option data length is longer than the supplied data" );I don't understand this error. What can the user do about it? Furthermore, the error is not propagated to the user space (see also below).
Quoted 1 line
Shouldn't this be
WARN_ONor something?
Sure, that is fine by me.
Quoted 9 lines
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 116
Quoted 6 lines
net/sched/act_tunnel_key.c +5
-0+return -EINVAL ; + } + + class =nla_get_u16 (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS ]); +put_unaligned_be16 (class, &opt->opt_class);How this can be unaligned, given we check that the option length is a multiple of 4 bytes and the option header is 4 bytes?
True.
Quoted 10 lines
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+ + opt->type =nla_get_u8 (tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE ]); + opt->length = data_len /4 ;/* length is in units of 4 bytes */ + opt->r1 =0 ; + opt->r2 =0 ; + opt->r3 =0 ; + +memcpy (opt +1 , data, data_len); + } +
Quoted 8 lines
net/sched/act_tunnel_key.c static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, · line 131
Quoted 5 lines
net/sched/act_tunnel_key.c +5
-0+return opt_len; +} + +static int tunnel_key_copy_opts (const struct nlattr *nla,u8 *dst, +int dst_len,struct netlink_ext_ack *extack)Please be consistent with parameter ordering, dst and
dst_lenare in a different order here and intunnel_key_copy_geneve_opt.
Sure, will do.
Quoted 5 lines
[...]
Quoted 4 lines
net/sched/act_tunnel_key.c +0
-0@@ -157,6 +292,11 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, goto err_out; }
Quoted 7 lines
net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 298
Quoted 4 lines
net/sched/act_tunnel_key.c +4
-0+if (opts_len) +tunnel_key_opts_set (tb[TCA_TUNNEL_KEY_ENC_OPTS ], + &metadata->u.tun_info, opts_len, + extack);You need to propagate the error here. The previous validation is not enough as errors while copying to
tun_infowere not covered.
Thanks, sorry for missing that.
Quoted 8 lines
Quoted 8 lines
net/sched/act_tunnel_key.c +1
-0+ metadata->u.tun_info.mode |=IP_TUNNEL_INFO_TX ;break ;default :@@ -221,6 +361,53 @@ static void tunnel_key_release(struct tc_action *a)kfree_rcu (params, rcu); }
Quoted 13 lines
net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 374
Quoted 11 lines
net/sched/act_tunnel_key.c +11
-0+static int tunnel_key_geneve_opts_dump (struct sk_buff *skb, +const struct ip_tunnel_info *info) +{ +int len = info->options_len; +u8 *src = (u8 *)(info +1 ); + +while (len >0 ) { +struct geneve_opt *opt = (struct geneve_opt *)src; +u16 class; + + class =get_unaligned_be16 (&opt->opt_class);I don't think this can be unaligned.
Thanks, I'm not sure why I thought otherwise.
Quoted 5 lines
Quoted 5 lines
net/sched/act_tunnel_key.c +5
-0+if (nla_put_u16 (skb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS , + class) || +nla_put_u8 (skb,TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE , + opt->type) || + nla_put(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA,
Quoted 8 lines
net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 385
Quoted 6 lines
net/sched/act_tunnel_key.c +6
-0+ opt->length * 4, opt + 1)) +return -EMSGSIZE ; + + len -=sizeof (struct geneve_opt ) + opt->length *4 ; + src +=sizeof (struct geneve_opt ) + opt->length *4 ; + }All of this needs to be nested in
TCA_TUNNEL_KEY_ENC_OPTS_GENEVE.
Agreed.
Quoted 22 lines
Quoted 8 lines
net/sched/act_tunnel_key.c +8
-0+ +return 0 ; +} + +static int tunnel_key_opts_dump (struct sk_buff *skb, +const struct ip_tunnel_info *info) +{ +struct nlattr *start;net/sched/act_tunnel_key.c static void tunnel_key_release(struct tc_action *a) · line 403
Quoted 10 lines
net/sched/act_tunnel_key.c +10
-0+int err; + +if (!info->options_len) +return 0 ; + + start =nla_nest_start (skb,TCA_TUNNEL_KEY_ENC_OPTS ); +if (!start) +return -EMSGSIZE ; + + err =tunnel_key_geneve_opts_dump (skb, info);How do you know it is geneve opts and not some other (future) tunnel type options?
Quoted 4 lines
This is actually more fundamental problem with this patch. The
metadata_dstoptions are blindly set to the provided data, yet nowhere we check whether the tunnel type matches. This must be done somehow. We probably need to store the options type inmetadata_dst.
Thanks for pointing that out. Its a pretty fundamental oversight.