]>
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> | |
0eb71a9d | 7 | #include <linux/rhashtable-types.h> |
ac2a6666 | 8 | #include <linux/rcupdate.h> |
a1b2f04e | 9 | #include <linux/netfilter.h> |
af81f9e7 | 10 | #include <linux/netfilter/nf_conntrack_tuple_common.h> |
ac2a6666 | 11 | #include <net/dst.h> |
3b49e2e9 PNA |
12 | |
13 | struct nf_flowtable; | |
14 | ||
15 | struct nf_flowtable_type { | |
16 | struct list_head list; | |
17 | int family; | |
a268de77 | 18 | int (*init)(struct nf_flowtable *ft); |
b408c5b0 | 19 | void (*free)(struct nf_flowtable *ft); |
3b49e2e9 PNA |
20 | nf_hookfn *hook; |
21 | struct module *owner; | |
22 | }; | |
23 | ||
24 | struct nf_flowtable { | |
84453a90 | 25 | struct list_head list; |
3b49e2e9 | 26 | struct rhashtable rhashtable; |
71a8a63b | 27 | int priority; |
3b49e2e9 PNA |
28 | const struct nf_flowtable_type *type; |
29 | struct delayed_work gc_work; | |
30 | }; | |
31 | ||
ac2a6666 | 32 | enum flow_offload_tuple_dir { |
af81f9e7 FF |
33 | FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL, |
34 | FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY, | |
35 | FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX | |
ac2a6666 | 36 | }; |
ac2a6666 PNA |
37 | |
38 | struct flow_offload_tuple { | |
39 | union { | |
40 | struct in_addr src_v4; | |
41 | struct in6_addr src_v6; | |
42 | }; | |
43 | union { | |
44 | struct in_addr dst_v4; | |
45 | struct in6_addr dst_v6; | |
46 | }; | |
47 | struct { | |
48 | __be16 src_port; | |
49 | __be16 dst_port; | |
50 | }; | |
51 | ||
52 | int iifidx; | |
53 | ||
54 | u8 l3proto; | |
55 | u8 l4proto; | |
56 | u8 dir; | |
57 | ||
4f3780c0 FF |
58 | u16 mtu; |
59 | ||
ac2a6666 PNA |
60 | struct dst_entry *dst_cache; |
61 | }; | |
62 | ||
63 | struct flow_offload_tuple_rhash { | |
64 | struct rhash_head node; | |
65 | struct flow_offload_tuple tuple; | |
66 | }; | |
67 | ||
68 | #define FLOW_OFFLOAD_SNAT 0x1 | |
69 | #define FLOW_OFFLOAD_DNAT 0x2 | |
70 | #define FLOW_OFFLOAD_DYING 0x4 | |
59c466dd | 71 | #define FLOW_OFFLOAD_TEARDOWN 0x8 |
ac2a6666 PNA |
72 | |
73 | struct flow_offload { | |
74 | struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX]; | |
b32d2f34 | 75 | struct nf_conn *ct; |
ac2a6666 | 76 | u32 flags; |
9f48e9bf | 77 | u32 timeout; |
62248df8 | 78 | struct rcu_head rcu_head; |
ac2a6666 PNA |
79 | }; |
80 | ||
81 | #define NF_FLOW_TIMEOUT (30 * HZ) | |
82 | ||
83 | struct nf_flow_route { | |
84 | struct { | |
85 | struct dst_entry *dst; | |
ac2a6666 PNA |
86 | } tuple[FLOW_OFFLOAD_DIR_MAX]; |
87 | }; | |
88 | ||
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); | |
92 | ||
93 | int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow); | |
ac2a6666 PNA |
94 | struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table, |
95 | struct flow_offload_tuple *tuple); | |
5f1be84a | 96 | void nf_flow_table_cleanup(struct net_device *dev); |
c0ea1bcb | 97 | |
a268de77 | 98 | int nf_flow_table_init(struct nf_flowtable *flow_table); |
b408c5b0 | 99 | void nf_flow_table_free(struct nf_flowtable *flow_table); |
ac2a6666 | 100 | |
59c466dd | 101 | void flow_offload_teardown(struct flow_offload *flow); |
6bdc3c68 FF |
102 | static inline void flow_offload_dead(struct flow_offload *flow) |
103 | { | |
104 | flow->flags |= FLOW_OFFLOAD_DYING; | |
105 | } | |
ac2a6666 PNA |
106 | |
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); | |
113 | ||
114 | struct flow_ports { | |
115 | __be16 source, dest; | |
116 | }; | |
117 | ||
7c23b629 PNA |
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); | |
122 | ||
ac2a6666 PNA |
123 | #define MODULE_ALIAS_NF_FLOWTABLE(family) \ |
124 | MODULE_ALIAS("nf-flowtable-" __stringify(family)) | |
125 | ||
0286fbc6 | 126 | #endif /* _NF_FLOW_TABLE_H */ |