diff options
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r-- | net/xfrm/xfrm_user.c | 73 |
1 files changed, 25 insertions, 48 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 4210d91624cd..b14c7e590c31 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -674,7 +674,9 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb, | |||
674 | 674 | ||
675 | static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | 675 | static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) |
676 | { | 676 | { |
677 | struct xfrm_spdinfo si; | 677 | struct xfrmk_spdinfo si; |
678 | struct xfrmu_spdinfo spc; | ||
679 | struct xfrmu_spdhinfo sph; | ||
678 | struct nlmsghdr *nlh; | 680 | struct nlmsghdr *nlh; |
679 | u32 *f; | 681 | u32 *f; |
680 | 682 | ||
@@ -685,23 +687,17 @@ static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | |||
685 | f = nlmsg_data(nlh); | 687 | f = nlmsg_data(nlh); |
686 | *f = flags; | 688 | *f = flags; |
687 | xfrm_spd_getinfo(&si); | 689 | xfrm_spd_getinfo(&si); |
688 | 690 | spc.incnt = si.incnt; | |
689 | if (flags & XFRM_SPD_HMASK) | 691 | spc.outcnt = si.outcnt; |
690 | NLA_PUT_U32(skb, XFRMA_SPDHMASK, si.spdhcnt); | 692 | spc.fwdcnt = si.fwdcnt; |
691 | if (flags & XFRM_SPD_HMAX) | 693 | spc.inscnt = si.inscnt; |
692 | NLA_PUT_U32(skb, XFRMA_SPDHMAX, si.spdhmcnt); | 694 | spc.outscnt = si.outscnt; |
693 | if (flags & XFRM_SPD_ICNT) | 695 | spc.fwdscnt = si.fwdscnt; |
694 | NLA_PUT_U32(skb, XFRMA_SPDICNT, si.incnt); | 696 | sph.spdhcnt = si.spdhcnt; |
695 | if (flags & XFRM_SPD_OCNT) | 697 | sph.spdhmcnt = si.spdhmcnt; |
696 | NLA_PUT_U32(skb, XFRMA_SPDOCNT, si.outcnt); | 698 | |
697 | if (flags & XFRM_SPD_FCNT) | 699 | NLA_PUT(skb, XFRMA_SPD_INFO, sizeof(spc), &spc); |
698 | NLA_PUT_U32(skb, XFRMA_SPDFCNT, si.fwdcnt); | 700 | NLA_PUT(skb, XFRMA_SPD_HINFO, sizeof(sph), &sph); |
699 | if (flags & XFRM_SPD_ISCNT) | ||
700 | NLA_PUT_U32(skb, XFRMA_SPDISCNT, si.inscnt); | ||
701 | if (flags & XFRM_SPD_OSCNT) | ||
702 | NLA_PUT_U32(skb, XFRMA_SPDOSCNT, si.inscnt); | ||
703 | if (flags & XFRM_SPD_FSCNT) | ||
704 | NLA_PUT_U32(skb, XFRMA_SPDFSCNT, si.inscnt); | ||
705 | 701 | ||
706 | return nlmsg_end(skb, nlh); | 702 | return nlmsg_end(skb, nlh); |
707 | 703 | ||
@@ -719,23 +715,8 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
719 | u32 seq = nlh->nlmsg_seq; | 715 | u32 seq = nlh->nlmsg_seq; |
720 | int len = NLMSG_LENGTH(sizeof(u32)); | 716 | int len = NLMSG_LENGTH(sizeof(u32)); |
721 | 717 | ||
722 | 718 | len += RTA_SPACE(sizeof(struct xfrmu_spdinfo)); | |
723 | if (*flags & XFRM_SPD_HMASK) | 719 | len += RTA_SPACE(sizeof(struct xfrmu_spdhinfo)); |
724 | len += RTA_SPACE(sizeof(u32)); | ||
725 | if (*flags & XFRM_SPD_HMAX) | ||
726 | len += RTA_SPACE(sizeof(u32)); | ||
727 | if (*flags & XFRM_SPD_ICNT) | ||
728 | len += RTA_SPACE(sizeof(u32)); | ||
729 | if (*flags & XFRM_SPD_OCNT) | ||
730 | len += RTA_SPACE(sizeof(u32)); | ||
731 | if (*flags & XFRM_SPD_FCNT) | ||
732 | len += RTA_SPACE(sizeof(u32)); | ||
733 | if (*flags & XFRM_SPD_ISCNT) | ||
734 | len += RTA_SPACE(sizeof(u32)); | ||
735 | if (*flags & XFRM_SPD_OSCNT) | ||
736 | len += RTA_SPACE(sizeof(u32)); | ||
737 | if (*flags & XFRM_SPD_FSCNT) | ||
738 | len += RTA_SPACE(sizeof(u32)); | ||
739 | 720 | ||
740 | r_skb = alloc_skb(len, GFP_ATOMIC); | 721 | r_skb = alloc_skb(len, GFP_ATOMIC); |
741 | if (r_skb == NULL) | 722 | if (r_skb == NULL) |
@@ -749,7 +730,8 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
749 | 730 | ||
750 | static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | 731 | static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) |
751 | { | 732 | { |
752 | struct xfrm_sadinfo si; | 733 | struct xfrmk_sadinfo si; |
734 | struct xfrmu_sadhinfo sh; | ||
753 | struct nlmsghdr *nlh; | 735 | struct nlmsghdr *nlh; |
754 | u32 *f; | 736 | u32 *f; |
755 | 737 | ||
@@ -761,12 +743,11 @@ static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags) | |||
761 | *f = flags; | 743 | *f = flags; |
762 | xfrm_sad_getinfo(&si); | 744 | xfrm_sad_getinfo(&si); |
763 | 745 | ||
764 | if (flags & XFRM_SAD_HMASK) | 746 | sh.sadhmcnt = si.sadhmcnt; |
765 | NLA_PUT_U32(skb, XFRMA_SADHMASK, si.sadhcnt); | 747 | sh.sadhcnt = si.sadhcnt; |
766 | if (flags & XFRM_SAD_HMAX) | 748 | |
767 | NLA_PUT_U32(skb, XFRMA_SADHMAX, si.sadhmcnt); | 749 | NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt); |
768 | if (flags & XFRM_SAD_CNT) | 750 | NLA_PUT(skb, XFRMA_SAD_HINFO, sizeof(sh), &sh); |
769 | NLA_PUT_U32(skb, XFRMA_SADCNT, si.sadcnt); | ||
770 | 751 | ||
771 | return nlmsg_end(skb, nlh); | 752 | return nlmsg_end(skb, nlh); |
772 | 753 | ||
@@ -784,12 +765,8 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
784 | u32 seq = nlh->nlmsg_seq; | 765 | u32 seq = nlh->nlmsg_seq; |
785 | int len = NLMSG_LENGTH(sizeof(u32)); | 766 | int len = NLMSG_LENGTH(sizeof(u32)); |
786 | 767 | ||
787 | if (*flags & XFRM_SAD_HMASK) | 768 | len += RTA_SPACE(sizeof(struct xfrmu_sadhinfo)); |
788 | len += RTA_SPACE(sizeof(u32)); | 769 | len += RTA_SPACE(sizeof(u32)); |
789 | if (*flags & XFRM_SAD_HMAX) | ||
790 | len += RTA_SPACE(sizeof(u32)); | ||
791 | if (*flags & XFRM_SAD_CNT) | ||
792 | len += RTA_SPACE(sizeof(u32)); | ||
793 | 770 | ||
794 | r_skb = alloc_skb(len, GFP_ATOMIC); | 771 | r_skb = alloc_skb(len, GFP_ATOMIC); |
795 | 772 | ||