summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2004-06-18 14:06:46 +0000
committerbms <bms@FreeBSD.org>2004-06-18 14:06:46 +0000
commitc99430ca9d7450c96cd1dbded61980cc700c8b05 (patch)
tree5f6a300035fe464451d1d469e6b7980f5025a8f6 /sys/compat
parentd2de401fe0c3767032ebc467b5d47a90d1b5ead7 (diff)
downloadFreeBSD-src-c99430ca9d7450c96cd1dbded61980cc700c8b05.zip
FreeBSD-src-c99430ca9d7450c96cd1dbded61980cc700c8b05.tar.gz
Linux applications expect to be able to call SIOCGIFCONF with an
NULL ifc.ifc_buf pointer, to determine the expected buffer size. The submitted fix only takes account of interfaces with an AF_INET address configured. This could no doubt be improved. PR: kern/45753 Submitted by: Jacques Garrigue (with cleanups)
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_ioctl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index a222592..9f8c956 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -2081,6 +2081,20 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
if (error != 0)
return (error);
+ /* handle the 'request buffer size' case */
+ if (ifc.ifc_buf == NULL) {
+ ifc.ifc_len = 0;
+ TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+ struct sockaddr *sa = ifa->ifa_addr;
+ if (sa->sa_family == AF_INET)
+ ifc.ifc_len += sizeof(ifr);
+ }
+ }
+ error = copyout(&ifc, uifc, sizeof(ifc));
+ return (error);
+ }
+
/* much easier to use uiomove than keep track ourselves */
iov.iov_base = ifc.ifc_buf;
iov.iov_len = ifc.ifc_len;
OpenPOWER on IntegriCloud