mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 00:56:19 +00:00
zebra: Consolidate static_config_ipv[4|6] into one function.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
c5761c2b5b
commit
9de498ecad
@ -2317,49 +2317,49 @@ DEFUN (show_ip_route_vrf_all_summary_prefix,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write IPv4 static route configuration. */
|
/* Write static route configuration. */
|
||||||
static int
|
static int
|
||||||
static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
|
static_config (struct vty *vty, afi_t afi, safi_t safi, const char *cmd)
|
||||||
{
|
{
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct static_route *si;
|
struct static_route *si;
|
||||||
struct route_table *stable;
|
struct route_table *stable;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
struct zebra_vrf *zvrf;
|
struct zebra_vrf *zvrf;
|
||||||
char buf[BUFSIZ];
|
char buf[SRCDEST2STR_BUFFER];
|
||||||
int write =0;
|
int write =0;
|
||||||
|
|
||||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
|
||||||
{
|
{
|
||||||
if (!(zvrf = vrf->info))
|
if (!(zvrf = vrf->info))
|
||||||
continue;
|
continue;
|
||||||
if ((stable = zvrf->stable[AFI_IP][safi]) == NULL)
|
if ((stable = zvrf->stable[afi][safi]) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (rn = route_top (stable); rn; rn = route_next (rn))
|
for (rn = route_top (stable); rn; rn = srcdest_route_next (rn))
|
||||||
for (si = rn->info; si; si = si->next)
|
for (si = rn->info; si; si = si->next)
|
||||||
{
|
{
|
||||||
vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf));
|
vty_out (vty, "%s %s", cmd, srcdest_rnode2str (rn, buf, sizeof buf));
|
||||||
|
|
||||||
switch (si->type)
|
switch (si->type)
|
||||||
{
|
{
|
||||||
case STATIC_IPV4_GATEWAY:
|
case STATIC_IPV4_GATEWAY:
|
||||||
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
|
vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
|
||||||
break;
|
break;
|
||||||
|
case STATIC_IPV6_GATEWAY:
|
||||||
|
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
|
||||||
|
break;
|
||||||
case STATIC_IFINDEX:
|
case STATIC_IFINDEX:
|
||||||
vty_out (vty, " %s", si->ifname);
|
vty_out (vty, " %s", si->ifname);
|
||||||
break;
|
break;
|
||||||
case STATIC_BLACKHOLE:
|
case STATIC_BLACKHOLE:
|
||||||
vty_out (vty, " Null0");
|
vty_out (vty, " Null0");
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_GATEWAY:
|
case STATIC_IPV6_GATEWAY_IFINDEX:
|
||||||
vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
|
vty_out (vty, " %s %s",
|
||||||
break;
|
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
|
||||||
case STATIC_IPV6_GATEWAY_IFINDEX:
|
ifindex2ifname (si->ifindex, si->vrf_id));
|
||||||
vty_out (vty, " %s %s",
|
break;
|
||||||
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
|
|
||||||
ifindex2ifname (si->ifindex, si->vrf_id));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flags are incompatible with STATIC_BLACKHOLE */
|
/* flags are incompatible with STATIC_BLACKHOLE */
|
||||||
@ -2379,7 +2379,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
|
|||||||
vty_out (vty, " %d", si->distance);
|
vty_out (vty, " %d", si->distance);
|
||||||
|
|
||||||
if (si->vrf_id != VRF_DEFAULT)
|
if (si->vrf_id != VRF_DEFAULT)
|
||||||
vty_out (vty, " vrf %s", zvrf ? zvrf_name (zvrf) : "");
|
vty_out (vty, " vrf %s", zvrf_name (zvrf));
|
||||||
|
|
||||||
/* Label information */
|
/* Label information */
|
||||||
if (si->snh_label.num_labels)
|
if (si->snh_label.num_labels)
|
||||||
@ -3843,85 +3843,6 @@ DEFUN (show_ipv6_route_vrf_all_summary_prefix,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write IPv6 static route configuration. */
|
|
||||||
static int
|
|
||||||
static_config_ipv6 (struct vty *vty)
|
|
||||||
{
|
|
||||||
struct route_node *rn;
|
|
||||||
struct static_route *si;
|
|
||||||
int write = 0;
|
|
||||||
char buf[SRCDEST2STR_BUFFER];
|
|
||||||
struct route_table *stable;
|
|
||||||
struct vrf *vrf;
|
|
||||||
struct zebra_vrf *zvrf;
|
|
||||||
|
|
||||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
|
|
||||||
{
|
|
||||||
if (!(zvrf = vrf->info))
|
|
||||||
continue;
|
|
||||||
if ((stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (rn = route_top (stable); rn; rn = srcdest_route_next (rn))
|
|
||||||
for (si = rn->info; si; si = si->next)
|
|
||||||
{
|
|
||||||
vty_out (vty, "ipv6 route %s", srcdest_rnode2str (rn, buf, sizeof buf));
|
|
||||||
|
|
||||||
switch (si->type)
|
|
||||||
{
|
|
||||||
case STATIC_IPV4_GATEWAY:
|
|
||||||
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, BUFSIZ));
|
|
||||||
break;
|
|
||||||
case STATIC_IFINDEX:
|
|
||||||
vty_out (vty, " %s", si->ifname);
|
|
||||||
break;
|
|
||||||
case STATIC_BLACKHOLE:
|
|
||||||
vty_out (vty, " Null0" );
|
|
||||||
break;
|
|
||||||
case STATIC_IPV6_GATEWAY_IFINDEX:
|
|
||||||
vty_out (vty, " %s %s",
|
|
||||||
inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
|
|
||||||
ifindex2ifname (si->ifindex, si->vrf_id));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flags are incompatible with STATIC_BLACKHOLE */
|
|
||||||
if (si->type != STATIC_BLACKHOLE)
|
|
||||||
{
|
|
||||||
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
|
|
||||||
vty_out (vty, " %s", "reject");
|
|
||||||
if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
|
|
||||||
vty_out (vty, " %s", "blackhole");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (si->tag)
|
|
||||||
vty_out (vty, " tag %"ROUTE_TAG_PRI, si->tag);
|
|
||||||
|
|
||||||
if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
|
|
||||||
vty_out (vty, " %d", si->distance);
|
|
||||||
|
|
||||||
if (si->vrf_id != VRF_DEFAULT)
|
|
||||||
{
|
|
||||||
vty_out (vty, " vrf %s", zvrf_name (zvrf));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Label information */
|
|
||||||
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));
|
|
||||||
|
|
||||||
vty_out (vty, "%s", VTY_NEWLINE);
|
|
||||||
|
|
||||||
write = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return write;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (allow_external_route_update,
|
DEFUN (allow_external_route_update,
|
||||||
allow_external_route_update_cmd,
|
allow_external_route_update_cmd,
|
||||||
"allow-external-route-update",
|
"allow-external-route-update",
|
||||||
@ -3978,9 +3899,9 @@ zebra_ip_config (struct vty *vty)
|
|||||||
{
|
{
|
||||||
int write = 0;
|
int write = 0;
|
||||||
|
|
||||||
write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
|
write += static_config (vty, AFI_IP, SAFI_UNICAST, "ip route");
|
||||||
write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
|
write += static_config (vty, AFI_IP, SAFI_MULTICAST, "ip mroute");
|
||||||
write += static_config_ipv6 (vty);
|
write += static_config (vty, AFI_IP6, SAFI_UNICAST, "ipv6 route");
|
||||||
|
|
||||||
write += zebra_import_table_config (vty);
|
write += zebra_import_table_config (vty);
|
||||||
return write;
|
return write;
|
||||||
|
Loading…
Reference in New Issue
Block a user