From 88bdb27b6d535600c10ef446391a51fc56691350 Mon Sep 17 00:00:00 2001 From: Daniele Palmas Date: Fri, 8 Jun 2018 11:43:49 +0200 Subject: [PATCH 1/1] ip: add rmnet initial support This patch adds basic support for rmnet devices. Currently the only possible actions are creating a new link with a specific mux id and removing a link. Signed-off-by: Daniele Palmas --- ip/Makefile | 2 +- ip/iplink.c | 2 +- ip/iplink_rmnet.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 ip/iplink_rmnet.c diff --git a/ip/Makefile b/ip/Makefile index 77fadee..a88f936 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -10,7 +10,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \ iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \ iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \ - ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o + ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o RTMONOBJ=rtmon.o diff --git a/ip/iplink.c b/ip/iplink.c index 9ff5f69..d678301 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -121,7 +121,7 @@ void iplink_usage(void) " bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n" " gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan |\n" " vti | nlmon | team_slave | bond_slave | ipvlan | geneve |\n" - " bridge_slave | vrf | macsec | netdevsim }\n"); + " bridge_slave | vrf | macsec | netdevsim | rmnet}\n"); } exit(-1); } diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c new file mode 100644 index 0000000..d3b0672 --- /dev/null +++ b/ip/iplink_rmnet.c @@ -0,0 +1,74 @@ +/* + * iplink_rmnet.c RMNET device support + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Daniele Palmas + */ + +#include +#include +#include + +#include "rt_names.h" +#include "utils.h" +#include "ip_common.h" + +static void print_explain(FILE *f) +{ + fprintf(f, + "Usage: ... rmnet mux_id MUXID\n" + "\n" + "MUXID := 1-127\n" + ); +} + +static void explain(void) +{ + print_explain(stderr); +} + +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) { + if (matches(*argv, "mux_id") == 0) { + NEXT_ARG(); + if (get_u16(&mux_id, *argv, 0)) + invarg("mux_id is invalid", *argv); + addattr_l(n, 1024, IFLA_RMNET_MUX_ID, &mux_id, 2); + } else if (matches(*argv, "help") == 0) { + explain(); + return -1; + } else { + fprintf(stderr, "rmnet: unknown command \"%s\"?\n", *argv); + explain(); + return -1; + } + argc--, argv++; + } + + if (flags.mask) + addattr_l(n, 1024, IFLA_RMNET_FLAGS, &flags, sizeof(flags)); + + return 0; +} + +static void rmnet_print_help(struct link_util *lu, int argc, char **argv, + FILE *f) +{ + print_explain(f); +} + +struct link_util rmnet_link_util = { + .id = "rmnet", + .maxattr = IFLA_RMNET_MAX, + .parse_opt = rmnet_parse_opt, + .print_help = rmnet_print_help, +}; -- 2.7.4