]>
Commit | Line | Data |
---|---|---|
3b49e2e9 PNA |
1 | #ifndef _NF_FLOW_TABLE_H |
2 | #define _NF_FLOW_TABLE_H | |
3 | ||
ac2a6666 PNA |
4 | #include <linux/in.h> |
5 | #include <linux/in6.h> | |
6 | #include <linux/netdevice.h> | |
3b49e2e9 | 7 | #include <linux/rhashtable.h> |
ac2a6666 PNA |
8 | #include <linux/rcupdate.h> |
9 | #include <net/dst.h> | |
3b49e2e9 PNA |
10 | |
11 | struct nf_flowtable; | |
12 | ||
13 | struct nf_flowtable_type { | |
14 | struct list_head list; | |
15 | int family; | |
16 | void (*gc)(struct work_struct *work); | |
17 | const struct rhashtable_params *params; | |
18 | nf_hookfn *hook; | |
19 | struct module *owner; | |
20 | }; | |
21 | ||
22 | struct nf_flowtable { | |
23 | struct rhashtable rhashtable; | |
24 | const struct nf_flowtable_type *type; | |
25 | struct delayed_work gc_work; | |
26 | }; | |
27 | ||
ac2a6666 PNA |
28 | enum flow_offload_tuple_dir { |
29 | FLOW_OFFLOAD_DIR_ORIGINAL, | |
30 | FLOW_OFFLOAD_DIR_REPLY, | |
31 | __FLOW_OFFLOAD_DIR_MAX = FLOW_OFFLOAD_DIR_REPLY, | |
32 | }; | |
33 | #define FLOW_OFFLOAD_DIR_MAX (__FLOW_OFFLOAD_DIR_MAX + 1) | |
34 | ||
35 | struct flow_offload_tuple { | |
36 | union { | |
37 | struct in_addr src_v4; | |
38 | struct in6_addr src_v6; | |
39 | }; | |
40 | union { | |
41 | struct in_addr dst_v4; | |
42 | struct in6_addr dst_v6; | |
43 | }; | |
44 | struct { | |
45 | __be16 src_port; | |
46 | __be16 dst_port; | |
47 | }; | |
48 | ||
49 | int iifidx; | |
50 | ||
51 | u8 l3proto; | |
52 | u8 l4proto; | |
53 | u8 dir; | |
54 | ||
55 | int oifidx; | |
56 | ||
57 | struct dst_entry *dst_cache; | |
58 | }; | |
59 | ||
60 | struct flow_offload_tuple_rhash { | |
61 | struct rhash_head node; | |
62 | struct flow_offload_tuple tuple; | |
63 | }; | |
64 | ||
65 | #define FLOW_OFFLOAD_SNAT 0x1 | |
66 | #define FLOW_OFFLOAD_DNAT 0x2 | |
67 | #define FLOW_OFFLOAD_DYING 0x4 | |
68 | ||
69 | struct flow_offload { | |
70 | struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX]; | |
71 | u32 flags; | |
72 | union { | |
73 | /* Your private driver data here. */ | |
74 | u32 timeout; | |
75 | }; | |
76 | }; | |
77 | ||
78 | #define NF_FLOW_TIMEOUT (30 * HZ) | |
79 | ||
80 | struct nf_flow_route { | |
81 | struct { | |
82 | struct dst_entry *dst; | |
83 | int ifindex; | |
84 | } tuple[FLOW_OFFLOAD_DIR_MAX]; | |
85 | }; | |
86 | ||
87 | struct flow_offload *flow_offload_alloc(struct nf_conn *ct, | |
88 | struct nf_flow_route *route); | |
89 | void flow_offload_free(struct flow_offload *flow); | |
90 | ||
91 | int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow); | |
92 | void flow_offload_del(struct nf_flowtable *flow_table, struct flow_offload *flow); | |
93 | struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table, | |
94 | struct flow_offload_tuple *tuple); | |
95 | int nf_flow_table_iterate(struct nf_flowtable *flow_table, | |
96 | void (*iter)(struct flow_offload *flow, void *data), | |
97 | void *data); | |
c0ea1bcb PNA |
98 | |
99 | void nf_flow_table_cleanup(struct net *net, struct net_device *dev); | |
100 | ||
ac2a6666 PNA |
101 | void nf_flow_offload_work_gc(struct work_struct *work); |
102 | extern const struct rhashtable_params nf_flow_offload_rhash_params; | |
103 | ||
104 | void flow_offload_dead(struct flow_offload *flow); | |
105 | ||
106 | int nf_flow_snat_port(const struct flow_offload *flow, | |
107 | struct sk_buff *skb, unsigned int thoff, | |
108 | u8 protocol, enum flow_offload_tuple_dir dir); | |
109 | int nf_flow_dnat_port(const struct flow_offload *flow, | |
110 | struct sk_buff *skb, unsigned int thoff, | |
111 | u8 protocol, enum flow_offload_tuple_dir dir); | |
112 | ||
113 | struct flow_ports { | |
114 | __be16 source, dest; | |
115 | }; | |
116 | ||
7c23b629 PNA |
117 | unsigned int nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, |
118 | const struct nf_hook_state *state); | |
119 | unsigned int nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, | |
120 | const struct nf_hook_state *state); | |
121 | ||
ac2a6666 PNA |
122 | #define MODULE_ALIAS_NF_FLOWTABLE(family) \ |
123 | MODULE_ALIAS("nf-flowtable-" __stringify(family)) | |
124 | ||
3b49e2e9 | 125 | #endif /* _FLOW_OFFLOAD_H */ |