Skip to content

Commit d0f6dd8

Browse files
amirvdavem330
authored andcommitted
net/sched: Introduce act_tunnel_key
This action could be used before redirecting packets to a shared tunnel device, or when redirecting packets arriving from a such a device. The action will release the metadata created by the tunnel device (decap), or set the metadata with the specified values for encap operation. For example, the following flower filter will forward all ICMP packets destined to 11.11.11.2 through the shared vxlan device 'vxlan0'. Before redirecting, a metadata for the vxlan tunnel is created using the tunnel_key action and it's arguments: $ tc filter add dev net0 protocol ip parent ffff: \ flower \ ip_proto 1 \ dst_ip 11.11.11.2 \ action tunnel_key set \ src_ip 11.11.0.1 \ dst_ip 11.11.0.2 \ id 11 \ action mirred egress redirect dev vxlan0 Signed-off-by: Amir Vadai <[email protected]> Signed-off-by: Hadar Hen Zion <[email protected]> Reviewed-by: Shmulik Ladkani <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bc3103f commit d0f6dd8

File tree

5 files changed

+434
-0
lines changed

5 files changed

+434
-0
lines changed

include/net/tc_act/tc_tunnel_key.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2016, Amir Vadai <[email protected]>
3+
* Copyright (c) 2016, Mellanox Technologies. All rights reserved.
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*/
10+
11+
#ifndef __NET_TC_TUNNEL_KEY_H
12+
#define __NET_TC_TUNNEL_KEY_H
13+
14+
#include <net/act_api.h>
15+
16+
struct tcf_tunnel_key_params {
17+
struct rcu_head rcu;
18+
int tcft_action;
19+
int action;
20+
struct metadata_dst *tcft_enc_metadata;
21+
};
22+
23+
struct tcf_tunnel_key {
24+
struct tc_action common;
25+
struct tcf_tunnel_key_params __rcu *params;
26+
};
27+
28+
#define to_tunnel_key(a) ((struct tcf_tunnel_key *)a)
29+
30+
#endif /* __NET_TC_TUNNEL_KEY_H */
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2016, Amir Vadai <[email protected]>
3+
* Copyright (c) 2016, Mellanox Technologies. All rights reserved.
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*/
10+
11+
#ifndef __LINUX_TC_TUNNEL_KEY_H
12+
#define __LINUX_TC_TUNNEL_KEY_H
13+
14+
#include <linux/pkt_cls.h>
15+
16+
#define TCA_ACT_TUNNEL_KEY 17
17+
18+
#define TCA_TUNNEL_KEY_ACT_SET 1
19+
#define TCA_TUNNEL_KEY_ACT_RELEASE 2
20+
21+
struct tc_tunnel_key {
22+
tc_gen;
23+
int t_action;
24+
};
25+
26+
enum {
27+
TCA_TUNNEL_KEY_UNSPEC,
28+
TCA_TUNNEL_KEY_TM,
29+
TCA_TUNNEL_KEY_PARMS,
30+
TCA_TUNNEL_KEY_ENC_IPV4_SRC, /* be32 */
31+
TCA_TUNNEL_KEY_ENC_IPV4_DST, /* be32 */
32+
TCA_TUNNEL_KEY_ENC_IPV6_SRC, /* struct in6_addr */
33+
TCA_TUNNEL_KEY_ENC_IPV6_DST, /* struct in6_addr */
34+
TCA_TUNNEL_KEY_ENC_KEY_ID, /* be64 */
35+
TCA_TUNNEL_KEY_PAD,
36+
__TCA_TUNNEL_KEY_MAX,
37+
};
38+
39+
#define TCA_TUNNEL_KEY_MAX (__TCA_TUNNEL_KEY_MAX - 1)
40+
41+
#endif

net/sched/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,17 @@ config NET_ACT_IFE
761761
To compile this code as a module, choose M here: the
762762
module will be called act_ife.
763763

764+
config NET_ACT_TUNNEL_KEY
765+
tristate "IP tunnel metadata manipulation"
766+
depends on NET_CLS_ACT
767+
---help---
768+
Say Y here to set/release ip tunnel metadata.
769+
770+
If unsure, say N.
771+
772+
To compile this code as a module, choose M here: the
773+
module will be called act_tunnel_key.
774+
764775
config NET_IFE_SKBMARK
765776
tristate "Support to encoding decoding skb mark on IFE action"
766777
depends on NET_ACT_IFE

net/sched/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ obj-$(CONFIG_NET_ACT_CONNMARK) += act_connmark.o
2222
obj-$(CONFIG_NET_ACT_IFE) += act_ife.o
2323
obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o
2424
obj-$(CONFIG_NET_IFE_SKBPRIO) += act_meta_skbprio.o
25+
obj-$(CONFIG_NET_ACT_TUNNEL_KEY)+= act_tunnel_key.o
2526
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
2627
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
2728
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o

0 commit comments

Comments
 (0)