Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F96155393
D38358.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D38358.diff
View Options
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -1474,26 +1474,79 @@
return (error);
}
+struct linux_ifname_cb_s {
+ struct ifnet *ifp;
+ int ethno;
+ char *buffer;
+ size_t buflen;
+};
+
+static int
+linux_ifname_cb(if_t ifp, void *arg)
+{
+ struct linux_ifname_cb_s *cbs = arg;
+
+ if (ifp == cbs->ifp)
+ return (snprintf(cbs->buffer, cbs->buflen, "eth%d", cbs->ethno));
+ if (!linux_use_real_ifname(ifp))
+ cbs->ethno++;
+ return (0);
+}
+
static int
linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
{
- struct ifnet *ifscan;
- int ethno;
+ struct linux_ifname_cb_s arg;
IFNET_RLOCK_ASSERT();
+ arg.ifp = ifp;
+ arg.buffer = buffer;
+ arg.buflen = buflen;
+ arg.ethno = 0;
+
/* Short-circuit non ethernet interfaces */
if (linux_use_real_ifname(ifp))
- return (strlcpy(buffer, ifp->if_xname, buflen));
+ return (strlcpy(buffer, if_name(ifp), buflen));
/* Determine the (relative) unit number for ethernet interfaces */
- ethno = 0;
- CK_STAILQ_FOREACH(ifscan, &V_ifnet, if_link) {
- if (ifscan == ifp)
- return (snprintf(buffer, buflen, "eth%d", ethno));
- if (!linux_use_real_ifname(ifscan))
- ethno++;
- }
+ return (if_foreach(linux_ifname_cb, &arg));
+}
+
+static int
+linprocfs_donetdev_cb(if_t ifp, void *arg)
+{
+ char ifname[16]; /* XXX LINUX_IFNAMSIZ */
+ struct sbuf *sb = arg;
+
+ linux_ifname(ifp, ifname, sizeof ifname);
+ sbuf_printf(sb, "%6.6s: ", ifname);
+ sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ",
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_IBYTES),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_IPACKETS),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_IERRORS),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_IQDROPS),
+ /* rx_missed_errors */
+ 0UL, /* rx_fifo_errors */
+ 0UL, /* rx_length_errors +
+ * rx_over_errors +
+ * rx_crc_errors +
+ * rx_frame_errors */
+ 0UL, /* rx_compressed */
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_IMCASTS));
+ /* XXX-BZ rx only? */
+ sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n",
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_OBYTES),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_OPACKETS),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_OERRORS),
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_OQDROPS),
+ 0UL, /* tx_fifo_errors */
+ (uintmax_t )if_getcounter(ifp, IFCOUNTER_COLLISIONS),
+ 0UL, /* tx_carrier_errors +
+ * tx_aborted_errors +
+ * tx_window_errors +
+ * tx_heartbeat_errors*/
+ 0UL); /* tx_compressed */
return (0);
}
@@ -1504,9 +1557,6 @@
static int
linprocfs_donetdev(PFS_FILL_ARGS)
{
- char ifname[16]; /* XXX LINUX_IFNAMSIZ */
- struct ifnet *ifp;
-
sbuf_printf(sb, "%6s|%58s|%s\n"
"%6s|%58s|%58s\n",
"Inter-", " Receive", " Transmit",
@@ -1516,36 +1566,7 @@
CURVNET_SET(TD_TO_VNET(curthread));
IFNET_RLOCK();
- CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) {
- linux_ifname(ifp, ifname, sizeof ifname);
- sbuf_printf(sb, "%6.6s: ", ifname);
- sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ",
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IBYTES),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IERRORS),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IQDROPS),
- /* rx_missed_errors */
- 0UL, /* rx_fifo_errors */
- 0UL, /* rx_length_errors +
- * rx_over_errors +
- * rx_crc_errors +
- * rx_frame_errors */
- 0UL, /* rx_compressed */
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IMCASTS));
- /* XXX-BZ rx only? */
- sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n",
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OBYTES),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OERRORS),
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS),
- 0UL, /* tx_fifo_errors */
- (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_COLLISIONS),
- 0UL, /* tx_carrier_errors +
- * tx_aborted_errors +
- * tx_window_errors +
- * tx_heartbeat_errors*/
- 0UL); /* tx_compressed */
- }
+ if_foreach(linprocfs_donetdev_cb, sb);
IFNET_RUNLOCK();
CURVNET_RESTORE();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 24, 9:36 PM (10 m, 33 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
12566265
Default Alt Text
D38358.diff (4 KB)
Attached To
Mode
D38358: linprocfs: Migrate to IfAPI
Attached
Detach File
Event Timeline
Log In to Comment