diff options
author | Patrick McHardy <kaber@trash.net> | 2007-09-28 17:39:55 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:35 -0400 |
commit | f73e924cdd166360e8cc9a1b193008fdc9b3e3e2 (patch) | |
tree | 48fbf4b0f9101359e05fb53eabe194495f8214d1 /net/ipv6 | |
parent | 5bf758539388fa9383afd539d052ae93229544b9 (diff) |
[NETFILTER]: ctnetlink: use netlink policy
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 10 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 12 |
2 files changed, 9 insertions, 13 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 567fbe230ce6..37a3db926953 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
@@ -350,9 +350,9 @@ nla_put_failure: | |||
350 | return -1; | 350 | return -1; |
351 | } | 351 | } |
352 | 352 | ||
353 | static const size_t cta_min_ip[CTA_IP_MAX+1] = { | 353 | static const struct nla_policy ipv6_nla_policy[CTA_IP_MAX+1] = { |
354 | [CTA_IP_V6_SRC] = sizeof(u_int32_t)*4, | 354 | [CTA_IP_V6_SRC] = { .len = sizeof(u_int32_t)*4 }, |
355 | [CTA_IP_V6_DST] = sizeof(u_int32_t)*4, | 355 | [CTA_IP_V6_DST] = { .len = sizeof(u_int32_t)*4 }, |
356 | }; | 356 | }; |
357 | 357 | ||
358 | static int ipv6_nlattr_to_tuple(struct nlattr *tb[], | 358 | static int ipv6_nlattr_to_tuple(struct nlattr *tb[], |
@@ -361,9 +361,6 @@ static int ipv6_nlattr_to_tuple(struct nlattr *tb[], | |||
361 | if (!tb[CTA_IP_V6_SRC] || !tb[CTA_IP_V6_DST]) | 361 | if (!tb[CTA_IP_V6_SRC] || !tb[CTA_IP_V6_DST]) |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | 363 | ||
364 | if (nlattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) | ||
365 | return -EINVAL; | ||
366 | |||
367 | memcpy(&t->src.u3.ip6, nla_data(tb[CTA_IP_V6_SRC]), | 364 | memcpy(&t->src.u3.ip6, nla_data(tb[CTA_IP_V6_SRC]), |
368 | sizeof(u_int32_t) * 4); | 365 | sizeof(u_int32_t) * 4); |
369 | memcpy(&t->dst.u3.ip6, nla_data(tb[CTA_IP_V6_DST]), | 366 | memcpy(&t->dst.u3.ip6, nla_data(tb[CTA_IP_V6_DST]), |
@@ -384,6 +381,7 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 __read_mostly = { | |||
384 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) | 381 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) |
385 | .tuple_to_nlattr = ipv6_tuple_to_nlattr, | 382 | .tuple_to_nlattr = ipv6_tuple_to_nlattr, |
386 | .nlattr_to_tuple = ipv6_nlattr_to_tuple, | 383 | .nlattr_to_tuple = ipv6_nlattr_to_tuple, |
384 | .nla_policy = ipv6_nla_policy, | ||
387 | #endif | 385 | #endif |
388 | #ifdef CONFIG_SYSCTL | 386 | #ifdef CONFIG_SYSCTL |
389 | .ctl_table_path = nf_net_netfilter_sysctl_path, | 387 | .ctl_table_path = nf_net_netfilter_sysctl_path, |
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index 238ea6bc864e..fbdc66920de4 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | |||
@@ -226,10 +226,10 @@ nla_put_failure: | |||
226 | return -1; | 226 | return -1; |
227 | } | 227 | } |
228 | 228 | ||
229 | static const size_t cta_min_proto[CTA_PROTO_MAX+1] = { | 229 | static const struct nla_policy icmpv6_nla_policy[CTA_PROTO_MAX+1] = { |
230 | [CTA_PROTO_ICMPV6_TYPE] = sizeof(u_int8_t), | 230 | [CTA_PROTO_ICMPV6_TYPE] = { .type = NLA_U8 }, |
231 | [CTA_PROTO_ICMPV6_CODE] = sizeof(u_int8_t), | 231 | [CTA_PROTO_ICMPV6_CODE] = { .type = NLA_U8 }, |
232 | [CTA_PROTO_ICMPV6_ID] = sizeof(u_int16_t) | 232 | [CTA_PROTO_ICMPV6_ID] = { .type = NLA_U16 }, |
233 | }; | 233 | }; |
234 | 234 | ||
235 | static int icmpv6_nlattr_to_tuple(struct nlattr *tb[], | 235 | static int icmpv6_nlattr_to_tuple(struct nlattr *tb[], |
@@ -240,9 +240,6 @@ static int icmpv6_nlattr_to_tuple(struct nlattr *tb[], | |||
240 | || !tb[CTA_PROTO_ICMPV6_ID]) | 240 | || !tb[CTA_PROTO_ICMPV6_ID]) |
241 | return -EINVAL; | 241 | return -EINVAL; |
242 | 242 | ||
243 | if (nlattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) | ||
244 | return -EINVAL; | ||
245 | |||
246 | tuple->dst.u.icmp.type = | 243 | tuple->dst.u.icmp.type = |
247 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_TYPE]); | 244 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_TYPE]); |
248 | tuple->dst.u.icmp.code = | 245 | tuple->dst.u.icmp.code = |
@@ -291,6 +288,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly = | |||
291 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) | 288 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) |
292 | .tuple_to_nlattr = icmpv6_tuple_to_nlattr, | 289 | .tuple_to_nlattr = icmpv6_tuple_to_nlattr, |
293 | .nlattr_to_tuple = icmpv6_nlattr_to_tuple, | 290 | .nlattr_to_tuple = icmpv6_nlattr_to_tuple, |
291 | .nla_policy = icmpv6_nla_policy, | ||
294 | #endif | 292 | #endif |
295 | #ifdef CONFIG_SYSCTL | 293 | #ifdef CONFIG_SYSCTL |
296 | .ctl_table_header = &icmpv6_sysctl_header, | 294 | .ctl_table_header = &icmpv6_sysctl_header, |