vrf: Add support for table names
Currently, the table id for VRF devices requires an integer. Convert
it to use rtnl_rttable_a2n which handles table names from the iproute2
directory.
This also fixes a bug in the original commit where table name are not
properly handled.
Fixes: 15faa0a30b ("add support for VRF device")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
This commit is contained in:
parent
ed108cfc02
commit
8a23f82045
|
|
@ -28,12 +28,6 @@ static void explain(void)
|
||||||
vrf_explain(stderr);
|
vrf_explain(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int table_arg(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Error: argument of \"table\" must be 0-32767 and currently unused\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vrf_parse_opt(struct link_util *lu, int argc, char **argv,
|
static int vrf_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||||
struct nlmsghdr *n)
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
|
|
@ -43,9 +37,8 @@ static int vrf_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
||||||
table = atoi(*argv);
|
if (rtnl_rttable_a2n(&table, *argv))
|
||||||
if (table > 32767)
|
invarg("invalid table ID\n", *argv);
|
||||||
return table_arg();
|
|
||||||
addattr32(n, 1024, IFLA_VRF_TABLE, table);
|
addattr32(n, 1024, IFLA_VRF_TABLE, table);
|
||||||
} else if (matches(*argv, "help") == 0) {
|
} else if (matches(*argv, "help") == 0) {
|
||||||
explain();
|
explain();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue