]>
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> |
af81f9e7 | 9 | #include <linux/netfilter/nf_conntrack_tuple_common.h> |
ac2a6666 | 10 | #include <net/dst.h> |
3b49e2e9 PNA |
11 | |
12 | struct nf_flowtable; | |
13 | ||
14 | struct nf_flowtable_type { | |
15 | struct list_head list; | |
16 | int family; | |
a268de77 | 17 | int (*init)(struct nf_flowtable *ft); |
b408c5b0 | 18 | void (*free)(struct nf_flowtable *ft); |
3b49e2e9 PNA |
19 | nf_hookfn *hook; |
20 | struct module *owner; | |
21 | }; | |
22 | ||
23 | struct nf_flowtable { | |
84453a90 | 24 | struct list_head list; |
3b49e2e9 PNA |
25 | struct rhashtable rhashtable; |
26 | const struct nf_flowtable_type *type; | |
27 | struct delayed_work gc_work; | |
28 | }; | |
29 | ||
ac2a6666 | 30 | enum flow_offload_tuple_dir { |
af81f9e7 FF |
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 | |
ac2a6666 | 34 | }; |
ac2a6666 PNA |
35 | |
36 | struct flow_offload_tuple { | |
37 | union { | |
38 | struct in_addr src_v4; | |
39 | struct in6_addr src_v6; | |
40 | }; | |
41 | union { | |
42 | struct in_addr dst_v4; | |
43 | struct in6_addr dst_v6; | |
44 | }; | |
45 | struct { | |
46 | __be16 src_port; | |
47 | __be16 dst_port; | |
48 | }; | |
49 | ||
50 | int iifidx; | |
51 | ||
52 | u8 l3proto; | |
53 | u8 l4proto; | |
54 | u8 dir; | |
55 | ||
4f3780c0 FF |
56 | u16 mtu; |
57 | ||
ac2a6666 PNA |
58 | struct dst_entry *dst_cache; |
59 | }; | |
60 | ||
61 | struct flow_offload_tuple_rhash { | |
62 | struct rhash_head node; | |
63 | struct flow_offload_tuple tuple; | |
64 | }; | |
65 | ||
66 | #define FLOW_OFFLOAD_SNAT 0x1 | |
67 | #define FLOW_OFFLOAD_DNAT 0x2 | |
68 | #define FLOW_OFFLOAD_DYING 0x4 | |
59c466dd | 69 | #define FLOW_OFFLOAD_TEARDOWN 0x8 |
ac2a6666 PNA |
70 | |
71 | struct flow_offload { | |
72 | struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX]; | |
73 | u32 flags; | |
74 | union { | |
75 | /* Your private driver data here. */ | |
76 | u32 timeout; | |
77 | }; | |
78 | }; | |
79 | ||
80 | #define NF_FLOW_TIMEOUT (30 * HZ) | |
81 | ||
82 | struct nf_flow_route { | |
83 | struct { | |
84 | struct dst_entry *dst; | |
ac2a6666 PNA |
85 | } tuple[FLOW_OFFLOAD_DIR_MAX]; |
86 | }; | |
87 | ||
88 | struct flow_offload *flow_offload_alloc(struct nf_conn *ct, | |
89 | struct nf_flow_route *route); | |
90 | void flow_offload_free(struct flow_offload *flow); | |
91 | ||
92 | int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow); | |
ac2a6666 PNA |
93 | struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table, |
94 | struct flow_offload_tuple *tuple); | |
5f1be84a | 95 | void nf_flow_table_cleanup(struct net_device *dev); |
c0ea1bcb | 96 | |
a268de77 | 97 | int nf_flow_table_init(struct nf_flowtable *flow_table); |
b408c5b0 | 98 | void nf_flow_table_free(struct nf_flowtable *flow_table); |
ac2a6666 | 99 | |
59c466dd | 100 | void flow_offload_teardown(struct flow_offload *flow); |
6bdc3c68 FF |
101 | static inline void flow_offload_dead(struct flow_offload *flow) |
102 | { | |
103 | flow->flags |= FLOW_OFFLOAD_DYING; | |
104 | } | |
ac2a6666 PNA |
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 */ |