aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-12-18 01:41:35 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:59:03 -0500
commit0dfedd28746266a35b3008cb6bb03466115e95b9 (patch)
tree6e737525abde739b3eb25ed7286aedc7ba0fed3a
parentbaab2ce7d2a8dbf6280ab09c011cfec1dd5972de (diff)
[NETFILTER]: nfnetlink_log: use endianness-aware attribute functions
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/netfilter/nfnetlink_log.c87
1 files changed, 35 insertions, 52 deletions
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index ac58dc9d7247..950b1f0713dd 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -389,32 +389,27 @@ __build_packet_message(struct nfulnl_instance *inst,
389 NLA_PUT(inst->skb, NFULA_PREFIX, plen, prefix); 389 NLA_PUT(inst->skb, NFULA_PREFIX, plen, prefix);
390 390
391 if (indev) { 391 if (indev) {
392 tmp_uint = htonl(indev->ifindex);
393#ifndef CONFIG_BRIDGE_NETFILTER 392#ifndef CONFIG_BRIDGE_NETFILTER
394 NLA_PUT(inst->skb, NFULA_IFINDEX_INDEV, sizeof(tmp_uint), 393 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_INDEV,
395 &tmp_uint); 394 htonl(indev->ifindex));
396#else 395#else
397 if (pf == PF_BRIDGE) { 396 if (pf == PF_BRIDGE) {
398 /* Case 1: outdev is physical input device, we need to 397 /* Case 1: outdev is physical input device, we need to
399 * look for bridge group (when called from 398 * look for bridge group (when called from
400 * netfilter_bridge) */ 399 * netfilter_bridge) */
401 NLA_PUT(inst->skb, NFULA_IFINDEX_PHYSINDEV, 400 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSINDEV,
402 sizeof(tmp_uint), &tmp_uint); 401 htonl(indev->ifindex));
403 /* this is the bridge group "brX" */ 402 /* this is the bridge group "brX" */
404 tmp_uint = htonl(indev->br_port->br->dev->ifindex); 403 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_INDEV,
405 NLA_PUT(inst->skb, NFULA_IFINDEX_INDEV, 404 htonl(indev->br_port->br->dev->ifindex));
406 sizeof(tmp_uint), &tmp_uint);
407 } else { 405 } else {
408 /* Case 2: indev is bridge group, we need to look for 406 /* Case 2: indev is bridge group, we need to look for
409 * physical device (when called from ipv4) */ 407 * physical device (when called from ipv4) */
410 NLA_PUT(inst->skb, NFULA_IFINDEX_INDEV, 408 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_INDEV,
411 sizeof(tmp_uint), &tmp_uint); 409 htonl(indev->ifindex));
412 if (skb->nf_bridge && skb->nf_bridge->physindev) { 410 if (skb->nf_bridge && skb->nf_bridge->physindev)
413 tmp_uint = 411 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSINDEV,
414 htonl(skb->nf_bridge->physindev->ifindex); 412 htonl(skb->nf_bridge->physindev->ifindex));
415 NLA_PUT(inst->skb, NFULA_IFINDEX_PHYSINDEV,
416 sizeof(tmp_uint), &tmp_uint);
417 }
418 } 413 }
419#endif 414#endif
420 } 415 }
@@ -422,38 +417,32 @@ __build_packet_message(struct nfulnl_instance *inst,
422 if (outdev) { 417 if (outdev) {
423 tmp_uint = htonl(outdev->ifindex); 418 tmp_uint = htonl(outdev->ifindex);
424#ifndef CONFIG_BRIDGE_NETFILTER 419#ifndef CONFIG_BRIDGE_NETFILTER
425 NLA_PUT(inst->skb, NFULA_IFINDEX_OUTDEV, sizeof(tmp_uint), 420 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_OUTDEV,
426 &tmp_uint); 421 htonl(outdev->ifindex));
427#else 422#else
428 if (pf == PF_BRIDGE) { 423 if (pf == PF_BRIDGE) {
429 /* Case 1: outdev is physical output device, we need to 424 /* Case 1: outdev is physical output device, we need to
430 * look for bridge group (when called from 425 * look for bridge group (when called from
431 * netfilter_bridge) */ 426 * netfilter_bridge) */
432 NLA_PUT(inst->skb, NFULA_IFINDEX_PHYSOUTDEV, 427 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSOUTDEV,
433 sizeof(tmp_uint), &tmp_uint); 428 htonl(outdev->ifindex));
434 /* this is the bridge group "brX" */ 429 /* this is the bridge group "brX" */
435 tmp_uint = htonl(outdev->br_port->br->dev->ifindex); 430 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_OUTDEV,
436 NLA_PUT(inst->skb, NFULA_IFINDEX_OUTDEV, 431 htonl(outdev->br_port->br->dev->ifindex));
437 sizeof(tmp_uint), &tmp_uint);
438 } else { 432 } else {
439 /* Case 2: indev is a bridge group, we need to look 433 /* Case 2: indev is a bridge group, we need to look
440 * for physical device (when called from ipv4) */ 434 * for physical device (when called from ipv4) */
441 NLA_PUT(inst->skb, NFULA_IFINDEX_OUTDEV, 435 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_OUTDEV,
442 sizeof(tmp_uint), &tmp_uint); 436 htonl(outdev->ifindex));
443 if (skb->nf_bridge && skb->nf_bridge->physoutdev) { 437 if (skb->nf_bridge && skb->nf_bridge->physoutdev)
444 tmp_uint = 438 NLA_PUT_BE32(inst->skb, NFULA_IFINDEX_PHYSOUTDEV,
445 htonl(skb->nf_bridge->physoutdev->ifindex); 439 htonl(skb->nf_bridge->physoutdev->ifindex));
446 NLA_PUT(inst->skb, NFULA_IFINDEX_PHYSOUTDEV,
447 sizeof(tmp_uint), &tmp_uint);
448 }
449 } 440 }
450#endif 441#endif
451 } 442 }
452 443
453 if (skb->mark) { 444 if (skb->mark)
454 tmp_uint = htonl(skb->mark); 445 NLA_PUT_BE32(inst->skb, NFULA_MARK, htonl(skb->mark));
455 NLA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint);
456 }
457 446
458 if (indev && skb->dev) { 447 if (indev && skb->dev) {
459 struct nfulnl_msg_packet_hw phw; 448 struct nfulnl_msg_packet_hw phw;
@@ -480,21 +469,19 @@ __build_packet_message(struct nfulnl_instance *inst,
480 __be32 uid = htonl(skb->sk->sk_socket->file->f_uid); 469 __be32 uid = htonl(skb->sk->sk_socket->file->f_uid);
481 /* need to unlock here since NLA_PUT may goto */ 470 /* need to unlock here since NLA_PUT may goto */
482 read_unlock_bh(&skb->sk->sk_callback_lock); 471 read_unlock_bh(&skb->sk->sk_callback_lock);
483 NLA_PUT(inst->skb, NFULA_UID, sizeof(uid), &uid); 472 NLA_PUT_BE32(inst->skb, NFULA_UID, uid);
484 } else 473 } else
485 read_unlock_bh(&skb->sk->sk_callback_lock); 474 read_unlock_bh(&skb->sk->sk_callback_lock);
486 } 475 }
487 476
488 /* local sequence number */ 477 /* local sequence number */
489 if (inst->flags & NFULNL_CFG_F_SEQ) { 478 if (inst->flags & NFULNL_CFG_F_SEQ)
490 tmp_uint = htonl(inst->seq++); 479 NLA_PUT_BE32(inst->skb, NFULA_SEQ, htonl(inst->seq++));
491 NLA_PUT(inst->skb, NFULA_SEQ, sizeof(tmp_uint), &tmp_uint); 480
492 }
493 /* global sequence number */ 481 /* global sequence number */
494 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) { 482 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL)
495 tmp_uint = htonl(atomic_inc_return(&global_seq)); 483 NLA_PUT_BE32(inst->skb, NFULA_SEQ_GLOBAL,
496 NLA_PUT(inst->skb, NFULA_SEQ_GLOBAL, sizeof(tmp_uint), &tmp_uint); 484 htonl(atomic_inc_return(&global_seq)));
497 }
498 485
499 if (data_len) { 486 if (data_len) {
500 struct nlattr *nla; 487 struct nlattr *nla;
@@ -775,8 +762,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
775 } 762 }
776 763
777 if (nfula[NFULA_CFG_TIMEOUT]) { 764 if (nfula[NFULA_CFG_TIMEOUT]) {
778 __be32 timeout = 765 __be32 timeout = nla_get_be32(nfula[NFULA_CFG_TIMEOUT]);
779 *(__be32 *)nla_data(nfula[NFULA_CFG_TIMEOUT]);
780 766
781 if (!inst) { 767 if (!inst) {
782 ret = -ENODEV; 768 ret = -ENODEV;
@@ -786,8 +772,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
786 } 772 }
787 773
788 if (nfula[NFULA_CFG_NLBUFSIZ]) { 774 if (nfula[NFULA_CFG_NLBUFSIZ]) {
789 __be32 nlbufsiz = 775 __be32 nlbufsiz = nla_get_be32(nfula[NFULA_CFG_NLBUFSIZ]);
790 *(__be32 *)nla_data(nfula[NFULA_CFG_NLBUFSIZ]);
791 776
792 if (!inst) { 777 if (!inst) {
793 ret = -ENODEV; 778 ret = -ENODEV;
@@ -797,8 +782,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
797 } 782 }
798 783
799 if (nfula[NFULA_CFG_QTHRESH]) { 784 if (nfula[NFULA_CFG_QTHRESH]) {
800 __be32 qthresh = 785 __be32 qthresh = nla_get_be32(nfula[NFULA_CFG_QTHRESH]);
801 *(__be32 *)nla_data(nfula[NFULA_CFG_QTHRESH]);
802 786
803 if (!inst) { 787 if (!inst) {
804 ret = -ENODEV; 788 ret = -ENODEV;
@@ -808,8 +792,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
808 } 792 }
809 793
810 if (nfula[NFULA_CFG_FLAGS]) { 794 if (nfula[NFULA_CFG_FLAGS]) {
811 __be16 flags = 795 __be16 flags = nla_get_be16(nfula[NFULA_CFG_FLAGS]);
812 *(__be16 *)nla_data(nfula[NFULA_CFG_FLAGS]);
813 796
814 if (!inst) { 797 if (!inst) {
815 ret = -ENODEV; 798 ret = -ENODEV;