]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/tc_act/tc_gact.h
net: core: limit nested device depth
[mirror_ubuntu-bionic-kernel.git] / include / net / tc_act / tc_gact.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef __NET_TC_GACT_H
3#define __NET_TC_GACT_H
4
5#include <net/act_api.h>
3b01cf56 6#include <linux/tc_act/tc_gact.h>
1da177e4 7
e9ce1cd3 8struct tcf_gact {
ec0595cc 9 struct tc_action common;
1da177e4 10#ifdef CONFIG_GACT_PROB
cc6510a9
ED
11 u16 tcfg_ptype;
12 u16 tcfg_pval;
13 int tcfg_paction;
14 atomic_t packets;
1da177e4 15#endif
1da177e4 16};
a85a970a 17#define to_gact(a) ((struct tcf_gact *)a)
e9ce1cd3 18
e457d86a
JP
19static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
20 bool is_ext)
3b01cf56 21{
00175aec 22#ifdef CONFIG_NET_CLS_ACT
3b01cf56
JF
23 struct tcf_gact *gact;
24
25 if (a->ops && a->ops->type != TCA_ACT_GACT)
26 return false;
27
a85a970a 28 gact = to_gact(a);
e457d86a
JP
29 if ((!is_ext && gact->tcf_action == act) ||
30 (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
3b01cf56
JF
31 return true;
32
00175aec 33#endif
3b01cf56
JF
34 return false;
35}
5a4d1fee 36
3b8e9238
JP
37static inline bool is_tcf_gact_ok(const struct tc_action *a)
38{
39 return __is_tcf_gact_act(a, TC_ACT_OK, false);
40}
41
5a4d1fee
JP
42static inline bool is_tcf_gact_shot(const struct tc_action *a)
43{
e457d86a 44 return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
5a4d1fee
JP
45}
46
47static inline bool is_tcf_gact_trap(const struct tc_action *a)
48{
e457d86a
JP
49 return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
50}
51
52static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
53{
54 return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
55}
56
57static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
58{
355aa709 59 return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
5a4d1fee
JP
60}
61
e9ce1cd3 62#endif /* __NET_TC_GACT_H */