Re: OPTIM : IPv6 literal address parsing

2015-11-01 Thread Willy Tarreau
On Sun, Nov 01, 2015 at 08:52:19PM +0100, Mildis wrote: > Understood. > > Here the corrected patch. Great, I've applied it, thanks. Please don't forget to update the doc, I'm pretty sure the address format is mentionned there. Thanks, Willy

Re: OPTIM : IPv6 literal address parsing

2015-10-27 Thread Mildis
Hi, I’ve reworked the patch. No warnings whatsoever, wether using GCC or LLVM. checkpatch is OK, no warnings either. Buffers are secured and all loops exit naturally or with an index I’ve checked against off-by-one. I’ve made a custom loop to remove the brackets : I found it easier than to

Re: OPTIM : IPv6 literal address parsing

2015-10-22 Thread Mildis
Hi Willy, Here are two patches, rebased on current HEAD. The first allows IPv6 with square brackets, the second parses colon to look for a port. The logic is meant to be backward compatible with current behavior : as you suggested, starting from the end, it looks for either a colon or a

Re: OPTIM : IPv6 literal address parsing

2015-10-22 Thread Willy Tarreau
Hi, On Thu, Oct 22, 2015 at 08:26:01PM +0200, Mildis wrote: > Hi Willy, > > Here are two patches, rebased on current HEAD. > The first allows IPv6 with square brackets, the second parses colon to > look for a port. OK thanks. > The logic is meant to be backward compatible with current

Re: OPTIM : IPv6 literal address parsing

2015-10-17 Thread Mildis
Hi again, Let’s go step by step. Here is a first patch which allows square-brackets literals. It does not change the port parser, just remove the brackets in str2ip2. It expects the IP address to be either plain or surrounded with square brackets, thus if first and last chars are not

Re: OPTIM : IPv6 literal address parsing

2015-10-13 Thread Mildis
Le 2015-10-10 15:49, Willy Tarreau a écrit : Hi, @@ -856,11 +883,28 @@ struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high, char else { /* IPv4 and IPv6 */ int use_fqdn = 0; - port1 = strrchr(str2, ':'); - if (port1)

Re: OPTIM : IPv6 literal address parsing

2015-10-10 Thread Mildis
Aw, man ! My C skills are so rusted :) I’ll look at your comments and correct all this. BTW, a bit off-topic : have you looked at a code-review server like gerrit ? Quite useful for multi-round patchset submission like this one. -- Mildis Le 2015-10-10 15:49, Willy Tarreau a écrit : Hi,

Re: OPTIM : IPv6 literal address parsing

2015-10-10 Thread Willy Tarreau
On Sat, Oct 10, 2015 at 05:02:08PM +0200, Mildis wrote: > Aw, man ! > My C skills are so rusted :) > > I???ll look at your comments and correct all this. Thanks. > BTW, a bit off-topic : have you looked at a code-review server like > gerrit ? No but quite frankly I don't believe a single

Re: OPTIM : IPv6 literal address parsing

2015-10-10 Thread Mildis
Here is a working patch for IPv6 literal with square brackets. Tested with : "2001:db8::1234:5678", "2001:db8::1234:5678:", "2001:db8::1234:5678:80", "2001:db8::1234:5678:80:", "::", ":::", ":::80", "[2001:db8::1234:5678]", "[2001:db8::1234:5678]:", "[2001:db8::1234:5678]:80", "[::]", "[::]:",

Re: OPTIM : IPv6 literal address parsing

2015-10-10 Thread Willy Tarreau
Hi, On Sat, Oct 10, 2015 at 01:50:46PM +0200, Mildis wrote: > Here is a working patch for IPv6 literal with square brackets. > Tested with : > "2001:db8::1234:5678", > "2001:db8::1234:5678:", > "2001:db8::1234:5678:80", > "2001:db8::1234:5678:80:", > "::", > ":::", > ":::80", >

Re: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Willy Tarreau
Hi, On Tue, Oct 06, 2015 at 05:34:07PM +0200, Mildis wrote: > Hi Willy, > > My bad : in the doc, I didn???t get the « add a colon without a port to > end an address » trick. > That???s why I was lost at first. > The doc obviously says ???[:[port]]??? making the port optional > and an ending

Re: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Mildis
Hi Willy, My bad : in the doc, I didn’t get the « add a colon without a port to end an address » trick. That’s why I was lost at first. The doc obviously says ‘[:[port]]’ making the port optional and an ending colon valid but it looks like a typo to me as ending an IPv6 address with a colon

RE: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Mildis
Thanks for your feedback. I think it need improvement as I currently replace the closing bracket with a null directly in the string. Working on a copy and leave the original string as-is should be better. Plus adding some logic here and there to match all cases ... I’ll work on this asap.

Re: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Willy Tarreau
On Mon, Oct 05, 2015 at 06:42:52PM +0200, Mildis wrote: > Le 2015-10-05 18:07, David du Colombier a écrit : > >>It looks like IPv6 parsing may lead to errors. > >>The logic cannot distinguish from ???2001:db8::1234:80??? as : > >>- a plain IPv6 address 2001:db8::1234:80 > >>- IPv6 2001:db8::1234

Re: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Mildis
Le 2015-10-06 17:47, Willy Tarreau a écrit : Hi, You must not forbid "[2001:db8::1234]:" otherwise people will not adopt the square brackets notation. Some of them probably already do things like this : server srv1 $IP_SRV1:$PORT_SRV1 And fill the respective environment variables with

Re: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Willy Tarreau
On Tue, Oct 06, 2015 at 05:57:09PM +0200, Mildis wrote: > >And regarding "2001:db8::1234", you can't forbit it simply because you > >don't know if 1234 is a port or not in this context, as you have > >reported. > > Sure. In this very specific case 1234 can???t be a port as 2001:db8:: is > then

RE: OPTIM : IPv6 literal address parsing

2015-10-06 Thread Lukas Tribus
Hi Mildis, >> And regarding "2001:db8::1234", you can't forbit it simply because you >> don't know if 1234 is a port or not in this context, as you have >> reported. > > Sure. In this very specific case 1234 can’t be a port as 2001:db8:: is > then a subnet. For the record: you can't know that,

Re: OPTIM : IPv6 literal address parsing

2015-10-05 Thread David du Colombier
> It looks like IPv6 parsing may lead to errors. > The logic cannot distinguish from ‘2001:db8::1234:80’ as : > - a plain IPv6 address 2001:db8::1234:80 > - IPv6 2001:db8::1234 on port 80 As far I remember, to prevent this confusion, we made the final colon mandatory on IPv6 addresses. This way,