]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/net/tc_act/tc_tunnel_key.h
net: core: limit nested device depth
[mirror_ubuntu-bionic-kernel.git] / include / net / tc_act / tc_tunnel_key.h
1 /*
2 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
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 #include <linux/tc_act/tc_tunnel_key.h>
16 #include <net/dst_metadata.h>
17
18 struct tcf_tunnel_key_params {
19 struct rcu_head rcu;
20 int tcft_action;
21 struct metadata_dst *tcft_enc_metadata;
22 };
23
24 struct tcf_tunnel_key {
25 struct tc_action common;
26 struct tcf_tunnel_key_params __rcu *params;
27 };
28
29 #define to_tunnel_key(a) ((struct tcf_tunnel_key *)a)
30
31 static inline bool is_tcf_tunnel_set(const struct tc_action *a)
32 {
33 #ifdef CONFIG_NET_CLS_ACT
34 struct tcf_tunnel_key *t = to_tunnel_key(a);
35 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
36
37 if (a->ops && a->ops->type == TCA_ACT_TUNNEL_KEY)
38 return params->tcft_action == TCA_TUNNEL_KEY_ACT_SET;
39 #endif
40 return false;
41 }
42
43 static inline bool is_tcf_tunnel_release(const struct tc_action *a)
44 {
45 #ifdef CONFIG_NET_CLS_ACT
46 struct tcf_tunnel_key *t = to_tunnel_key(a);
47 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
48
49 if (a->ops && a->ops->type == TCA_ACT_TUNNEL_KEY)
50 return params->tcft_action == TCA_TUNNEL_KEY_ACT_RELEASE;
51 #endif
52 return false;
53 }
54
55 static inline struct ip_tunnel_info *tcf_tunnel_info(const struct tc_action *a)
56 {
57 #ifdef CONFIG_NET_CLS_ACT
58 struct tcf_tunnel_key *t = to_tunnel_key(a);
59 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
60
61 return &params->tcft_enc_metadata->u.tun_info;
62 #else
63 return NULL;
64 #endif
65 }
66 #endif /* __NET_TC_TUNNEL_KEY_H */