2 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
3 * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
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.
11 #ifndef __NET_TC_TUNNEL_KEY_H
12 #define __NET_TC_TUNNEL_KEY_H
14 #include <net/act_api.h>
15 #include <linux/tc_act/tc_tunnel_key.h>
16 #include <net/dst_metadata.h>
18 struct tcf_tunnel_key_params
{
22 struct metadata_dst
*tcft_enc_metadata
;
25 struct tcf_tunnel_key
{
26 struct tc_action common
;
27 struct tcf_tunnel_key_params __rcu
*params
;
30 #define to_tunnel_key(a) ((struct tcf_tunnel_key *)a)
32 static inline bool is_tcf_tunnel_set(const struct tc_action
*a
)
34 #ifdef CONFIG_NET_CLS_ACT
35 struct tcf_tunnel_key
*t
= to_tunnel_key(a
);
36 struct tcf_tunnel_key_params
*params
= rtnl_dereference(t
->params
);
38 if (a
->ops
&& a
->ops
->type
== TCA_ACT_TUNNEL_KEY
)
39 return params
->tcft_action
== TCA_TUNNEL_KEY_ACT_SET
;
44 static inline bool is_tcf_tunnel_release(const struct tc_action
*a
)
46 #ifdef CONFIG_NET_CLS_ACT
47 struct tcf_tunnel_key
*t
= to_tunnel_key(a
);
48 struct tcf_tunnel_key_params
*params
= rtnl_dereference(t
->params
);
50 if (a
->ops
&& a
->ops
->type
== TCA_ACT_TUNNEL_KEY
)
51 return params
->tcft_action
== TCA_TUNNEL_KEY_ACT_RELEASE
;
56 static inline struct ip_tunnel_info
*tcf_tunnel_info(const struct tc_action
*a
)
58 #ifdef CONFIG_NET_CLS_ACT
59 struct tcf_tunnel_key
*t
= to_tunnel_key(a
);
60 struct tcf_tunnel_key_params
*params
= rtnl_dereference(t
->params
);
62 return ¶ms
->tcft_enc_metadata
->u
.tun_info
;
67 #endif /* __NET_TC_TUNNEL_KEY_H */