diff options
author | Nicolas Escande <nico.escande@gmail.com> | 2022-03-04 11:33:54 +0100 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-03-11 09:20:55 -0700 |
commit | 8acb5247e3907762441875f6519b2a60b35c04f7 (patch) | |
tree | 2891c6126b012d8418ccbfb2f59de61faa43b3d4 | |
parent | 0431d8e8c4ddeccfb7a33e4aed43cb9fb43128d5 (diff) | |
download | iproute2-8acb5247e3907762441875f6519b2a60b35c04f7.tar.gz |
ip/batadv: allow to specify RA when creating link
This patch adds the possibility to specify batadv specific options when
creating a new batman link. The only option available on link creation
is IFLA_BATADV_ALGO_NAME which specifies the routing algorithm.
Note there is no batadv specific attr to be handled on link dump.
Signed-off-by: Nicolas Escande <nico.escande@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r-- | ip/Makefile | 2 | ||||
-rw-r--r-- | ip/iplink_batadv.c | 64 |
2 files changed, 65 insertions, 1 deletions
diff --git a/ip/Makefile b/ip/Makefile index 2a7a51c31..11a361cef 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -12,7 +12,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \ ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \ ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o ipioam6.o \ - iplink_amt.o + iplink_amt.o iplink_batadv.o RTMONOBJ=rtmon.o diff --git a/ip/iplink_batadv.c b/ip/iplink_batadv.c new file mode 100644 index 000000000..45bd923f7 --- /dev/null +++ b/ip/iplink_batadv.c @@ -0,0 +1,64 @@ +/* + * iplink_batadv.c Batman-adv support + * + * Authors: Nicolas Escande <nico.escande@gmail.com> + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <linux/batman_adv.h> + +#include "rt_names.h" +#include "utils.h" +#include "ip_common.h" + +static void print_explain(FILE *f) +{ + fprintf(f, + "Usage: ... batadv [ ra ROUTING_ALG ]\n" + "\n" + "Where: ROUTING_ALG := { BATMAN_IV | BATMAN_V }\n" + ); +} + +static void explain(void) +{ + print_explain(stderr); +} + +static int batadv_parse_opt(struct link_util *lu, int argc, char **argv, + struct nlmsghdr *n) +{ + while (argc > 0) { + if (matches(*argv, "ra") == 0) { + NEXT_ARG(); + addattrstrz(n, 1024, IFLA_BATADV_ALGO_NAME, *argv); + } else if (matches(*argv, "help") == 0) { + explain(); + return -1; + } else { + fprintf(stderr, + "batadv: unknown command \"%s\"?\n", + *argv); + explain(); + return -1; + } + argc--, argv++; + } + + return 0; +} + +static void batadv_print_help(struct link_util *lu, int argc, char **argv, + FILE *f) +{ + print_explain(f); +} + +struct link_util batadv_link_util = { + .id = "batadv", + .maxattr = IFLA_BATADV_MAX, + .parse_opt = batadv_parse_opt, + .print_help = batadv_print_help, +}; |