Re: [patch] ipvs: prevent some underflows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Jun 08, 2015 at 10:16:23PM +0300, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Fri, 5 Jun 2015, Dan Carpenter wrote:
> 
> > @@ -1363,7 +1363,8 @@ static int set_sync_mesg_maxlen(struct net *net, int sync_state)
> 
> 	May be we should use min(dev->mtu, 1500) instead of
> dev->mtu to avoid sending too large packets for the common
> case.

That will put an upper limit on it, no? If the load balancers share a
big MTU, why not use it?

Thanks,
Marcelo

> >  		       sizeof(struct udphdr) -
> >  		       SYNC_MESG_HEADER_LEN - 20) / SIMPLE_CONN_SIZE;
> >  		ipvs->send_mesg_maxlen = SYNC_MESG_HEADER_LEN +
> > -			SIMPLE_CONN_SIZE * min(num, MAX_CONNS_PER_SYNCBUFF);
> > +			SIMPLE_CONN_SIZE * min_t(uint, num,
> > +						 MAX_CONNS_PER_SYNCBUFF);
> 
> 	ipvs->send_mesg_maxlen = max(min(dev->mtu, 1500) -
> 		sizeof(struct iphdr) - sizeof(struct udphdr),
> 		/* Some new const is needed here: */
> 		2 * FULL_CONN_SIZE);
> 
> 	And may be we should add more correct checks in
> ip_vs_sync_conn() in case dev->mtu was changed after thread
> start. Currently, it is assumed that fresh new buffer from
> ip_vs_sync_buff_create() will have space for at least one
> message... We can even set inet->pmtudisc to IP_PMTUDISC_DONT
> so that packets can be fragmented for too small MTU.
> 
> >  		IP_VS_DBG(7, "setting the maximum length of sync sending "
> >  			  "message %d.\n", ipvs->send_mesg_maxlen);
> >  	} else if (sync_state == IP_VS_STATE_BACKUP) {
> > @@ -1371,8 +1372,11 @@ static int set_sync_mesg_maxlen(struct net *net, int sync_state)
> >  		if (!dev)
> >  			return -ENODEV;
> >  
> > -		ipvs->recv_mesg_maxlen = dev->mtu -
> > -			sizeof(struct iphdr) - sizeof(struct udphdr);
> > +		if (dev->mtu < sizeof(struct iphdr) + sizeof(struct udphdr))
> > +			ipvs->recv_mesg_maxlen = 0;
> > +		else
> > +			ipvs->recv_mesg_maxlen = dev->mtu -
> > +				sizeof(struct iphdr) - sizeof(struct udphdr);
> 
> 	May be ipvs->recv_mesg_maxlen = max(dev->mtu, 1500);
> This is single buffer allocated when backup starts...
> 
> >  		IP_VS_DBG(7, "setting the maximum length of sync receiving "
> >  			  "message %d.\n", ipvs->recv_mesg_maxlen);
> >  	}
> > 
> 
> Regards
> 
> --
> Julian Anastasov <ja@xxxxxx>
> --
> To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux