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))
Unified · Split
| @@ -315,9 +315,6 @@ struct xt_match { · 314 unmodified lines | |||
| 315 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ | 315 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
| 316 | struct module *me; | 316 | struct module *me; |
| 317 | 317 | ||
| 318 | /* Free to use by each match */ | ||
| 319 | unsigned long data; | ||
| 320 | |||
| 321 | const char *table; | 318 | const char *table; |
| 322 | unsigned int matchsize; | 319 | unsigned int matchsize; |
| 323 | #ifdef CONFIG_COMPAT | 320 | #ifdef CONFIG_COMPAT |
| @@ -41,6 +41,8 @@ MODULE_ALIAS("ip6t_dst"); · 40 unmodified lines | |||
| 41 | * 5 -> RTALERT 2 x x | 41 | * 5 -> RTALERT 2 x x |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | static struct xt_match hbh_mt6_reg[] __read_mostly; | ||
| 45 | |||
| 44 | static bool | 46 | static bool |
| 45 | hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par) | 47 | hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par) |
| 46 | { | 48 | { |
| @@ -58,7 +60,9 @@ hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par) · 11 unmodified lines | |||
| 58 | unsigned int optlen; | 60 | unsigned int optlen; |
| 59 | int err; | 61 | int err; |
| 60 | 62 | ||
| 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); | ||
| 62 | if (err < 0) { | 66 | if (err < 0) { |
| 63 | if (err != -ENOENT) | 67 | if (err != -ENOENT) |
| 64 | *par->hotdrop = true; | 68 | *par->hotdrop = true; |
| @@ -179,13 +183,13 @@ static bool hbh_mt6_check(const struct xt_mtchk_param *par) · 114 unmodified lines | |||
| 179 | 183 | ||
| 180 | static struct xt_match hbh_mt6_reg[] __read_mostly = { | 184 | static struct xt_match hbh_mt6_reg[] __read_mostly = { |
| 181 | { | 185 | { |
| 186 | /* Note, hbh_mt6 relies on the order of hbh_mt6_reg */ | ||
| 182 | .name = "hbh", | 187 | .name = "hbh", |
| 183 | .family = NFPROTO_IPV6, | 188 | .family = NFPROTO_IPV6, |
| 184 | .match = hbh_mt6, | 189 | .match = hbh_mt6, |
| 185 | .matchsize = sizeof(struct ip6t_opts), | 190 | .matchsize = sizeof(struct ip6t_opts), |
| 186 | .checkentry = hbh_mt6_check, | 191 | .checkentry = hbh_mt6_check, |
| 187 | .me = THIS_MODULE, | 192 | .me = THIS_MODULE, |
| 188 | .data = NEXTHDR_HOP, | ||
| 189 | }, | 193 | }, |
| 190 | { | 194 | { |
| 191 | .name = "dst", | 195 | .name = "dst", |
| @@ -194,7 +198,6 @@ static struct xt_match hbh_mt6_reg[] __read_mostly = { · 2 unmodified lines | |||
| 194 | .matchsize = sizeof(struct ip6t_opts), | 198 | .matchsize = sizeof(struct ip6t_opts), |
| 195 | .checkentry = hbh_mt6_check, | 199 | .checkentry = hbh_mt6_check, |
| 196 | .me = THIS_MODULE, | 200 | .me = THIS_MODULE, |
| 197 | .data = NEXTHDR_DEST, | ||
| 198 | }, | 201 | }, |
| 199 | }; | 202 | }; |
| 200 | 203 | ||