[XFRM] SPD info TLV aggregation
authorJamal Hadi Salim <hadi@cyberus.ca>
Fri, 4 May 2007 19:55:39 +0000 (12:55 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 May 2007 19:55:39 +0000 (12:55 -0700)
Aggregate the SPD info TLVs.

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/xfrm.h
include/net/xfrm.h
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_user.c

index c237fe3af8ceec333de58f2359cafb0ee7475c22..b58adc52448d62df6f3a3dee465c458946cbdf00 100644 (file)
@@ -288,36 +288,29 @@ struct xfrmu_sadhinfo {
        __u32 sadhmcnt; /* max allowed hash bkts */
 };
 
-/* SPD Table filter flags  */
-enum xfrm_spd_ftype_t {
-       XFRM_SPD_UNSPEC,
-       XFRM_SPD_HMASK=1,
-       XFRM_SPD_HMAX=2,
-       XFRM_SPD_ICNT=4,
-       XFRM_SPD_OCNT=8,
-       XFRM_SPD_FCNT=16,
-       XFRM_SPD_ISCNT=32,
-       XFRM_SPD_OSCNT=64,
-       XFRM_SPD_FSCNT=128,
-       __XFRM_SPD_MAX
-
-#define XFRM_SPD_MAX (__XFRM_SPD_MAX - 1)
-};
 enum xfrm_spdattr_type_t {
        XFRMA_SPD_UNSPEC,
-       XFRMA_SPDHMASK,
-       XFRMA_SPDHMAX,
-       XFRMA_SPDICNT,
-       XFRMA_SPDOCNT,
-       XFRMA_SPDFCNT,
-       XFRMA_SPDISCNT,
-       XFRMA_SPDOSCNT,
-       XFRMA_SPDFSCNT,
+       XFRMA_SPD_INFO,
+       XFRMA_SPD_HINFO,
        __XFRMA_SPD_MAX
 
 #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
 };
 
+struct xfrmu_spdinfo {
+       __u32 incnt;
+       __u32 outcnt;
+       __u32 fwdcnt;
+       __u32 inscnt;
+       __u32 outscnt;
+       __u32 fwdscnt;
+};
+
+struct xfrmu_spdhinfo {
+       __u32 spdhcnt;
+       __u32 spdhmcnt;
+};
+
 struct xfrm_usersa_info {
        struct xfrm_selector            sel;
        struct xfrm_id                  id;
index d0d7db51d3fcf074d65889ec59ed092dc23e5447..39ef925d39dd5dd8dce802e4e35ee668338d7d6c 100644 (file)
@@ -416,17 +416,6 @@ struct xfrm_audit
        u32     secid;
 };
 
-struct xfrm_spdinfo
-{
-       u32 incnt;
-       u32 outcnt;
-       u32 fwdcnt;
-       u32 inscnt;
-       u32 outscnt;
-       u32 fwdscnt;
-       u32 spdhcnt;
-       u32 spdhmcnt;
-};
 #ifdef CONFIG_AUDITSYSCALL
 extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result,
                    struct xfrm_policy *xp, struct xfrm_state *x);
@@ -963,11 +952,22 @@ struct xfrmk_sadinfo {
        u32 sadcnt; /* current running count */
 };
 
+struct xfrmk_spdinfo {
+       u32 incnt;
+       u32 outcnt;
+       u32 fwdcnt;
+       u32 inscnt;
+       u32 outscnt;
+       u32 fwdscnt;
+       u32 spdhcnt;
+       u32 spdhmcnt;
+};
+
 extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
 extern int xfrm_state_delete(struct xfrm_state *x);
 extern void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
 extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si);
-extern void xfrm_spd_getinfo(struct xfrm_spdinfo *si);
+extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si);
 extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq);
 extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
 extern void xfrm_replay_notify(struct xfrm_state *x, int event);
index 263e34e452650f7bd5cbd029c36f42bd8be37273..95271e8426a11e3c4f31b3447322fcc02cde34b3 100644 (file)
@@ -579,7 +579,7 @@ static inline int xfrm_byidx_should_resize(int total)
        return 0;
 }
 
-void xfrm_spd_getinfo(struct xfrm_spdinfo *si)
+void xfrm_spd_getinfo(struct xfrmk_spdinfo *si)
 {
        read_lock_bh(&xfrm_policy_lock);
        si->incnt = xfrm_policy_count[XFRM_POLICY_IN];
index c35b9ea3b62b3eda7808d42961f87a9602cefa46..b14c7e590c31b8e5898ba2f389f7accbe17ec853 100644 (file)
@@ -674,7 +674,9 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
 
 static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
 {
-       struct xfrm_spdinfo si;
+       struct xfrmk_spdinfo si;
+       struct xfrmu_spdinfo spc;
+       struct xfrmu_spdhinfo sph;
        struct nlmsghdr *nlh;
        u32 *f;
 
@@ -685,23 +687,17 @@ static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
        f = nlmsg_data(nlh);
        *f = flags;
        xfrm_spd_getinfo(&si);
-
-       if (flags & XFRM_SPD_HMASK)
-               NLA_PUT_U32(skb, XFRMA_SPDHMASK, si.spdhcnt);
-       if (flags & XFRM_SPD_HMAX)
-               NLA_PUT_U32(skb, XFRMA_SPDHMAX, si.spdhmcnt);
-       if (flags & XFRM_SPD_ICNT)
-               NLA_PUT_U32(skb, XFRMA_SPDICNT, si.incnt);
-       if (flags & XFRM_SPD_OCNT)
-               NLA_PUT_U32(skb, XFRMA_SPDOCNT, si.outcnt);
-       if (flags & XFRM_SPD_FCNT)
-               NLA_PUT_U32(skb, XFRMA_SPDFCNT, si.fwdcnt);
-       if (flags & XFRM_SPD_ISCNT)
-               NLA_PUT_U32(skb, XFRMA_SPDISCNT, si.inscnt);
-       if (flags & XFRM_SPD_OSCNT)
-               NLA_PUT_U32(skb, XFRMA_SPDOSCNT, si.inscnt);
-       if (flags & XFRM_SPD_FSCNT)
-               NLA_PUT_U32(skb, XFRMA_SPDFSCNT, si.inscnt);
+       spc.incnt = si.incnt;
+       spc.outcnt = si.outcnt;
+       spc.fwdcnt = si.fwdcnt;
+       spc.inscnt = si.inscnt;
+       spc.outscnt = si.outscnt;
+       spc.fwdscnt = si.fwdscnt;
+       sph.spdhcnt = si.spdhcnt;
+       sph.spdhmcnt = si.spdhmcnt;
+
+       NLA_PUT(skb, XFRMA_SPD_INFO, sizeof(spc), &spc);
+       NLA_PUT(skb, XFRMA_SPD_HINFO, sizeof(sph), &sph);
 
        return nlmsg_end(skb, nlh);
 
@@ -719,23 +715,8 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
        u32 seq = nlh->nlmsg_seq;
        int len = NLMSG_LENGTH(sizeof(u32));
 
-
-       if (*flags & XFRM_SPD_HMASK)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_HMAX)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_ICNT)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_OCNT)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_FCNT)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_ISCNT)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_OSCNT)
-               len += RTA_SPACE(sizeof(u32));
-       if (*flags & XFRM_SPD_FSCNT)
-               len += RTA_SPACE(sizeof(u32));
+       len += RTA_SPACE(sizeof(struct xfrmu_spdinfo));
+       len += RTA_SPACE(sizeof(struct xfrmu_spdhinfo));
 
        r_skb = alloc_skb(len, GFP_ATOMIC);
        if (r_skb == NULL)