summaryrefslogtreecommitdiffstats
path: root/staticd/static_zebra.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-07-09 21:55:29 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2021-07-09 21:58:45 +0200
commit4067e951407bbbdcdb8f4edb9c64763cd777476d (patch)
tree75c13be9ee6a60f7da70edd4aa5eae570188d0fc /staticd/static_zebra.c
parentMerge pull request #8997 from donaldsharp/opaque_length (diff)
downloadfrr-4067e951407bbbdcdb8f4edb9c64763cd777476d.tar.xz
frr-4067e951407bbbdcdb8f4edb9c64763cd777476d.zip
staticd: simplify the northbound code
Add a couple of back pointers to static route/path/nexthop structures to simplify the NB code and save ~200 lines. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'staticd/static_zebra.c')
-rw-r--r--staticd/static_zebra.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index 40275908f..452b5c42a 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -261,9 +261,10 @@ static void static_nht_hash_free(void *data)
XFREE(MTYPE_TMP, nhtd);
}
-void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh,
- bool reg)
+void static_zebra_nht_register(struct static_nexthop *nh, bool reg)
{
+ struct static_path *pn = nh->pn;
+ struct route_node *rn = pn->rn;
struct static_nht_data *nhtd, lookup;
uint32_t cmd;
struct prefix p;
@@ -339,8 +340,10 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh,
* When nexthop gets updated via configuration then use the
* already registered NH and resend the route to zebra
*/
-int static_zebra_nh_update(struct route_node *rn, struct static_nexthop *nh)
+int static_zebra_nh_update(struct static_nexthop *nh)
{
+ struct static_path *pn = nh->pn;
+ struct route_node *rn = pn->rn;
struct static_nht_data *nhtd, lookup = {};
struct prefix p = {};
afi_t afi = AFI_IP;
@@ -381,25 +384,23 @@ int static_zebra_nh_update(struct route_node *rn, struct static_nexthop *nh)
return 0;
}
-extern void static_zebra_route_add(struct route_node *rn,
- struct static_path *pn, safi_t safi,
- bool install)
+extern void static_zebra_route_add(struct static_path *pn, bool install)
{
+ struct route_node *rn = pn->rn;
+ struct static_route_info *si = rn->info;
struct static_nexthop *nh;
const struct prefix *p, *src_pp;
struct zapi_nexthop *api_nh;
struct zapi_route api;
uint32_t nh_num = 0;
- struct stable_info *info;
p = src_pp = NULL;
srcdest_rnode_prefixes(rn, &p, &src_pp);
memset(&api, 0, sizeof(api));
- info = static_get_stable_info(rn);
- api.vrf_id = GET_STABLE_VRF_ID(info);
+ api.vrf_id = si->svrf->vrf->vrf_id;
api.type = ZEBRA_ROUTE_STATIC;
- api.safi = safi;
+ api.safi = si->safi;
memcpy(&api.prefix, p, sizeof(api.prefix));
if (src_pp) {