mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
build: fix compilation on systems missing libnl and new includes
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.
This commit is contained in:
parent
20991b937b
commit
f7ed693666
@ -510,7 +510,7 @@ ifaceSetMacaddr(const char *ifname ATTRIBUTE_UNUSED,
|
||||
*
|
||||
* 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 ATTRIBUTE_UNUSED,
|
||||
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 ATTRIBUTE_UNUSED,
|
||||
*
|
||||
* 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_kernel ATTRIBUTE_UNUSED,
|
||||
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_kernel ATTRIBUTE_UNUSED,
|
||||
*
|
||||
* 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_UNUSED,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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__) && defined(HAVE_LIBNL)
|
||||
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 ATTRIBUTE_UNUSED,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user