Revert "tty: hvc: Fix data abort due to race in hvc_open"
[linux/fpc-iii.git] / include / net / tc_act / tc_tunnel_key.h
blobe1057b255f69a7669ff159947b9d3a11eed3a63d
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
4 * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
5 */
7 #ifndef __NET_TC_TUNNEL_KEY_H
8 #define __NET_TC_TUNNEL_KEY_H
10 #include <net/act_api.h>
11 #include <linux/tc_act/tc_tunnel_key.h>
12 #include <net/dst_metadata.h>
14 struct tcf_tunnel_key_params {
15 struct rcu_head rcu;
16 int tcft_action;
17 struct metadata_dst *tcft_enc_metadata;
20 struct tcf_tunnel_key {
21 struct tc_action common;
22 struct tcf_tunnel_key_params __rcu *params;
25 #define to_tunnel_key(a) ((struct tcf_tunnel_key *)a)
27 static inline bool is_tcf_tunnel_set(const struct tc_action *a)
29 #ifdef CONFIG_NET_CLS_ACT
30 struct tcf_tunnel_key *t = to_tunnel_key(a);
31 struct tcf_tunnel_key_params *params;
33 params = rcu_dereference_protected(t->params,
34 lockdep_is_held(&a->tcfa_lock));
35 if (a->ops && a->ops->id == TCA_ID_TUNNEL_KEY)
36 return params->tcft_action == TCA_TUNNEL_KEY_ACT_SET;
37 #endif
38 return false;
41 static inline bool is_tcf_tunnel_release(const struct tc_action *a)
43 #ifdef CONFIG_NET_CLS_ACT
44 struct tcf_tunnel_key *t = to_tunnel_key(a);
45 struct tcf_tunnel_key_params *params;
47 params = rcu_dereference_protected(t->params,
48 lockdep_is_held(&a->tcfa_lock));
49 if (a->ops && a->ops->id == TCA_ID_TUNNEL_KEY)
50 return params->tcft_action == TCA_TUNNEL_KEY_ACT_RELEASE;
51 #endif
52 return false;
55 static inline struct ip_tunnel_info *tcf_tunnel_info(const struct tc_action *a)
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);
61 return &params->tcft_enc_metadata->u.tun_info;
62 #else
63 return NULL;
64 #endif
67 static inline struct ip_tunnel_info *
68 tcf_tunnel_info_copy(const struct tc_action *a)
70 #ifdef CONFIG_NET_CLS_ACT
71 struct ip_tunnel_info *tun = tcf_tunnel_info(a);
73 if (tun) {
74 size_t tun_size = sizeof(*tun) + tun->options_len;
75 struct ip_tunnel_info *tun_copy = kmemdup(tun, tun_size,
76 GFP_ATOMIC);
78 return tun_copy;
80 #endif
81 return NULL;
83 #endif /* __NET_TC_TUNNEL_KEY_H */