diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2020-08-05 19:55:47 -0700 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2020-08-05 19:55:47 -0700 |
commit | f6f9079abf1c67976656c42c8847eda57d734035 (patch) | |
tree | b6892fe3ac0c70f80986f1f4010b7b3059697979 | |
parent | 2f31d12a25d289d864fd9bffc417e4518043e37d (diff) |
iplink_rmnet: Allow passing IFLA_RMNET_FLAGS
Parse and pass IFLA_RMNET_FLAGS to the kernel, to allow changing the
flags from the default of ingress-aggregate only.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | ip/iplink_rmnet.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c index 1d16440c..97e9e0f6 100644 --- a/ip/iplink_rmnet.c +++ b/ip/iplink_rmnet.c @@ -29,6 +29,7 @@ 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 = { }; __u16 mux_id; while (argc > 0) { @@ -37,6 +38,18 @@ static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv, 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, "ingress-deaggregation") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_DEAGGREGATION; + } else if (matches(*argv, "ingress-map-commands") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS; + } else if (matches(*argv, "ingress-map-chksumv4") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4; + } else if (matches(*argv, "egress-map-chksumv4") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4; } else if (matches(*argv, "help") == 0) { explain(); return -1; @@ -48,11 +61,28 @@ 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) +{ + if (flags & RMNET_FLAGS_INGRESS_DEAGGREGATION) + print_string(PRINT_ANY, NULL, "%s ", "ingress-deaggregation"); + if (flags & RMNET_FLAGS_INGRESS_MAP_COMMANDS) + print_string(PRINT_ANY, NULL, "%s ", "ingress-map-commands"); + if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) + print_string(PRINT_ANY, NULL, "%s ", "ingress-map-chksumv4"); + if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) + print_string(PRINT_ANY, NULL, "%s ", "egress-map-cksumv4"); +} + static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) { + struct ifla_vlan_flags *flags; + if (!tb) return; @@ -64,6 +94,14 @@ 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, |