diff options
author | Patrick McHardy <kaber@trash.net> | 2007-09-28 17:37:03 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:31 -0400 |
commit | df6fb868d6118686805c2fa566e213a8f31c8e4f (patch) | |
tree | 3a0d7d7e9c7d2d8c2d7a06b32e02702eecbfddf6 /net/ipv6 | |
parent | 7c8d4cb4198d199e65a6ced8c81f71e3ac3f4cfc (diff) |
[NETFILTER]: nfnetlink: convert to generic netlink attribute functions
Get rid of the duplicated rtnetlink macros and use the generic netlink
attribute functions. The old duplicated stuff is moved to a new header
file that exists just for userspace.
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 | 20 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 30 |
2 files changed, 25 insertions, 25 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 3153e15e0f7c..f0ea3fb51670 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
@@ -340,33 +340,33 @@ static ctl_table nf_ct_ipv6_sysctl_table[] = { | |||
340 | static int ipv6_tuple_to_nfattr(struct sk_buff *skb, | 340 | static int ipv6_tuple_to_nfattr(struct sk_buff *skb, |
341 | const struct nf_conntrack_tuple *tuple) | 341 | const struct nf_conntrack_tuple *tuple) |
342 | { | 342 | { |
343 | NFA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4, | 343 | NLA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4, |
344 | &tuple->src.u3.ip6); | 344 | &tuple->src.u3.ip6); |
345 | NFA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4, | 345 | NLA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4, |
346 | &tuple->dst.u3.ip6); | 346 | &tuple->dst.u3.ip6); |
347 | return 0; | 347 | return 0; |
348 | 348 | ||
349 | nfattr_failure: | 349 | nla_put_failure: |
350 | return -1; | 350 | return -1; |
351 | } | 351 | } |
352 | 352 | ||
353 | static const size_t cta_min_ip[CTA_IP_MAX] = { | 353 | static const size_t cta_min_ip[CTA_IP_MAX+1] = { |
354 | [CTA_IP_V6_SRC-1] = sizeof(u_int32_t)*4, | 354 | [CTA_IP_V6_SRC] = sizeof(u_int32_t)*4, |
355 | [CTA_IP_V6_DST-1] = sizeof(u_int32_t)*4, | 355 | [CTA_IP_V6_DST] = sizeof(u_int32_t)*4, |
356 | }; | 356 | }; |
357 | 357 | ||
358 | static int ipv6_nfattr_to_tuple(struct nfattr *tb[], | 358 | static int ipv6_nfattr_to_tuple(struct nlattr *tb[], |
359 | struct nf_conntrack_tuple *t) | 359 | struct nf_conntrack_tuple *t) |
360 | { | 360 | { |
361 | if (!tb[CTA_IP_V6_SRC-1] || !tb[CTA_IP_V6_DST-1]) | 361 | if (!tb[CTA_IP_V6_SRC] || !tb[CTA_IP_V6_DST]) |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | 363 | ||
364 | if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) | 364 | if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) |
365 | return -EINVAL; | 365 | return -EINVAL; |
366 | 366 | ||
367 | memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]), | 367 | memcpy(&t->src.u3.ip6, nla_data(tb[CTA_IP_V6_SRC]), |
368 | sizeof(u_int32_t) * 4); | 368 | sizeof(u_int32_t) * 4); |
369 | memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]), | 369 | memcpy(&t->dst.u3.ip6, nla_data(tb[CTA_IP_V6_DST]), |
370 | sizeof(u_int32_t) * 4); | 370 | sizeof(u_int32_t) * 4); |
371 | 371 | ||
372 | return 0; | 372 | return 0; |
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index ab154fb90018..c18183823faf 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | |||
@@ -213,42 +213,42 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff, | |||
213 | static int icmpv6_tuple_to_nfattr(struct sk_buff *skb, | 213 | static int icmpv6_tuple_to_nfattr(struct sk_buff *skb, |
214 | const struct nf_conntrack_tuple *t) | 214 | const struct nf_conntrack_tuple *t) |
215 | { | 215 | { |
216 | NFA_PUT(skb, CTA_PROTO_ICMPV6_ID, sizeof(u_int16_t), | 216 | NLA_PUT(skb, CTA_PROTO_ICMPV6_ID, sizeof(u_int16_t), |
217 | &t->src.u.icmp.id); | 217 | &t->src.u.icmp.id); |
218 | NFA_PUT(skb, CTA_PROTO_ICMPV6_TYPE, sizeof(u_int8_t), | 218 | NLA_PUT(skb, CTA_PROTO_ICMPV6_TYPE, sizeof(u_int8_t), |
219 | &t->dst.u.icmp.type); | 219 | &t->dst.u.icmp.type); |
220 | NFA_PUT(skb, CTA_PROTO_ICMPV6_CODE, sizeof(u_int8_t), | 220 | NLA_PUT(skb, CTA_PROTO_ICMPV6_CODE, sizeof(u_int8_t), |
221 | &t->dst.u.icmp.code); | 221 | &t->dst.u.icmp.code); |
222 | 222 | ||
223 | return 0; | 223 | return 0; |
224 | 224 | ||
225 | nfattr_failure: | 225 | nla_put_failure: |
226 | return -1; | 226 | return -1; |
227 | } | 227 | } |
228 | 228 | ||
229 | static const size_t cta_min_proto[CTA_PROTO_MAX] = { | 229 | static const size_t cta_min_proto[CTA_PROTO_MAX+1] = { |
230 | [CTA_PROTO_ICMPV6_TYPE-1] = sizeof(u_int8_t), | 230 | [CTA_PROTO_ICMPV6_TYPE] = sizeof(u_int8_t), |
231 | [CTA_PROTO_ICMPV6_CODE-1] = sizeof(u_int8_t), | 231 | [CTA_PROTO_ICMPV6_CODE] = sizeof(u_int8_t), |
232 | [CTA_PROTO_ICMPV6_ID-1] = sizeof(u_int16_t) | 232 | [CTA_PROTO_ICMPV6_ID] = sizeof(u_int16_t) |
233 | }; | 233 | }; |
234 | 234 | ||
235 | static int icmpv6_nfattr_to_tuple(struct nfattr *tb[], | 235 | static int icmpv6_nfattr_to_tuple(struct nlattr *tb[], |
236 | struct nf_conntrack_tuple *tuple) | 236 | struct nf_conntrack_tuple *tuple) |
237 | { | 237 | { |
238 | if (!tb[CTA_PROTO_ICMPV6_TYPE-1] | 238 | if (!tb[CTA_PROTO_ICMPV6_TYPE] |
239 | || !tb[CTA_PROTO_ICMPV6_CODE-1] | 239 | || !tb[CTA_PROTO_ICMPV6_CODE] |
240 | || !tb[CTA_PROTO_ICMPV6_ID-1]) | 240 | || !tb[CTA_PROTO_ICMPV6_ID]) |
241 | return -EINVAL; | 241 | return -EINVAL; |
242 | 242 | ||
243 | if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) | 243 | if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) |
244 | return -EINVAL; | 244 | return -EINVAL; |
245 | 245 | ||
246 | tuple->dst.u.icmp.type = | 246 | tuple->dst.u.icmp.type = |
247 | *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_TYPE-1]); | 247 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_TYPE]); |
248 | tuple->dst.u.icmp.code = | 248 | tuple->dst.u.icmp.code = |
249 | *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]); | 249 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_CODE]); |
250 | tuple->src.u.icmp.id = | 250 | tuple->src.u.icmp.id = |
251 | *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]); | 251 | *(__be16 *)nla_data(tb[CTA_PROTO_ICMPV6_ID]); |
252 | 252 | ||
253 | if (tuple->dst.u.icmp.type < 128 | 253 | if (tuple->dst.u.icmp.type < 128 |
254 | || tuple->dst.u.icmp.type - 128 >= sizeof(invmap) | 254 | || tuple->dst.u.icmp.type - 128 >= sizeof(invmap) |