summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-08-04 20:57:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-08-04 20:57:20 +0000
commit55d0db52b5c169eb783c2bfcc82ee73fe7bf6f56 (patch)
treece09fb3999eb3291421706eeb93a125e3bd6daa7
parentc2949af81c08c3ee575b6bf4ff8b93659c4aff6b (diff)
Add hack to SIOCGIFCONF where if ifc_len is 0, fill it in with the size needed and return; Linux does this too. Suggested by cmetz@inner.net
-rw-r--r--sys/net/if.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 301b1007507..6519d86152f 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.16 1998/03/25 07:37:29 deraadt Exp $ */
+/* $OpenBSD: if.c,v 1.17 1998/08/04 20:57:19 millert Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -588,6 +588,14 @@ ifconf(cmd, data)
struct ifreq ifr, *ifrp;
int space = ifc->ifc_len, error = 0;
+ /* If ifc->ifc_len is 0, fill it in with the needed size and return. */
+ if (space == 0) {
+ for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
+ space += sizeof (ifr);
+ ifc->ifc_len = space;
+ return(0);
+ }
+
ifrp = ifc->ifc_req;
for (ifp = ifnet.tqh_first; space >= sizeof (ifr) && ifp != 0;
ifp = ifp->if_list.tqe_next) {