It's finally here!  IP Aliasing support for IRIX!

Unfortunately, this is probably not a "final" solution for this,
as there are cleanliness issues, almost certainly portability
issues (it affects one of the main files in the tree, rather
than something in the ports/irix directory, and uses IRIX
specific calls... so other OS's will almost certainly stop
building BIND with this patch applied)...

BUT, it seems to work.  I've tested it briefly on an IRIX 6.5
machine, and it listened to the appropriate addresses, answered
queries on them, etc...  I have not done extensive testing, nor
a thourough walk through the code, so standard disclaimers
apply, but it does seem to do the trick.

Many thanks go to Pedro Miguel Zeferino for submitting this
patch!

I hope one day to provide a patch that is more friendly to other
OS's, etc., but for now, I'm supplying it as is, as I know the
demand is high for this, and both my time and my access to IRIX
machines has been seriously limited of late...

Here is the mail that was sent to me about this patch:

> From: Pedro Miguel Zeferino <pedro@nextvision.pt>
> Date: Tue, 13 Oct 1998 15:46:09 +0100
> Organization: Nextvision, Lda.
> To: bind-irix-port-maintainer@daveltd.com
> Subject: bind won't listen on aliased ip addresses in Irix (patch)
> 
> From your BIND-IRIX-PORT page:
> > BIND does not correctly detect IP aliasing (so the listen-on
> > configuration directive doesn't work with such aliases, and it
> > doesn't pick up those addresses with the default listening,
> > either.) A fix for this is in the works, but it's slow going.
> > If you'd like to help with this, let me know, and I can give
> > you a little something to get it started.
> 
> Hi!
> 
> Here is a patch I've done to solve that problem.
> I think it could be done in a better way.. but it works...
> 
> It can maybe help you to speed up your fix.
> 
> 
> Regards,
> 
> Pedro


And here is the patch that was included (Thanks again, Pedro!):

----  [cut here (optional)] ----
bind won't listen on aliased ip addresses in Irix (patch)
		pedro@nextvision.pt

diff -ru src.orig/bin/named/ns_main.c src/bin/named/ns_main.c
--- src.orig/bin/named/ns_main.c	Tue Apr 28 20:17:46 1998
+++ src/bin/named/ns_main.c	Tue Oct 13 12:31:26 1998
@@ -93,6 +93,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/ioctl.h>
+#include <sys/sysctl.h>
 #include <sys/socket.h>
 #ifdef SVR4	/* XXX */
 # include <sys/sockio.h>
@@ -997,6 +998,11 @@
 	u_char *mask_ptr;
 	struct in_addr mask;
 
+	struct rt_msghdr *rmsghdr;
+	char ifname[16], *sctlbuf;
+	int mib[]={CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0}, x;
+	size_t sctlbs=0;
+
 	ns_debug(ns_log_default, 1, "getnetconf(generation %lu)",
 		 (u_long)my_generation);
 
@@ -1022,11 +1028,46 @@
 		free_ip_match_list(local_networks);
 	local_networks = new_ip_match_list();
 
-	ifc.ifc_len = sizeof buf;
+	ifc.ifc_len = 0;
 	ifc.ifc_buf = buf;
-	if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0)
-		ns_panic(ns_log_default, 1, "get interface configuration: %s",
-			 strerror(errno));
+
+	if(sysctl(mib,6,NULL,&sctlbs,NULL,0) < 0) {
+		puts("sysctl() failed");
+		return;
+	}
+
+
+	if( (sctlbuf=malloc(sctlbs)) == NULL)
+		return;
+
+	if(sysctl(mib,6, sctlbuf ,&sctlbs,NULL,0) < 0) {
+		puts("sysctl() failed");
+		return;
+	}
+
+	memset(ifc.ifc_buf, 0, sizeof(ifc.ifc_buf));
+
+	for (x=0, rmsghdr=(struct rt_msghdr *)sctlbuf;
+		 rmsghdr->rtm_msglen>0 && x<sctlbs;x+=rmsghdr->rtm_msglen) {
+
+		rmsghdr=(struct rt_msghdr *)(sctlbuf+x);
+
+		if (rmsghdr->rtm_type==RTM_IFINFO) {	/* RTM_IFINFO=14 */
+			memset(ifname, 0, 16);
+			if (rmsghdr->rtm_flags & RTF_UP) {	/* RTF_UP=0x1 */
+				memcpy(ifname, (char *)rmsghdr+92,
+				(size_t) *((char *)rmsghdr+89) & 0xff);
+			}
+                }
+		else if (rmsghdr->rtm_type==RTM_NEWADDR
+			 && (char) *ifname!='\0') {
+					/* RTM_NEWADDR=12 */
+			memcpy(ifc.ifc_buf+ifc.ifc_len, ifname, 16);
+			memcpy(ifc.ifc_buf+ifc.ifc_len+16,
+				(char *)rmsghdr+28, 16);
+			ifc.ifc_len+=32;
+		}
+	}
 
 	ns_debug(ns_log_default, 2, "getnetconf: SIOCGIFCONF: ifc_len = %d",
 		 ifc.ifc_len);

