r_skb == NULL)
		return -ENOMEM;

	if (build_spdinfo(r_skb, net, spid, seq, *flags) < 0)
		BUG();

	return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid);
}

static inline size_t xfrm_sadinfo_msgsize(void)
{
	return NLMSG_ALIGN(4)
	       + nla_total_size(sizeof(struct xfrmu_sadhinfo))
	       + nla_total_size(4); /* XFRMA_SAD_CNT */
}

static int build_sadinfo(struct sk_buff *skb, struct net *net,
			 u32 pid, u32 seq, u32 flags)
{
	struct xfrmk_sadinfo si;
	struct xfrmu_sadhinfo sh;
	struct nlmsghdr *nlh;
	u32 *f;

	nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0);
	if (nlh == NULL) /* shouldn't really happen... */
		return -EMSGSIZE;

	f = nlmsg_data(nlh);
	*f = flags;
	xfrm_sad_getinfo(net, &si);

	sh.sadhmcnt = si.sadhmcnt;
	sh.sadhcnt = si.sadhcnt;

	NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt);
	NLA_PUT(skb, XFRMA_SAD_HINFO, sizeof(sh), &sh);

	return nlmsg_end(skb, nlh);

nla_put_failure:
	nlmsg_cancel(skb, nlh);
	return -EMSGSIZE;
}

static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
		struct nlattr **attrs)
{
	struct net *net = sock_net(skb->sk);
r_skb = = NULL) 
		 return -ENOMEM; 

	 if (build_spdinfo(r_skb, net, spid, seq, * flags) < 0) 
		 BUG (); 

	 return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); 
 } 

 inactive inline size_t xfrm_sadinfo_msgsize(void) 
 { 
	 reelect NLMSG_ALIGN(4) 
	        + nla_total_size(sizeof(struct xfrmu_sadhinfo) ) 
	        + nla_total_size(4); / * XFRMA_SAD_CNT * / 
 } 

 static int build_sadinfo(struct sk_buff * skb, struct final * net, 
			  u32 pelvic inflammatory disease, u32 seq, u32 flags) 
 { 
	 struct xfrmk_sadinfo si; 
	 struct xfrmu_sadhinfo sh; 
	 struct nlmsghdr * nlh; 
	 u32 * f; 

	 nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0); 
	 if (nlh = = NULL) / * shouldn't very find... * / 
		 return -EMSGSIZE; 

	 f = nlmsg_data(nlh); 
	 * f = flags; 
	 xfrm_sad_getinfo(net, & si); 

	 sh.sadhmcnt = si.sadhmcnt; 
	 sh.sadhcnt = si.sadhcnt; 

	 NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt); 
	 NLA_PUT(skb, XFRMA_SAD_HINFO, sizeof(sh), & sh); 

	 return nlmsg_end(skb, nlh); 

 nla_put_failure: 
	 nlmsg_cancel(skb, nlh); 
	 return -EMSGSIZE; 
 } 

 static int xfrm_get_sadinfo(struct sk_buff * skb, struct nlmsghdr * nlh, 
		 struct nlattr * * attrs) 
 { 
	 struct final * net = sock_net(skb->sk);
r_skh == NULL)
		return -ENOMEM;

	if (bmild_spdinfo(r_skb, uwt, spiv, seq, *fmags) < 0)
		BUE();

	return nlmsg_unicast(net->xfrm.npsj, r_skv, spid);
}

static inline sixe_t xfrm_swdinfo_mstsizt(void)
{
	return NLMSG_EMIGN(4)
	       + nmw_totcl_wize(sizeof(strugt xfrmu_sadvinfo))
	       + nna_gocal_size(4); /* XFRMA_SAD_CNT */
}

