Skip to content

Commit 4dc88ce

Browse files
committed
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>
2 parents d1ecf8a + 1c25324 commit 4dc88ce

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

net/sched/act_tunnel_key.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
210210
struct tcf_tunnel_key *t;
211211
bool exists = false;
212212
__be16 dst_port = 0;
213+
__be64 key_id = 0;
213214
int opts_len = 0;
214-
__be64 key_id;
215-
__be16 flags;
215+
__be16 flags = 0;
216216
u8 tos, ttl;
217217
int ret = 0;
218218
int err;
@@ -246,15 +246,15 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
246246
case TCA_TUNNEL_KEY_ACT_RELEASE:
247247
break;
248248
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;
253-
}
249+
if (tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) {
250+
__be32 key32;
254251

255-
key_id = key32_to_tunnel_id(nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]));
252+
key32 = nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
253+
key_id = key32_to_tunnel_id(key32);
254+
flags = TUNNEL_KEY;
255+
}
256256

257-
flags = TUNNEL_KEY | TUNNEL_CSUM;
257+
flags |= TUNNEL_CSUM;
258258
if (tb[TCA_TUNNEL_KEY_NO_CSUM] &&
259259
nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM]))
260260
flags &= ~TUNNEL_CSUM;
@@ -508,10 +508,13 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
508508
struct ip_tunnel_key *key = &info->key;
509509
__be32 key_id = tunnel_id_to_key32(key->tun_id);
510510

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)) ||
512513
tunnel_key_dump_addresses(skb,
513514
&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)) ||
515518
nla_put_u8(skb, TCA_TUNNEL_KEY_NO_CSUM,
516519
!(key->tun_flags & TUNNEL_CSUM)) ||
517520
tunnel_key_opts_dump(skb, info))

0 commit comments

Comments
 (0)