Skip to content

Commit e948b20

Browse files
Jan Engelhardtkaber
authored andcommitted
netfilter: rename ipt_recent to xt_recent
Like with other modules (such as ipt_state), ipt_recent.h is changed to forward definitions to (IOW include) xt_recent.h, and xt_recent.c is changed to use the new constant names. Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 76108ce commit e948b20

8 files changed

Lines changed: 69 additions & 49 deletions

File tree

include/linux/netfilter/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ header-y += xt_owner.h
3232
header-y += xt_pkttype.h
3333
header-y += xt_rateest.h
3434
header-y += xt_realm.h
35+
header-y += xt_recent.h
3536
header-y += xt_sctp.h
3637
header-y += xt_state.h
3738
header-y += xt_statistic.h
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef _LINUX_NETFILTER_XT_RECENT_H
2+
#define _LINUX_NETFILTER_XT_RECENT_H 1
3+
4+
enum {
5+
XT_RECENT_CHECK = 1 << 0,
6+
XT_RECENT_SET = 1 << 1,
7+
XT_RECENT_UPDATE = 1 << 2,
8+
XT_RECENT_REMOVE = 1 << 3,
9+
XT_RECENT_TTL = 1 << 4,
10+
11+
XT_RECENT_SOURCE = 0,
12+
XT_RECENT_DEST = 1,
13+
14+
XT_RECENT_NAME_LEN = 200,
15+
};
16+
17+
struct xt_recent_mtinfo {
18+
u_int32_t seconds;
19+
u_int32_t hit_count;
20+
u_int8_t check_set;
21+
u_int8_t invert;
22+
char name[XT_RECENT_NAME_LEN];
23+
u_int8_t side;
24+
};
25+
26+
#endif /* _LINUX_NETFILTER_XT_RECENT_H */
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
#ifndef _IPT_RECENT_H
22
#define _IPT_RECENT_H
33

4-
#define RECENT_NAME "ipt_recent"
5-
#define RECENT_VER "v0.3.1"
4+
#include <linux/netfilter/xt_recent.h>
65

7-
#define IPT_RECENT_CHECK 1
8-
#define IPT_RECENT_SET 2
9-
#define IPT_RECENT_UPDATE 4
10-
#define IPT_RECENT_REMOVE 8
11-
#define IPT_RECENT_TTL 16
6+
#define ipt_recent_info xt_recent_mtinfo
127

