[PATCH v2 1/2] Make virNetDevSetupControl() public.

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

 



This method is useful not only in virnetdev.c.
---
 src/libvirt_private.syms         |  1 +
 src/util/virnetdev.c             | 15 +++++++++++++--
 src/util/virnetdev.h             | 11 +++++++++++
 src/util/virnetdevmacvlan.c      |  2 +-
 src/util/virnetdevvportprofile.c |  2 +-
 5 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9d5f74b..da3dc63 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1529,6 +1529,7 @@ virNetDevSetMTUFromDevice;
 virNetDevSetName;
 virNetDevSetNamespace;
 virNetDevSetOnline;
+virNetDevSetupControl;
 virNetDevValidateConfig;
 
 
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cee4001..f658c6d 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -88,11 +88,22 @@ static int virNetDevSetupControlFull(const char *ifname,
 }
 
 
-static int virNetDevSetupControl(const char *ifname,
-                                 struct ifreq *ifr)
+int
+virNetDevSetupControl(const char *ifname,
+                      struct ifreq *ifr)
 {
     return virNetDevSetupControlFull(ifname, ifr, VIR_NETDEV_FAMILY, SOCK_DGRAM);
 }
+#else
+int
+virNetDevSetupControl(const char *ifname ATTRIBUTE_UNUSED,
+                      void *ifr ATTRIBUTE_UNUSED)
+{
+    virReportSystemError(ENOSYS,
+                         _("%s is not supported on this platform"),
+                         __func__);
+    return -1;
+}
 #endif
 
 
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index bc0777c..97369c1 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -23,11 +23,22 @@
 #ifndef __VIR_NETDEV_H__
 # define __VIR_NETDEV_H__
 
+# include <net/if.h>
+
 # include "virsocketaddr.h"
 # include "virnetlink.h"
 # include "virmacaddr.h"
 # include "virpci.h"
 
+#ifdef HAVE_STRUCT_IFREQ
+int virNetDevSetupControl(const char *ifname,
+                          struct ifreq *ifr)
+    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+#else
+int virNetDevSetupControl(const char *ifname,
+                          void *ifr);
+#endif
+
 int virNetDevExists(const char *brname)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 6c338fa..a61c45f 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -49,7 +49,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
 # include <sys/socket.h>
 # include <sys/ioctl.h>
 
-# include <linux/if.h>
+# include <net/if.h>
 # include <linux/if_tun.h>
 
 /* Older kernels lacked this enum value.  */
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index c337fb3..0f1b6a1 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -49,7 +49,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
 # include <sys/socket.h>
 # include <sys/ioctl.h>
 
-# include <linux/if.h>
+# include <net/if.h>
 # include <linux/if_tun.h>
 
 # include "virnetlink.h"
-- 
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]