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.h>
10 #include <linux/netfilter/nf_conntrack_tuple_common.h>
15 struct nf_flowtable_type {
16 struct list_head list;
18 int (*init)(struct nf_flowtable *ft);
19 void (*free)(struct nf_flowtable *ft);
25 struct list_head list;
26 struct rhashtable rhashtable;
27 const struct nf_flowtable_type *type;
28 struct delayed_work gc_work;
31 enum flow_offload_tuple_dir {
32 FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL,
33 FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY,
34 FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX
37 struct flow_offload_tuple {
39 struct in_addr src_v4;
40 struct in6_addr src_v6;
43 struct in_addr dst_v4;
44 struct in6_addr dst_v6;
59 struct dst_entry *dst_cache;
62 struct flow_offload_tuple_rhash {
63 struct rhash_head node;
64 struct flow_offload_tuple tuple;
67 #define FLOW_OFFLOAD_SNAT 0x1
68 #define FLOW_OFFLOAD_DNAT 0x2
69 #define FLOW_OFFLOAD_DYING 0x4
70 #define FLOW_OFFLOAD_TEARDOWN 0x8
73 struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX];
76 /* Your private driver data here. */
81 #define NF_FLOW_TIMEOUT (30 * HZ)
83 struct nf_flow_route {
85 struct dst_entry *dst;
86 } tuple[FLOW_OFFLOAD_DIR_MAX];
89 struct flow_offload *flow_offload_alloc(struct nf_conn *ct,
90 struct nf_flow_route *route);
91 void flow_offload_free(struct flow_offload *flow);
93 int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow);
94 struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
95 struct flow_offload_tuple *tuple);
96 void nf_flow_table_cleanup(struct net_device *dev);
98 int nf_flow_table_init(struct nf_flowtable *flow_table);
99 void nf_flow_table_free(struct nf_flowtable *flow_table);
101 void flow_offload_teardown(struct flow_offload *flow);
102 static inline void flow_offload_dead(struct flow_offload *flow)
104 flow->flags |= FLOW_OFFLOAD_DYING;
107 int nf_flow_snat_port(const struct flow_offload *flow,
108 struct sk_buff *skb, unsigned int thoff,
109 u8 protocol, enum flow_offload_tuple_dir dir);
110 int nf_flow_dnat_port(const struct flow_offload *flow,
111 struct sk_buff *skb, unsigned int thoff,
112 u8 protocol, enum flow_offload_tuple_dir dir);
118 unsigned int nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
119 const struct nf_hook_state *state);
120 unsigned int nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
121 const struct nf_hook_state *state);
123 #define MODULE_ALIAS_NF_FLOWTABLE(family) \
124 MODULE_ALIAS("nf-flowtable-" __stringify(family))
126 #endif /* _NF_FLOW_TABLE_H */