Skip to content

Commit

Permalink
netfilter: add xt_FLOWOFFLOAD target
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
nbd168 authored and xanmod committed Oct 30, 2023
1 parent 81d9073 commit 43e8b77
Show file tree
Hide file tree
Showing 6 changed files with 731 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/net/netfilter/nf_flow_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ void nf_flow_table_free(struct nf_flowtable *flow_table);

void flow_offload_teardown(struct flow_offload *flow);

int nf_flow_table_iterate(struct nf_flowtable *flow_table,
void (*iter)(struct nf_flowtable *flowtable,
struct flow_offload *flow, void *data),
void *data);

void nf_flow_snat_port(const struct flow_offload *flow,
struct sk_buff *skb, unsigned int thoff,
u8 protocol, enum flow_offload_tuple_dir dir);
Expand Down
17 changes: 17 additions & 0 deletions include/uapi/linux/netfilter/xt_FLOWOFFLOAD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _XT_FLOWOFFLOAD_H
#define _XT_FLOWOFFLOAD_H

#include <linux/types.h>

enum {
XT_FLOWOFFLOAD_HW = 1 << 0,

XT_FLOWOFFLOAD_MASK = XT_FLOWOFFLOAD_HW
};

struct xt_flowoffload_target_info {
__u32 flags;
};

#endif /* _XT_FLOWOFFLOAD_H */
9 changes: 9 additions & 0 deletions net/netfilter/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,15 @@ config NETFILTER_XT_TARGET_NOTRACK
depends on NETFILTER_ADVANCED
select NETFILTER_XT_TARGET_CT

config NETFILTER_XT_TARGET_FLOWOFFLOAD
tristate '"FLOWOFFLOAD" target support'
depends on NF_FLOW_TABLE
depends on NETFILTER_INGRESS
help
This option adds a `FLOWOFFLOAD' target, which uses the nf_flow_offload
module to speed up processing of packets by bypassing the usual
netfilter chains

config NETFILTER_XT_TARGET_RATEEST
tristate '"RATEEST" target support'
depends on NETFILTER_ADVANCED
Expand Down
1 change: 1 addition & 0 deletions net/netfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
obj-$(CONFIG_NETFILTER_XT_TARGET_CT) += xt_CT.o
obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
obj-$(CONFIG_NETFILTER_XT_TARGET_FLOWOFFLOAD) += xt_FLOWOFFLOAD.o
obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o
obj-$(CONFIG_NETFILTER_XT_TARGET_HMARK) += xt_HMARK.o
obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
Expand Down
5 changes: 2 additions & 3 deletions net/netfilter/nf_flow_table_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <linux/netdevice.h>
#include <net/ip.h>
#include <net/ip6_route.h>
#include <net/netfilter/nf_tables.h>
#include <net/netfilter/nf_flow_table.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_core.h>
Expand Down Expand Up @@ -366,8 +365,7 @@ flow_offload_lookup(struct nf_flowtable *flow_table,
}
EXPORT_SYMBOL_GPL(flow_offload_lookup);

static int
nf_flow_table_iterate(struct nf_flowtable *flow_table,
int nf_flow_table_iterate(struct nf_flowtable *flow_table,
void (*iter)(struct nf_flowtable *flowtable,
struct flow_offload *flow, void *data),
void *data)
Expand Down Expand Up @@ -428,6 +426,7 @@ static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
nf_flow_offload_stats(flow_table, flow);
}
}
EXPORT_SYMBOL_GPL(nf_flow_table_iterate);

void nf_flow_table_gc_run(struct nf_flowtable *flow_table)
{
Expand Down

0 comments on commit 43e8b77

Please sign in to comment.