static int pfkey_spdget ( struct sock * sk , struct sk_buff * skb , const struct sadb_msg * hdr , void * const * ext_hdrs ) {
 struct net * net = sock_net ( sk ) ;
 unsigned int dir ;
 int err = 0 , delete ;
 struct sadb_x_policy * pol ;
 struct xfrm_policy * xp ;
 struct km_event c ;
 if ( ( pol = ext_hdrs [ SADB_X_EXT_POLICY - 1 ] ) == NULL ) return - EINVAL ;
 dir = xfrm_policy_id2dir ( pol -> sadb_x_policy_id ) ;
 if ( dir >= XFRM_POLICY_MAX ) return - EINVAL ;
 delete = ( hdr -> sadb_msg_type == SADB_X_SPDDELETE2 ) ;
 xp = xfrm_policy_byid ( net , DUMMY_MARK , XFRM_POLICY_TYPE_MAIN , dir , pol -> sadb_x_policy_id , delete , & err ) ;
 if ( xp == NULL ) return - ENOENT ;
 if ( delete ) {
 xfrm_audit_policy_delete ( xp , err ? 0 : 1 , audit_get_loginuid ( current ) , audit_get_sessionid ( current ) , 0 ) ;
 if ( err ) goto out ;
 c . seq = hdr -> sadb_msg_seq ;
 c . portid = hdr -> sadb_msg_pid ;
 c . data . byid = 1 ;
 c . event = XFRM_MSG_DELPOLICY ;
 km_policy_notify ( xp , dir , & c ) ;
 }
 else {
 err = key_pol_get_resp ( sk , xp , hdr , dir ) ;
 }
 out : xfrm_pol_put ( xp ) ;
 return err ;
 }
static int pfkey_spdget ( struct sock * sk , struct sk_buff * skb , const struct sadb_msg * hdr , void * const * ext_hdrs ) {
 struct net * net = sock_net ( sk ) ;
 unsigned int dir ;
 int err = 0 , delete ;
 struct sadb_x_policy * pol ;
 struct xfrm_policy * xp ;
 struct km_event c ;
 if ( ( pol = ext_hdrs [ SADB_X_EXT_POLICY - 1 ] ) == NULL ) return - EINVAL ;
 dir = xfrm_policy_id2dir ( pol -> sadb_x_policy_id ) ;
 if ( dir >= XFRM_POLICY_MAX ) return - EINVAL ;
 delete = ( hdr -> sadb_msg_type == SADB_X_SPDDELETE2 ) ;
 xp = xfrm_policy_byid ( net , DUMMY_MARK , XFRM_POLICY_TYPE_MAIN , dir , pol -> sadb_x_policy_id , delete , & err ) ;
 if ( xp == NULL ) return - ENOENT ;
 if ( delete ) {
 xfrm_audit_policy_delete ( xp , err ? 0 : 1 , audit_get_loginuid ( current ) , audit_get_sessionid ( current ) , 0 ) ;
 if ( err ) goto out ;
 c . seq = hdr -> sadb_msg_seq ;
 c . portid = hdr -> sadb_msg_pid ;
 c . data . byid = 1 ;
 c . event = XFRM_MSG_DELPOLICY ;
 km_policy_notify ( xp , dir , & c ) ;
 }
 else {
 err = key_pol_get_resp ( sk , xp , hdr , dir ) ;
 }
 out : xfrm_pol_put ( xp ) ;
 return err ;
 }