FreeBSD/sys/ofed/drivers/infiniband/core/cma.c
/*
 * Check that the requested port is available.  This is called when trying to
 * bind to a specific port, or when trying to listen on a bound port.  In
 * the latter case, the provided id_priv may already be on the bind_list, but
 * we still need to check that it's okay to start listening.
 */
Check that the requested port is available.  This is called when trying to
bind to a specific port, or when trying to listen on a bound port.  In
the latter case, the provided id_priv may already be on the bind_list, but
we still need to check that it's okay to start listening.
Check that the requested port is available . This is called when trying to bind to a specific port or when trying to listen on a bound port . In the latter case the provided id_priv may already be on the bind_list but we still need to check that it ' s okay to start listening .
static int cma_check_port(struct rdma_bind_list *bind_list,
			  struct rdma_id_private *id_priv, uint8_t reuseaddr)
{
	struct rdma_id_private *cur_id;
	struct sockaddr *addr, *cur_addr;
	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
	hlist_for_each_entry(cur_id, &bind_list->owners, node) {
		if (id_priv == cur_id)
			continue;
		if ((cur_id->state != RDMA_CM_LISTEN) && reuseaddr &&
		    cur_id->reuseaddr)
			continue;
		cur_addr = (struct sockaddr *) &cur_id->id.route.addr.src_addr;
		if (id_priv->afonly && cur_id->afonly &&
		    (addr->sa_family != cur_addr->sa_family))
			continue;
		if (cma_any_addr(addr) || cma_any_addr(cur_addr))
			return -EADDRNOTAVAIL;
		if (!cma_addr_cmp(addr, cur_addr))
			return -EADDRINUSE;
	}
	return 0;
}
static int cma_check_port ( struct rdma_bind_list * bind_list , struct rdma_id_private * id_priv , uint8_t reuseaddr ) { struct rdma_id_private * cur_id ; struct sockaddr * addr , * cur_addr ; addr = ( struct sockaddr * ) & id_priv -> id . route . addr . src_addr ; hlist_for_each_entry ( cur_id , & bind_list -> owners , node ) { if ( id_priv == cur_id ) continue ; if ( ( cur_id -> state != RDMA_CM_LISTEN ) && reuseaddr && cur_id -> reuseaddr ) continue ; cur_addr = ( struct sockaddr * ) & cur_id -> id . route . addr . src_addr ; if ( id_priv -> afonly && cur_id -> afonly && ( addr -> sa_family != cur_addr -> sa_family ) ) continue ; if ( cma_any_addr ( addr ) || cma_any_addr ( cur_addr ) ) return - EADDRNOTAVAIL ; if ( ! cma_addr_cmp ( addr , cur_addr ) ) return - EADDRINUSE ; } return 0 ; }
Check that the requested port is available.
Check that the requested port is available .