Subject: Re: ifconfig breakage
To: Christos Zoulas <christos@zoulas.com>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: current-users
Date: 03/07/2000 18:32:57
christos@zoulas.com (Christos Zoulas) writes:

> I understand. But what is the choice? Live with requiring COMPAT_43
> forever?

With a patch below, second or later `ifconfig wi0 inet 0.0.0.0' no
longer gives an EAFNOSUPPORT (at least for me).

When ifconfig adds an address, it first tries to delete existing one
using deferent struct ifreq (or, xxx_ifreq depending on protocol) than
the struct ifreq containing new address.  And a sa_family of it
doesn't initialized at all (though when the same struct ifreq is used
to delete alias, it does).

Comments?

# BTW, IMHO, af_ridreq and af_addreq should be `struct ifreq *' or
# `struct ifaliasreq *' rather than caddr_t and points union of ifreq
# and xxx_ifreq etc, shouldn't they?
enami.

Index: ifconfig.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.73
diff -u -r1.73 ifconfig.c
--- ifconfig.c	2000/03/06 09:00:13	1.73
+++ ifconfig.c	2000/03/07 09:10:40
@@ -749,6 +749,8 @@
 	char *addr;
 	int param;
 {
+	struct ifreq *ifr;
+
 	/*
 	 * Delay the ioctl to set the interface addr until flags are all set.
 	 * The address interpretation may depend on the flags,
@@ -757,8 +759,11 @@
 	setaddr++;
 	if (newaddr == -1)
 		newaddr = 1;
-	if (doalias == 0)
+	if (doalias == 0) {
 		clearaddr = 1;
+		ifr = (struct ifreq *)afp->af_ridreq;	/* XXX */
+		ifr->ifr_addr.sa_family = afp->af_af;
+	}
 	(*afp->af_getaddr)(addr, (doalias >= 0 ? ADDR : RIDADDR));
 }