summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_socket.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-02-13 13:10:34 +0000
committermpi <mpi@openbsd.org>2014-02-13 13:10:34 +0000
commit9a415598a955533d4a3e6b7e78b64c306c0a541d (patch)
treed7be02916b3e6666bdc4d5c6665cabecbdb1e20a /sys/compat/linux/linux_socket.c
parentwrap long lines (diff)
downloadwireguard-openbsd-9a415598a955533d4a3e6b7e78b64c306c0a541d.tar.xz
wireguard-openbsd-9a415598a955533d4a3e6b7e78b64c306c0a541d.zip
Instead of iterating over the per-interface list of addresses to
find the link-layer address of an interface, use the pointer to the sockaddr_dl already present in the interface's descriptor. Tested for regression by pirofti@ with opera.
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
-rw-r--r--sys/compat/linux/linux_socket.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 397325d9599..3a9f77fc1be 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_socket.c,v 1.47 2014/01/23 04:11:46 tedu Exp $ */
+/* $OpenBSD: linux_socket.c,v 1.48 2014/02/13 13:10:34 mpi Exp $ */
/* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */
/*
@@ -1586,7 +1586,6 @@ linux_ioctl_socket(p, v, retval)
struct linux_ifreq *ifr = (struct linux_ifreq *)SCARG(uap, data);
struct sockaddr_dl *sdl;
struct ifnet *ifp;
- struct ifaddr *ifa;
/*
* Note that we don't actually respect the name in the ifreq
@@ -1595,16 +1594,14 @@ linux_ioctl_socket(p, v, retval)
TAILQ_FOREACH(ifp, &ifnet, if_list) {
if (ifp->if_type != IFT_ETHER)
continue;
- TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
- if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
- (sdl->sdl_family == AF_LINK) &&
- (sdl->sdl_type == IFT_ETHER)) {
- error = copyout(LLADDR(sdl),
- (caddr_t)&ifr->ifr_hwaddr.sa_data,
- LINUX_IFHWADDRLEN);
- dosys = 0;
- goto out;
- }
+ if ((sdl = ifp->if_sadl) &&
+ (sdl->sdl_family == AF_LINK) &&
+ (sdl->sdl_type == IFT_ETHER)) {
+ error = copyout(LLADDR(sdl),
+ &ifr->ifr_hwaddr.sa_data,
+ LINUX_IFHWADDRLEN);
+ dosys = 0;
+ goto out;
}
}
error = ENOENT;