Skip to content

Commit 4f948db

Browse files
author
Jan Engelhardt
committed
netfilter: xtables: remove almost-unused xt_match_param.data member
This member is taking up a "long" per match, yet is only used by one module out of the roughly 90 modules, ip6t_hbh. ip6t_hbh can be restructured a little to accomodate for the lack of the .data member. This variant uses checking the par->match address, which should avoid having to add two extra functions, including calls, i.e. (hbh_mt6: call hbhdst_mt6(skb, par, NEXTHDR_OPT), dst_mt6: call hbhdst_mt6(skb, par, NEXTHDR_DEST)) Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
1 parent 1659978 commit 4f948db

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎include/linux/netfilter/x_tables.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ struct xt_match {
315315
/* Set this to THIS_MODULE if you are a module, otherwise NULL */
316316
struct module *me;
317317

318-
/* Free to use by each match */
319-
unsigned long data;
320-
321318
const char *table;
322319
unsigned int matchsize;
323320
#ifdef CONFIG_COMPAT

‎net/ipv6/netfilter/ip6t_hbh.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ MODULE_ALIAS("ip6t_dst");
4141
* 5 -> RTALERT 2 x x
4242
*/
4343

44+
static struct xt_match hbh_mt6_reg[] __read_mostly;
45+
4446
static bool
4547
hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
4648
{
@@ -58,7 +60,9 @@ hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
5860
unsigned int optlen;
5961
int err;
6062

61-
err = ipv6_find_hdr(skb, &ptr, par->match->data, NULL);
63+
err = ipv6_find_hdr(skb, &ptr,
64+
(par->match == &hbh_mt6_reg[0]) ?
65+
NEXTHDR_HOP : NEXTHDR_DEST, NULL);
6266
if (err < 0) {
6367
if (err != -ENOENT)
6468
*par->hotdrop = true;
@@ -179,13 +183,13 @@ static bool hbh_mt6_check(const struct xt_mtchk_param *par)
179183

180184
static struct xt_match hbh_mt6_reg[] __read_mostly = {
181185
{
186+
/* Note, hbh_mt6 relies on the order of hbh_mt6_reg */
182187
.name = "hbh",
183188
.family = NFPROTO_IPV6,
184189
.match = hbh_mt6,
185190
.matchsize = sizeof(struct ip6t_opts),
186191
.checkentry = hbh_mt6_check,
187192
.me = THIS_MODULE,
188-
.data = NEXTHDR_HOP,
189193
},
190194
{
191195
.name = "dst",
@@ -194,7 +198,6 @@ static struct xt_match hbh_mt6_reg[] __read_mostly = {
194198
.matchsize = sizeof(struct ip6t_opts),
195199
.checkentry = hbh_mt6_check,
196200
.me = THIS_MODULE,
197-
.data = NEXTHDR_DEST,
198201
},
199202
};
200203

0 commit comments

Comments
 (0)