build: avoid header conflict for <linux/if.h> and <net/if.h> with "nm-platform.h"
In the past, the headers "linux/if.h" and "net/if.h" were incompatible. That means, we can either include one or the other, but not both. This is fixed in the meantime, however the issue still exists when building against older kernel/glibc. That means, including one of these headers from a header file is problematic. In particular if it's a header like "nm-platform.h", which itself is dragged in by many other headers. Avoid that by not including these headers from "platform.h", but instead from the source files where needed (or possibly from less popular header files). Currently there is no problem. However, this allows an unknowing user to include <net/if.h> at the same time with "nm-platform.h", which is easy to get wrong.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "nm-device-infiniband.h"
|
||||
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <linux/if.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/if_tunnel.h>
|
||||
#include <linux/ip6_tunnel.h>
|
||||
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-manager.h"
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "nm-device-macvlan.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <linux/if_link.h>
|
||||
|
||||
#include "nm-device-private.h"
|
||||
#include "settings/nm-settings.h"
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "nm-act-request.h"
|
||||
#include "nm-device-private.h"
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include "nm-utils/nm-dedup-multi.h"
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if_addr.h>
|
||||
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
@@ -88,8 +88,8 @@ nmtst_platform_ip4_address_full (const char *address, const char *peer_address,
|
||||
{
|
||||
NMPlatformIP4Address *addr = nmtst_platform_ip4_address (address, peer_address, plen);
|
||||
|
||||
G_STATIC_ASSERT (IFNAMSIZ == sizeof (addr->label));
|
||||
g_assert (!label || strlen (label) < IFNAMSIZ);
|
||||
G_STATIC_ASSERT (NMP_IFNAMSIZ == sizeof (addr->label));
|
||||
g_assert (!label || strlen (label) < NMP_IFNAMSIZ);
|
||||
|
||||
addr->ifindex = ifindex;
|
||||
addr->addr_source = source;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#include <netinet/icmp6.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "nm-utils.h"
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/sockios.h>
|
||||
#include <linux/mii.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <fcntl.h>
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <linux/if_tunnel.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
@@ -21,12 +21,6 @@
|
||||
#ifndef __NETWORKMANAGER_PLATFORM_H__
|
||||
#define __NETWORKMANAGER_PLATFORM_H__
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include <linux/if_link.h>
|
||||
#include <linux/ip6_tunnel.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-core-types-internal.h"
|
||||
|
||||
@@ -53,6 +47,12 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* IFNAMSIZ is both defined in <linux/if.h> and <net/if.h>. In the past, these
|
||||
* headers conflicted, so we cannot simply include either of them in a header-file.*/
|
||||
#define NMP_IFNAMSIZ 16
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct udev_device;
|
||||
|
||||
typedef gboolean (*NMPObjectPredicateFunc) (const NMPObject *obj,
|
||||
@@ -208,7 +208,7 @@ typedef enum {
|
||||
|
||||
struct _NMPlatformLink {
|
||||
__NMPlatformObject_COMMON;
|
||||
char name[IFNAMSIZ];
|
||||
char name[NMP_IFNAMSIZ];
|
||||
NMLinkType type;
|
||||
|
||||
/* rtnl_link_get_type(), IFLA_INFO_KIND. */
|
||||
@@ -355,7 +355,7 @@ struct _NMPlatformIP4Address {
|
||||
* */
|
||||
in_addr_t peer_address; /* PTP peer address */
|
||||
|
||||
char label[IFNAMSIZ];
|
||||
char label[NMP_IFNAMSIZ];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1106,12 +1106,12 @@ const char *nm_platform_error_to_string (NMPlatformError error,
|
||||
((const char *) NULL), -1, (path)
|
||||
|
||||
#define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \
|
||||
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + IFNAMSIZ + strlen (path), \
|
||||
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + NMP_IFNAMSIZ + strlen (path), \
|
||||
"net:/sys/class/net/%s/%s", (ifname), (path)), \
|
||||
(dirfd), (path)
|
||||
|
||||
#define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \
|
||||
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + IFNAMSIZ, \
|
||||
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + NMP_IFNAMSIZ, \
|
||||
"net:/sys/class/net/%s/%s", (ifname), path), \
|
||||
(dirfd), (""path"")
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/if.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#include "nm-utils.h"
|
||||
|
@@ -21,6 +21,9 @@
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_link.h>
|
||||
#include <linux/ip6_tunnel.h>
|
||||
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nmp-object.h"
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <net/ethernet.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "nm-wifi-utils-private.h"
|
||||
|
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "nm-wpan-utils.h"
|
||||
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "platform/linux/nl802154.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/if_addr.h>
|
||||
|
||||
#include "nm-ip6-config.h"
|
||||
|
||||
|
Reference in New Issue
Block a user