@@ -42,8 +42,10 @@ static void usage(void)
"SELECTOR := [ id ID ] [ dev DEV ] [ vrf NAME ] [ master DEV ]\n"
" [ groups ] [ fdb ]\n"
"NH := { blackhole | [ via ADDRESS ] [ dev DEV ] [ onlink ]\n"
- " [ encap ENCAPTYPE ENCAPHDR ] | group GROUP [ fdb ] }\n"
+ " [ encap ENCAPTYPE ENCAPHDR ] |\n"
+ " group GROUP [ fdb ] [ type TYPE ] }\n"
"GROUP := [ <id[,weight]>/<id[,weight]>/... ]\n"
+ "TYPE := { mpath }\n"
"ENCAPTYPE := [ mpls ]\n"
"ENCAPHDR := [ MPLSLABEL ]\n");
exit(-1);
@@ -327,6 +329,32 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
return addattr_l(n, maxlen, NHA_GROUP, grps, count * sizeof(*grps));
}
+static int read_nh_group_type(const char *name)
+{
+ if (strcmp(name, "mpath") == 0)
+ return NEXTHOP_GRP_TYPE_MPATH;
+
+ return __NEXTHOP_GRP_TYPE_MAX;
+}
+
+static void parse_nh_group_type(struct nlmsghdr *n, int maxlen, int *argcp,
+ char ***argvp)
+{
+ char **argv = *argvp;
+ int argc = *argcp;
+ __u16 type;
+
+ NEXT_ARG();
+ type = read_nh_group_type(*argv);
+ if (type > NEXTHOP_GRP_TYPE_MAX)
+ invarg("\"type\" value is invalid\n", *argv);
+
+ *argcp = argc;
+ *argvp = argv;
+
+ addattr16(n, maxlen, NHA_GROUP_TYPE, type);
+}
+
static int ipnh_parse_id(const char *argv)
{
__u32 id;
@@ -409,6 +437,8 @@ static int ipnh_modify(int cmd, unsigned int flags, int argc, char **argv)
if (add_nh_group_attr(&req.n, sizeof(req), *argv))
invarg("\"group\" value is invalid\n", *argv);
+ } else if (!strcmp(*argv, "type")) {
+ parse_nh_group_type(&req.n, sizeof(req), &argc, &argv);
} else if (matches(*argv, "protocol") == 0) {
__u32 prot;
@@ -54,7 +54,9 @@ ip-nexthop \- nexthop object management
.BR fdb " ] | "
.B group
.IR GROUP " [ "
-.BR fdb " ] } "
+.BR fdb " ] [ "
+.B type
+.IR TYPE " ] } "
.ti -8
.IR ENCAP " := [ "
@@ -71,6 +73,10 @@ ip-nexthop \- nexthop object management
.IR GROUP " := "
.BR id "[," weight "[/...]"
+.ti -8
+.IR TYPE " := { "
+.BR mpath " }"
+
.SH DESCRIPTION
.B ip nexthop
is used to manipulate entries in the kernel's nexthop tables.
@@ -122,9 +128,18 @@ is a set of encapsulation attributes specific to the
.in -2
.TP
-.BI group " GROUP"
+.BI group " GROUP [ " type " TYPE ]"
create a nexthop group. Group specification is id with an optional
weight (id,weight) and a '/' as a separator between entries.
+.sp
+.I TYPE
+is a string specifying the nexthop group type. Namely:
+
+.in +8
+.BI mpath
+- Multipath nexthop group backed by the hash-threshold algorithm. The
+default when the type is unspecified.
+
.TP
.B blackhole
create a blackhole nexthop