diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-18 01:29:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:58:54 -0500 |
commit | 77236b6e33b06aaf756a86ed1965ca7d460b1b53 (patch) | |
tree | 487fcefd4f686bd0fbce4ee05564349d58d2e68c /net/ipv4 | |
parent | 838965ba22066c7fcdbacfc543c387d0eb76c14c (diff) |
[NETFILTER]: ctnetlink: use netlink attribute helpers
Use NLA_PUT_BE32, nla_get_be32() etc.
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 | 10 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 18 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_core.c | 12 |
3 files changed, 14 insertions, 26 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index cd2d8451dda..78e64951137 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
@@ -363,10 +363,8 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len) | |||
363 | static int ipv4_tuple_to_nlattr(struct sk_buff *skb, | 363 | static int ipv4_tuple_to_nlattr(struct sk_buff *skb, |
364 | const struct nf_conntrack_tuple *tuple) | 364 | const struct nf_conntrack_tuple *tuple) |
365 | { | 365 | { |
366 | NLA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), | 366 | NLA_PUT_BE32(skb, CTA_IP_V4_SRC, tuple->src.u3.ip); |
367 | &tuple->src.u3.ip); | 367 | NLA_PUT_BE32(skb, CTA_IP_V4_DST, tuple->dst.u3.ip); |
368 | NLA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), | ||
369 | &tuple->dst.u3.ip); | ||
370 | return 0; | 368 | return 0; |
371 | 369 | ||
372 | nla_put_failure: | 370 | nla_put_failure: |
@@ -384,8 +382,8 @@ static int ipv4_nlattr_to_tuple(struct nlattr *tb[], | |||
384 | if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST]) | 382 | if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST]) |
385 | return -EINVAL; | 383 | return -EINVAL; |
386 | 384 | ||
387 | t->src.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_SRC]); | 385 | t->src.u3.ip = nla_get_be32(tb[CTA_IP_V4_SRC]); |
388 | t->dst.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_DST]); | 386 | t->dst.u3.ip = nla_get_be32(tb[CTA_IP_V4_DST]); |
389 | 387 | ||
390 | return 0; | 388 | return 0; |
391 | } | 389 | } |
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index 4153e049498..3e2e5cdda9d 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
@@ -234,12 +234,9 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff, | |||
234 | static int icmp_tuple_to_nlattr(struct sk_buff *skb, | 234 | static int icmp_tuple_to_nlattr(struct sk_buff *skb, |
235 | const struct nf_conntrack_tuple *t) | 235 | const struct nf_conntrack_tuple *t) |
236 | { | 236 | { |
237 | NLA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), | 237 | NLA_PUT_BE16(skb, CTA_PROTO_ICMP_ID, t->src.u.icmp.id); |
238 | &t->src.u.icmp.id); | 238 | NLA_PUT_U8(skb, CTA_PROTO_ICMP_TYPE, t->dst.u.icmp.type); |
239 | NLA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), | 239 | NLA_PUT_U8(skb, CTA_PROTO_ICMP_CODE, t->dst.u.icmp.code); |
240 | &t->dst.u.icmp.type); | ||
241 | NLA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t), | ||
242 | &t->dst.u.icmp.code); | ||
243 | 240 | ||
244 | return 0; | 241 | return 0; |
245 | 242 | ||
@@ -261,12 +258,9 @@ static int icmp_nlattr_to_tuple(struct nlattr *tb[], | |||
261 | || !tb[CTA_PROTO_ICMP_ID]) | 258 | || !tb[CTA_PROTO_ICMP_ID]) |
262 | return -EINVAL; | 259 | return -EINVAL; |
263 | 260 | ||
264 | tuple->dst.u.icmp.type = | 261 | tuple->dst.u.icmp.type = nla_get_u8(tb[CTA_PROTO_ICMP_TYPE]); |
265 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_TYPE]); | 262 | tuple->dst.u.icmp.code = nla_get_u8(tb[CTA_PROTO_ICMP_CODE]); |
266 | tuple->dst.u.icmp.code = | 263 | tuple->src.u.icmp.id = nla_get_be16(tb[CTA_PROTO_ICMP_ID]); |
267 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_CODE]); | ||
268 | tuple->src.u.icmp.id = | ||
269 | *(__be16 *)nla_data(tb[CTA_PROTO_ICMP_ID]); | ||
270 | 264 | ||
271 | if (tuple->dst.u.icmp.type >= sizeof(invmap) | 265 | if (tuple->dst.u.icmp.type >= sizeof(invmap) |
272 | || !invmap[tuple->dst.u.icmp.type]) | 266 | || !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 746c2efddcd..4ee67e9f42b 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -547,10 +547,8 @@ int | |||
547 | nf_nat_port_range_to_nlattr(struct sk_buff *skb, | 547 | nf_nat_port_range_to_nlattr(struct sk_buff *skb, |
548 | const struct nf_nat_range *range) | 548 | const struct nf_nat_range *range) |
549 | { | 549 | { |
550 | NLA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16), | 550 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MIN, range->min.tcp.port); |
551 | &range->min.tcp.port); | 551 | NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MAX, range->max.tcp.port); |
552 | NLA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16), | ||
553 | &range->max.tcp.port); | ||
554 | 552 | ||
555 | return 0; | 553 | return 0; |
556 | 554 | ||
@@ -568,8 +566,7 @@ nf_nat_port_nlattr_to_range(struct nlattr *tb[], struct nf_nat_range *range) | |||
568 | 566 | ||
569 | if (tb[CTA_PROTONAT_PORT_MIN]) { | 567 | if (tb[CTA_PROTONAT_PORT_MIN]) { |
570 | ret = 1; | 568 | ret = 1; |
571 | range->min.tcp.port = | 569 | range->min.tcp.port = nla_get_be16(tb[CTA_PROTONAT_PORT_MIN]); |
572 | *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MIN]); | ||
573 | } | 570 | } |
574 | 571 | ||
575 | if (!tb[CTA_PROTONAT_PORT_MAX]) { | 572 | if (!tb[CTA_PROTONAT_PORT_MAX]) { |
@@ -577,8 +574,7 @@ nf_nat_port_nlattr_to_range(struct nlattr *tb[], struct nf_nat_range *range) | |||
577 | range->max.tcp.port = range->min.tcp.port; | 574 | range->max.tcp.port = range->min.tcp.port; |
578 | } else { | 575 | } else { |
579 | ret = 1; | 576 | ret = 1; |
580 | range->max.tcp.port = | 577 | range->max.tcp.port = nla_get_be16(tb[CTA_PROTONAT_PORT_MAX]); |
581 | *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MAX]); | ||
582 | } | 578 | } |
583 | 579 | ||
584 | return ret; | 580 | return ret; |