hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/include/net/tc_act/tc_tunnel_key.h
....@@ -1,11 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
34 * 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.
95 */
106
117 #ifndef __NET_TC_TUNNEL_KEY_H
....@@ -32,9 +28,11 @@
3228 {
3329 #ifdef CONFIG_NET_CLS_ACT
3430 struct tcf_tunnel_key *t = to_tunnel_key(a);
35
- struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
31
+ struct tcf_tunnel_key_params *params;
3632
37
- if (a->ops && a->ops->type == TCA_ACT_TUNNEL_KEY)
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)
3836 return params->tcft_action == TCA_TUNNEL_KEY_ACT_SET;
3937 #endif
4038 return false;
....@@ -44,9 +42,11 @@
4442 {
4543 #ifdef CONFIG_NET_CLS_ACT
4644 struct tcf_tunnel_key *t = to_tunnel_key(a);
47
- struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
45
+ struct tcf_tunnel_key_params *params;
4846
49
- if (a->ops && a->ops->type == TCA_ACT_TUNNEL_KEY)
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)
5050 return params->tcft_action == TCA_TUNNEL_KEY_ACT_RELEASE;
5151 #endif
5252 return false;
....@@ -56,11 +56,31 @@
5656 {
5757 #ifdef CONFIG_NET_CLS_ACT
5858 struct tcf_tunnel_key *t = to_tunnel_key(a);
59
- struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
59
+ struct tcf_tunnel_key_params *params;
60
+
61
+ params = rcu_dereference_protected(t->params,
62
+ lockdep_is_held(&a->tcfa_lock));
6063
6164 return &params->tcft_enc_metadata->u.tun_info;
6265 #else
6366 return NULL;
6467 #endif
6568 }
69
+
70
+static inline struct ip_tunnel_info *
71
+tcf_tunnel_info_copy(const struct tc_action *a)
72
+{
73
+#ifdef CONFIG_NET_CLS_ACT
74
+ struct ip_tunnel_info *tun = tcf_tunnel_info(a);
75
+
76
+ if (tun) {
77
+ size_t tun_size = sizeof(*tun) + tun->options_len;
78
+ struct ip_tunnel_info *tun_copy = kmemdup(tun, tun_size,
79
+ GFP_ATOMIC);
80
+
81
+ return tun_copy;
82
+ }
83
+#endif
84
+ return NULL;
85
+}
6686 #endif /* __NET_TC_TUNNEL_KEY_H */