13-
#define IPT_RECENT_SOURCE 0
14-
#define IPT_RECENT_DEST 1
8+
enum {
9+
IPT_RECENT_CHECK = XT_RECENT_CHECK,
10+
IPT_RECENT_SET = XT_RECENT_SET,
11+
IPT_RECENT_UPDATE = XT_RECENT_UPDATE,
12+
IPT_RECENT_REMOVE = XT_RECENT_REMOVE,
13+
IPT_RECENT_TTL = XT_RECENT_TTL,
1514

16-
#define IPT_RECENT_NAME_LEN 200
15+
IPT_RECENT_SOURCE = XT_RECENT_SOURCE,
16+
IPT_RECENT_DEST = XT_RECENT_DEST,
1717

18-
struct ipt_recent_info {
19-
u_int32_t seconds;
20-
u_int32_t hit_count;
21-
u_int8_t check_set;
22-
u_int8_t invert;
23-
char name[IPT_RECENT_NAME_LEN];
24-
u_int8_t side;
18+
IPT_RECENT_NAME_LEN = XT_RECENT_NAME_LEN,
2519
};
2620

2721
#endif /*_IPT_RECENT_H*/

net/ipv4/netfilter/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,6 @@ config IP_NF_IPTABLES
5757
To compile it as a module, choose M here. If unsure, say N.
5858

5959
# The matches.
60-
config IP_NF_MATCH_RECENT
61-
tristate '"recent" match support'
62-
depends on IP_NF_IPTABLES
63-
depends on NETFILTER_ADVANCED
64-
help
65-
This match is used for creating one or many lists of recently
66-
used addresses and then matching against that/those list(s).
67-
68-
Short options are available by using 'iptables -m recent -h'
69-
Official Website: <http://snowman.net/projects/ipt_recent/>
70-
71-
To compile it as a module, choose M here. If unsure, say N.
72-
7360
config IP_NF_MATCH_ECN
7461
tristate '"ecn" match support'
7562
depends on IP_NF_IPTABLES

net/ipv4/netfilter/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ obj-$(CONFIG_IP_NF_SECURITY) += iptable_security.o
4848
obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o
4949
obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o
5050
obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o
51-
obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o
5251
obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
5352

5453
# targets

net/netfilter/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,17 @@ config NETFILTER_XT_MATCH_REALM
732732
If you want to compile it as a module, say M here and read
733733
<file:Documentation/kbuild/modules.txt>. If unsure, say `N'.
734734

735+
config NETFILTER_XT_MATCH_RECENT
736+
tristate '"recent" match support'
737+
depends on NETFILTER_XTABLES
738+
depends on NETFILTER_ADVANCED
739+
---help---
740+
This match is used for creating one or many lists of recently
741+
used addresses and then matching against that/those list(s).
742+
743+
Short options are available by using 'iptables -m recent -h'
744+
Official Website: <http://snowman.net/projects/ipt_recent/>
745+
735746
config NETFILTER_XT_MATCH_SCTP
736747
tristate '"sctp" protocol match support (EXPERIMENTAL)'
737748
depends on NETFILTER_XTABLES && EXPERIMENTAL

net/netfilter/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o
7676
obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o
7777
obj-$(CONFIG_NETFILTER_XT_MATCH_RATEEST) += xt_rateest.o
7878
obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o
79+
obj-$(CONFIG_NETFILTER_XT_MATCH_RECENT) += xt_recent.o
7980
obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o
8081
obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o
8182
obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
#include <net/net_namespace.h>
2828

2929
#include <linux/netfilter/x_tables.h>
30-
#include <linux/netfilter_ipv4/ipt_recent.h>
30+
#include <linux/netfilter/xt_recent.h>
3131

3232
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
3333
MODULE_DESCRIPTION("Xtables: \"recently-seen\" host matching for IPv4");
3434
MODULE_LICENSE("GPL");
35+
MODULE_ALIAS("ipt_recent");
3536

3637
static unsigned int ip_list_tot = 100;
3738
static unsigned int ip_pkt_list_tot = 20;
@@ -64,7 +65,7 @@ struct recent_entry {
6465

6566
struct recent_table {
6667
struct list_head list;
67-
char name[IPT_RECENT_NAME_LEN];
68+
char name[XT_RECENT_NAME_LEN];
6869
#ifdef CONFIG_PROC_FS
6970
struct proc_dir_entry *proc;
7071
#endif
@@ -175,14 +176,14 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,
175176
const void *matchinfo, int offset, unsigned int protoff,
176177
bool *hotdrop)
177178
{
178-
const struct ipt_recent_info *info = matchinfo;
179+
const struct xt_recent_mtinfo *info = matchinfo;
179180
struct recent_table *t;
180181
struct recent_entry *e;
181182
__be32 addr;
182183
u_int8_t ttl;
183184
bool ret = info->invert;
184185

185-
if (info->side == IPT_RECENT_DEST)
186+
if (info->side == XT_RECENT_DEST)
186187
addr = ip_hdr(skb)->daddr;
187188
else
188189
addr = ip_hdr(skb)->saddr;
@@ -195,9 +196,9 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,
195196
spin_lock_bh(&recent_lock);
196197
t = recent_table_lookup(info->name);
197198
e = recent_entry_lookup(t, addr,
198-
info->check_set & IPT_RECENT_TTL ? ttl : 0);
199+
info->check_set & XT_RECENT_TTL ? ttl : 0);
199200
if (e == NULL) {
200-
if (!(info->check_set & IPT_RECENT_SET))
201+
if (!(info->check_set & XT_RECENT_SET))
201202
goto out;
202203
e = recent_entry_init(t, addr, ttl);
203204
if (e == NULL)
@@ -206,12 +207,12 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,
206207
goto out;
207208
}
208209

209-
if (info->check_set & IPT_RECENT_SET)
210+
if (info->check_set & XT_RECENT_SET)
210211
ret = !ret;
211-
else if (info->check_set & IPT_RECENT_REMOVE) {
212+
else if (info->check_set & XT_RECENT_REMOVE) {
212213
recent_entry_remove(t, e);
213214
ret = !ret;
214-
} else if (info->check_set & (IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) {
215+
} else if (info->check_set & (XT_RECENT_CHECK | XT_RECENT_UPDATE)) {
215216
unsigned long time = jiffies - info->seconds * HZ;
216217
unsigned int i, hits = 0;
217218

@@ -225,8 +226,8 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,
225226
}
226227
}
227228

228-
if (info->check_set & IPT_RECENT_SET ||
229-
(info->check_set & IPT_RECENT_UPDATE && ret)) {
229+
if (info->check_set & XT_RECENT_SET ||
230+
(info->check_set & XT_RECENT_UPDATE && ret)) {
230231
recent_entry_update(t, e);
231232
e->ttl = ttl;
232233
}
@@ -240,22 +241,22 @@ recent_mt_check(const char *tablename, const void *ip,
240241
const struct xt_match *match, void *matchinfo,
241242
unsigned int hook_mask)
242243
{
243-
const struct ipt_recent_info *info = matchinfo;
244+
const struct xt_recent_mtinfo *info = matchinfo;
244245
struct recent_table *t;
245246
unsigned i;
246247
bool ret = false;
247248

248249
if (hweight8(info->check_set &
249-
(IPT_RECENT_SET | IPT_RECENT_REMOVE |
250-
IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) != 1)
250+
(XT_RECENT_SET | XT_RECENT_REMOVE |
251+
XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1)
251252
return false;
252-
if ((info->check_set & (IPT_RECENT_SET | IPT_RECENT_REMOVE)) &&
253+
if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) &&
253254
(info->seconds || info->hit_count))
254255
return false;
255256
if (info->hit_count > ip_pkt_list_tot)
256257
return false;
257258
if (info->name[0] == '\0' ||
258-
strnlen(info->name, IPT_RECENT_NAME_LEN) == IPT_RECENT_NAME_LEN)
259+
strnlen(info->name, XT_RECENT_NAME_LEN) == XT_RECENT_NAME_LEN)
259260
return false;
260261

261262
mutex_lock(&recent_mutex);
@@ -296,7 +297,7 @@ recent_mt_check(const char *tablename, const void *ip,
296297

297298
static void recent_mt_destroy(const struct xt_match *match, void *matchinfo)
298299
{
299-
const struct ipt_recent_info *info = matchinfo;
300+
const struct xt_recent_mtinfo *info = matchinfo;
300301
struct recent_table *t;
301302

302303
mutex_lock(&recent_mutex);
@@ -461,7 +462,7 @@ static struct xt_match recent_mt_reg __read_mostly = {
461462
.name = "recent",
462463
.family = AF_INET,
463464
.match = recent_mt,
464-
.matchsize = sizeof(struct ipt_recent_info),
465+
.matchsize = sizeof(struct xt_recent_mtinfo),
465466
.checkentry = recent_mt_check,
466467
.destroy = recent_mt_destroy,
467468
.me = THIS_MODULE,

0 commit comments

Comments
 (0)