RE: [Pound Mailing List] Location comparision with backend address & host

Joe Gooch <[email protected]>
Newsgroups gmane.comp.web.pound.general
Message-ID <[email protected]>
Since I split my listeners, (ipv4 and ipv6, no wildcard), I haven't had this problem.  It's something that could be dealt with easily with log parsers/helper scripts.

However, I could see how some might want the ips translated.

I think you'll find this is more simplistic and accomplishes the same result.

Joe

> -----Original Message-----
> From: Bussi Andrea [mailto:[email protected]]
> Sent: Monday, March 25, 2013 11:07 AM
> To: [email protected]
> Subject: Re: [Pound Mailing List] Location comparision with backend
> address & host
> 
> On 03/18/2013 09:43 AM, Bussi Andrea wrote:
> > On 03/16/2013 09:30 AM, Raj Kishore1/CHN/TCS wrote:
> >> Hi Joe,
> >>
> >> Thanks for the previous replies.
> >>
> >> We have modified the pound 1.9 socket structures to listen IPV4/ipv6
> >> address.
> >>
> >> However when IPV4 request comes,it is mapped to IPV6 address as
> >> ::ffff:<X.X.X.X> In case of IPV6 client, it is fetching the IPV6
> >> address only.
> >>
> >> Is it the right mechansim to handle ipv4 client in ipv4 mapped ipv6
> >> address mode in pound?
> >>
> >> Do we need to handele explicitly  the IPV4-6 mapped address in dual
> >> stack?
> >>
> > I had the same problem with Pound 2.6; it seems to be an issue in the
> > inet_ntop function, if I'm not mistaken.
> >
> > I don't believe my patch (attached below) is the right way to solve
> > it; the proper way should be a patched inet_ntop.
> >
> > But this solved my troubles; maybe somebody else will find it useful
> > too.
> >
> 
> The patch I previously posted didn't initialize the port variable for
> IPv4 addresses, so the addr2str function would print an uninitialized
> stack value as the port number.
> 
> This is the right patch.
> 
> Sorry for the mistake,
> 				Bussi Andrea
> 
> 
> > Best regards,
> >                      Bussi Andrea
> >
>
pound-2.6-ipv4-mapped-in-ipv6-sockets-jjg.patch (application/octet-stream, 1 KB)
diff --git i/svc.c w/svc.c
index 65a3e43..e30674b 100644
--- i/svc.c
+++ w/svc.c
@@ -425,8 +425,14 @@ addr2str(char *const res, const int res_len, const struct addrinfo *addr, const
     case AF_INET6:
         src = (void *)&((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr.s6_addr;
         port = ntohs(((struct sockaddr_in6 *)addr->ai_addr)->sin6_port);
-        if(inet_ntop(AF_INET6, src, buf, MAXBUF - 1) == NULL)
-            strncpy(buf, "(UNKNOWN)", MAXBUF - 1);
+        if( IN6_IS_ADDR_V4MAPPED( &(((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr) )) {
+            src = (void *)&((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr.s6_addr[12];
+            if(inet_ntop(AF_INET, src, buf, MAXBUF - 1) == NULL)
+                strncpy(buf, "(UNKNOWN)", MAXBUF - 1);
+        } else {
+            if(inet_ntop(AF_INET6, src, buf, MAXBUF - 1) == NULL)
+                strncpy(buf, "(UNKNOWN)", MAXBUF - 1);
+        }
         break;
     case AF_UNIX:
         strncpy(buf, (char *)addr->ai_addr, MAXBUF - 1);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.