2018-01-06 17:04:07 -07:00
|
|
|
#ifndef _NF_FLOW_TABLE_H
|
|
|
|
#define _NF_FLOW_TABLE_H
|
|
|
|
|
2018-01-06 17:04:11 -07:00
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/in6.h>
|
|
|
|
#include <linux/netdevice.h>
|
2018-06-17 20:52:50 -06:00
|
|
|
#include <linux/rhashtable-types.h>
|
2018-01-06 17:04:11 -07:00
|
|
|
#include <linux/rcupdate.h>
|
2018-02-26 02:15:08 -07:00
|
|
|
#include <linux/netfilter/nf_conntrack_tuple_common.h>
|
2018-01-06 17:04:11 -07:00
|
|
|
#include <net/dst.h>
|
2018-01-06 17:04:07 -07:00
|
|
|
|
|
|
|
struct nf_flowtable;
|
|
|
|
|
|
|
|
struct nf_flowtable_type {
|
|
|
|
struct list_head list;
|
|
|
|
int family;
|
2018-02-26 02:15:17 -07:00
|
|
|
int (*init)(struct nf_flowtable *ft);
|
2018-02-06 05:22:47 -07:00
|
|
|
void (*free)(struct nf_flowtable *ft);
|
2018-01-06 17:04:07 -07:00
|
|
|
nf_hookfn *hook;
|
|
|
|
struct module *owner;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nf_flowtable {
|
2018-02-26 02:15:19 -07:00
|
|
|
struct list_head list;
|
2018-01-06 17:04:07 -07:00
|
|
|
struct rhashtable rhashtable;
|
|
|
|
const struct nf_flowtable_type *type;
|
|
|
|
struct delayed_work gc_work;
|
|
|
|
};
|
|
|
|
|
2018-01-06 17:04:11 -07:00
|
|
|
enum flow_offload_tuple_dir {
|
2018-02-26 02:15:08 -07:00
|
|
|
FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL,
|
|
|
|
FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY,
|
|
|
|
FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX
|
2018-01-06 17:04:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct flow_offload_tuple {
|
|
|
|
union {
|
|
|
|
struct in_addr src_v4;
|
|
|
|
struct in6_addr src_v6;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
struct in_addr dst_v4;
|
|
|
|
struct in6_addr dst_v6;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
__be16 src_port;
|
|
|
|
__be16 dst_port;
|
|
|
|
};
|
|
|
|
|
|
|
|
int iifidx;
|
|
|
|
|
|
|
|
u8 l3proto;
|
|
|
|
u8 l4proto;
|
|
|
|
u8 dir;
|
|
|
|
|
|
|
|
int oifidx;
|
|
|
|
|
2018-02-26 02:15:11 -07:00
|
|
|
u16 mtu;
|
|
|
|
|
2018-01-06 17:04:11 -07:00
|
|
|
struct dst_entry *dst_cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct flow_offload_tuple_rhash {
|
|
|
|
struct rhash_head node;
|
|
|
|
struct flow_offload_tuple tuple;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FLOW_OFFLOAD_SNAT 0x1
|
|
|
|
#define FLOW_OFFLOAD_DNAT 0x2
|
|
|
|
#define FLOW_OFFLOAD_DYING 0x4
|
2018-02-26 02:15:21 -07:00
|
|
|
#define FLOW_OFFLOAD_TEARDOWN 0x8
|
2018-01-06 17:04:11 -07:00
|
|
|
|
|
|
|
struct flow_offload {
|
|
|
|
struct flow_offload_tuple_rhash tuplehash[FLOW_OFFLOAD_DIR_MAX];
|
|
|
|
u32 flags;
|
|
|
|
union {
|
|
|
|
/* Your private driver data here. */
|
|
|
|
u32 timeout;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NF_FLOW_TIMEOUT (30 * HZ)
|
|
|
|
|
|
|
|
struct nf_flow_route {
|
|
|
|
struct {
|
|
|
|
struct dst_entry *dst;
|
|
|
|
int ifindex;
|
|
|
|
} tuple[FLOW_OFFLOAD_DIR_MAX];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct flow_offload *flow_offload_alloc(struct nf_conn *ct,
|
|
|
|
struct nf_flow_route *route);
|
|
|
|
void flow_offload_free(struct flow_offload *flow);
|
|
|
|
|
|
|
|
int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow);
|
|
|
|
struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
|
|
|
|
struct flow_offload_tuple *tuple);
|
|
|
|
int nf_flow_table_iterate(struct nf_flowtable *flow_table,
|
|
|
|
void (*iter)(struct flow_offload *flow, void *data),
|
|
|
|
void *data);
|
2018-02-06 05:22:44 -07:00
|
|
|
|
2018-10-11 12:01:54 -06:00
|
|
|
void nf_flow_table_cleanup(struct net_device *dev);
|
2018-02-06 05:22:44 -07:00
|
|
|
|
2018-02-26 02:15:17 -07:00
|
|
|
int nf_flow_table_init(struct nf_flowtable *flow_table);
|
2018-02-06 05:22:47 -07:00
|
|
|
void nf_flow_table_free(struct nf_flowtable *flow_table);
|
2018-01-06 17:04:11 -07:00
|
|
|
|
2018-02-26 02:15:21 -07:00
|
|
|
void flow_offload_teardown(struct flow_offload *flow);
|
2018-02-26 02:15:20 -07:00
|
|
|
static inline void flow_offload_dead(struct flow_offload *flow)
|
|
|
|
{
|
|
|
|
flow->flags |= FLOW_OFFLOAD_DYING;
|
|
|
|
}
|
2018-01-06 17:04:11 -07:00
|
|
|
|
|
|
|
int nf_flow_snat_port(const struct flow_offload *flow,
|
|
|
|
struct sk_buff *skb, unsigned int thoff,
|
|
|
|
u8 protocol, enum flow_offload_tuple_dir dir);
|
|
|
|
int nf_flow_dnat_port(const struct flow_offload *flow,
|
|
|
|
struct sk_buff *skb, unsigned int thoff,
|
|
|
|
u8 protocol, enum flow_offload_tuple_dir dir);
|
|
|
|
|
|
|
|
struct flow_ports {
|
|
|
|
__be16 source, dest;
|
|
|
|
};
|
|
|
|
|
2018-01-06 17:04:22 -07:00
|
|
|
unsigned int nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
|
|
|
|
const struct nf_hook_state *state);
|
|
|
|
unsigned int nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
|
|
|
|
const struct nf_hook_state *state);
|
|
|
|
|
2018-01-06 17:04:11 -07:00
|
|
|
#define MODULE_ALIAS_NF_FLOWTABLE(family) \
|
|
|
|
MODULE_ALIAS("nf-flowtable-" __stringify(family))
|
|
|
|
|
2018-01-06 17:04:07 -07:00
|
|
|
#endif /* _FLOW_OFFLOAD_H */
|