* [PATCH iproute2 0/6] include file changes for musl libc
@ 2024-12-12 22:24 Stephen Hemminger
2024-12-12 22:24 ` [PATCH iproute2 1/6] libnetlink: add missing endian.h Stephen Hemminger
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
This is a set of patches to address some of the include file
issues identified by building on a musl libc based system (Alpine).
Stephen Hemminger (6):
libnetlink: add missing endian.h
rdma: add missing header for basename
ip: rearrange and prune header files
cg_map: use limits.h
flower: replace XATTR_SIZE_MAX
uapi: remove no longer used linux/limits.h
include/libnetlink.h | 1 +
include/uapi/linux/limits.h | 21 ---------------------
ip/iplink.c | 13 +++++--------
ip/ipnetns.c | 19 +++++++++----------
lib/cg_map.c | 3 ++-
rdma/rdma.h | 3 ++-
tc/f_flower.c | 37 ++++++++++++++++++++-----------------
7 files changed, 39 insertions(+), 58 deletions(-)
delete mode 100644 include/uapi/linux/limits.h
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH iproute2 1/6] libnetlink: add missing endian.h 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 2/6] rdma: add missing header for basename Stephen Hemminger ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger Need endian.h to get htobe64 with musl. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- include/libnetlink.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libnetlink.h b/include/libnetlink.h index 30f0c2d2..7074e913 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -4,6 +4,7 @@ #include <stdio.h> #include <string.h> +#include <endian.h> #include <asm/types.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 2/6] rdma: add missing header for basename 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 1/6] libnetlink: add missing endian.h Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 3/6] ip: rearrange and prune header files Stephen Hemminger ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger The function basename prototype is in libgen.h Fixes build on musl Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- rdma/rdma.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rdma/rdma.h b/rdma/rdma.h index fb037bcf..fda0a45c 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -10,11 +10,12 @@ #include <string.h> #include <errno.h> #include <getopt.h> +#include <time.h> +#include <libgen.h> #include <netinet/in.h> #include <libmnl/libmnl.h> #include <rdma/rdma_netlink.h> #include <rdma/rdma_user_cm.h> -#include <time.h> #include <net/if_arp.h> #include "list.h" -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 3/6] ip: rearrange and prune header files 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 1/6] libnetlink: add missing endian.h Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 2/6] rdma: add missing header for basename Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 4/6] cg_map: use limits.h Stephen Hemminger ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger The recent report of issues with missing limits.h impacting musl suggested looking at what files are and are not included in ip code. The standard practice is to put standard headers first, then system, then local headers. Used iwyu to get suggestions about missing and extraneous headers. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- ip/iplink.c | 13 +++++-------- ip/ipnetns.c | 19 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index aa2332fc..59e8caf4 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -11,17 +11,14 @@ #include <fcntl.h> #include <dlfcn.h> #include <errno.h> +#include <string.h> +#include <strings.h> +#include <limits.h> + #include <sys/socket.h> +#include <arpa/inet.h> #include <linux/if.h> -#include <linux/if_packet.h> #include <linux/if_ether.h> -#include <linux/sockios.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <string.h> -#include <sys/ioctl.h> -#include <stdbool.h> -#include <linux/mpls.h> #include "rt_names.h" #include "utils.h" diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 5c943400..a20cd8bc 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -1,21 +1,21 @@ /* SPDX-License-Identifier: GPL-2.0 */ #define _ATFILE_SOURCE -#include <sys/file.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <sys/inotify.h> -#include <sys/mount.h> -#include <sys/syscall.h> + #include <stdio.h> +#include <stdint.h> #include <string.h> -#include <sched.h> #include <fcntl.h> #include <dirent.h> #include <errno.h> #include <unistd.h> #include <ctype.h> -#include <linux/limits.h> +#include <limits.h> + +#include <sys/file.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/inotify.h> +#include <sys/mount.h> #include <linux/net_namespace.h> @@ -23,7 +23,6 @@ #include "list.h" #include "ip_common.h" #include "namespace.h" -#include "json_print.h" static int usage(void) { -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 4/6] cg_map: use limits.h 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger ` (2 preceding siblings ...) 2024-12-12 22:24 ` [PATCH iproute2 3/6] ip: rearrange and prune header files Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 5/6] flower: replace XATTR_SIZE_MAX Stephen Hemminger ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger Prefer limits.h from system headers over linux/limits.h Fixes build with musl. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- lib/cg_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cg_map.c b/lib/cg_map.c index e5d14d51..0feb854f 100644 --- a/lib/cg_map.c +++ b/lib/cg_map.c @@ -9,8 +9,9 @@ #include <string.h> #include <stdio.h> #include <stdbool.h> +#include <limits.h> + #include <linux/types.h> -#include <linux/limits.h> #include <ftw.h> #include "cg_map.h" -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 5/6] flower: replace XATTR_SIZE_MAX 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger ` (3 preceding siblings ...) 2024-12-12 22:24 ` [PATCH iproute2 4/6] cg_map: use limits.h Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 6/6] uapi: remove no longer used linux/limits.h Stephen Hemminger 2024-12-13 19:20 ` [PATCH iproute2 0/6] include file changes for musl libc patchwork-bot+netdevbpf 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger The flower tc parser was using XATTR_SIZE_MAX from linux/limits.h, but this constant is intended to before extended filesystem attributes not for TC. Replace it with a local define. This fixes issue on systems with musl and XATTR_SIZE_MAX is not defined in limits.h there. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- tc/f_flower.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tc/f_flower.c b/tc/f_flower.c index 3b61c219..6fc2c6a1 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -10,7 +10,7 @@ #include <unistd.h> #include <string.h> #include <net/if.h> -#include <linux/limits.h> + #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/ip.h> @@ -22,6 +22,9 @@ #include "tc_util.h" #include "rt_names.h" +/* maximum length of options string */ +#define FLOWER_OPTS_MAX 4096 + #ifndef IPPROTO_L2TP #define IPPROTO_L2TP 115 #endif @@ -1252,7 +1255,7 @@ static int flower_check_enc_opt_key(char *key) static int flower_parse_enc_opts_geneve(char *str, struct nlmsghdr *n) { - char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX]; + char key[FLOWER_OPTS_MAX], mask[FLOWER_OPTS_MAX]; int data_len, key_len, mask_len, err; char *token, *slash; struct rtattr *nest; @@ -1265,7 +1268,7 @@ static int flower_parse_enc_opts_geneve(char *str, struct nlmsghdr *n) if (slash) *slash = '\0'; - if ((key_len + strlen(token) > XATTR_SIZE_MAX) || + if ((key_len + strlen(token) > FLOWER_OPTS_MAX) || flower_check_enc_opt_key(token)) return -1; @@ -1275,7 +1278,7 @@ static int flower_parse_enc_opts_geneve(char *str, struct nlmsghdr *n) if (!slash) { /* Pad out mask when not provided */ - if (mask_len + strlen(token) > XATTR_SIZE_MAX) + if (mask_len + strlen(token) > FLOWER_OPTS_MAX) return -1; data_len = strlen(rindex(token, ':')); @@ -1288,7 +1291,7 @@ static int flower_parse_enc_opts_geneve(char *str, struct nlmsghdr *n) continue; } - if (mask_len + strlen(slash + 1) > XATTR_SIZE_MAX) + if (mask_len + strlen(slash + 1) > FLOWER_OPTS_MAX) return -1; strcpy(&mask[mask_len], slash + 1); @@ -1318,7 +1321,7 @@ static int flower_parse_enc_opts_geneve(char *str, struct nlmsghdr *n) static int flower_parse_enc_opts_vxlan(char *str, struct nlmsghdr *n) { - char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX]; + char key[FLOWER_OPTS_MAX], mask[FLOWER_OPTS_MAX]; struct rtattr *nest; char *slash; int err; @@ -1326,14 +1329,14 @@ static int flower_parse_enc_opts_vxlan(char *str, struct nlmsghdr *n) slash = strchr(str, '/'); if (slash) { *slash++ = '\0'; - if (strlen(slash) > XATTR_SIZE_MAX) + if (strlen(slash) > FLOWER_OPTS_MAX) return -1; strcpy(mask, slash); } else { strcpy(mask, "0xffffffff"); } - if (strlen(str) > XATTR_SIZE_MAX) + if (strlen(str) > FLOWER_OPTS_MAX) return -1; strcpy(key, str); @@ -1355,7 +1358,7 @@ static int flower_parse_enc_opts_vxlan(char *str, struct nlmsghdr *n) static int flower_parse_enc_opts_erspan(char *str, struct nlmsghdr *n) { - char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX]; + char key[FLOWER_OPTS_MAX], mask[FLOWER_OPTS_MAX]; struct rtattr *nest; char *slash; int err; @@ -1364,7 +1367,7 @@ static int flower_parse_enc_opts_erspan(char *str, struct nlmsghdr *n) slash = strchr(str, '/'); if (slash) { *slash++ = '\0'; - if (strlen(slash) > XATTR_SIZE_MAX) + if (strlen(slash) > FLOWER_OPTS_MAX) return -1; strcpy(mask, slash); } else { @@ -1376,7 +1379,7 @@ static int flower_parse_enc_opts_erspan(char *str, struct nlmsghdr *n) strcpy(mask + index, ":0xffffffff:0xff:0xff"); } - if (strlen(str) > XATTR_SIZE_MAX) + if (strlen(str) > FLOWER_OPTS_MAX) return -1; strcpy(key, str); @@ -1398,7 +1401,7 @@ static int flower_parse_enc_opts_erspan(char *str, struct nlmsghdr *n) static int flower_parse_enc_opts_gtp(char *str, struct nlmsghdr *n) { - char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX]; + char key[FLOWER_OPTS_MAX], mask[FLOWER_OPTS_MAX]; struct rtattr *nest; char *slash; int err; @@ -1406,13 +1409,13 @@ static int flower_parse_enc_opts_gtp(char *str, struct nlmsghdr *n) slash = strchr(str, '/'); if (slash) { *slash++ = '\0'; - if (strlen(slash) > XATTR_SIZE_MAX) + if (strlen(slash) > FLOWER_OPTS_MAX) return -1; strcpy(mask, slash); } else strcpy(mask, "ff:ff"); - if (strlen(str) > XATTR_SIZE_MAX) + if (strlen(str) > FLOWER_OPTS_MAX) return -1; strcpy(key, str); @@ -1433,7 +1436,7 @@ static int flower_parse_enc_opts_gtp(char *str, struct nlmsghdr *n) static int flower_parse_enc_opts_pfcp(char *str, struct nlmsghdr *n) { - char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX]; + char key[FLOWER_OPTS_MAX], mask[FLOWER_OPTS_MAX]; struct rtattr *nest; char *slash; int err; @@ -1442,14 +1445,14 @@ static int flower_parse_enc_opts_pfcp(char *str, struct nlmsghdr *n) slash = strchr(str, '/'); if (slash) { *slash++ = '\0'; - if (strlen(slash) > XATTR_SIZE_MAX) + if (strlen(slash) > FLOWER_OPTS_MAX) return -1; strcpy(mask, slash); } else { strcpy(mask, "ff:ffffffffffffffff"); } - if (strlen(str) > XATTR_SIZE_MAX) + if (strlen(str) > FLOWER_OPTS_MAX) return -1; strcpy(key, str); -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 6/6] uapi: remove no longer used linux/limits.h 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger ` (4 preceding siblings ...) 2024-12-12 22:24 ` [PATCH iproute2 5/6] flower: replace XATTR_SIZE_MAX Stephen Hemminger @ 2024-12-12 22:24 ` Stephen Hemminger 2024-12-13 19:20 ` [PATCH iproute2 0/6] include file changes for musl libc patchwork-bot+netdevbpf 6 siblings, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2024-12-12 22:24 UTC (permalink / raw) To: netdev; +Cc: Stephen Hemminger Code is now using limits.h instead. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- include/uapi/linux/limits.h | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 include/uapi/linux/limits.h diff --git a/include/uapi/linux/limits.h b/include/uapi/linux/limits.h deleted file mode 100644 index c3547f07..00000000 --- a/include/uapi/linux/limits.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_LIMITS_H -#define _LINUX_LIMITS_H - -#define NR_OPEN 1024 - -#define NGROUPS_MAX 65536 /* supplemental group IDs are available */ -#define ARG_MAX 131072 /* # bytes of args + environ for exec() */ -#define LINK_MAX 127 /* # links a file may have */ -#define MAX_CANON 255 /* size of the canonical input queue */ -#define MAX_INPUT 255 /* size of the type-ahead buffer */ -#define NAME_MAX 255 /* # chars in a file name */ -#define PATH_MAX 4096 /* # chars in a path name including nul */ -#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ -#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ -#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ -#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ - -#define RTSIG_MAX 32 - -#endif -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2 0/6] include file changes for musl libc 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger ` (5 preceding siblings ...) 2024-12-12 22:24 ` [PATCH iproute2 6/6] uapi: remove no longer used linux/limits.h Stephen Hemminger @ 2024-12-13 19:20 ` patchwork-bot+netdevbpf 6 siblings, 0 replies; 8+ messages in thread From: patchwork-bot+netdevbpf @ 2024-12-13 19:20 UTC (permalink / raw) To: Stephen Hemminger; +Cc: netdev Hello: This series was applied to iproute2/iproute2.git (main) by Stephen Hemminger <stephen@networkplumber.org>: On Thu, 12 Dec 2024 14:24:25 -0800 you wrote: > This is a set of patches to address some of the include file > issues identified by building on a musl libc based system (Alpine). > > Stephen Hemminger (6): > libnetlink: add missing endian.h > rdma: add missing header for basename > ip: rearrange and prune header files > cg_map: use limits.h > flower: replace XATTR_SIZE_MAX > uapi: remove no longer used linux/limits.h > > [...] Here is the summary with links: - [iproute2,1/6] libnetlink: add missing endian.h https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=c8b3ecc22ed0 - [iproute2,2/6] rdma: add missing header for basename https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=fa3949b792e2 - [iproute2,3/6] ip: rearrange and prune header files https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=7e23da91fca6 - [iproute2,4/6] cg_map: use limits.h https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f982f30e166a - [iproute2,5/6] flower: replace XATTR_SIZE_MAX https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=ac547ad027e3 - [iproute2,6/6] uapi: remove no longer used linux/limits.h https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=458dce5d0431 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-12-13 19:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-12 22:24 [PATCH iproute2 0/6] include file changes for musl libc Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 1/6] libnetlink: add missing endian.h Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 2/6] rdma: add missing header for basename Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 3/6] ip: rearrange and prune header files Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 4/6] cg_map: use limits.h Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 5/6] flower: replace XATTR_SIZE_MAX Stephen Hemminger 2024-12-12 22:24 ` [PATCH iproute2 6/6] uapi: remove no longer used linux/limits.h Stephen Hemminger 2024-12-13 19:20 ` [PATCH iproute2 0/6] include file changes for musl libc patchwork-bot+netdevbpf
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.