| Add macro _NO_CONVERT_IFNAME that prevent interface names to be converted to |
| eth*. Useful when using linprocfs separately without Linux binary |
| compatibility. |
| |
| diff -ru --exclude-from freebsd-src-diff-exclude-names /var/tmp/freebsd-src/usr/src/sys/compat/linprocfs/linprocfs.c freebsd-10.3/usr/src/sys/compat/linprocfs/linprocfs.c |
| --- /var/tmp/freebsd-src/usr/src/sys/compat/linprocfs/linprocfs.c 2016-03-25 09:09:43.000000000 +0800 |
| +++ freebsd-10.3/usr/src/sys/compat/linprocfs/linprocfs.c 2016-12-06 13:00:44.235972123 +0800 |
| @@ -39,6 +39,8 @@ |
| * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 |
| */ |
| |
| +#define _NO_CONVERT_IFNAME 1 |
| + |
| #include <sys/cdefs.h> |
| __FBSDID("$FreeBSD: releng/10.3/sys/compat/linprocfs/linprocfs.c 295951 2016-02-24 02:34:11Z araujo $"); |
| |
| @@ -1077,6 +1081,7 @@ |
| return (error); |
| } |
| |
| +#ifndef _NO_CONVERT_IFNAME |
| /* |
| * Criteria for interface name translation |
| */ |
| @@ -1105,6 +1110,7 @@ |
| |
| return (0); |
| } |
| +#endif |
| |
| /* |
| * Filler function for proc/net/dev |
| @@ -1112,7 +1118,9 @@ |
| static int |
| linprocfs_donetdev(PFS_FILL_ARGS) |
| { |
| +#ifndef _NO_CONVERT_IFNAME |
| char ifname[16]; /* XXX LINUX_IFNAMSIZ */ |
| +#endif |
| struct ifnet *ifp; |
| |
| sbuf_printf(sb, "%6s|%58s|%s\n" |
| @@ -1125,8 +1133,12 @@ |
| CURVNET_SET(TD_TO_VNET(curthread)); |
| IFNET_RLOCK(); |
| TAILQ_FOREACH(ifp, &V_ifnet, if_link) { |
| +#ifdef _NO_CONVERT_IFNAME |
| + sbuf_printf(sb, "%6.6s: ", ifp->if_xname); |
| +#else |
| linux_ifname(ifp, ifname, sizeof ifname); |
| sbuf_printf(sb, "%6.6s: ", ifname); |
| +#endif |
| sbuf_printf(sb, "%7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu ", |
| ifp->if_ibytes, /* rx_bytes */ |
| ifp->if_ipackets, /* rx_packets */ |