1 /* iplink_vrf.c VRF device support
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version
6 * 2 of the License, or (at your option) any later version.
8 * Authors: Shrijeet Mukherjee <shm@cumulusnetworks.com>
14 #include <sys/socket.h>
15 #include <linux/if_link.h>
19 #include "ip_common.h"
21 static void vrf_explain(FILE *f
)
23 fprintf(f
, "Usage: ... vrf table TABLEID\n");
26 static void explain(void)
31 static int vrf_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
35 if (matches(*argv
, "table") == 0) {
40 if (rtnl_rttable_a2n(&table
, *argv
))
41 invarg("invalid table ID\n", *argv
);
42 addattr32(n
, 1024, IFLA_VRF_TABLE
, table
);
43 } else if (matches(*argv
, "help") == 0) {
47 fprintf(stderr
, "vrf: unknown option \"%s\"?\n",
58 static void vrf_print_opt(struct link_util
*lu
, FILE *f
, struct rtattr
*tb
[])
63 if (tb
[IFLA_VRF_TABLE
])
64 fprintf(f
, "table %u ", rta_getattr_u32(tb
[IFLA_VRF_TABLE
]));
67 static void vrf_slave_print_opt(struct link_util
*lu
, FILE *f
,
73 if (tb
[IFLA_VRF_PORT_TABLE
]) {
74 fprintf(f
, "table %u ",
75 rta_getattr_u32(tb
[IFLA_VRF_PORT_TABLE
]));
79 static void vrf_print_help(struct link_util
*lu
, int argc
, char **argv
,
85 struct link_util vrf_link_util
= {
87 .maxattr
= IFLA_VRF_MAX
,
88 .parse_opt
= vrf_parse_opt
,
89 .print_opt
= vrf_print_opt
,
90 .print_help
= vrf_print_help
,
93 struct link_util vrf_slave_link_util
= {
95 .maxattr
= IFLA_VRF_PORT_MAX
,
96 .print_opt
= vrf_slave_print_opt
,