Commit 80ef0f22 authored by Adi Nissim's avatar Adi Nissim Committed by David S. Miller

net/sched: act_tunnel_key: Allow key-less tunnels

Allow setting a tunnel without a tunnel key. This is required for
tunneling protocols, such as GRE, that define the key as an optional
field.
Signed-off-by: default avatarAdi Nissim <adin@mellanox.com>
Acked-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: default avatarOz Shlomo <ozsh@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d1ecf8a6
...@@ -210,9 +210,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -210,9 +210,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
struct tcf_tunnel_key *t; struct tcf_tunnel_key *t;
bool exists = false; bool exists = false;
__be16 dst_port = 0; __be16 dst_port = 0;
__be64 key_id = 0;
int opts_len = 0; int opts_len = 0;
__be64 key_id; __be16 flags = 0;
__be16 flags;
u8 tos, ttl; u8 tos, ttl;
int ret = 0; int ret = 0;
int err; int err;
...@@ -246,15 +246,15 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -246,15 +246,15 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
case TCA_TUNNEL_KEY_ACT_RELEASE: case TCA_TUNNEL_KEY_ACT_RELEASE:
break; break;
case TCA_TUNNEL_KEY_ACT_SET: case TCA_TUNNEL_KEY_ACT_SET:
if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) { if (tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) {
NL_SET_ERR_MSG(extack, "Missing tunnel key id"); __be32 key32;
ret = -EINVAL;
goto err_out;
}
key_id = key32_to_tunnel_id(nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID])); key32 = nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
key_id = key32_to_tunnel_id(key32);
flags = TUNNEL_KEY;
}
flags = TUNNEL_KEY | TUNNEL_CSUM; flags |= TUNNEL_CSUM;
if (tb[TCA_TUNNEL_KEY_NO_CSUM] && if (tb[TCA_TUNNEL_KEY_NO_CSUM] &&
nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM])) nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM]))
flags &= ~TUNNEL_CSUM; flags &= ~TUNNEL_CSUM;
...@@ -508,7 +508,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -508,7 +508,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
struct ip_tunnel_key *key = &info->key; struct ip_tunnel_key *key = &info->key;
__be32 key_id = tunnel_id_to_key32(key->tun_id); __be32 key_id = tunnel_id_to_key32(key->tun_id);
if (nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id) || if (((key->tun_flags & TUNNEL_KEY) &&
nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id)) ||
tunnel_key_dump_addresses(skb, tunnel_key_dump_addresses(skb,
&params->tcft_enc_metadata->u.tun_info) || &params->tcft_enc_metadata->u.tun_info) ||
nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst) || nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst) ||
......
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