/* Description: Attempt to label a socket using the NetLabel mechanism using the given SID. Returns zero values on success, negative values on failure.  */
int selinux_netlbl_socket_post_create(struct sock *sk, u16 family)
/* Description: Attempt to label a socket using the NetLabel mechanism using the given SID. Returns zero values on success, negative values on failure.  */
int selinux_netlbl_socket_post_create(struct sock *sk, u16 family)
{
	int rc;
	struct sk_security_struct *sksec = sk->sk_security;
	struct netlbl_lsm_secattr *secattr;
	if (family != PF_INET)
		return 0;
	secattr = selinux_netlbl_sock_genattr(sk);
	if (secattr == NULL)
		return -ENOMEM;
	rc = netlbl_sock_setattr(sk, family, secattr);
	switch (rc) {
	case 0:
		sksec->nlbl_state = NLBL_LABELED;
		break;
	case -EDESTADDRREQ:
		sksec->nlbl_state = NLBL_REQSKB;
		rc = 0;
		break;
	}
	return rc;
}