Re: [PATCH] BUG/MINOR: tcp: don't try to set defaultmss when value is negative

2020-02-12 Thread William Dauchy
On Wed, Feb 12, 2020 at 03:32:07PM +0100, Willy Tarreau wrote:
> I'd do it differently so that we neither try nor report an error if
> the default mss was not set. Indeed, if it already failed earlier,
> we already had an issue, so no need to fail again. So if you agree
> I'll change it to :
> 
>  if (defaultmss > 0 &&
>  tmpmaxseg != defaultmss &&
>  setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &defaultmss, 
> sizeof(defaultmss)) == -1)

agreed, sent v2 as well.

Thanks,
-- 
William



Re: [PATCH] BUG/MINOR: tcp: don't try to set defaultmss when value is negative

2020-02-12 Thread Willy Tarreau
On Wed, Feb 12, 2020 at 01:16:15PM +0100, William Dauchy wrote:
>   getsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &tmpmaxseg, &len);
> - if (tmpmaxseg != defaultmss && setsockopt(fd, IPPROTO_TCP,
> - TCP_MAXSEG, &defaultmss,
> - sizeof(defaultmss)) == -1) {
> + if (defaultmss < 0 ||
> + (tmpmaxseg != defaultmss &&
> +  setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &defaultmss, 
> sizeof(defaultmss)) == -1)) {
>   msg = "cannot set MSS";
>   err |= ERR_WARN;

I'd do it differently so that we neither try nor report an error if
the default mss was not set. Indeed, if it already failed earlier,
we already had an issue, so no need to fail again. So if you agree
I'll change it to :

 if (defaultmss > 0 &&
 tmpmaxseg != defaultmss &&
 setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &defaultmss, 
sizeof(defaultmss)) == -1)

Thanks,
Willy