diff options
author | hsu <hsu@FreeBSD.org> | 2002-12-22 05:35:03 +0000 |
---|---|---|
committer | hsu <hsu@FreeBSD.org> | 2002-12-22 05:35:03 +0000 |
commit | 82e1e3bab0d3abe1018a0b56559c154485f2f676 (patch) | |
tree | d0f9ee7e6f9d8014e6f8f94ab6965e85c268792e /sys/compat | |
parent | 2afef11c570b7b725c3145fc710f8dcd8d7ed4e0 (diff) | |
download | FreeBSD-src-82e1e3bab0d3abe1018a0b56559c154485f2f676.zip FreeBSD-src-82e1e3bab0d3abe1018a0b56559c154485f2f676.tar.gz |
SMP locking for ifnet list.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linprocfs/linprocfs.c | 2 | ||||
-rw-r--r-- | sys/compat/linux/linux_ioctl.c | 14 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_sockio.c | 5 |
3 files changed, 16 insertions, 5 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index aca3f06..1ccd25a 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -725,6 +725,7 @@ linprocfs_donetdev(PFS_FILL_ARGS) "bytes packets errs drop fifo frame compressed", "bytes packets errs drop fifo frame compressed"); + IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) { linux_ifname(ifp, ifname, sizeof ifname); sbuf_printf(sb, "%6.6s:", ifname); @@ -733,6 +734,7 @@ linprocfs_donetdev(PFS_FILL_ARGS) sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL); } + IFNET_RUNLOCK(); return (0); } diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 9714433..186b84c 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -1907,12 +1907,16 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) /* Determine the (relative) unit number for ethernet interfaces */ ethno = 0; + IFNET_RLOCK(); TAILQ_FOREACH(ifscan, &ifnet, if_link) { - if (ifscan == ifp) + if (ifscan == ifp) { + IFNET_RUNLOCK(); return (snprintf(buffer, buflen, "eth%d", ethno)); + } if (IFP_IS_ETH(ifscan)) ethno++; } + IFNET_RUNLOCK(); return (0); } @@ -1942,6 +1946,7 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname) return (NULL); index = 0; is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0; + IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) { /* * Allow Linux programs to use FreeBSD names. Don't presume @@ -1954,6 +1959,7 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname) if (is_eth && IFP_IS_ETH(ifp) && unit == index++) break; } + IFNET_RUNLOCK(); if (ifp != NULL) snprintf(bsdname, IFNAMSIZ, "%s%d", ifp->if_name, ifp->if_unit); return (ifp); @@ -1993,6 +1999,7 @@ linux_ifconf(struct thread *td, struct ifconf *uifc) ethno = 0; /* Return all AF_INET addresses of all interfaces */ + IFNET_RLOCK(); /* could sleep XXX */ TAILQ_FOREACH(ifp, &ifnet, if_link) { if (uio.uio_resid <= 0) break; @@ -2019,11 +2026,14 @@ linux_ifconf(struct thread *td, struct ifconf *uifc) error = uiomove((caddr_t)&ifr, sizeof ifr, &uio); - if (error != 0) + if (error != 0) { + IFNET_RUNLOCK(); return (error); + } } } } + IFNET_RUNLOCK(); ifc.ifc_len -= uio.uio_resid; error = copyout(&ifc, uifc, sizeof ifc); diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c index 8dc65a8..8ecd1d4 100644 --- a/sys/compat/svr4/svr4_sockio.c +++ b/sys/compat/svr4/svr4_sockio.c @@ -100,7 +100,7 @@ svr4_sock_ioctl(fp, td, retval, fd, cmd, data) * fix is to make SVR4_SIOCGIFCONF return only one * entry per physical interface? */ - + IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) if (TAILQ_FIRST(&ifp->if_addrhead) == NULL) ifnum++; @@ -108,8 +108,7 @@ svr4_sock_ioctl(fp, td, retval, fd, cmd, data) TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) ifnum++; - - + IFNET_RUNLOCK(); DPRINTF(("SIOCGIFNUM %d\n", ifnum)); return copyout(&ifnum, data, sizeof(ifnum)); } |