* [PATCH] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS
@ 2021-03-13 0:02 Bjorn Andersson
2021-03-15 14:23 ` Daniele Palmas
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2021-03-13 0:02 UTC (permalink / raw)
To: netdev; +Cc: Daniele Palmas, Alex Elder
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>
---
ip/iplink_rmnet.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c
index 1d16440c6900..8a488f3d0316 100644
--- a/ip/iplink_rmnet.c
+++ b/ip/iplink_rmnet.c
@@ -16,6 +16,10 @@ static void print_explain(FILE *f)
{
fprintf(f,
"Usage: ... rmnet mux_id MUXID\n"
+ " [ingress-deaggregation]\n"
+ " [ingress-commands]\n"
+ " [ingress-chksumv4]\n"
+ " [egress-chksumv4]\n"
"\n"
"MUXID := 1-254\n"
);
@@ -29,6 +33,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 +42,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-commands") == 0) {
+ flags.mask = ~0;
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
+ } else if (matches(*argv, "ingress-chksumv4") == 0) {
+ flags.mask = ~0;
+ flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
+ } else if (matches(*argv, "egress-chksumv4") == 0) {
+ flags.mask = ~0;
+ flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
@@ -48,11 +65,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-commands");
+ if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
+ print_string(PRINT_ANY, NULL, "%s ", "ingress-chksumv4");
+ if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
+ print_string(PRINT_ANY, NULL, "%s ", "egress-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 +98,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,
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS
2021-03-13 0:02 [PATCH] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS Bjorn Andersson
@ 2021-03-15 14:23 ` Daniele Palmas
2021-03-15 15:43 ` Bjorn Andersson
0 siblings, 1 reply; 3+ messages in thread
From: Daniele Palmas @ 2021-03-15 14:23 UTC (permalink / raw)
To: Bjorn Andersson; +Cc: Network Development, Alex Elder
Hi Bjorn,
Il giorno sab 13 mar 2021 alle ore 01:02 Bjorn Andersson
<bjorn.andersson@linaro.org> ha scritto:
>
> 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>
> ---
> ip/iplink_rmnet.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c
> index 1d16440c6900..8a488f3d0316 100644
> --- a/ip/iplink_rmnet.c
> +++ b/ip/iplink_rmnet.c
> @@ -16,6 +16,10 @@ static void print_explain(FILE *f)
> {
> fprintf(f,
> "Usage: ... rmnet mux_id MUXID\n"
> + " [ingress-deaggregation]\n"
> + " [ingress-commands]\n"
> + " [ingress-chksumv4]\n"
> + " [egress-chksumv4]\n"
> "\n"
> "MUXID := 1-254\n"
> );
> @@ -29,6 +33,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 +42,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-commands") == 0) {
> + flags.mask = ~0;
> + flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
> + } else if (matches(*argv, "ingress-chksumv4") == 0) {
> + flags.mask = ~0;
> + flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
> + } else if (matches(*argv, "egress-chksumv4") == 0) {
> + flags.mask = ~0;
> + flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
> } else if (matches(*argv, "help") == 0) {
> explain();
> return -1;
> @@ -48,11 +65,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-commands");
> + if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
> + print_string(PRINT_ANY, NULL, "%s ", "ingress-chksumv4");
> + if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
> + print_string(PRINT_ANY, NULL, "%s ", "egress-cksumv4");
> +}
> +
> static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> {
> + struct ifla_vlan_flags *flags;
just for my understanding, why not struct ifla_rmnet_flags (though
they are exactly the same)?
Thanks,
Daniele
> +
> if (!tb)
> return;
>
> @@ -64,6 +98,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,
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS
2021-03-15 14:23 ` Daniele Palmas
@ 2021-03-15 15:43 ` Bjorn Andersson
0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-03-15 15:43 UTC (permalink / raw)
To: Daniele Palmas; +Cc: Network Development, Alex Elder
On Mon 15 Mar 09:23 CDT 2021, Daniele Palmas wrote:
> Hi Bjorn,
>
> Il giorno sab 13 mar 2021 alle ore 01:02 Bjorn Andersson
> <bjorn.andersson@linaro.org> ha scritto:
> >
> > 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>
> > ---
> > ip/iplink_rmnet.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 42 insertions(+)
> >
> > diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c
> > index 1d16440c6900..8a488f3d0316 100644
> > --- a/ip/iplink_rmnet.c
> > +++ b/ip/iplink_rmnet.c
> > @@ -16,6 +16,10 @@ static void print_explain(FILE *f)
> > {
> > fprintf(f,
> > "Usage: ... rmnet mux_id MUXID\n"
> > + " [ingress-deaggregation]\n"
> > + " [ingress-commands]\n"
> > + " [ingress-chksumv4]\n"
> > + " [egress-chksumv4]\n"
> > "\n"
> > "MUXID := 1-254\n"
> > );
> > @@ -29,6 +33,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 +42,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-commands") == 0) {
> > + flags.mask = ~0;
> > + flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS;
> > + } else if (matches(*argv, "ingress-chksumv4") == 0) {
> > + flags.mask = ~0;
> > + flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4;
> > + } else if (matches(*argv, "egress-chksumv4") == 0) {
> > + flags.mask = ~0;
> > + flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
> > } else if (matches(*argv, "help") == 0) {
> > explain();
> > return -1;
> > @@ -48,11 +65,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-commands");
> > + if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
> > + print_string(PRINT_ANY, NULL, "%s ", "ingress-chksumv4");
> > + if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
> > + print_string(PRINT_ANY, NULL, "%s ", "egress-cksumv4");
> > +}
> > +
> > static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> > {
> > + struct ifla_vlan_flags *flags;
>
> just for my understanding, why not struct ifla_rmnet_flags (though
> they are exactly the same)?
>
That's a copy-paste or code complete mistake, thanks for spotting it.
Regards,
Bjorn
> Thanks,
> Daniele
>
> > +
> > if (!tb)
> > return;
> >
> > @@ -64,6 +98,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,
> > --
> > 2.28.0
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-15 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 0:02 [PATCH] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS Bjorn Andersson
2021-03-15 14:23 ` Daniele Palmas
2021-03-15 15:43 ` Bjorn Andersson
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.