1 From 98ec18f098e5ef68e3a8cc6954fcaf5a7fb8b7be Mon Sep 17 00:00:00 2001
2 From: pali <7141871+pali@users.noreply.github.com>
3 Date: Mon, 15 Feb 2021 07:54:01 +0100
4 Subject: [PATCH] pppd: Fix compilation with older glibc or kernel headers
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 glibc versions prior to 2.24 do not define SOL_NETLINK and linux kernel
11 versions prior to 4.3 do not define NETLINK_CAP_ACK. So add fallback
12 definitions for these macros into pppd/sys-linux.c file.
14 Also extend description why we call SOL_NETLINK/NETLINK_CAP_ACK option.
16 Signed-off-by: Pali Rohár <pali@kernel.org>
18 pppd/sys-linux.c | 18 +++++++++++++++++-
19 1 file changed, 17 insertions(+), 1 deletion(-)
21 --- a/pppd/sys-linux.c
22 +++ b/pppd/sys-linux.c
24 #include <linux/netlink.h>
25 #include <linux/rtnetlink.h>
26 #include <linux/if_addr.h>
27 +/* glibc versions prior to 2.24 do not define SOL_NETLINK */
29 +#define SOL_NETLINK 270
31 +/* linux kernel versions prior to 4.3 do not define/support NETLINK_CAP_ACK */
32 +#ifndef NETLINK_CAP_ACK
33 +#define NETLINK_CAP_ACK 10
38 @@ -2843,7 +2851,15 @@ static int append_peer_ipv6_address(unsi
42 - /* do not ask for error message content */
44 + * Tell kernel to not send to us payload of acknowledgment error message.
45 + * NETLINK_CAP_ACK option is supported since Linux kernel version 4.3 and
46 + * older kernel versions always send full payload in acknowledgment netlink
47 + * message. We ignore payload of this message as we need only error code,
48 + * to check if our set remote peer address request succeeded or failed.
49 + * So ignore return value from the following setsockopt() call as setting
50 + * option NETLINK_CAP_ACK means for us just a kernel hint / optimization.
53 setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one));