summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1994-10-05 20:11:28 +0000
committerwollman <wollman@FreeBSD.org>1994-10-05 20:11:28 +0000
commit4c7a70a838fddaab862576e2dd0d34ae4d39e01a (patch)
tree38bd01d2f2c4bc4fdefa0b4b7831c53c08b85593 /sys/net/if.c
parent82fae818f5e3102629fff41728bfd4167609ecec (diff)
downloadFreeBSD-src-4c7a70a838fddaab862576e2dd0d34ae4d39e01a.zip
FreeBSD-src-4c7a70a838fddaab862576e2dd0d34ae4d39e01a.tar.gz
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
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6507bf5..3dabc65 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,
OpenPOWER on IntegriCloud