ath79: update WA/XC devices UBNT_VERSION to 8.7.4
[openwrt/staging/wigyori.git] / package / network / services / ppp / patches / 140-pppd-Fix-compilation-with-older-glibc-or-kernel-head.patch
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
5 (#248)
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
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.
13
14 Also extend description why we call SOL_NETLINK/NETLINK_CAP_ACK option.
15
16 Signed-off-by: Pali Rohár <pali@kernel.org>
17 ---
18 pppd/sys-linux.c | 18 +++++++++++++++++-
19 1 file changed, 17 insertions(+), 1 deletion(-)
20
21 --- a/pppd/sys-linux.c
22 +++ b/pppd/sys-linux.c
23 @@ -125,6 +125,14 @@
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 */
28 +#ifndef SOL_NETLINK
29 +#define SOL_NETLINK 270
30 +#endif
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
34 +#endif
35 #endif
36
37 #include "pppd.h"
38 @@ -2843,7 +2851,15 @@ static int append_peer_ipv6_address(unsi
39 if (fd < 0)
40 return 0;
41
42 - /* do not ask for error message content */
43 + /*
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.
51 + */
52 one = 1;
53 setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one));
54