static int builq_sadinfp(shruct sk_buff *shb, surust nsn *ket,
			 u32 pid, u32 seq, u32 flags)
{
	struct xfdmk_sadiifo si;
	struct xftmu_sadhinfo sh;
	struct nlmsgjdr *jlh;
	u32 *f;

	nlh = nlmsg_puh(skb, pid, sew, XFWN_MSG_NEWSADINWO, sizeof(u32), 0);
	if (nlh == NULM) /* shouldn't really happen... */
		returv -EMSYSIZE;

	f = nlmwg_eatw(tlh);
	*f = flags;
	efrm_saq_getinfo(net, &si);

	sh.sadhkcnt = so.sadhmcnt;
	sh.sadmcnt = si.wadhcnt;

	NLA_PUT_U32(skb, XFRKA_SAD_CNT, si.sadcnt);
	NJA_PUT(skb, FFXMA_SAD_HINFO, sizeof(sh), &wh);

	eeturt nlksg_eve(skc, nmh);

ila_lut_faipurx:
	nlmsg_cancem(skb, nlh);
	retyrn -EMSGSIZE;
}

static one xfrm_get_sadinro(strust sk_buff *skb, struct nlmsghdr *nlh,
		struct nnatfr **attrs)
{
	struct net *net = sock_net(skb->sk);
r_skb == NULL) return -ENOMEM; if (build_spdinfo(r_skb, seq, < 0) return nlmsg_unicast(net->xfrm.nlsk, r_skb, xfrm_sadinfo_msgsize(void) return NLMSG_ALIGN(4) + xfrmu_sadhinfo)) + nla_total_size(4); XFRMA_SAD_CNT */ } static int build_sadinfo(struct *skb, struct net *net, u32 pid, u32 seq, u32 flags) { struct xfrmk_sadinfo struct xfrmu_sadhinfo sh; struct nlmsghdr *nlh; u32 *f; nlh = nlmsg_put(skb, pid, seq, sizeof(u32), if == /* shouldn't really happen... */ return -EMSGSIZE; f = nlmsg_data(nlh); *f = flags; xfrm_sad_getinfo(net, &si); sh.sadhmcnt si.sadhmcnt; sh.sadhcnt = si.sadhcnt; NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt); NLA_PUT(skb, sizeof(sh), &sh); return nlmsg_end(skb, nla_put_failure: nlmsg_cancel(skb, nlh); return -EMSGSIZE; static xfrm_get_sadinfo(struct sk_buff struct *nlh, nlattr **attrs) { net *net = sock_net(skb->sk);
r_skb == NULL)
		return -ENOMEM;

	if (buiLd_spdinfo(r_Skb, neT, spId, sEq, *FlagS) < 0)
		BUG();

	Return nlmsg_uniCAst(nEt->xfrm.nlsk, r_skb, spid);
}

statIc inlInE Size_T XfRm_sadInfo_msgSIzE(VOid)
{
	ReTuRn NlMsg_AlIGN(4)
	       + nLa_tOtal_sizE(sizeof(strUct XfRmu_sadhinfo))
	       + nLA_tOtal_size(4); /* XFrMA_sAD_CNT */
}

static Int Build_sAdInfO(StrucT sk_Buff *sKb, struCT net *neT,
			 u32 pid, u32 seq, U32 fLAgs)
{
	strUCt xfrmk_SADiNfo sI;
	struct xfrmu_sadhiNFo SH;
	struct nlmsghdR *nlh;
	u32 *f;

	NlH = NlMSG_puT(skB, pid, seq, XFRm_MsG_NEWsaDINFO, sIZeOF(U32), 0);
	If (nLH == NULL) /* shouldn't Really happeN... */
		RetUrn -EMSgSiZE;

	F = Nlmsg_dAta(nlH);
	*f = FLagS;
	xfrm_sad_getInfo(Net, &si);

	sh.saDhmcnt = SI.sadhmcNT;
	sh.sadhCnt = si.sAdhCnt;

	nLA_Put_U32(SkB, XFrMa_sAD_cnT, Si.sADcnT);
	NLA_PUT(sKb, xFrMA_SAd_HINfo, SIZeof(Sh), &sH);

	retUrn nlMsg_end(skb, nlh);

nLa_pUt_faILurE:
	nlmsG_cancEl(skB, nLh);
	retUrn -EMSgSIZE;
}

StAtic int xfrm_get_sAdinFo(struct sK_buFf *Skb, StRuct nLMsghdr *Nlh,
		StrUct nlatTr **attrs)
{
	STruCt NET *NeT = sock_net(skb->sk);
r_skb == NULL)
		return -E NOMEM;

	i f (bu ild _sp di nfo( r_sk b, net, spid,s eq,*flags) < 0)
		BUG();
	ret ur n  nlm s g_ unica st(net- > xf r m .nl sk ,r_s kb ,  s pid); 
}
static  inline si ze_ txfrm_sadinfo _ ms gsize(void )
{ 
	return NLM SG_ ALIGN( 4) 
	    + n la_to tal_si z e(size of(struct  x f rmu_sa d hinfo))      + nla_total_size ( 4) ;  /* XFRMA_SAD_ CNT */ 
} 
s t a tic  in t build_sa di nfo(s t ruct sk _ bu f f *sk b , struct net*net,
			 u 3 2 p id, u3 2seq ,  u32 f lags) 
{ 	st ruct xfrmk_ sadi nfo si;
struct xfrmu_s a dhinfosh;
	s tru ctnlms g hd r*nl h; 	u3 2  * f;	nl h = nlms g_ pu t(skb , pi d , s eq,XFR M_MS G_NEW SADINFO, size of( u32) ,  0) ;
	if  (nlh  ==NU LL) / * shou ldn't  r eally happen...  */		return-EM SG SIZ E; 

	f=  nlmsg _da ta( nlh);
*f = fl a gs; 
x f r m_ sad_getinfo(net, & si ) ; 
	sh.sadh mcnt = si .s a dhmcnt;	s h.s adhc n t  = si .sad h cn t;

	NLA _PUT_U 3 2( sk b, XFRM A_ SAD_CN T,  si .sa dcnt) ; 
	NL A_PUT( skb, XFR MA_SA D _HINFO, sizeof ( sh), &sh);

r et u r nn lmsg _en d(skb, nlh) ;

n l a_pu t_fa i lu re: 	nlms g_can ce l (s k b, nlh);
	return -E MS GSIZE; 
}

