~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/tc_act/tc_ct.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __NET_TC_CT_H
  3 #define __NET_TC_CT_H
  4 
  5 #include <net/act_api.h>
  6 #include <uapi/linux/tc_act/tc_ct.h>
  7 
  8 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
  9 #include <net/netfilter/nf_nat.h>
 10 #include <net/netfilter/nf_conntrack_labels.h>
 11 
 12 struct tcf_ct_params {
 13         struct nf_conntrack_helper *helper;
 14         struct nf_conn *tmpl;
 15         u16 zone;
 16 
 17         u32 mark;
 18         u32 mark_mask;
 19 
 20         u32 labels[NF_CT_LABELS_MAX_SIZE / sizeof(u32)];
 21         u32 labels_mask[NF_CT_LABELS_MAX_SIZE / sizeof(u32)];
 22 
 23         struct nf_nat_range2 range;
 24         bool ipv4_range;
 25         bool put_labels;
 26 
 27         u16 ct_action;
 28 
 29         struct rcu_head rcu;
 30 
 31         struct tcf_ct_flow_table *ct_ft;
 32         struct nf_flowtable *nf_ft;
 33 };
 34 
 35 struct tcf_ct {
 36         struct tc_action common;
 37         struct tcf_ct_params __rcu *params;
 38 };
 39 
 40 #define to_ct(a) ((struct tcf_ct *)a)
 41 #define to_ct_params(a)                                                 \
 42         ((struct tcf_ct_params *)                                       \
 43          rcu_dereference_protected(to_ct(a)->params,                    \
 44                                    lockdep_is_held(&a->tcfa_lock)))
 45 
 46 static inline uint16_t tcf_ct_zone(const struct tc_action *a)
 47 {
 48         return to_ct_params(a)->zone;
 49 }
 50 
 51 static inline int tcf_ct_action(const struct tc_action *a)
 52 {
 53         return to_ct_params(a)->ct_action;
 54 }
 55 
 56 static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
 57 {
 58         return to_ct_params(a)->nf_ft;
 59 }
 60 
 61 static inline struct nf_conntrack_helper *tcf_ct_helper(const struct tc_action *a)
 62 {
 63         return to_ct_params(a)->helper;
 64 }
 65 
 66 #else
 67 static inline uint16_t tcf_ct_zone(const struct tc_action *a) { return 0; }
 68 static inline int tcf_ct_action(const struct tc_action *a) { return 0; }
 69 static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
 70 {
 71         return NULL;
 72 }
 73 static inline struct nf_conntrack_helper *tcf_ct_helper(const struct tc_action *a)
 74 {
 75         return NULL;
 76 }
 77 #endif /* CONFIG_NF_CONNTRACK */
 78 
 79 #if IS_ENABLED(CONFIG_NET_ACT_CT)
 80 static inline void
 81 tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie)
 82 {
 83         enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK;
 84         struct nf_conn *ct;
 85 
 86         ct = (struct nf_conn *)(cookie & NFCT_PTRMASK);
 87         nf_conntrack_get(&ct->ct_general);
 88         nf_ct_set(skb, ct, ctinfo);
 89 }
 90 #else
 91 static inline void
 92 tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) { }
 93 #endif
 94 
 95 static inline bool is_tcf_ct(const struct tc_action *a)
 96 {
 97 #if defined(CONFIG_NET_CLS_ACT) && IS_ENABLED(CONFIG_NF_CONNTRACK)
 98         if (a->ops && a->ops->id == TCA_ID_CT)
 99                 return true;
100 #endif
101         return false;
102 }
103 
104 #endif /* __NET_TC_CT_H */
105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php