/*
* special macro to allow us to get the correct zebra_vrf
*/
-#define ZEBRA_DECLVAR_CONTEXT(A, B) \
- struct vrf *A = VTY_GET_CONTEXT(vrf); \
- struct zebra_vrf *B = \
- (vrf) ? vrf->info : NULL; \
+#define ZEBRA_DECLVAR_CONTEXT(A, B) \
+ struct vrf *A = VTY_GET_CONTEXT(vrf); \
+ struct zebra_vrf *B = (vrf) ? vrf->info : NULL;
/* VNI range as per RFC 7432 */
#define CMD_VNI_RANGE "(1-16777215)"
/* General function for static route. */
-static int zebra_static_route_leak(struct vty *vty,
- struct zebra_vrf *zvrf,
- struct zebra_vrf *nh_zvrf,
- afi_t afi, safi_t safi,
- const char *negate, const char *dest_str,
- const char *mask_str, const char *src_str,
- const char *gate_str, const char *ifname,
- const char *flag_str, const char *tag_str,
- const char *distance_str,
- const char *label_str)
+static int zebra_static_route_leak(
+ struct vty *vty, struct zebra_vrf *zvrf, struct zebra_vrf *nh_zvrf,
+ afi_t afi, safi_t safi, const char *negate, const char *dest_str,
+ const char *mask_str, const char *src_str, const char *gate_str,
+ const char *ifname, const char *flag_str, const char *tag_str,
+ const char *distance_str, const char *label_str)
{
int ret;
u_char distance;
/* Null0 static route. */
if (ifname != NULL) {
- if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0 ||
- strncasecmp(ifname, "reject", strlen(ifname)) == 0 ||
- strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) {
- vty_out(vty, "%% Nexthop interface cannot be Null0, reject or blackhole\n");
+ if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0
+ || strncasecmp(ifname, "reject", strlen(ifname)) == 0
+ || strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) {
+ vty_out(vty,
+ "%% Nexthop interface cannot be Null0, reject or blackhole\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
}
static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
- const char *negate, const char *dest_str,
- const char *mask_str, const char *src_str,
- const char *gate_str, const char *ifname,
- const char *flag_str, const char *tag_str,
- const char *distance_str, const char *vrf_name,
- const char *label_str)
+ const char *negate, const char *dest_str,
+ const char *mask_str, const char *src_str,
+ const char *gate_str, const char *ifname,
+ const char *flag_str, const char *tag_str,
+ const char *distance_str, const char *vrf_name,
+ const char *label_str)
{
struct zebra_vrf *zvrf;
struct vrf *vrf;
/* Mark as having FRR configuration */
vrf_set_user_cfged(vrf);
}
- return zebra_static_route_leak(vty, zvrf, zvrf, afi, safi,
- negate, dest_str, mask_str, src_str,
- gate_str, ifname, flag_str, tag_str,
- distance_str, label_str);
+ return zebra_static_route_leak(
+ vty, zvrf, zvrf, afi, safi, negate, dest_str, mask_str, src_str,
+ gate_str, ifname, flag_str, tag_str, distance_str, label_str);
}
MPLS_LABEL_HELPSTR)
{
return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, NULL, NULL, flag,
- tag_str, distance_str, vrf, label);
+ mask_str, NULL, NULL, NULL, flag, tag_str,
+ distance_str, vrf, label);
}
DEFPY(ip_route_blackhole_vrf,
* valid. Add an assert to make it happy
*/
assert(prefix);
- return zebra_static_route_leak(vty, zvrf, zvrf,
- AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, NULL, NULL, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(vty, zvrf, zvrf, AFI_IP, SAFI_UNICAST,
+ no, prefix, mask_str, NULL, NULL, NULL,
+ flag, tag_str, distance_str, label);
}
DEFPY(ip_route_address_interface,
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n",
- vrf);
+ vty_out(vty, "%% vrf %s is not defined\n", vrf);
return CMD_WARNING_CONFIG_FAILED;
}
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, gate_str, ifname, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label);
}
DEFPY(ip_route_address_interface_vrf,
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, gate_str, ifname, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label);
}
DEFPY(ip_route,
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n",
- vrf);
+ vty_out(vty, "%% vrf %s is not defined\n", vrf);
return CMD_WARNING_CONFIG_FAILED;
}
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, gate_str, ifname, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label);
}
DEFPY(ip_route_vrf,
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP, SAFI_UNICAST, no, prefix,
- mask_str, NULL, gate_str, ifname, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+ NULL, gate_str, ifname, flag, tag_str, distance_str, label);
}
/* New RIB. Detailed information for IPv4 route. */
vty_out(vty, " Last update ");
if (uptime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm->tm_hour,
- tm->tm_min, tm->tm_sec);
+ vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm->tm_yday,
- tm->tm_hour, tm->tm_min);
+ vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+ tm->tm_min);
else
vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
tm->tm_yday - ((tm->tm_yday / 7) * 7),
tm->tm_hour);
vty_out(vty, " ago\n");
- for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+ for (ALL_NEXTHOPS(re->ng, nexthop)) {
char addrstr[32];
vty_out(vty, " %c%s",
CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
- ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
- ? ' ' : '*'
+ ? CHECK_FLAG(nexthop->flags,
+ NEXTHOP_FLAG_DUPLICATE)
+ ? ' '
+ : '*'
: ' ',
nexthop->rparent ? " " : "");
}
if (uptime < ONE_DAY_SECOND)
- sprintf(buf, "%02d:%02d:%02d", tm->tm_hour,
- tm->tm_min, tm->tm_sec);
+ sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
else if (uptime < ONE_WEEK_SECOND)
- sprintf(buf, "%dd%02dh%02dm", tm->tm_yday,
- tm->tm_hour, tm->tm_min);
+ sprintf(buf, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+ tm->tm_min);
else
sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7,
tm->tm_yday - ((tm->tm_yday / 7) * 7),
json_object_string_add(json_route, "uptime", buf);
- for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+ for (ALL_NEXTHOPS(re->ng, nexthop)) {
json_nexthop = json_object_new_object();
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
struct vrf *vrf =
vrf_lookup_by_id(nexthop->vrf_id);
- json_object_string_add(json_nexthop,
- "vrf",
+ json_object_string_add(json_nexthop, "vrf",
vrf->name);
}
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
}
/* Nexthop information. */
- for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
- if (nexthop == re->nexthop) {
+ for (ALL_NEXTHOPS(re->ng, nexthop)) {
+ if (nexthop == re->ng.nexthop) {
/* Prefix information. */
len = vty_out(vty, "%c", zebra_route_char(re->type));
if (re->instance)
} else {
vty_out(vty, " %c%*c",
CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
- ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
- ? ' ' : '*'
+ ? CHECK_FLAG(nexthop->flags,
+ NEXTHOP_FLAG_DUPLICATE)
+ ? ' '
+ : '*'
: ' ',
len - 3 + (2 * nexthop_level(nexthop)), ' ');
}
dest = rib_dest_from_rnode(rn);
RNODE_FOREACH_RE (rn, re) {
- if (use_fib
- && re != dest->selected_fib)
+ if (use_fib && re != dest->selected_fib)
continue;
if (tag && re->tag != tag)
struct vrf *vrf;
struct zebra_vrf *zvrf;
- RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if ((zvrf = vrf->info) == NULL
|| (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
continue;
struct vrf *vrf;
struct zebra_vrf *zvrf;
- RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if ((zvrf = vrf->info) == NULL
|| (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
continue;
* In case of ECMP, count only once.
*/
cnt = 0;
- for (nexthop = re->nexthop; (!cnt && nexthop);
+ for (nexthop = re->ng.nexthop; (!cnt && nexthop);
nexthop = nexthop->next) {
cnt++;
rib_cnt[ZEBRA_ROUTE_TOTAL]++;
}
/* Write static route configuration. */
-int static_config(struct vty *vty, struct zebra_vrf *zvrf,
- afi_t afi, safi_t safi, const char *cmd)
+int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
+ safi_t safi, const char *cmd)
{
char spacing[100];
struct route_node *rn;
if ((stable = zvrf->stable[afi][safi]) == NULL)
return write;
- sprintf(spacing, "%s%s",
- (zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ",
+ sprintf(spacing, "%s%s", (zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ",
cmd);
for (rn = route_top(stable); rn; rn = srcdest_route_next(rn))
switch (si->type) {
case STATIC_IPV4_GATEWAY:
- vty_out(vty, " %s",
- inet_ntoa(si->addr.ipv4));
+ vty_out(vty, " %s", inet_ntoa(si->addr.ipv4));
break;
case STATIC_IPV6_GATEWAY:
vty_out(vty, " %s",
- inet_ntop(AF_INET6,
- &si->addr.ipv6, buf,
+ inet_ntop(AF_INET6, &si->addr.ipv6, buf,
sizeof buf));
break;
case STATIC_IFNAME:
break;
case STATIC_IPV4_GATEWAY_IFNAME:
vty_out(vty, " %s %s",
- inet_ntop(AF_INET,
- &si->addr.ipv4, buf,
+ inet_ntop(AF_INET, &si->addr.ipv4, buf,
sizeof buf),
si->ifname);
break;
case STATIC_IPV6_GATEWAY_IFNAME:
vty_out(vty, " %s %s",
- inet_ntop(AF_INET6,
- &si->addr.ipv6, buf,
+ inet_ntop(AF_INET6, &si->addr.ipv6, buf,
sizeof buf),
si->ifname);
break;
}
if (si->tag)
- vty_out(vty, " tag %" ROUTE_TAG_PRI,
- si->tag);
+ vty_out(vty, " tag %" ROUTE_TAG_PRI, si->tag);
- if (si->distance
- != ZEBRA_STATIC_DISTANCE_DEFAULT)
+ if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
vty_out(vty, " %d", si->distance);
if (si->nh_vrf_id != si->vrf_id) {
if (si->snh_label.num_labels)
vty_out(vty, " label %s",
mpls_label2str(si->snh_label.num_labels,
- si->snh_label.label,
- buf, sizeof buf, 0));
+ si->snh_label.label, buf,
+ sizeof buf, 0));
vty_out(vty, "\n");
MPLS_LABEL_HELPSTR)
{
return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, NULL, NULL, flag,
- tag_str, distance_str, vrf, label);
+ NULL, from_str, NULL, NULL, flag, tag_str,
+ distance_str, vrf, label);
}
DEFPY(ipv6_route_blackhole_vrf,
* valid. Add an assert to make it happy
*/
assert(prefix);
- return zebra_static_route_leak(vty, zvrf, zvrf,
- AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, NULL, NULL, flag,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+ from_str, NULL, NULL, flag, tag_str, distance_str, label);
}
DEFPY(ipv6_route_address_interface,
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n",
- vrf);
+ vty_out(vty, "%% vrf %s is not defined\n", vrf);
return CMD_WARNING_CONFIG_FAILED;
}
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, gate_str, ifname, NULL,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
}
DEFPY(ipv6_route_address_interface_vrf,
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, gate_str, ifname, NULL,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
}
DEFPY(ipv6_route,
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n",
- vrf);
+ vty_out(vty, "%% vrf %s is not defined\n", vrf);
return CMD_WARNING_CONFIG_FAILED;
}
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, gate_str, ifname, NULL,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
}
DEFPY(ipv6_route_vrf,
nh_zvrf = zvrf;
if (!nh_zvrf) {
- vty_out(vty, "%% nexthop vrf %s is not defined\n",
- nexthop_vrf);
+ vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
- return zebra_static_route_leak(vty, zvrf, nh_zvrf,
- AFI_IP6, SAFI_UNICAST, no, prefix_str,
- NULL, from_str, gate_str, ifname, NULL,
- tag_str, distance_str, label);
+ return zebra_static_route_leak(
+ vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+ from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
}
/*
continue;
vty_out(vty, "vrf %s ", zvrf_name(zvrf));
- if (zvrf_id(zvrf) == VRF_UNKNOWN)
+ if (zvrf_id(zvrf) == VRF_UNKNOWN || !zvrf_is_active(zvrf))
vty_out(vty, "inactive");
+ else if (zvrf_ns_name(zvrf))
+ vty_out(vty, "id %u netns %s", zvrf_id(zvrf),
+ zvrf_ns_name(zvrf));
else
vty_out(vty, "id %u table %u", zvrf_id(zvrf),
zvrf->table_id);
}
if (!uj)
- vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n",
- "VRF", "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
+ vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", "VRF",
+ "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
- RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
zvrf = vrf->info;
if (!zvrf)
continue;
"Work Queue\n"
"Time in milliseconds\n")
{
- uint32_t timer = strtoul(argv[2]->arg, NULL, 10);
- zebrad.ribq->spec.hold = timer;
+ uint32_t timer = strtoul(argv[2]->arg, NULL, 10);
+ zebrad.ribq->spec.hold = timer;
- return CMD_SUCCESS;
+ return CMD_SUCCESS;
}
DEFUN_HIDDEN (no_zebra_workqueue_timer,
"Work Queue\n"
"Time in milliseconds\n")
{
- zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME;
+ zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME;
- return CMD_SUCCESS;
+ return CMD_SUCCESS;
}
DEFUN (no_ip_zebra_import_table,
vty_out(vty, "zebra work-queue %u\n", zebrad.ribq->spec.hold);
if (zebrad.packets_to_process != ZEBRA_ZAPI_PACKETS_TO_PROCESS)
- vty_out(vty,
- "zebra zapi-packets %u\n", zebrad.packets_to_process);
+ vty_out(vty, "zebra zapi-packets %u\n",
+ zebrad.packets_to_process);
enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get();
vty_out(vty,
"VRF Installs Removals Updates Installs Removals\n");
- RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
struct zebra_vrf *zvrf = vrf->info;
vty_out(vty, "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64
install_element(CONFIG_NODE, &no_default_vrf_vni_mapping_cmd);
install_element(VRF_NODE, &vrf_vni_mapping_cmd);
install_element(VRF_NODE, &no_vrf_vni_mapping_cmd);
-
}