All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2 5/6] flower: replace XATTR_SIZE_MAX
Date: Thu, 12 Dec 2024 14:24:30 -0800	[thread overview]
Message-ID: <20241212222549.43749-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20241212222549.43749-1-stephen@networkplumber.org>

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


  parent reply	other threads:[~2024-12-12 22:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Stephen Hemminger [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241212222549.43749-6-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.