Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'act_tunnel_key-support-key-less-tunnels'

Or Gerlitz says:

====================
net/sched: act_tunnel_key: support key-less tunnels

This short series from Adi Nissim allows to support key-less tunnels
by the tc tunnel key actions, which is needed for some GRE use-cases.

changes from V0:
- addresses build warning spotted by kbuild, make sure to always init
to zero the tunnel key
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+14 -11
+14 -11
net/sched/act_tunnel_key.c
··· 210 210 struct tcf_tunnel_key *t; 211 211 bool exists = false; 212 212 __be16 dst_port = 0; 213 + __be64 key_id = 0; 213 214 int opts_len = 0; 214 - __be64 key_id; 215 - __be16 flags; 215 + __be16 flags = 0; 216 216 u8 tos, ttl; 217 217 int ret = 0; 218 218 int err; ··· 246 246 case TCA_TUNNEL_KEY_ACT_RELEASE: 247 247 break; 248 248 case TCA_TUNNEL_KEY_ACT_SET: 249 - if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) { 250 - NL_SET_ERR_MSG(extack, "Missing tunnel key id"); 251 - ret = -EINVAL; 252 - goto err_out; 249 + if (tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) { 250 + __be32 key32; 251 + 252 + key32 = nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]); 253 + key_id = key32_to_tunnel_id(key32); 254 + flags = TUNNEL_KEY; 253 255 } 254 256 255 - key_id = key32_to_tunnel_id(nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID])); 256 - 257 - flags = TUNNEL_KEY | TUNNEL_CSUM; 257 + flags |= TUNNEL_CSUM; 258 258 if (tb[TCA_TUNNEL_KEY_NO_CSUM] && 259 259 nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM])) 260 260 flags &= ~TUNNEL_CSUM; ··· 508 508 struct ip_tunnel_key *key = &info->key; 509 509 __be32 key_id = tunnel_id_to_key32(key->tun_id); 510 510 511 - if (nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id) || 511 + if (((key->tun_flags & TUNNEL_KEY) && 512 + nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id)) || 512 513 tunnel_key_dump_addresses(skb, 513 514 &params->tcft_enc_metadata->u.tun_info) || 514 - nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst) || 515 + (key->tp_dst && 516 + nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, 517 + key->tp_dst)) || 515 518 nla_put_u8(skb, TCA_TUNNEL_KEY_NO_CSUM, 516 519 !(key->tun_flags & TUNNEL_CSUM)) || 517 520 tunnel_key_opts_dump(skb, info))