Skip to content

Commit 5fa2a76

Browse files
kaberDavid S. Miller
authored andcommitted
[NETFILTER]: ip6_tables: consolidate dst and hbh matches
The matches are identical besides one looking for NEXTHDR_HOP, the other for NEXTHDR_DEST. Remove ip6t_dst.c and handle both in ip6t_hbh.c. Signed-off-by: Patrick McHardy <kaber@trash,net> Signed-off-by: David S. Miller <[email protected]>
1 parent 91270cf commit 5fa2a76

File tree

3 files changed

+25
-244
lines changed

3 files changed

+25
-244
lines changed

net/ipv6/netfilter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Link order matters here.
66
obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
77
obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o
8-
obj-$(CONFIG_IP6_NF_MATCH_OPTS) += ip6t_hbh.o ip6t_dst.o
8+
obj-$(CONFIG_IP6_NF_MATCH_OPTS) += ip6t_hbh.o
99
obj-$(CONFIG_IP6_NF_MATCH_IPV6HEADER) += ip6t_ipv6header.o
1010
obj-$(CONFIG_IP6_NF_MATCH_FRAG) += ip6t_frag.o
1111
obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o

net/ipv6/netfilter/ip6t_dst.c

Lines changed: 0 additions & 219 deletions
This file was deleted.

net/ipv6/netfilter/ip6t_hbh.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@
1919
#include <linux/netfilter_ipv6/ip6_tables.h>
2020
#include <linux/netfilter_ipv6/ip6t_opts.h>
2121

22-
#define HOPBYHOP 1
23-
2422
MODULE_LICENSE("GPL");
25-
#if HOPBYHOP
26-
MODULE_DESCRIPTION("IPv6 HbH match");
27-
#else
28-
MODULE_DESCRIPTION("IPv6 DST match");
29-
#endif
23+
MODULE_DESCRIPTION("IPv6 opts match");
3024
MODULE_AUTHOR("Andras Kis-Szabo <[email protected]>");
25+
MODULE_ALIAS("ip6t_dst");
3126

3227
#if 0
3328
#define DEBUGP printk
@@ -71,11 +66,7 @@ match(const struct sk_buff *skb,
7166
u8 _optlen, *lp = NULL;
7267
unsigned int optlen;
7368

74-
#if HOPBYHOP
75-
if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP, NULL) < 0)
76-
#else
77-
if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST, NULL) < 0)
78-
#endif
69+
if (ipv6_find_hdr(skb, &ptr, match->data, NULL) < 0)
7970
return 0;
8071

8172
oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
@@ -193,26 +184,35 @@ checkentry(const char *tablename,
193184
return 1;
194185
}
195186

196-
static struct ip6t_match opts_match = {
197-
#if HOPBYHOP
198-
.name = "hbh",
199-
#else
200-
.name = "dst",
201-
#endif
202-
.match = match,
203-
.matchsize = sizeof(struct ip6t_opts),
204-
.checkentry = checkentry,
205-
.me = THIS_MODULE,
187+
static struct xt_match opts_match[] = {
188+
{
189+
.name = "hbh",
190+
.family = AF_INET6,
191+
.match = match,
192+
.matchsize = sizeof(struct ip6t_opts),
193+
.checkentry = checkentry,
194+
.me = THIS_MODULE,
195+
.data = NEXTHDR_HOP,
196+
},
197+
{
198+
.name = "dst",
199+
.family = AF_INET6,
200+
.match = match,
201+
.matchsize = sizeof(struct ip6t_opts),
202+
.checkentry = checkentry,
203+
.me = THIS_MODULE,
204+
.data = NEXTHDR_DEST,
205+
},
206206
};
207207

208208
static int __init ip6t_hbh_init(void)
209209
{
210-
return ip6t_register_match(&opts_match);
210+
return xt_register_matches(opts_match, ARRAY_SIZE(opts_match));
211211
}
212212

213213
static void __exit ip6t_hbh_fini(void)
214214
{
215-
ip6t_unregister_match(&opts_match);
215+
xt_unregister_matches(opts_match, ARRAY_SIZE(opts_match));
216216
}
217217

218218
module_init(ip6t_hbh_init);

0 commit comments

Comments
 (0)