mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-04 15:21:12 +00:00
all: add src/nm-compat-headers for patching included system headers
We already have src/linux-headers, where we have complete copies of linux user space headers. Of course that exists, because we want to use certain features and don't depend on the installed kernel headers. Which works well, because kernel user space API is stable, and we anyway want to support compiling against a newer kernel and run against an older (e.g. in a container). So having our copy of newer kernel headers is merely as if we compiled against as newer kernel. Add "src/nm-compat-headers" which has a similar purpose, but a different approach. Instead of replacing the included header entirely, include the system header and patch it with #define. Use this for "linux/if_addr.h". Of course, the approach here is that we no longer include <linux/if_addr.h> directly, but instead include "nm-compat-headers/linux/if_addr.h".
This commit is contained in:
parent
dd2e1bc1cd
commit
231671fd02
|
@ -317,7 +317,10 @@ The second include is the header that belongs to the C source file. This
|
|||
is so that header files are self-contained (aside what default dependencies that
|
||||
they get and everybody can rely on).
|
||||
|
||||
The next includes are system headers with `<>`.
|
||||
The next includes are system headers with `<>`. Exceptions are headers like
|
||||
"libnm-std-aux/nm-linux-compat.h" and "nm-compat-headers/\*" which are our small
|
||||
wrappers around system headers. These are also to be included together with system
|
||||
headers.
|
||||
|
||||
Finally, all other headers from our source tree. Note that all build targets
|
||||
have `-I. -I./src/` in their build arguments. So to include a header like
|
||||
|
|
|
@ -596,6 +596,8 @@ src_libnm_platform_libnm_platform_la_SOURCES = \
|
|||
src/linux-headers/nl80211-vnd-intel.h \
|
||||
src/linux-headers/nl802154.h \
|
||||
\
|
||||
src/nm-compat-headers/linux/if_addr.h \
|
||||
\
|
||||
src/libnm-platform/nm-linux-platform.c \
|
||||
src/libnm-platform/nm-linux-platform.h \
|
||||
src/libnm-platform/nm-netlink.c \
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "nm-l3-config-data.h"
|
||||
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "nm-l3-ipv6ll.h"
|
||||
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "libnm-std-aux/nm-linux-compat.h"
|
||||
|
||||
#include <net/if.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "src/core/nm-default-daemon.h"
|
||||
|
||||
#include <linux/if_addr.h>
|
||||
#include "nm-compat-headers/linux/if_addr.h"
|
||||
|
||||
#include "nm-l3cfg.h"
|
||||
#include "nm-l3-ipv4ll.h"
|
||||
|
|
|
@ -8,3 +8,8 @@ certain version of kernel API.
|
|||
|
||||
These headers should be taken without modification
|
||||
from Linux.
|
||||
|
||||
Don't include any of these these headers directly, instead
|
||||
include "libnm-std-aux/nm-linux-compat.h" which drags these
|
||||
headers in. This ensures that we include at all places our own
|
||||
patched variant, instead of the system headers.
|
||||
|
|
10
src/nm-compat-headers/README.md
Normal file
10
src/nm-compat-headers/README.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
nm-compat-headers
|
||||
=================
|
||||
|
||||
When we build against older system headers, we sometimes
|
||||
want to use newer features. This directory contains compat
|
||||
headers that patch the included sources with what we need.
|
||||
|
||||
The goal is similar to linux-headers directory, but the approach
|
||||
is different. The former completely replaces system headers
|
||||
while this uses system headers and extends them.
|
16
src/nm-compat-headers/linux/if_addr.h
Normal file
16
src/nm-compat-headers/linux/if_addr.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef __NM_COMPAT_HEADER_LINUX_IF_ADDR_H__
|
||||
#define __NM_COMPAT_HEADER_LINUX_IF_ADDR_H__
|
||||
|
||||
#include <linux/if_addr.h>
|
||||
|
||||
#ifndef IFA_F_MANAGETEMPADDR
|
||||
#define IFA_F_MANAGETEMPADDR 0x100
|
||||
#endif
|
||||
|
||||
#ifndef IFA_F_NOPREFIXROUTE
|
||||
#define IFA_F_NOPREFIXROUTE 0x200
|
||||
#endif
|
||||
|
||||
#endif /* __NM_COMPAT_HEADER_LINUX_IF_ADDR_H__ */
|
Loading…
Reference in a new issue