Hi Willy,

On Tue, Jan 09, 2018 at 03:17:24PM +0100, Willy Tarreau wrote:
> Hi Olivier,
> 
> On Mon, Jan 08, 2018 at 04:35:35PM +0100, Olivier Houchard wrote:
> > Hi,
> > 
> > The attached patch attempts to map SRV record weight to haproxy weight 
> > correctly,
> > SRV weight goes from 0 to 65536 while haproxy uses 0 to 256, so we have to
> > divide it by 256, and a SRV weight of 0 doesn't mean the server shouldn't be
> > used, so we use a minimum weight of 1.
> 
> From what I'm seeing in the code, it's 0..65535 for the SRV record. And
> that allows us to simplify it and use the full range of the weight like
> this :
> 
>    hap_weight = srv_weight / 256 + 1;
> 
> => 0..255 return 1
>    1..511 return 2
>    ...
>    65280..65535 return 256
> 
> What do you think ?
> 
> Willy
> 

Sure, sounds good, for some reason I thought the max was 255, but it's
actually 256, one day I'll learn how to read C.

Regards,

Olivier

Reply via email to