/* Sets the netlabel socket state on sk from parent  */
static int smack_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
/* Sets the netlabel socket state on sk from parent  */
static int smack_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
{
	struct netlbl_lsm_secattr secattr;
	struct sock *sk;
	char smack[SMK_LABELLEN];
	int family = PF_INET;
	u32 s;
	int rc;
	if (sock != NULL) {
		sk = sock->sk;
		if (sk->sk_family != PF_INET && sk->sk_family != PF_INET6)
			return 0;
		family = sk->sk_family;
	}
	netlbl_secattr_init(&secattr);
	rc = netlbl_skbuff_getattr(skb, family, &secattr);
	if (rc == 0)
		smack_from_secattr(&secattr, smack);
	netlbl_secattr_destroy(&secattr);
	if (rc != 0)
		return rc;
	s = smack_to_secid(smack);
	if (s == 0)
		return -EINVAL;
	*secid = s;
	return 0;
}