Subject: Re: [PATCH 3/5 net-next] cnic: Randomize initial TCP port for iSCSI connections

From: "Michael Chan" <[email-masked]>
Date: Thu, 9 Jun 2011 18:08:00 -0700

On Thu, 2011-06-09 at 08:27 -0700, Stephen Hemminger wrote:
> On Wed, 8 Jun 2011 22:29:34 -0700
> "Michael Chan" <[email-masked]> wrote:
> 
> >  static int cnic_cm_alloc_mem(struct cnic_dev *dev)
> >  {
> >  	struct cnic_local *cp = dev->cnic_priv;
> > +	u32 port_id;
> >  
> >  	cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ,
> >  			      GFP_KERNEL);
> >  	if (!cp->csk_tbl)
> >  		return -ENOMEM;
> >  
> > +	get_random_bytes(&port_id, sizeof(port_id));
> 
> I think random32() or it's alias net_random() would be sufficient
> for your needs here.
> 

random32() is pseudo random so we can get the same number after reboot,
right?  One scenario is that we may be booting from an iSCSI target, but
due to some failure, the user may be rebooting multiple times rapidly.
We want to use a different port during each boot.