]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/net/netfilter/nf_flow_table.h
netfilter: nf_flow_table: fix priv pointer for netdev hook
[mirror_ubuntu-jammy-kernel.git] / include / net / netfilter / nf_flow_table.h
CommitLineData
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 8#include <linux/rcupdate.h>
af81f9e7 9#include <linux/netfilter/nf_conntrack_tuple_common.h>
ac2a6666 10#include <net/dst.h>
3b49e2e9
PNA
11
12struct nf_flowtable;
13
14struct 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
23struct nf_flowtable {
24 struct rhashtable rhashtable;
25 const struct nf_flowtable_type *type;
26 struct delayed_work gc_work;
27};
28
ac2a6666 29enum flow_offload_tuple_dir {
af81f9e7
FF
30 FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL,
31 FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY,
32 FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX
ac2a6666 33};
ac2a6666
PNA
34
35struct 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
4f3780c0
FF
57 u16 mtu;
58
ac2a6666
PNA
59 struct dst_entry *dst_cache;
60};
61
62struct flow_offload_tuple_rhash {
63 struct rhash_head node;
64 struct flow_offload_tuple tuple;
65};
66
67#define FLOW_OFFLOAD_SNAT 0x1
68#define FLOW_OFFLOAD_DNAT 0x2
69#define FLOW_OFFLOAD_DYING 0x4
70
71struct 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
82struct nf_flow_route {
83 struct {
84 struct dst_entry *dst;
85 int ifindex;
86 } tuple[FLOW_OFFLOAD_DIR_MAX];
87};
88
89struct flow_offload *flow_offload_alloc(struct nf_conn *ct,
90 struct nf_flow_route *route);
91void flow_offload_free(struct flow_offload *flow);
92
93int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow);
ac2a6666
PNA
94struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
95 struct flow_offload_tuple *tuple);
96int nf_flow_table_iterate(struct nf_flowtable *flow_table,
97 void (*iter)(struct flow_offload *flow, void *data),
98 void *data);
c0ea1bcb
PNA
99
100void nf_flow_table_cleanup(struct net *net, struct net_device *dev);
101
a268de77 102int nf_flow_table_init(struct nf_flowtable *flow_table);
b408c5b0 103void nf_flow_table_free(struct nf_flowtable *flow_table);
ac2a6666
PNA
104
105void flow_offload_dead(struct flow_offload *flow);
106
107int 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);
110int 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
114struct flow_ports {
115 __be16 source, dest;
116};
117
7c23b629
PNA
118unsigned int nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
119 const struct nf_hook_state *state);
120unsigned 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
3b49e2e9 126#endif /* _FLOW_OFFLOAD_H */