Commit ab4f21e6fb1c09b13c4c3cb8357babe8223471bd
Committed by
Patrick McHardy
1 parent
92f3b2b1bc
Exists in
master
and in
39 other branches
netfilter: xtables: use NFPROTO_UNSPEC in more extensions
Lots of extensions are completely family-independent, so squash some code. Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
Showing 7 changed files with 43 additions and 120 deletions Side-by-side Diff
net/netfilter/xt_MARK.c
... | ... | @@ -149,7 +149,7 @@ |
149 | 149 | static struct xt_target mark_tg_reg[] __read_mostly = { |
150 | 150 | { |
151 | 151 | .name = "MARK", |
152 | - .family = NFPROTO_IPV4, | |
152 | + .family = NFPROTO_UNSPEC, | |
153 | 153 | .revision = 0, |
154 | 154 | .checkentry = mark_tg_check_v0, |
155 | 155 | .target = mark_tg_v0, |
... | ... | @@ -164,37 +164,7 @@ |
164 | 164 | }, |
165 | 165 | { |
166 | 166 | .name = "MARK", |
167 | - .family = NFPROTO_IPV4, | |
168 | - .revision = 1, | |
169 | - .checkentry = mark_tg_check_v1, | |
170 | - .target = mark_tg_v1, | |
171 | - .targetsize = sizeof(struct xt_mark_target_info_v1), | |
172 | -#ifdef CONFIG_COMPAT | |
173 | - .compatsize = sizeof(struct compat_xt_mark_target_info_v1), | |
174 | - .compat_from_user = mark_tg_compat_from_user_v1, | |
175 | - .compat_to_user = mark_tg_compat_to_user_v1, | |
176 | -#endif | |
177 | - .table = "mangle", | |
178 | - .me = THIS_MODULE, | |
179 | - }, | |
180 | - { | |
181 | - .name = "MARK", | |
182 | - .family = NFPROTO_IPV6, | |
183 | - .revision = 0, | |
184 | - .checkentry = mark_tg_check_v0, | |
185 | - .target = mark_tg_v0, | |
186 | - .targetsize = sizeof(struct xt_mark_target_info), | |
187 | -#ifdef CONFIG_COMPAT | |
188 | - .compatsize = sizeof(struct compat_xt_mark_target_info), | |
189 | - .compat_from_user = mark_tg_compat_from_user_v0, | |
190 | - .compat_to_user = mark_tg_compat_to_user_v0, | |
191 | -#endif | |
192 | - .table = "mangle", | |
193 | - .me = THIS_MODULE, | |
194 | - }, | |
195 | - { | |
196 | - .name = "MARK", | |
197 | - .family = NFPROTO_IPV6, | |
167 | + .family = NFPROTO_UNSPEC, | |
198 | 168 | .revision = 1, |
199 | 169 | .checkentry = mark_tg_check_v1, |
200 | 170 | .target = mark_tg_v1, |
net/netfilter/xt_NOTRACK.c
... | ... | @@ -30,31 +30,23 @@ |
30 | 30 | return XT_CONTINUE; |
31 | 31 | } |
32 | 32 | |
33 | -static struct xt_target notrack_tg_reg[] __read_mostly = { | |
34 | - { | |
35 | - .name = "NOTRACK", | |
36 | - .family = NFPROTO_IPV4, | |
37 | - .target = notrack_tg, | |
38 | - .table = "raw", | |
39 | - .me = THIS_MODULE, | |
40 | - }, | |
41 | - { | |
42 | - .name = "NOTRACK", | |
43 | - .family = NFPROTO_IPV6, | |
44 | - .target = notrack_tg, | |
45 | - .table = "raw", | |
46 | - .me = THIS_MODULE, | |
47 | - }, | |
33 | +static struct xt_target notrack_tg_reg __read_mostly = { | |
34 | + .name = "NOTRACK", | |
35 | + .revision = 0, | |
36 | + .family = NFPROTO_UNSPEC, | |
37 | + .target = notrack_tg, | |
38 | + .table = "raw", | |
39 | + .me = THIS_MODULE, | |
48 | 40 | }; |
49 | 41 | |
50 | 42 | static int __init notrack_tg_init(void) |
51 | 43 | { |
52 | - return xt_register_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg)); | |
44 | + return xt_register_target(¬rack_tg_reg); | |
53 | 45 | } |
54 | 46 | |
55 | 47 | static void __exit notrack_tg_exit(void) |
56 | 48 | { |
57 | - xt_unregister_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg)); | |
49 | + xt_unregister_target(¬rack_tg_reg); | |
58 | 50 | } |
59 | 51 | |
60 | 52 | module_init(notrack_tg_init); |
net/netfilter/xt_comment.c
... | ... | @@ -22,31 +22,23 @@ |
22 | 22 | return true; |
23 | 23 | } |
24 | 24 | |
25 | -static struct xt_match comment_mt_reg[] __read_mostly = { | |
26 | - { | |
27 | - .name = "comment", | |
28 | - .family = NFPROTO_IPV4, | |
29 | - .match = comment_mt, | |
30 | - .matchsize = sizeof(struct xt_comment_info), | |
31 | - .me = THIS_MODULE | |
32 | - }, | |
33 | - { | |
34 | - .name = "comment", | |
35 | - .family = NFPROTO_IPV6, | |
36 | - .match = comment_mt, | |
37 | - .matchsize = sizeof(struct xt_comment_info), | |
38 | - .me = THIS_MODULE | |
39 | - }, | |
25 | +static struct xt_match comment_mt_reg __read_mostly = { | |
26 | + .name = "comment", | |
27 | + .revision = 0, | |
28 | + .family = NFPROTO_UNSPEC, | |
29 | + .match = comment_mt, | |
30 | + .matchsize = sizeof(struct xt_comment_info), | |
31 | + .me = THIS_MODULE, | |
40 | 32 | }; |
41 | 33 | |
42 | 34 | static int __init comment_mt_init(void) |
43 | 35 | { |
44 | - return xt_register_matches(comment_mt_reg, ARRAY_SIZE(comment_mt_reg)); | |
36 | + return xt_register_match(&comment_mt_reg); | |
45 | 37 | } |
46 | 38 | |
47 | 39 | static void __exit comment_mt_exit(void) |
48 | 40 | { |
49 | - xt_unregister_matches(comment_mt_reg, ARRAY_SIZE(comment_mt_reg)); | |
41 | + xt_unregister_match(&comment_mt_reg); | |
50 | 42 | } |
51 | 43 | |
52 | 44 | module_init(comment_mt_init); |
net/netfilter/xt_mac.c
... | ... | @@ -36,37 +36,25 @@ |
36 | 36 | ^ info->invert); |
37 | 37 | } |
38 | 38 | |
39 | -static struct xt_match mac_mt_reg[] __read_mostly = { | |
40 | - { | |
41 | - .name = "mac", | |
42 | - .family = NFPROTO_IPV4, | |
43 | - .match = mac_mt, | |
44 | - .matchsize = sizeof(struct xt_mac_info), | |
45 | - .hooks = (1 << NF_INET_PRE_ROUTING) | | |
46 | - (1 << NF_INET_LOCAL_IN) | | |
47 | - (1 << NF_INET_FORWARD), | |
48 | - .me = THIS_MODULE, | |
49 | - }, | |
50 | - { | |
51 | - .name = "mac", | |
52 | - .family = NFPROTO_IPV6, | |
53 | - .match = mac_mt, | |
54 | - .matchsize = sizeof(struct xt_mac_info), | |
55 | - .hooks = (1 << NF_INET_PRE_ROUTING) | | |
56 | - (1 << NF_INET_LOCAL_IN) | | |
57 | - (1 << NF_INET_FORWARD), | |
58 | - .me = THIS_MODULE, | |
59 | - }, | |
39 | +static struct xt_match mac_mt_reg __read_mostly = { | |
40 | + .name = "mac", | |
41 | + .revision = 0, | |
42 | + .family = NFPROTO_UNSPEC, | |
43 | + .match = mac_mt, | |
44 | + .matchsize = sizeof(struct xt_mac_info), | |
45 | + .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) | | |
46 | + (1 << NF_INET_FORWARD), | |
47 | + .me = THIS_MODULE, | |
60 | 48 | }; |
61 | 49 | |
62 | 50 | static int __init mac_mt_init(void) |
63 | 51 | { |
64 | - return xt_register_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg)); | |
52 | + return xt_register_match(&mac_mt_reg); | |
65 | 53 | } |
66 | 54 | |
67 | 55 | static void __exit mac_mt_exit(void) |
68 | 56 | { |
69 | - xt_unregister_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg)); | |
57 | + xt_unregister_match(&mac_mt_reg); | |
70 | 58 | } |
71 | 59 | |
72 | 60 | module_init(mac_mt_init); |
net/netfilter/xt_owner.c
... | ... | @@ -160,17 +160,7 @@ |
160 | 160 | { |
161 | 161 | .name = "owner", |
162 | 162 | .revision = 1, |
163 | - .family = NFPROTO_IPV4, | |
164 | - .match = owner_mt, | |
165 | - .matchsize = sizeof(struct xt_owner_match_info), | |
166 | - .hooks = (1 << NF_INET_LOCAL_OUT) | | |
167 | - (1 << NF_INET_POST_ROUTING), | |
168 | - .me = THIS_MODULE, | |
169 | - }, | |
170 | - { | |
171 | - .name = "owner", | |
172 | - .revision = 1, | |
173 | - .family = NFPROTO_IPV6, | |
163 | + .family = NFPROTO_UNSPEC, | |
174 | 164 | .match = owner_mt, |
175 | 165 | .matchsize = sizeof(struct xt_owner_match_info), |
176 | 166 | .hooks = (1 << NF_INET_LOCAL_OUT) | |
net/netfilter/xt_physdev.c
... | ... | @@ -112,33 +112,24 @@ |
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | -static struct xt_match physdev_mt_reg[] __read_mostly = { | |
116 | - { | |
117 | - .name = "physdev", | |
118 | - .family = NFPROTO_IPV4, | |
119 | - .checkentry = physdev_mt_check, | |
120 | - .match = physdev_mt, | |
121 | - .matchsize = sizeof(struct xt_physdev_info), | |
122 | - .me = THIS_MODULE, | |
123 | - }, | |
124 | - { | |
125 | - .name = "physdev", | |
126 | - .family = NFPROTO_IPV6, | |
127 | - .checkentry = physdev_mt_check, | |
128 | - .match = physdev_mt, | |
129 | - .matchsize = sizeof(struct xt_physdev_info), | |
130 | - .me = THIS_MODULE, | |
131 | - }, | |
115 | +static struct xt_match physdev_mt_reg __read_mostly = { | |
116 | + .name = "physdev", | |
117 | + .revision = 0, | |
118 | + .family = NFPROTO_UNSPEC, | |
119 | + .checkentry = physdev_mt_check, | |
120 | + .match = physdev_mt, | |
121 | + .matchsize = sizeof(struct xt_physdev_info), | |
122 | + .me = THIS_MODULE, | |
132 | 123 | }; |
133 | 124 | |
134 | 125 | static int __init physdev_mt_init(void) |
135 | 126 | { |
136 | - return xt_register_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg)); | |
127 | + return xt_register_match(&physdev_mt_reg); | |
137 | 128 | } |
138 | 129 | |
139 | 130 | static void __exit physdev_mt_exit(void) |
140 | 131 | { |
141 | - xt_unregister_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg)); | |
132 | + xt_unregister_match(&physdev_mt_reg); | |
142 | 133 | } |
143 | 134 | |
144 | 135 | module_init(physdev_mt_init); |
net/netfilter/xt_realm.c
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | .matchsize = sizeof(struct xt_realm_info), |
37 | 37 | .hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_FORWARD) | |
38 | 38 | (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN), |
39 | - .family = NFPROTO_IPV4, | |
39 | + .family = NFPROTO_UNSPEC, | |
40 | 40 | .me = THIS_MODULE |
41 | 41 | }; |
42 | 42 |