readers.conf ignores specified IPv6 prefixes

Antonio Querubin tony at lava.net
Sun Mar 24 09:37:56 UTC 2002


On Thu, 21 Mar 2002, Antonio Querubin wrote:

> On Thu, 21 Mar 2002, Jeffrey M. Vinocur wrote:
>
> > On Thu, 21 Mar 2002, Antonio Querubin wrote:
>
> > > I also notice from the doc that the bindaddress/sourceaddress6 parameters
> > > don't work either.  I'll try to take a look at that as well.
> >
> > That's in innfeed, not innd, you know.
>
> Yes, I was looking at it a few nights ago.  Doesn't look too difficult to
> fix.

Attached is a patch that fixes the bindaddress functionality in innfeed
for IPv6 connections.  There are a couple of caveats though.

1.  'bindaddress' is still used for locking down the source address to a
specific IPv4 address for IPv4 connections.  'bindaddress6' is a new
optional parameter in innfeed.conf which does the same thing for IPv6
connections.  Which one is used depends on the type of address retrieved
for the destination host.  As with 'bindaddress', if 'bindaddress6' is not
specified, the system will end up choosing the IPv6 source address.

2.  'bindaddress6' will need to be added to the man page for innfeed.conf.
However, I'm not familiar enough with nroff syntax to edit the manpage
competently.  I'd appreciate it if someone else could do that.

3.  On an IPv6-enabled system, if 'bindaddress6' is specified but
'bindaddress' is not, innfeed will generate a spurious error message that
it cannot determine the IPv4 bind address.  This seems to be caused by
some kind of confusion by the getString() function in parsing the
innfeed.conf file.  Otherwise the error message can be ignored.

---

inn.conf uses 'sourceaddress' and 'sourceaddress6' to do the same thing
for innd.  I'm wondering if we should instead use those parameter names in
innfeed.conf.



-- Attached file included as plaintext by Ecartis --
-- File: connection.c.diff
-- Desc: for CURRENT snapshot

--- innfeed/connection.c.orig	Fri Mar 22 00:00:41 2002
+++ innfeed/connection.c	Sat Mar 23 23:05:48 2002
@@ -242,7 +242,8 @@
 static u_int gCxnCount = 0 ;
 static u_int max_reconnect_period = MAX_RECON_PER ;
 static u_int init_reconnect_period = INIT_RECON_PER ;
-static struct sockaddr *bind_addr = NULL;
+static struct sockaddr_in *bind_addr = NULL;
+static struct sockaddr_in6 *bind_addr6 = NULL;
 #if 0
 static bool inited = false ;
 #endif
@@ -383,34 +384,41 @@
     iv = INIT_RECON_PER ;
   init_reconnect_period = (u_int) iv ;
 
-  if (getString (topScope,"bindaddress",&sv,NO_INHERIT))
-    {
 #ifdef HAVE_INET6
+  if (getString (topScope,"bindaddress6",&sv,NO_INHERIT))
+    {
       struct addrinfo *res, hints;
 
       memset( &hints, 0, sizeof( hints ) );
       hints.ai_flags = AI_NUMERICHOST;
       if( getaddrinfo( sv, NULL, &hints, &res ) )
         {
-	  logOrPrint (LOG_ERR,fp,"innfeed unable to determine bind ip") ;
+	  logOrPrint (LOG_ERR, fp, 
+                      "innfeed unable to determine IPv6 bind address") ;
 	}
       else
         {
-	  bind_addr = (struct sockaddr *) MALLOC( res->ai_addrlen );
-	  memcpy( bind_addr, res->ai_addr, res->ai_addrlen );
+	  bind_addr6 = (struct sockaddr_in6 *) MALLOC( res->ai_addrlen );
+	  memcpy( bind_addr6, res->ai_addr, res->ai_addrlen );
         }
-#else
+    }
+#endif
+
+  if (getString (topScope,"bindaddress",&sv,NO_INHERIT))
+    {
       struct in_addr addr ;
+
       if (!inet_aton(sv,&addr))
         {
-	  logOrPrint (LOG_ERR,fp,"innfeed unable to determine bind ip") ;
+	  logOrPrint (LOG_ERR, fp,
+                      "innfeed unable to determine IPv4 bind address") ;
 	}
       else
         {
-	  bind_addr = (struct sockaddr *) MALLOC( sizeof(struct sockaddr_in) );
+	  bind_addr = (struct sockaddr_in *) 
+		      MALLOC( sizeof(struct sockaddr_in) );
 	  make_sin( (struct sockaddr_in *)bind_addr, &addr );
         }
-#endif
     }
 
   return rval ;
@@ -532,6 +540,10 @@
   struct sockaddr *retAddr;
   int fd, rval ;
   const char *peerName = hostPeerName (cxn->myHost) ;
+  char msgbuf[100];
+#ifdef HAVE_INET6
+  char paddr[INET6_ADDRSTRLEN];
+#endif
 
   ASSERT (cxn->myEp == NULL) ;
 
@@ -585,14 +597,37 @@
       return false ;
     }
 
-  /* bind to a specified virtual host */
+#ifdef HAVE_INET6
+  /* bind to a specified IPv6 address */
+  if( (cxnAddr.ss_family == AF_INET6) && bind_addr6 )
+    {
+      memcpy( &cxnSelf, bind_addr6, SA_LEN(bind_addr6) );
+      if (bind (fd, (struct sockaddr *) &cxnSelf,
+		  SA_LEN((struct sockaddr_in6 *)&cxnAddr)) < 0)
+	{
+          snprintf(msgbuf, sizeof(msgbuf), "bind (%s): %%m",
+                   inet_ntop(AF_INET6, bind_addr6->sin6_addr.s6_addr,
+                             paddr, sizeof(paddr)) );
+
+	  syslog (LOG_ERR, msgbuf) ;
+
+	  cxnSleepOrDie (cxn) ;
+
+	  return false ;
+	}
+    }
+  else
+#endif
+  /* bind to a specified IPv4 address */
   if (bind_addr)
     {
-      memcpy( &cxnSelf, &bind_addr, SA_LEN(bind_addr) );
+      memcpy( &cxnSelf, bind_addr, SA_LEN(bind_addr) );
       if (bind (fd, (struct sockaddr *) &cxnSelf,
-		  SA_LEN((struct sockaddr *)&cxnAddr)) < 0)
+		  SA_LEN((struct sockaddr_in *)&cxnAddr)) < 0)
 	{
-	  syslog (LOG_ERR,"bind: %m") ;
+          snprintf(msgbuf, sizeof(msgbuf), "bind (%s): %%m",
+                   inet_ntoa(bind_addr->sin_addr));
+	  syslog (LOG_ERR, msgbuf) ;
 
 	  cxnSleepOrDie (cxn) ;
 



More information about the inn-bugs mailing list