Message ID | b614d787896a33481e09487deec42b482fdc8643.1615568866.git.petrm@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | David Ahern |
Headers | show |
Series | ip: nexthop: Support resilient groups | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 3/12/21 10:23 AM, Petr Machata wrote: > From: Petr Machata <me@pmachata.org> > > From: Ido Schimmel <idosch@nvidia.com> All of the patches have the above. If Ido is the author and you are sending, AIUI you add your Signed-off-by below his. > > Next patches are going to add a 'resilient' nexthop group type, so allow > users to specify the type using the 'type' argument. Currently, only > 'mpath' type is supported. > > These two command are equivalent: > > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > --- > ip/ipnexthop.c | 32 +++++++++++++++++++++++++++++++- > man/man8/ip-nexthop.8 | 18 ++++++++++++++++-- > 2 files changed, 47 insertions(+), 3 deletions(-) > ... > diff --git a/man/man8/ip-nexthop.8 b/man/man8/ip-nexthop.8 > index 4d55f4dbcc75..f02e0555a000 100644 > --- a/man/man8/ip-nexthop.8 > +++ b/man/man8/ip-nexthop.8 > @@ -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,17 @@ 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 > + Add a comment that this is the default group type and refers to the legacy hash-bashed multipath group. The rest of the patches look ok to me.
David Ahern <dsahern@gmail.com> writes: > On 3/12/21 10:23 AM, Petr Machata wrote: >> From: Petr Machata <me@pmachata.org> >> >> From: Ido Schimmel <idosch@nvidia.com> > > All of the patches have the above. If Ido is the author and you are > sending, AIUI you add your Signed-off-by below his. Sorry about that, that's a leftover from when I was sending the DCB patches. I'll resend with the correct headers. >> +.sp >> +.I TYPE >> +is a string specifying the nexthop group type. Namely: >> + >> +.in +8 >> +.BI mpath >> +- multipath nexthop group >> + > > Add a comment that this is the default group type and refers to the > legacy hash-bashed multipath group. OK.
diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c index 126b0b17cab4..5aae32629edd 100644 --- a/ip/ipnexthop.c +++ b/ip/ipnexthop.c @@ -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; diff --git a/man/man8/ip-nexthop.8 b/man/man8/ip-nexthop.8 index 4d55f4dbcc75..f02e0555a000 100644 --- a/man/man8/ip-nexthop.8 +++ b/man/man8/ip-nexthop.8 @@ -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,17 @@ 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 + .TP .B blackhole create a blackhole nexthop