[PATCH 2/2] fix compilation on systems missing libnl and new includes

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

 



This patch fixes the compilation of netlink.c and interface.c on those
systems missing either libnl or that have an older linux/if_link.h
include file not supporting macvtap or VF_PORTS.

WITH_MACVTAP is '1' if newer include files were detected, '0' otherwise.

IFLA_PORT_MAX is defined in linux/if_link.h if yet more functionality is
supported.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>

---
 src/util/interface.c |   31 +++++++++++++++++++++++++++----
 src/util/netlink.c   |    6 +++++-
 src/util/netlink.h   |    4 +++-
 3 files changed, 35 insertions(+), 6 deletions(-)

Index: libvirt-acl/src/util/interface.c
===================================================================
--- libvirt-acl.orig/src/util/interface.c
+++ libvirt-acl/src/util/interface.c
@@ -510,7 +510,7 @@ ifaceSetMacaddr(const char *ifname ATTRI
  *
  * Returns 0 on success, -1 on fatal error.
  */
-#if __linux__
+#if defined(__linux__) && WITH_MACVTAP
 int
 ifaceMacvtapLinkAdd(const char *type,
                     const unsigned char *macaddress, int macaddrsize,
@@ -649,8 +649,14 @@ ifaceMacvtapLinkAdd(const char *type ATT
                     int *retry ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
+# if defined(__linux__) && !WITH_MACVTAP
+               _("ifaceMacvtapLinkAdd is not supported since the include "
+                 "files were too old"));
+# else
                _("ifaceMacvtapLinkAdd is not supported on non-linux "
                  "platforms"));
+# endif
+
     return -1;
 }
 
@@ -666,7 +672,7 @@ ifaceMacvtapLinkAdd(const char *type ATT
  *
  * Returns 0 on success, -1 on fatal error.
  */
-#if __linux__
+#if defined( __linux__) && WITH_MACVTAP
 int
 ifaceLinkDel(const char *ifname)
 {
@@ -751,14 +757,20 @@ int
 ifaceLinkDel(const char *ifname ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
+# if defined(__linux__) && !WITH_MACVTAP
+               _("ifaceLinkDel is not supported since the include files "
+                 "were too old"));
+# else
                _("ifaceLinkDel is not supported on non-linux platforms"));
+# endif
     return -1;
 }
 
 #endif
 

-#if __linux__
+#if defined(__linux__) && defined(IFLA_PORT_MAX)
+
 static struct nla_policy ifla_policy[IFLA_MAX + 1] =
 {
   [IFLA_VF_PORTS] = { .type = NLA_NESTED },
@@ -894,8 +906,14 @@ ifaceMacvtapLinkDump(bool nltarget_kerne
                      uint32_t (*getPidFunc)(void) ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
+# if defined(__linux__) && !defined(IFLA_PORT_MAX)
+               _("ifaceMacvtapLinkDump is not supported since the include "
+                 "files were too old"));
+# else
                _("ifaceMacvtapLinkDump is not supported on non-linux "
                  "platforms"));
+# endif
+
     return -1;
 }
 
@@ -920,7 +938,7 @@ ifaceMacvtapLinkDump(bool nltarget_kerne
  *
  * Return 0 on success, != 0 otherwise
  */
-#if __linux__
+#if defined(__linux__) && WITH_MACVTAP
 int
 ifaceGetNthParent(int ifindex, const char *ifname, unsigned int nthParent,
                   int *parent_ifindex, char *parent_ifname,
@@ -981,7 +999,12 @@ ifaceGetNthParent(int ifindex ATTRIBUTE_
                   unsigned int *nth ATTRIBUTE_UNUSED)
 {
     ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
+# if defined(__linux__) && !WITH_MACVTAP
+               _("ifaceGetNthParent is not supported since the include files "
+                 "were too old"));
+# else
                _("ifaceGetNthParent is not supported on non-linux platforms"));
+# endif
     return -1;
 }
 
Index: libvirt-acl/src/util/netlink.c
===================================================================
--- libvirt-acl.orig/src/util/netlink.c
+++ libvirt-acl/src/util/netlink.c
@@ -55,7 +55,7 @@
  * Returns 0 on success, -1 on error. In case of error, no response
  * buffer will be returned.
  */
-#if __linux__
+#if defined(__linux__) && WITH_MACVTAP
 int nlComm(struct nl_msg *nl_msg,
            unsigned char **respbuf, unsigned int *respbuflen,
            int nl_pid)
@@ -143,7 +143,11 @@ int nlComm(struct nl_msg *nl_msg ATTRIBU
            int nl_pid ATTRIBUTE_UNUSED)
 {
     netlinkError(VIR_ERR_INTERNAL_ERROR, "%s",
+# if defined(__linux__) && !defined(HAVE_LIBNL)
+                 _("nlComm is not supported since libnl was not available"));
+# else
                  _("nlComm is not supported on non-linux platforms"));
+# endif
     return -1;
 }
 
Index: libvirt-acl/src/util/netlink.h
===================================================================
--- libvirt-acl.orig/src/util/netlink.h
+++ libvirt-acl/src/util/netlink.h
@@ -20,7 +20,9 @@
 #ifndef __VIR_NETLINK_H__
 # define __VIR_NETLINK_H__
 
-# if __linux__
+# include "config.h"
+
+# if defined(__linux__) && defined(HAVE_LIBNL)
 
 #  include <netlink/msg.h>
 


--
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]