Skip to content

Commit 75bfbca

Browse files
hadarhenziondavem330
authored andcommitted
net/sched: act_tunnel_key: Add UDP dst port option
The current tunnel set action supports only IP addresses and key options. Add UDP dst port option. Signed-off-by: Hadar Hen Zion <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 24ba898 commit 75bfbca

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/uapi/linux/tc_act/tc_tunnel_key.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum {
3333
TCA_TUNNEL_KEY_ENC_IPV6_DST, /* struct in6_addr */
3434
TCA_TUNNEL_KEY_ENC_KEY_ID, /* be64 */
3535
TCA_TUNNEL_KEY_PAD,
36+
TCA_TUNNEL_KEY_ENC_DST_PORT, /* be16 */
3637
__TCA_TUNNEL_KEY_MAX,
3738
};
3839

net/sched/act_tunnel_key.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = {
6666
[TCA_TUNNEL_KEY_ENC_IPV6_SRC] = { .len = sizeof(struct in6_addr) },
6767
[TCA_TUNNEL_KEY_ENC_IPV6_DST] = { .len = sizeof(struct in6_addr) },
6868
[TCA_TUNNEL_KEY_ENC_KEY_ID] = { .type = NLA_U32 },
69+
[TCA_TUNNEL_KEY_ENC_DST_PORT] = {.type = NLA_U16},
6970
};
7071

7172
static int tunnel_key_init(struct net *net, struct nlattr *nla,
@@ -80,6 +81,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
8081
struct tc_tunnel_key *parm;
8182
struct tcf_tunnel_key *t;
8283
bool exists = false;
84+
__be16 dst_port = 0;
8385
__be64 key_id;
8486
int ret = 0;
8587
int err;
@@ -110,6 +112,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
110112

111113
key_id = key32_to_tunnel_id(nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]));
112114

115+
if (tb[TCA_TUNNEL_KEY_ENC_DST_PORT])
116+
dst_port = nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
117+
113118
if (tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC] &&
114119
tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]) {
115120
__be32 saddr;
@@ -119,7 +124,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
119124
daddr = nla_get_in_addr(tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]);
120125

121126
metadata = __ip_tun_set_dst(saddr, daddr, 0, 0,
122-
0, TUNNEL_KEY, key_id, 0);
127+
dst_port, TUNNEL_KEY,
128+
key_id, 0);
123129
} else if (tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC] &&
124130
tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]) {
125131
struct in6_addr saddr;
@@ -129,7 +135,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
129135
daddr = nla_get_in6_addr(tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]);
130136

131137
metadata = __ipv6_tun_set_dst(&saddr, &daddr, 0, 0, 0,
132-
0, TUNNEL_KEY, key_id, 0);
138+
dst_port, TUNNEL_KEY,
139+
key_id, 0);
133140
}
134141

135142
if (!metadata) {
@@ -257,7 +264,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
257264

258265
if (nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id) ||
259266
tunnel_key_dump_addresses(skb,
260-
&params->tcft_enc_metadata->u.tun_info))
267+
&params->tcft_enc_metadata->u.tun_info) ||
268+
nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst))
261269
goto nla_put_failure;
262270
}
263271

0 commit comments

Comments
 (0)