]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/net/tc_act/tc_tunnel_key.h
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / include / net / tc_act / tc_tunnel_key.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
d0f6dd8a
AV
2/*
3 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
4 * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
d0f6dd8a
AV
5 */
6
7#ifndef __NET_TC_TUNNEL_KEY_H
8#define __NET_TC_TUNNEL_KEY_H
9
10#include <net/act_api.h>
9ce183b4
HHZ
11#include <linux/tc_act/tc_tunnel_key.h>
12#include <net/dst_metadata.h>
d0f6dd8a
AV
13
14struct tcf_tunnel_key_params {
15 struct rcu_head rcu;
16 int tcft_action;
d0f6dd8a
AV
17 struct metadata_dst *tcft_enc_metadata;
18};
19
20struct tcf_tunnel_key {
21 struct tc_action common;
22 struct tcf_tunnel_key_params __rcu *params;
23};
24
25#define to_tunnel_key(a) ((struct tcf_tunnel_key *)a)
26
9ce183b4
HHZ
27static inline bool is_tcf_tunnel_set(const struct tc_action *a)
28{
29#ifdef CONFIG_NET_CLS_ACT
30 struct tcf_tunnel_key *t = to_tunnel_key(a);
31 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
32
eddd2cf1 33 if (a->ops && a->ops->id == TCA_ID_TUNNEL_KEY)
9ce183b4
HHZ
34 return params->tcft_action == TCA_TUNNEL_KEY_ACT_SET;
35#endif
36 return false;
37}
38
39static inline bool is_tcf_tunnel_release(const struct tc_action *a)
40{
41#ifdef CONFIG_NET_CLS_ACT
42 struct tcf_tunnel_key *t = to_tunnel_key(a);
43 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
44
eddd2cf1 45 if (a->ops && a->ops->id == TCA_ID_TUNNEL_KEY)
9ce183b4
HHZ
46 return params->tcft_action == TCA_TUNNEL_KEY_ACT_RELEASE;
47#endif
48 return false;
49}
50
51static inline struct ip_tunnel_info *tcf_tunnel_info(const struct tc_action *a)
52{
53#ifdef CONFIG_NET_CLS_ACT
54 struct tcf_tunnel_key *t = to_tunnel_key(a);
55 struct tcf_tunnel_key_params *params = rtnl_dereference(t->params);
56
57 return &params->tcft_enc_metadata->u.tun_info;
58#else
59 return NULL;
60#endif
61}
d0f6dd8a 62#endif /* __NET_TC_TUNNEL_KEY_H */