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/ipv4 | |
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/ipv4')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 20 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 30 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_core.c | 16 |
3 files changed, 33 insertions, 33 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index f813e02aab30..f8771e058b9e 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
@@ -363,32 +363,32 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len) | |||
363 | static int ipv4_tuple_to_nfattr(struct sk_buff *skb, | 363 | static int ipv4_tuple_to_nfattr(struct sk_buff *skb, |
364 | const struct nf_conntrack_tuple *tuple) | 364 | const struct nf_conntrack_tuple *tuple) |
365 | { | 365 | { |
366 | NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), | 366 | NLA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), |
367 | &tuple->src.u3.ip); | 367 | &tuple->src.u3.ip); |
368 | NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), | 368 | NLA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), |
369 | &tuple->dst.u3.ip); | 369 | &tuple->dst.u3.ip); |
370 | return 0; | 370 | return 0; |
371 | 371 | ||
372 | nfattr_failure: | 372 | nla_put_failure: |
373 | return -1; | 373 | return -1; |
374 | } | 374 | } |
375 | 375 | ||
376 | static const size_t cta_min_ip[CTA_IP_MAX] = { | 376 | static const size_t cta_min_ip[CTA_IP_MAX+1] = { |
377 | [CTA_IP_V4_SRC-1] = sizeof(u_int32_t), | 377 | [CTA_IP_V4_SRC] = sizeof(u_int32_t), |
378 | [CTA_IP_V4_DST-1] = sizeof(u_int32_t), | 378 | [CTA_IP_V4_DST] = sizeof(u_int32_t), |
379 | }; | 379 | }; |
380 | 380 | ||
381 | static int ipv4_nfattr_to_tuple(struct nfattr *tb[], | 381 | static int ipv4_nfattr_to_tuple(struct nlattr *tb[], |
382 | struct nf_conntrack_tuple *t) | 382 | struct nf_conntrack_tuple *t) |
383 | { | 383 | { |
384 | if (!tb[CTA_IP_V4_SRC-1] || !tb[CTA_IP_V4_DST-1]) | 384 | if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST]) |
385 | return -EINVAL; | 385 | return -EINVAL; |
386 | 386 | ||
387 | if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) | 387 | if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) |
388 | return -EINVAL; | 388 | return -EINVAL; |
389 | 389 | ||
390 | t->src.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); | 390 | t->src.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_SRC]); |
391 | t->dst.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]); | 391 | t->dst.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_DST]); |
392 | 392 | ||
393 | return 0; | 393 | return 0; |
394 | } | 394 | } |
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index 6593fd2c5b10..714332b8869e 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
@@ -235,42 +235,42 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff, | |||
235 | static int icmp_tuple_to_nfattr(struct sk_buff *skb, | 235 | static int icmp_tuple_to_nfattr(struct sk_buff *skb, |
236 | const struct nf_conntrack_tuple *t) | 236 | const struct nf_conntrack_tuple *t) |
237 | { | 237 | { |
238 | NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), | 238 | NLA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), |
239 | &t->src.u.icmp.id); | 239 | &t->src.u.icmp.id); |
240 | NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), | 240 | NLA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), |
241 | &t->dst.u.icmp.type); | 241 | &t->dst.u.icmp.type); |
242 | NFA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t), | 242 | NLA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t), |
243 | &t->dst.u.icmp.code); | 243 | &t->dst.u.icmp.code); |
244 | 244 | ||
245 | return 0; | 245 | return 0; |
246 | 246 | ||
247 | nfattr_failure: | 247 | nla_put_failure: |
248 | return -1; | 248 | return -1; |
249 | } | 249 | } |
250 | 250 | ||
251 | static const size_t cta_min_proto[CTA_PROTO_MAX] = { | 251 | static const size_t cta_min_proto[CTA_PROTO_MAX+1] = { |
252 | [CTA_PROTO_ICMP_TYPE-1] = sizeof(u_int8_t), | 252 | [CTA_PROTO_ICMP_TYPE] = sizeof(u_int8_t), |
253 | [CTA_PROTO_ICMP_CODE-1] = sizeof(u_int8_t), | 253 | [CTA_PROTO_ICMP_CODE] = sizeof(u_int8_t), |
254 | [CTA_PROTO_ICMP_ID-1] = sizeof(u_int16_t) | 254 | [CTA_PROTO_ICMP_ID] = sizeof(u_int16_t) |
255 | }; | 255 | }; |
256 | 256 | ||
257 | static int icmp_nfattr_to_tuple(struct nfattr *tb[], | 257 | static int icmp_nfattr_to_tuple(struct nlattr *tb[], |
258 | struct nf_conntrack_tuple *tuple) | 258 | struct nf_conntrack_tuple *tuple) |
259 | { | 259 | { |
260 | if (!tb[CTA_PROTO_ICMP_TYPE-1] | 260 | if (!tb[CTA_PROTO_ICMP_TYPE] |
261 | || !tb[CTA_PROTO_ICMP_CODE-1] | 261 | || !tb[CTA_PROTO_ICMP_CODE] |
262 | || !tb[CTA_PROTO_ICMP_ID-1]) | 262 | || !tb[CTA_PROTO_ICMP_ID]) |
263 | return -EINVAL; | 263 | return -EINVAL; |
264 | 264 | ||
265 | if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) | 265 | if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) |
266 | return -EINVAL; | 266 | return -EINVAL; |
267 | 267 | ||
268 | tuple->dst.u.icmp.type = | 268 | tuple->dst.u.icmp.type = |
269 | *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]); | 269 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_TYPE]); |
270 | tuple->dst.u.icmp.code = | 270 | tuple->dst.u.icmp.code = |
271 | *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]); | 271 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_CODE]); |
272 | tuple->src.u.icmp.id = | 272 | tuple->src.u.icmp.id = |
273 | *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); | 273 | *(__be16 *)nla_data(tb[CTA_PROTO_ICMP_ID]); |
274 | 274 | ||
275 | if (tuple->dst.u.icmp.type >= sizeof(invmap) | 275 | if (tuple->dst.u.icmp.type >= sizeof(invmap) |
276 | || !invmap[tuple->dst.u.icmp.type]) | 276 | || !invmap[tuple->dst.u.icmp.type]) |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index deab27facbad..4bdbb128fe50 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -547,38 +547,38 @@ int | |||
547 | nf_nat_port_range_to_nfattr(struct sk_buff *skb, | 547 | nf_nat_port_range_to_nfattr(struct sk_buff *skb, |
548 | const struct nf_nat_range *range) | 548 | const struct nf_nat_range *range) |
549 | { | 549 | { |
550 | NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16), | 550 | NLA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16), |
551 | &range->min.tcp.port); | 551 | &range->min.tcp.port); |
552 | NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16), | 552 | NLA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16), |
553 | &range->max.tcp.port); | 553 | &range->max.tcp.port); |
554 | 554 | ||
555 | return 0; | 555 | return 0; |
556 | 556 | ||
557 | nfattr_failure: | 557 | nla_put_failure: |
558 | return -1; | 558 | return -1; |
559 | } | 559 | } |
560 | EXPORT_SYMBOL_GPL(nf_nat_port_nfattr_to_range); | 560 | EXPORT_SYMBOL_GPL(nf_nat_port_nfattr_to_range); |
561 | 561 | ||
562 | int | 562 | int |
563 | nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range) | 563 | nf_nat_port_nfattr_to_range(struct nlattr *tb[], struct nf_nat_range *range) |
564 | { | 564 | { |
565 | int ret = 0; | 565 | int ret = 0; |
566 | 566 | ||
567 | /* we have to return whether we actually parsed something or not */ | 567 | /* we have to return whether we actually parsed something or not */ |
568 | 568 | ||
569 | if (tb[CTA_PROTONAT_PORT_MIN-1]) { | 569 | if (tb[CTA_PROTONAT_PORT_MIN]) { |
570 | ret = 1; | 570 | ret = 1; |
571 | range->min.tcp.port = | 571 | range->min.tcp.port = |
572 | *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]); | 572 | *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MIN]); |
573 | } | 573 | } |
574 | 574 | ||
575 | if (!tb[CTA_PROTONAT_PORT_MAX-1]) { | 575 | if (!tb[CTA_PROTONAT_PORT_MAX]) { |
576 | if (ret) | 576 | if (ret) |
577 | range->max.tcp.port = range->min.tcp.port; | 577 | range->max.tcp.port = range->min.tcp.port; |
578 | } else { | 578 | } else { |
579 | ret = 1; | 579 | ret = 1; |
580 | range->max.tcp.port = | 580 | range->max.tcp.port = |
581 | *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]); | 581 | *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MAX]); |
582 | } | 582 | } |
583 | 583 | ||
584 | return ret; | 584 | return ret; |