@@ -16,6 +16,10 @@ static void print_explain(FILE *f)
{
fprintf(f,
"Usage: ... rmnet mux_id MUXID\n"
+ " [ deaggregate { on | off } ]\n"
+ " [ commands { on | off } ]\n"
+ " [ qmapv4 { on | off } ]\n"
+ " [ qmapv5 { on | off } ]\n"
"\n"
"MUXID := 1-254\n"
);
@@ -26,9 +30,16 @@ static void explain(void)
print_explain(stderr);
}
+static int on_off(const char *msg, const char *arg)
+{
+ fprintf(stderr, "Error: argument of \"%s\" must be \"on\" or \"off\", not \"%s\"\n", msg, arg);
+ return -1;
+}
+
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;
while (argc > 0) {
@@ -37,6 +48,48 @@ 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, "deaggregate") == 0) {
+ NEXT_ARG();
+ flags.mask |= RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ if (strcmp(*argv, "on") == 0)
+ flags.flags |= RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ else if (strcmp(*argv, "off") == 0)
+ flags.flags &= RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ else
+ return on_off("deaggregate", *argv);
+ } else if (matches(*argv, "commands") == 0) {
+ NEXT_ARG();
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ if (strcmp(*argv, "on") == 0)
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ else if (strcmp(*argv, "off") == 0)
+ flags.flags &= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ else
+ return on_off("commands", *argv);
+ } else if (matches(*argv, "qmapv4") == 0) {
+ NEXT_ARG();
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ flags.mask |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ if (strcmp(*argv, "on") == 0) {
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ } else if (strcmp(*argv, "off") == 0) {
+ flags.flags &= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ flags.flags &= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ } else
+ return on_off("qmapv4", *argv);
+ } else if (matches(*argv, "qmapv5") == 0) {
+ NEXT_ARG();
+ flags.mask |= RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ flags.mask |= RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ if (strcmp(*argv, "on") == 0) {
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ } else if (strcmp(*argv, "off") == 0) {
+ flags.flags &= RMNET_FLAGS_INGRESS_MAP_CKSUMV5;
+ flags.flags &= RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+ } else
+ return on_off("qmapv5", *argv);
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
@@ -48,11 +101,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 +140,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,
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> --- ip/iplink_rmnet.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)