1 #ifndef _NF_CONNTRACK_ZONES_H
2 #define _NF_CONNTRACK_ZONES_H
4 #include <linux/netfilter/nf_conntrack_zones_common.h>
6 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
7 #include <net/netfilter/nf_conntrack_extend.h>
9 static inline const struct nf_conntrack_zone
*
10 nf_ct_zone(const struct nf_conn
*ct
)
12 const struct nf_conntrack_zone
*nf_ct_zone
= NULL
;
14 #ifdef CONFIG_NF_CONNTRACK_ZONES
15 nf_ct_zone
= nf_ct_ext_find(ct
, NF_CT_EXT_ZONE
);
17 return nf_ct_zone
? nf_ct_zone
: &nf_ct_zone_dflt
;
20 static inline const struct nf_conntrack_zone
*
21 nf_ct_zone_init(struct nf_conntrack_zone
*zone
, u16 id
, u8 dir
, u8 flags
)
30 static inline const struct nf_conntrack_zone
*
31 nf_ct_zone_tmpl(const struct nf_conn
*tmpl
, const struct sk_buff
*skb
,
32 struct nf_conntrack_zone
*tmp
)
34 const struct nf_conntrack_zone
*zone
;
37 return &nf_ct_zone_dflt
;
39 zone
= nf_ct_zone(tmpl
);
40 if (zone
->flags
& NF_CT_FLAG_MARK
)
41 zone
= nf_ct_zone_init(tmp
, skb
->mark
, zone
->dir
, 0);
46 static inline int nf_ct_zone_add(struct nf_conn
*ct
, gfp_t flags
,
47 const struct nf_conntrack_zone
*info
)
49 #ifdef CONFIG_NF_CONNTRACK_ZONES
50 struct nf_conntrack_zone
*nf_ct_zone
;
52 nf_ct_zone
= nf_ct_ext_add(ct
, NF_CT_EXT_ZONE
, flags
);
56 nf_ct_zone_init(nf_ct_zone
, info
->id
, info
->dir
,
62 static inline bool nf_ct_zone_matches_dir(const struct nf_conntrack_zone
*zone
,
63 enum ip_conntrack_dir dir
)
65 return zone
->dir
& (1 << dir
);
68 static inline u16
nf_ct_zone_id(const struct nf_conntrack_zone
*zone
,
69 enum ip_conntrack_dir dir
)
71 return nf_ct_zone_matches_dir(zone
, dir
) ?
72 zone
->id
: NF_CT_DEFAULT_ZONE_ID
;
75 static inline bool nf_ct_zone_equal(const struct nf_conn
*a
,
76 const struct nf_conntrack_zone
*b
,
77 enum ip_conntrack_dir dir
)
79 return nf_ct_zone_id(nf_ct_zone(a
), dir
) ==
80 nf_ct_zone_id(b
, dir
);
83 static inline bool nf_ct_zone_equal_any(const struct nf_conn
*a
,
84 const struct nf_conntrack_zone
*b
)
86 return nf_ct_zone(a
)->id
== b
->id
;
88 #endif /* IS_ENABLED(CONFIG_NF_CONNTRACK) */
89 #endif /* _NF_CONNTRACK_ZONES_H */
This page took 0.033646 seconds and 5 git commands to generate.