[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>
This commit is contained in:
parent
af11e31609
commit
5a6d34162f
4 changed files with 44 additions and 70 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
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;
|
||||
|
||||
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);
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue