1 #ifndef _NF_FLOW_TABLE_H
2 #define _NF_FLOW_TABLE_H
6 #include <linux/netdevice.h>
7 #include <linux/rhashtable-types.h>
8 #include <linux/rcupdate.h>
9 #include <linux/netfilter/nf_conntrack_tuple_common.h>
14 struct nf_flowtable_type {
15 struct list_head list;
17 int (*init)(struct nf_flowtable *ft);
18 void (*free)(struct nf_flowtable *ft);
24 struct list_head list;
25 struct rhashtable rhashtable;
26 const struct nf_flowtable_type *type;
27 struct delayed_work gc_work;
30 enum flow_offload_tuple_dir {
31 FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL,
32 FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY,
33 FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX
36 struct flow_offload_tuple {
38 struct in_addr src_v4;
39 struct in6_addr src_v6;
42 struct in_addr dst_v4;
43 struct in6_addr dst_v6;
60 struct dst_entry *dst_cache;
63 struct flow_offload_tuple_rhash {
64 struct rhash_head node;
65 struct flow_offload_tuple tuple;
68 #define FLOW_OFFLOAD_SNAT 0x1
69 #define FLOW_OFFLOAD_DNAT 0x2
70 #define FLOW_OFFLOAD_DYING 0x4
71 #define FLOW_OFFLOAD_TEARDOWN 0x8
74 struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX];
77 /* Your private driver data here. */
82 #define NF_FLOW_TIMEOUT (30 * HZ)
84 struct nf_flow_route {
86 struct dst_entry *dst;
88 } tuple[FLOW_OFFLOAD_DIR_MAX];
91 struct flow_offload *flow_offload_alloc(struct nf_conn *ct,
92 struct nf_flow_route *route);
93 void flow_offload_free(struct flow_offload *flow);
95 int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow);
96 struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
97 struct flow_offload_tuple *tuple);
98 void nf_flow_table_cleanup(struct net_device *dev);
100 int nf_flow_table_init(struct nf_flowtable *flow_table);
101 void nf_flow_table_free(struct nf_flowtable *flow_table);
103 void flow_offload_teardown(struct flow_offload *flow);
104 static inline void flow_offload_dead(struct flow_offload *flow)
106 flow->flags |= FLOW_OFFLOAD_DYING;
109 int nf_flow_snat_port(const struct flow_offload *flow,
110 struct sk_buff *skb, unsigned int thoff,
111 u8 protocol, enum flow_offload_tuple_dir dir);
112 int nf_flow_dnat_port(const struct flow_offload *flow,
113 struct sk_buff *skb, unsigned int thoff,
114 u8 protocol, enum flow_offload_tuple_dir dir);
120 unsigned int nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
121 const struct nf_hook_state *state);
122 unsigned int nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
123 const struct nf_hook_state *state);
125 #define MODULE_ALIAS_NF_FLOWTABLE(family) \
126 MODULE_ALIAS("nf-flowtable-" __stringify(family))
128 #endif /* _FLOW_OFFLOAD_H */