Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/linux/common Tweak linux_getifhwaddr
details: https://anonhg.NetBSD.org/src/rev/a37896039523
branches: trunk
changeset: 333897:a37896039523
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Nov 21 06:03:04 2014 +0000
description:
Tweak linux_getifhwaddr
No functional change.
diffstat:
sys/compat/linux/common/linux_socket.c | 79 +++++++++++++++++----------------
1 files changed, 40 insertions(+), 39 deletions(-)
diffs (102 lines):
diff -r 06af1ba1bb90 -r a37896039523 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c Fri Nov 21 01:39:09 2014 +0000
+++ b/sys/compat/linux/common/linux_socket.c Fri Nov 21 06:03:04 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.120 2014/11/09 17:48:08 maxv Exp $ */
+/* $NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.120 2014/11/09 17:48:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1234,45 +1234,46 @@
}
}
- if (strncmp(lreq.ifr_name, "eth", 3) == 0) {
- for (ifnum = 0, index = 3;
- index < LINUX_IFNAMSIZ && lreq.ifr_name[index] != '\0';
- index++) {
- ifnum *= 10;
- ifnum += lreq.ifr_name[index] - '0';
- }
-
- error = EINVAL; /* in case we don't find one */
- found = 0;
- IFNET_FOREACH(ifp) {
- if (found)
- break;
- memcpy(lreq.ifr_name, ifp->if_xname,
- MIN(LINUX_IFNAMSIZ, IFNAMSIZ));
- IFADDR_FOREACH(ifa, ifp) {
- sadl = satosdl(ifa->ifa_addr);
- /* only return ethernet addresses */
- /* XXX what about FDDI, etc. ? */
- if (sadl->sdl_family != AF_LINK ||
- sadl->sdl_type != IFT_ETHER)
- continue;
- if (ifnum--)
- /* not the reqested iface */
- continue;
- memcpy(&lreq.ifr_hwaddr.sa_data,
- CLLADDR(sadl),
- MIN(sadl->sdl_alen,
- sizeof(lreq.ifr_hwaddr.sa_data)));
- lreq.ifr_hwaddr.sa_family =
- sadl->sdl_family;
- error = copyout(&lreq, data, sizeof(lreq));
- found = 1;
- break;
- }
- }
- } else {
+ if (strncmp(lreq.ifr_name, "eth", 3) != 0) {
/* unknown interface, not even an "eth*" name */
error = ENODEV;
+ goto out;
+ }
+
+ for (ifnum = 0, index = 3;
+ index < LINUX_IFNAMSIZ && lreq.ifr_name[index] != '\0';
+ index++) {
+ ifnum *= 10;
+ ifnum += lreq.ifr_name[index] - '0';
+ }
+
+ error = EINVAL; /* in case we don't find one */
+ found = 0;
+ IFNET_FOREACH(ifp) {
+ if (found)
+ break;
+ memcpy(lreq.ifr_name, ifp->if_xname,
+ MIN(LINUX_IFNAMSIZ, IFNAMSIZ));
+ IFADDR_FOREACH(ifa, ifp) {
+ sadl = satosdl(ifa->ifa_addr);
+ /* only return ethernet addresses */
+ /* XXX what about FDDI, etc. ? */
+ if (sadl->sdl_family != AF_LINK ||
+ sadl->sdl_type != IFT_ETHER)
+ continue;
+ if (ifnum--)
+ /* not the reqested iface */
+ continue;
+ memcpy(&lreq.ifr_hwaddr.sa_data,
+ CLLADDR(sadl),
+ MIN(sadl->sdl_alen,
+ sizeof(lreq.ifr_hwaddr.sa_data)));
+ lreq.ifr_hwaddr.sa_family =
+ sadl->sdl_family;
+ error = copyout(&lreq, data, sizeof(lreq));
+ found = 1;
+ break;
+ }
}
out:
Home |
Main Index |
Thread Index |
Old Index