/* NOTE: This routine doesn't need to take the socket lock since it doesn't access any non-constant socket information.  */
static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
/* NOTE: This routine doesn't need to take the socket lock since it doesn't access any non-constant socket information.  */
static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
{
	struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
	u32 portref = tipc_sk_port(sock->sk)->ref;
	if (unlikely(!uaddr_len))
		return tipc_withdraw(portref, 0, NULL);
	if (uaddr_len < sizeof(struct sockaddr_tipc))
		return -EINVAL;
	if (addr->family != AF_TIPC)
		return -EAFNOSUPPORT;
	if (addr->addrtype == TIPC_ADDR_NAME)
		addr->addr.nameseq.upper = addr->addr.nameseq.lower;
	else if (addr->addrtype != TIPC_ADDR_NAMESEQ)
		return -EAFNOSUPPORT;
	return (addr->scope > 0) ?
		tipc_publish(portref, addr->scope, &addr->addr.nameseq) :
		tipc_withdraw(portref, -addr->scope, &addr->addr.nameseq);
}