[syslog-ng] Re: syslog-ng-2.0rc1 doesn't log hostaddress using ipv6

Bruce Penrod bmpenrod at endruntechnologies.com
Wed Sep 13 22:58:52 CEST 2006


> On Mon, 11 Sep 2006 12:00:09 +0200 (CEST), 
> syslog-ng-request at lists.balabit.hu
> wrote:
>
> >On Thu, 2006-08-10 at 19:06 -0700, Bruce Penrod wrote:
> >> I'm using the unpatched syslog-ng-2.0rc1.  When logging messages sent
> >> from another machine over udp6, the hostname of the sending machine is
> >> not logged and the receiving host's name is logged instead, so that it
> >> looks like the message was generated locally.  When using udp, it 
> works
> >> fine.
> >>
> >
> >Can you check if the patch below works for you? It seems to work for me,
> >however I don't have a live IPv6 environment.
> >
> >--- orig/src/misc.c
> >+++ mod/src/misc.c
> >@@ -127,37 +127,56 @@ gboolean
> > resolve_hostname(GString *result, GSockAddr *saddr, gboolean usedns, 
> gboolean usefqdn)
> > {
> >   static gchar local_hostname[256] = "";
> >-  char *hname, *p;
> >+  char *hname, *p, buf[256];
> >
> >-  if (saddr && saddr->sa.sa_family == AF_INET)
> >+  if (saddr)
> >     {
> >-      struct sockaddr_in *inet_addr = (struct sockaddr_in *) &saddr->sa;
> >-
> >-      /* FIXME: add nscache support here */
> >-
> >-      if (usedns)
> >-       {
> >-         struct hostent *hp;
> >-
> >-         hp = gethostbyaddr((char *) &(inet_addr->sin_addr),
> >-                            sizeof(struct in_addr), AF_INET);
> >-         hname = (hp && hp->h_name) ? hp->h_name : NULL;
> >-       }
> >+      if (saddr->sa.sa_family == AF_INET || saddr->sa.sa_family == 
> AF_INET6)
> >+        {
> >+          void *addr;
> >+          socklen_t addr_len;
> >+
> >+          if (saddr->sa.sa_family == AF_INET)
> >+            {
> >+              addr = &((struct sockaddr_in *) &saddr->sa)->sin_addr;
> >+              addr_len = sizeof(struct in_addr);
> >+            }
> >+          else
> >+            {
> >+              addr = &((struct sockaddr_in6 *) &saddr->sa)->sin6_addr;
> >+              addr_len = sizeof(struct in6_addr);
> >+            }
> >+
> >+          /* FIXME: add nscache support here */
> >+
> >+          if (usedns)
> >+            {
> >+              struct hostent *hp;
> >+
> >+              hp = gethostbyaddr(addr, addr_len, saddr->sa.sa_family);
> >+              hname = (hp && hp->h_name) ? hp->h_name : NULL;
> >+            }
> >+          else
> >+            hname = NULL;
> >+
> >+          if (!hname)
> >+            {
> >+              inet_ntop(saddr->sa.sa_family, addr, buf, sizeof(buf));
> >+              hname = buf;
> >+            }
> >+          else
> >+            {
> >+              if (!usefqdn)
> >+                {
> >+                  p = strchr(hname, '.');
> >+                  if (p) *p = 0;
> >+                }
> >+            }
> >+        }
> >       else
> >-       hname = NULL;
> >-
> >-      if (!hname)
> >-       {
> >-         hname = inet_ntoa(inet_addr->sin_addr);
> >-       }
> >-      else
> >-       {
> >-         if (!usefqdn)
> >-           {
> >-             p = strchr(hname, '.');
> >-             if (p) *p = 0;
> >-           }
> >-       }
> >+        {
> >+          g_assert_not_reached();
> >+        }
> >     }
> >   else
> >     {
> >
> >
> >
> >
> >
> >--
> >Bazsi
>
>
> Yes, it works, but only for about a minute and terminates silently.  
> Prior to
> that, it does indeed log an ipv6 address properly for the sending host.  I
> haven't scrutinized your patch yet to see if there is an obvious pointer
> problem.
>
> Thanks for getting it this far.
>
> Bruce


Apparently the patch to rc1 did not take well, because I am now running 
the rc2 code (which seems to have the same ipv6 patch included) and 
everything seems OK so far.

-- 
Bruce Penrod





More information about the syslog-ng mailing list