[openib-general] Re: [PATCH][RFC] CMA automatic port number assignment

James Lentini jlentini at netapp.com
Mon Feb 27 12:03:49 PST 2006



On Fri, 24 Feb 2006, Sean Hefty wrote:

> James Lentini wrote:
> > +static u16 cma_generate_ephemeral_port(void)
> > +{
> > +	u16 port;
> > +
> > +	get_random_bytes(&port, sizeof port);
> > +	return cpu_to_be16(port | 1024U);
> > +}
> 
> As you mentioned, we should verify that the port number is not in 
> use.

I'll work on a new patch for this.

> >  static void cma_format_hdr(void *hdr, enum rdma_port_space ps,
> >  			   struct rdma_route *route)
> >  {
> > @@ -1371,6 +1379,9 @@ static void cma_format_hdr(void *hdr, en
> >  	src4 = (struct sockaddr_in *) &route->addr.src_addr;
> >  	dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
> >  +	if (!src4->sin_port)
> > +		src4->sin_port = cma_generate_ephemeral_port();
> 
> This only sets the port number in the header.  It would make more 
> sense to save the port number in the rdma_cm_id's src_addr.

I thought I was saving the port number in the rdma_cm_id's src_addr. 
src4 is an alias of the rdma_id_private's rdma_cma_id's rdma_route's 
rdma_addr's src_addr field. 

How would you do it differently?



More information about the general mailing list