From 61beaa5d73b14afd5df6e8d35cbeb07c54362ed9 Mon Sep 17 00:00:00 2001 Message-Id: <61beaa5d73b14afd5df6e8d35cbeb07c54362ed9.1686053139.git.aclaudi@redhat.com> In-Reply-To: <527ed2d16bbd40b0e519587aeab96af7ed4f61ff.1686053139.git.aclaudi@redhat.com> References: <527ed2d16bbd40b0e519587aeab96af7ed4f61ff.1686053139.git.aclaudi@redhat.com> From: Andrea Claudi Date: Tue, 6 Jun 2023 13:18:36 +0200 Subject: [PATCH] macvlan: Add bclim parameter Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2209687 Upstream Status: iproute2-next.git commit e8a3fb47 commit e8a3fb470b4e96aa35a2731c7cc175b946c0a62d Author: Herbert Xu Date: Thu Mar 30 11:07:25 2023 +0800 macvlan: Add bclim parameter This patch adds support for setting the broadcast queueing threshold on macvlan devices. This controls which multicast packets will be processed in a workqueue instead of inline. Signed-off-by: Herbert Xu ip/iplink_macvlan.c | 26 ++++++++++++++++++++++++-- man/man8/ip-link.8.in | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) Signed-off-by: David Ahern --- ip/iplink_macvlan.c | 26 ++++++++++++++++++++++++-- man/man8/ip-link.8.in | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ip/iplink_macvlan.c b/ip/iplink_macvlan.c index 05e6bc77..6f84724d 100644 --- a/ip/iplink_macvlan.c +++ b/ip/iplink_macvlan.c @@ -30,13 +30,14 @@ static void print_explain(struct link_util *lu, FILE *f) { fprintf(f, - "Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN]\n" + "Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN] [bclim BCLIM]\n" "\n" "MODE: private | vepa | bridge | passthru | source\n" "MODE_FLAG: null | nopromisc | nodst\n" "MODE_OPTS: for mode \"source\":\n" "\tmacaddr { { add | del } | set [ [ ... ] ] | flush }\n" - "BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n", + "BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n" + "BCLIM: Threshold for broadcast queueing: 32-bit integer\n", lu->id ); } @@ -71,6 +72,12 @@ static int bc_queue_len_arg(const char *arg) return -1; } +static int bclim_arg(const char *arg) +{ + fprintf(stderr, "Error: illegal value for \"bclim\": \"%s\"\n", arg); + return -1; +} + static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv, struct nlmsghdr *n) { @@ -172,6 +179,15 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv, return bc_queue_len_arg(*argv); } addattr32(n, 1024, IFLA_MACVLAN_BC_QUEUE_LEN, bc_queue_len); + } else if (!strcmp(*argv, "bclim")) { + __s32 bclim; + NEXT_ARG(); + + if (get_s32(&bclim, *argv, 0)) { + return bclim_arg(*argv); + } + addattr_l(n, 1024, IFLA_MACVLAN_BC_CUTOFF, + &bclim, sizeof(bclim)); } else if (matches(*argv, "help") == 0) { explain(lu); return -1; @@ -249,6 +265,12 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[] print_luint(PRINT_ANY, "usedbcqueuelen", "usedbcqueuelen %lu ", bc_queue_len); } + if (tb[IFLA_MACVLAN_BC_CUTOFF] && + RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_CUTOFF]) >= sizeof(__s32)) { + __s32 bclim = rta_getattr_s32(tb[IFLA_MACVLAN_BC_CUTOFF]); + print_int(PRINT_ANY, "bclim", "bclim %d ", bclim); + } + /* in source mode, there are more options to print */ if (mode != MACVLAN_MODE_SOURCE) diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index ee189abc..6c278c50 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -1428,6 +1428,7 @@ the following additional arguments are supported: .BR mode " { " private " | " vepa " | " bridge " | " passthru .RB " [ " nopromisc " ] | " source " [ " nodst " ] } " .RB " [ " bcqueuelen " { " LENGTH " } ] " +.RB " [ " bclim " " LIMIT " ] " .in +8 .sp @@ -1486,6 +1487,13 @@ will be the maximum length that any macvlan interface has requested. When listing device parameters both the bcqueuelen parameter as well as the actual used bcqueuelen are listed to better help the user understand the setting. + +.BR bclim " " LIMIT +- Set the threshold for broadcast queueing. +.BR LIMIT " must be a 32-bit integer." +Setting this to -1 disables broadcast queueing altogether. Otherwise +a multicast address will be queued as broadcast if the number of devices +using it is greater than the given value. .in -8 .TP @@ -2591,6 +2599,9 @@ Update the broadcast/multicast queue length. [ .BI bcqueuelen " LENGTH " ] +[ +.BI bclim " LIMIT " +] .in +8 .BI bcqueuelen " LENGTH " @@ -2604,6 +2615,13 @@ will be the maximum length that any macvlan interface has requested. When listing device parameters both the bcqueuelen parameter as well as the actual used bcqueuelen are listed to better help the user understand the setting. + +.BI bclim " LIMIT " +- Set the threshold for broadcast queueing. +.IR LIMIT " must be a 32-bit integer." +Setting this to -1 disables broadcast queueing altogether. Otherwise +a multicast address will be queued as broadcast if the number of devices +using it is greater than the given value. .in -8 .SS ip link show - display device attributes -- 2.40.1