summaryrefslogtreecommitdiffstats
path: root/iptables/xtables-compat-multi.c
blob: 0b05eaded6175171e94b3a16db1013f24f2a7085 (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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xshared.h"

#include "xtables-multi.h"

static const struct subcommand multi_subcommands[] = {
	{"iptables-xml",		iptables_xml_main},
	{"xml",				iptables_xml_main},
	{"iptables",			xtables_ip4_main},
	{"iptables-compat",		xtables_ip4_main},
	{"main4",			xtables_ip4_main},
	{"save4",			xtables_ip4_save_main},
	{"restore4",			xtables_ip4_restore_main},
	{"iptables-save",		xtables_ip4_save_main},
	{"iptables-restore",		xtables_ip4_restore_main},
	{"iptables-compat-save",	xtables_ip4_save_main},
	{"iptables-compat-restore",	xtables_ip4_restore_main},
	{"ip6tables",			xtables_ip6_main},
	{"ip6tables-compat",		xtables_ip6_main},
	{"main6",			xtables_ip6_main},
	{"save6",			xtables_ip6_save_main},
	{"restore6",			xtables_ip6_restore_main},
	{"ip6tables-save",		xtables_ip6_save_main},
	{"ip6tables-restore",		xtables_ip6_restore_main},
	{"ip6tables-compat-save",	xtables_ip6_save_main},
	{"ip6tables-compat-restore",	xtables_ip6_restore_main},
	{"iptables-translate",		xtables_ip4_xlate_main},
	{"ip6tables-translate",		xtables_ip6_xlate_main},
	{"iptables-restore-translate",	xtables_ip4_xlate_restore_main},
	{"ip6tables-restore-translate",	xtables_ip6_xlate_restore_main},
	{"arptables",			xtables_arp_main},
	{"arptables-compat",		xtables_arp_main},
	{"ebtables-compat",		xtables_eb_main},
	{"ebtables-translate",		xtables_eb_xlate_main},
	{"ebtables",			xtables_eb_main},
	{NULL},
};

int main(int argc, char **argv)
{
	return subcmd_main(argc, argv, multi_subcommands);
}
ass='del'>-
/* The core set type structure */
struct ip_set_type {
struct list_head list;
@@ -294,8 +287,6 @@ struct ip_set {
const struct ip_set_type_variant *variant;
/* The actual INET family */
u8 family;
- /* Set type flags, filled/modified by create/resize */
- u8 flags;
/* The type specific data */
void *data;
};
@@ -318,12 +309,14 @@ extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
/* Allocate members */
static inline void *
-ip_set_alloc(size_t size, gfp_t gfp_mask, u8 *flags)
+ip_set_alloc(size_t size, gfp_t gfp_mask)
{
- void *members = kzalloc(size, gfp_mask | __GFP_NOWARN);
+ void *members = NULL;
+
+ if (size < KMALLOC_MAX_SIZE)
+ members = kzalloc(size, gfp_mask | __GFP_NOWARN);
if (members) {
- *flags |= IP_SET_FLAG_KMALLOC;
pr_debug("%p: allocated with kmalloc", members);
return members;
}
@@ -331,21 +324,20 @@ ip_set_alloc(size_t size, gfp_t gfp_mask, u8 *flags)
members = __vmalloc(size, gfp_mask | __GFP_ZERO, PAGE_KERNEL);
if (!members)
return NULL;
- *flags &= ~IP_SET_FLAG_KMALLOC;
pr_debug("%p: allocated with vmalloc", members);
return members;
}
static inline void
-ip_set_free(void *members, u8 flags)
+ip_set_free(void *members)
{
pr_debug("%p: free with %s", members,
- flags & IP_SET_FLAG_KMALLOC ? "kmalloc" : "vmalloc");
- if (flags & IP_SET_FLAG_KMALLOC)
- kfree(members);
- else
+ is_vmalloc_addr(members) ? "vfree" : "kfree");
+ if (is_vmalloc_addr(members))
vfree(members);
+ else
+ kfree(members);
}
static inline bool