diff options
author | Garrett Wollman <wollman@FreeBSD.org> | 1994-10-05 20:11:28 +0000 |
---|---|---|
committer | Garrett Wollman <wollman@FreeBSD.org> | 1994-10-05 20:11:28 +0000 |
commit | 2624cf89f955931ef760db5c2429f79c9170c39f (patch) | |
tree | 38bd01d2f2c4bc4fdefa0b4b7831c53c08b85593 /sys/net/if.c | |
parent | 29568da84a532c47f496e0c2b2e3743aeb16da61 (diff) | |
download | src-2624cf89f955931ef760db5c2429f79c9170c39f.tar.gz src-2624cf89f955931ef760db5c2429f79c9170c39f.zip |
A number of bug-fixes inspired by Mark Treacy:
- Allow PPP to run multicasts natively.
- Deal properly with lots of similarly-named interfaces.
- Don't sign-extend if_flags.
NB: the last fix (to rtsock.c) must be reversed when we expand if_flags to a
reasonable size.
Submitted by: Mark Treacy
Notes
Notes:
svn path=/head/; revision=3377
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 6507bf5e031c..3dabc6528423 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.c 8.3 (Berkeley) 1/4/94 - * $Id: if.c,v 1.6 1994/08/18 22:35:19 wollman Exp $ + * $Id: if.c,v 1.7 1994/09/16 05:47:03 phk Exp $ */ #include <sys/param.h> @@ -43,6 +43,7 @@ #include <sys/protosw.h> #include <sys/kernel.h> #include <sys/ioctl.h> +#include <sys/errno.h> #include <net/if.h> #include <net/if_dl.h> @@ -621,10 +622,19 @@ ifconf(cmd, data) ifrp = ifc->ifc_req; ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2; for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) { - strncpy(ifr.ifr_name, ifp->if_name, sizeof (ifr.ifr_name) - 2); - for (cp = ifr.ifr_name; cp < ep && *cp; cp++) - continue; - *cp++ = '0' + ifp->if_unit; *cp = '\0'; + char workbuf[12], *unitname; + int unitlen, ifnlen; + + unitname = sprint_d(ifp->if_unit, workbuf, sizeof workbuf); + unitlen = strlen(unitname); + ifnlen = strlen(ifp->if_name); + if(unitlen + ifnlen + 1 > sizeof ifr.ifr_name) { + error = ENAMETOOLONG; + } else { + strcpy(ifr.ifr_name, ifp->if_name); + strcpy(&ifr.ifr_name[ifnlen], unitname); + } + if ((ifa = ifp->if_addrlist) == 0) { bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); error = copyout((caddr_t)&ifr, (caddr_t)ifrp, |