summaryrefslogtreecommitdiff
path: root/staticd
diff options
context:
space:
mode:
Diffstat (limited to 'staticd')
-rw-r--r--staticd/static_nht.c34
-rw-r--r--staticd/static_routes.c63
-rw-r--r--staticd/static_routes.h1
-rw-r--r--staticd/static_zebra.c2
4 files changed, 31 insertions, 69 deletions
diff --git a/staticd/static_nht.c b/staticd/static_nht.c
index ebc5ea16cc..6be598434d 100644
--- a/staticd/static_nht.c
+++ b/staticd/static_nht.c
@@ -18,8 +18,7 @@
#include "static_nht.h"
static void static_nht_update_path(struct static_path *pn, struct prefix *nhp,
- uint32_t nh_num, vrf_id_t nh_vrf_id,
- struct vrf *vrf)
+ uint32_t nh_num, vrf_id_t nh_vrf_id)
{
struct static_nexthop *nh;
@@ -49,18 +48,13 @@ static void static_nht_update_path(struct static_path *pn, struct prefix *nhp,
static void static_nht_update_safi(struct prefix *sp, struct prefix *nhp,
uint32_t nh_num, afi_t afi, safi_t safi,
- struct vrf *vrf, vrf_id_t nh_vrf_id)
+ struct static_vrf *svrf, vrf_id_t nh_vrf_id)
{
struct route_table *stable;
- struct static_vrf *svrf;
struct route_node *rn;
struct static_path *pn;
struct static_route_info *si;
- svrf = vrf->info;
- if (!svrf)
- return;
-
stable = static_vrf_static_table(afi, safi, svrf);
if (!stable)
return;
@@ -71,7 +65,7 @@ static void static_nht_update_safi(struct prefix *sp, struct prefix *nhp,
si = static_route_info_from_rnode(rn);
frr_each(static_path_list, &si->path_list, pn) {
static_nht_update_path(pn, nhp, nh_num,
- nh_vrf_id, vrf);
+ nh_vrf_id);
}
route_unlock_node(rn);
}
@@ -83,7 +77,7 @@ static void static_nht_update_safi(struct prefix *sp, struct prefix *nhp,
if (!si)
continue;
frr_each(static_path_list, &si->path_list, pn) {
- static_nht_update_path(pn, nhp, nh_num, nh_vrf_id, vrf);
+ static_nht_update_path(pn, nhp, nh_num, nh_vrf_id);
}
}
}
@@ -91,29 +85,23 @@ static void static_nht_update_safi(struct prefix *sp, struct prefix *nhp,
void static_nht_update(struct prefix *sp, struct prefix *nhp, uint32_t nh_num,
afi_t afi, safi_t safi, vrf_id_t nh_vrf_id)
{
+ struct static_vrf *svrf;
- struct vrf *vrf;
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- static_nht_update_safi(sp, nhp, nh_num, afi, safi, vrf,
+ RB_FOREACH (svrf, svrf_name_head, &svrfs)
+ static_nht_update_safi(sp, nhp, nh_num, afi, safi, svrf,
nh_vrf_id);
}
static void static_nht_reset_start_safi(struct prefix *nhp, afi_t afi,
- safi_t safi, struct vrf *vrf,
+ safi_t safi, struct static_vrf *svrf,
vrf_id_t nh_vrf_id)
{
- struct static_vrf *svrf;
struct route_table *stable;
struct static_nexthop *nh;
struct static_path *pn;
struct route_node *rn;
struct static_route_info *si;
- svrf = vrf->info;
- if (!svrf)
- return;
-
stable = static_vrf_static_table(afi, safi, svrf);
if (!stable)
return;
@@ -153,10 +141,10 @@ static void static_nht_reset_start_safi(struct prefix *nhp, afi_t afi,
void static_nht_reset_start(struct prefix *nhp, afi_t afi, safi_t safi,
vrf_id_t nh_vrf_id)
{
- struct vrf *vrf;
+ struct static_vrf *svrf;
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- static_nht_reset_start_safi(nhp, afi, safi, vrf, nh_vrf_id);
+ RB_FOREACH (svrf, svrf_name_head, &svrfs)
+ static_nht_reset_start_safi(nhp, afi, safi, svrf, nh_vrf_id);
}
static void static_nht_mark_state_safi(struct prefix *sp, afi_t afi,
diff --git a/staticd/static_routes.c b/staticd/static_routes.c
index db3fc32fd8..cba38183bb 100644
--- a/staticd/static_routes.c
+++ b/staticd/static_routes.c
@@ -87,11 +87,6 @@ void zebra_stable_node_cleanup(struct route_table *table,
/* Install static path into rib. */
void static_install_path(struct static_path *pn)
{
- struct static_nexthop *nh;
-
- frr_each(static_nexthop_list, &pn->nexthop_list, nh)
- static_zebra_nht_register(nh, true);
-
if (static_nexthop_list_count(&pn->nexthop_list))
static_zebra_route_add(pn, true);
}
@@ -377,6 +372,17 @@ void static_install_nexthop(struct static_nexthop *nh)
}
}
+void static_uninstall_nexthop(struct static_nexthop *nh)
+{
+ struct static_path *pn = nh->pn;
+
+ if (nh->nh_vrf_id == VRF_UNKNOWN)
+ return;
+
+ static_zebra_nht_register(nh, false);
+ static_uninstall_path(pn);
+}
+
void static_delete_nexthop(struct static_nexthop *nh)
{
struct static_path *pn = nh->pn;
@@ -386,17 +392,8 @@ void static_delete_nexthop(struct static_nexthop *nh)
/* Remove BFD session/configuration if any. */
bfd_sess_free(&nh->bsp);
- if (nh->nh_vrf_id == VRF_UNKNOWN)
- goto EXIT;
+ static_uninstall_nexthop(nh);
- static_zebra_nht_register(nh, false);
- /*
- * If we have other si nodes then route replace
- * else delete the route
- */
- static_uninstall_path(pn);
-
-EXIT:
route_unlock_node(rn);
/* Free static route configuration. */
XFREE(MTYPE_STATIC_NEXTHOP, nh);
@@ -490,7 +487,6 @@ static void static_fixup_vrf(struct vrf *vrf, struct route_table *stable,
continue;
nh->nh_vrf_id = vrf->vrf_id;
- nh->nh_registered = false;
if (nh->ifname[0]) {
ifp = if_lookup_by_name(nh->ifname,
nh->nh_vrf_id);
@@ -500,7 +496,7 @@ static void static_fixup_vrf(struct vrf *vrf, struct route_table *stable,
continue;
}
- static_install_path(pn);
+ static_install_nexthop(nh);
}
}
}
@@ -518,8 +514,6 @@ static void static_fixup_vrf(struct vrf *vrf, struct route_table *stable,
static void static_enable_vrf(struct route_table *stable, afi_t afi, safi_t safi)
{
struct route_node *rn;
- struct static_nexthop *nh;
- struct interface *ifp;
struct static_path *pn;
struct static_route_info *si;
@@ -527,22 +521,8 @@ static void static_enable_vrf(struct route_table *stable, afi_t afi, safi_t safi
si = static_route_info_from_rnode(rn);
if (!si)
continue;
- frr_each(static_path_list, &si->path_list, pn) {
- frr_each(static_nexthop_list, &pn->nexthop_list, nh) {
- if (nh->nh_vrf_id == VRF_UNKNOWN)
- continue;
- if (nh->ifname[0]) {
- ifp = if_lookup_by_name(nh->ifname,
- nh->nh_vrf_id);
- if (ifp)
- nh->ifindex = ifp->ifindex;
- else
- continue;
- }
-
- static_install_path(pn);
- }
- }
+ frr_each(static_path_list, &si->path_list, pn)
+ static_install_path(pn);
}
}
@@ -604,7 +584,7 @@ static void static_cleanup_vrf(struct vrf *vrf, struct route_table *stable,
if (strcmp(vrf->name, nh->nh_vrfname) != 0)
continue;
- static_uninstall_path(pn);
+ static_uninstall_nexthop(nh);
nh->nh_vrf_id = VRF_UNKNOWN;
nh->ifindex = IFINDEX_INTERNAL;
@@ -625,7 +605,6 @@ static void static_disable_vrf(struct route_table *stable,
afi_t afi, safi_t safi)
{
struct route_node *rn;
- struct static_nexthop *nh;
struct static_path *pn;
struct static_route_info *si;
@@ -633,14 +612,8 @@ static void static_disable_vrf(struct route_table *stable,
si = static_route_info_from_rnode(rn);
if (!si)
continue;
- frr_each(static_path_list, &si->path_list, pn) {
- frr_each(static_nexthop_list, &pn->nexthop_list, nh) {
- if (nh->nh_vrf_id == VRF_UNKNOWN)
- continue;
-
- static_uninstall_path(pn);
- }
- }
+ frr_each(static_path_list, &si->path_list, pn)
+ static_uninstall_path(pn);
}
}
diff --git a/staticd/static_routes.h b/staticd/static_routes.h
index d88ed29364..2e2e4986c3 100644
--- a/staticd/static_routes.h
+++ b/staticd/static_routes.h
@@ -207,6 +207,7 @@ static_add_nexthop(struct static_path *pn, enum static_nh_type type,
struct ipaddr *ipaddr, const char *ifname,
const char *nh_vrf, uint32_t color);
extern void static_install_nexthop(struct static_nexthop *nh);
+extern void static_uninstall_nexthop(struct static_nexthop *nh);
extern void static_delete_nexthop(struct static_nexthop *nh);
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index a635cccb09..c4efc14a9d 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -390,7 +390,7 @@ extern void static_zebra_route_add(struct static_path *pn, bool install)
struct zapi_route api;
uint32_t nh_num = 0;
- if (!si->svrf->vrf)
+ if (!si->svrf->vrf || si->svrf->vrf->vrf_id == VRF_UNKNOWN)
return;
p = src_pp = NULL;