[PATCH 4/4] FreeBSD: implement virNetDevGetMTU().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/util/virnetdev.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 6e4f7ad..809c0f7 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -427,6 +427,32 @@ cleanup:
     VIR_FORCE_CLOSE(fd);
     return ret;
 }
+#elif defined(__FreeBSD__)
+int virNetDevGetMTU(const char *ifname)
+{
+    int s;
+    int ret;
+    struct ifreq ifr;
+
+    if ((s = virNetDevSetupControl(ifname, &ifr)) < 0)
+        return -1;
+
+    ifr.ifr_addr.sa_family = AF_INET;
+    virStrcpyStatic(ifr.ifr_name, ifname);
+    if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0) {
+        virReportSystemError(errno,
+                             _("Cannot get interface MTU on '%s'"),
+                            ifname);
+        ret = -1;
+        goto cleanup;
+    }
+
+    ret = ifr.ifr_mtu;
+
+cleanup:
+    VIR_FORCE_CLOSE(s);
+    return ret;
+}
 #else
 int virNetDevGetMTU(const char *ifname)
 {
-- 
1.8.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]