aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/iptables/patches/800-flowoffload_target.patch
blob: 2f79ee835a6fd5e17fa93339ab946030ab100015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- /dev/null
+++ b/extensions/libxt_FLOWOFFLOAD.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <xtables.h>
+#include <linux/netfilter/xt_FLOWOFFLOAD.h>
+
+enum {
+    O_HW,
+};
+
+static void offload_help(void)
+{
+	printf(
+"FLOWOFFLOAD target options:\n"
+" --hw				Enable hardware offload\n"
+	);
+}
+
+static const struct xt_option_entry offload_opts[] = {
+	{.name = "hw", .id = O_HW, .type = XTTYPE_NONE},
+	XTOPT_TABLEEND,
+};
+
+static void offload_parse(struct xt_option_call *cb)
+{
+	struct xt_flowoffload_target_info *info = cb->data;
+
+	xtables_option_parse(cb);
+	switch (cb->entry->id) {
+	case O_HW:
+		info->flags |= XT_FLOWOFFLOAD_HW;
+		break;
+	}
+}
+
+static void offload_print(const void *ip, const struct xt_entry_target *target, int numeric)
+{
+	const struct xt_flowoffload_target_info *info =
+		(const struct xt_flowoffload_target_info *)target->data;
+
+	printf(" FLOWOFFLOAD");
+	if (info->flags & XT_FLOWOFFLOAD_HW)
+		printf(" hw");
+}
+
+static void offload_save(const void *ip, const struct xt_entry_target *target)
+{
+	const struct xt_flowoffload_target_info *info =
+		(const struct xt_flowoffload_target_info *)target->data;
+
+	if (info->flags & XT_FLOWOFFLOAD_HW)
+		printf(" --hw");
+}
+
+static struct xtables_target offload_tg_reg[] = {
+	{
+		.family		= NFPROTO_UNSPEC,
+		.name		= "FLOWOFFLOAD",
+		.revision	= 0,
+		.version	= XTABLES_VERSION,
+		.size		= XT_ALIGN(sizeof(struct xt_flowoffload_target_info)),
+		.userspacesize	= sizeof(struct xt_flowoffload_target_info),
+		.help		= offload_help,
+		.print		= offload_print,
+		.save		= offload_save,
+		.x6_parse	= offload_parse,
+		.x6_options	= offload_opts,
+	},
+};
+
+void _init(void)
+{
+	xtables_register_targets(offload_tg_reg, ARRAY_SIZE(offload_tg_reg));
+}
--- /dev/null
+++ b/include/linux/netfilter/xt_FLOWOFFLOAD.h
@@ -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 */