aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamal Hadi Salim <hadi@cyberus.ca>2007-05-04 12:55:39 -0700
committerDavid S. Miller <davem@davemloft.net>2007-05-04 12:55:39 -0700
commit5a6d34162f5c6f522f857df274f1c8240f161e11 (patch)
tree537d305eef465617944821a1df59da3523a640df
parentaf11e31609d93765c1b22611592543e028f7aa54 (diff)
[XFRM] SPD info TLV aggregation
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>
-rw-r--r--include/linux/xfrm.h39
-rw-r--r--include/net/xfrm.h24
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--net/xfrm/xfrm_user.c51
4 files changed, 45 insertions, 71 deletions
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index c237fe3af8c..b58adc52448 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -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;
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index d0d7db51d3f..39ef925d39d 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -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);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 263e34e4526..95271e8426a 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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];
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index c35b9ea3b62..b14c7e590c3 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,
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)