* [iproute2-next v3] ip: link: rmnet: add support for flag handling
@ 2024-12-13 12:51 Robert Marko
2024-12-16 3:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Robert Marko @ 2024-12-13 12:51 UTC (permalink / raw)
To: netdev, stephen, davem, edumazet, kuba, dsahern, iri, andrew
Cc: luka.perkov, Robert Marko
Extend the current rmnet support to allow enabling or disabling
IFLA_RMNET_FLAGS via ip link as well as printing the current settings.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Changes in v3:
* Use parse_on_off() instead of hand-coding
* Drop on_off() error message printing
Changes in v2:
* Use strcmp() instead of matches()
* Fix disabling flags (Forgotten ~)
* Separate ingress and egress checksum flags
* Rename flags to more closely resemble their meaning.
For example add ingress when they only affect ingress, rename checksm
flags to mapv4/v5-checksum.
ip/iplink_rmnet.c | 120 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 118 insertions(+), 2 deletions(-)
diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c
index 1d16440c..d7596b2b 100644
--- a/ip/iplink_rmnet.c
+++ b/ip/iplink_rmnet.c
@@ -16,6 +16,12 @@ static void print_explain(FILE *f)
{
fprintf(f,
"Usage: ... rmnet mux_id MUXID\n"
+ " [ ingress-deaggregation { on | off } ]\n"
+ " [ ingress-commands { on | off } ]\n"
+ " [ ingress-mapv4-checksum { on | off } ]\n"
+ " [ egress-mapv4-checksum { on | off } ]\n"
+ " [ ingress-mapv5-checksum { on | off } ]\n"
+ " [ egress-mapv5-checksum { on | off } ]\n"
"\n"
"MUXID := 1-254\n"
);
@@ -29,15 +35,95 @@ static void explain(void)
static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
+ struct ifla_rmnet_flags flags = { 0 };
__u16 mux_id;
+ int ret;
while (argc > 0) {
- if (matches(*argv, "mux_id") == 0) {
+ if (strcmp(*argv, "mux_id") == 0) {
NEXT_ARG();
if (get_u16(&mux_id, *argv, 0))
invarg("mux_id is invalid", *argv);
addattr16(n, 1024, IFLA_RMNET_MUX_ID, mux_id);
- } else if (matches(*argv, "help") == 0) {
+ } else if (strcmp(*argv, "ingress-deaggregation") == 0) {
+ bool deaggregation;
+
+ NEXT_ARG();
+ deaggregation = parse_on_off("ingress-deaggregation", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ if (deaggregation)
+ flags.flags |= RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ else
+ flags.flags &= ~RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ } else if (strcmp(*argv, "ingress-commands") == 0) {
+ bool commands;
+
+ NEXT_ARG();
+ commands = parse_on_off("ingress-commands", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ if (commands)
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ else
+ flags.flags &= ~RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ } else if (strcmp(*argv, "ingress-mapv4-checksum") == 0) {
+ bool mapv4_checksum;
+
+ NEXT_ARG();
+ mapv4_checksum = parse_on_off("ingress-mapv4-checksum", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ if (mapv4_checksum)
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ else
+ flags.flags &= ~RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ } else if (strcmp(*argv, "egress-mapv4-checksum") == 0) {
+ bool mapv4_checksum;
+
+ NEXT_ARG();
+ mapv4_checksum = parse_on_off("egress-mapv4-checksum", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ if (mapv4_checksum)
+ flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ else
+ flags.flags &= ~RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ } else if (strcmp(*argv, "ingress-mapv5-checksum") == 0) {
+ bool mapv5_checksum;
+
+ NEXT_ARG();
+ mapv5_checksum = parse_on_off("ingress-mapv5-checksum", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ if (mapv5_checksum)
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ else
+ flags.flags &= ~RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ } else if (strcmp(*argv, "egress-mapv5-checksum") == 0) {
+ bool mapv5_checksum;
+
+ NEXT_ARG();
+ mapv5_checksum = parse_on_off("egress-mapv5-checksum", *argv, &ret);
+ if (ret)
+ return ret;
+
+ flags.mask |= RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ if (mapv5_checksum)
+ flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ else
+ flags.flags &= ~RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ } else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
} else {
@@ -48,11 +134,34 @@ static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv,
argc--, argv++;
}
+ if (flags.mask)
+ addattr_l(n, 1024, IFLA_RMNET_FLAGS, &flags, sizeof(flags));
+
return 0;
}
+static void rmnet_print_flags(FILE *fp, __u32 flags)
+{
+ open_json_array(PRINT_ANY, is_json_context() ? "flags" : "<");
+#define _PF(f) if (flags & RMNET_FLAGS_##f) { \
+ flags &= ~RMNET_FLAGS_##f; \
+ print_string(PRINT_ANY, NULL, flags ? "%s," : "%s", #f); \
+ }
+ _PF(INGRESS_DEAGGREGATION);
+ _PF(INGRESS_MAP_COMMANDS);
+ _PF(INGRESS_MAP_CKSUMV4);
+ _PF(EGRESS_MAP_CKSUMV4);
+ _PF(INGRESS_MAP_CKSUMV5);
+ _PF(EGRESS_MAP_CKSUMV5);
+#undef _PF
+ if (flags)
+ print_hex(PRINT_ANY, NULL, "%x", flags);
+ close_json_array(PRINT_ANY, "> ");
+}
static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
+ struct ifla_rmnet_flags *flags;
+
if (!tb)
return;
@@ -64,6 +173,13 @@ static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
"mux_id",
"mux_id %u ",
rta_getattr_u16(tb[IFLA_RMNET_MUX_ID]));
+
+ if (tb[IFLA_RMNET_FLAGS]) {
+ if (RTA_PAYLOAD(tb[IFLA_RMNET_FLAGS]) < sizeof(*flags))
+ return;
+ flags = RTA_DATA(tb[IFLA_RMNET_FLAGS]);
+ rmnet_print_flags(f, flags->flags);
+ }
}
static void rmnet_print_help(struct link_util *lu, int argc, char **argv,
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [iproute2-next v3] ip: link: rmnet: add support for flag handling
2024-12-13 12:51 [iproute2-next v3] ip: link: rmnet: add support for flag handling Robert Marko
@ 2024-12-16 3:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-16 3:10 UTC (permalink / raw)
To: Robert Marko
Cc: netdev, stephen, davem, edumazet, kuba, dsahern, iri, andrew,
luka.perkov
Hello:
This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Fri, 13 Dec 2024 13:51:00 +0100 you wrote:
> Extend the current rmnet support to allow enabling or disabling
> IFLA_RMNET_FLAGS via ip link as well as printing the current settings.
>
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
> ---
> Changes in v3:
> * Use parse_on_off() instead of hand-coding
> * Drop on_off() error message printing
>
> [...]
Here is the summary with links:
- [iproute2-next,v3] ip: link: rmnet: add support for flag handling
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=1f0f9deb55fd
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] 2+ messages in thread
end of thread, other threads:[~2024-12-16 3:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 12:51 [iproute2-next v3] ip: link: rmnet: add support for flag handling Robert Marko
2024-12-16 3:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).