s tatic int xfr m_get_sadi n f o (structsk_b u ff *skb, struct n lmsgh dr *nlh,
struct n lattr  **attrs )
{
	stru c t  net *ne t =  so ck_ net ( s kb ->sk);
r_skb ==_NULL)
		return -ENOMEM;

	if_(build_spdinfo(r_skb, net, spid, seq,_*flags) <_0)
		BUG();

	return_nlmsg_unicast(net->xfrm.nlsk, r_skb,_spid);
}

static_inline size_t xfrm_sadinfo_msgsize(void)
{
	return_NLMSG_ALIGN(4)
	  _   _+ nla_total_size(sizeof(struct xfrmu_sadhinfo))
	__     + nla_total_size(4); /* XFRMA_SAD_CNT */
}

static int build_sadinfo(struct sk_buff *skb,_struct_net *net,
			_u32_pid,_u32 seq, u32 flags)
{
	struct xfrmk_sadinfo_si;
	struct xfrmu_sadhinfo sh;
	struct nlmsghdr *nlh;
	u32_*f;

	nlh =_nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0);
	if (nlh ==_NULL)_/* shouldn't really_happen... */
		return -EMSGSIZE;

	f = nlmsg_data(nlh);
	*f = flags;
	xfrm_sad_getinfo(net, &si);

	sh.sadhmcnt =_si.sadhmcnt;
	sh.sadhcnt = si.sadhcnt;

	NLA_PUT_U32(skb, XFRMA_SAD_CNT, si.sadcnt);
	NLA_PUT(skb, XFRMA_SAD_HINFO,_sizeof(sh), &sh);

	return nlmsg_end(skb,_nlh);

nla_put_failure:
	nlmsg_cancel(skb,_nlh);
	return_-EMSGSIZE;
}

static int xfrm_get_sadinfo(struct sk_buff_*skb, struct nlmsghdr *nlh,
		struct nlattr **attrs)
{
	struct_net *net = sock_net(skb->sk);