#include "static_zebra.h"
/* Install static route into rib. */
-static void static_install_route(struct route_node *rn, safi_t safi)
+static void static_install_route(struct route_node *rn,
+ struct static_route *si_changed, safi_t safi)
{
struct static_route *si;
si = rn->info;
if (si)
- static_zebra_route_add(rn, si->vrf_id, safi, true);
+ static_zebra_route_add(rn, si_changed, si->vrf_id, safi, true);
}
/* Uninstall static route from RIB. */
static void static_uninstall_route(vrf_id_t vrf_id, safi_t safi,
- struct route_node *rn)
+ struct route_node *rn,
+ struct static_route *si_changed)
{
if (rn->info)
- static_zebra_route_add(rn, vrf_id, safi, true);
+ static_zebra_route_add(rn, si_changed, vrf_id, safi, true);
else
- static_zebra_route_add(rn, vrf_id, safi, false);
+ static_zebra_route_add(rn, si_changed, vrf_id, safi, false);
}
int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p,
/* check whether interface exists in system & install if it does */
if (!ifname)
- static_install_route(rn, safi);
+ static_install_route(rn, si, safi);
else {
struct interface *ifp;
ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
if (ifp && ifp->ifindex != IFINDEX_INTERNAL) {
si->ifindex = ifp->ifindex;
- static_install_route(rn, safi);
+ static_install_route(rn, si, safi);
} else
zlog_warn("Static Route using %s interface not installed because the interface does not exist in specified vrf",
ifname);
* If we have other si nodes then route replace
* else delete the route
*/
- static_uninstall_route(si->vrf_id, safi, rn);
+ static_uninstall_route(si->vrf_id, safi, rn, si);
route_unlock_node(rn);
/* Free static route configuration. */
}
}
- static_install_route(rn, safi);
+ static_install_route(rn, si, safi);
}
}
}
}
if (install)
- static_install_route(rn, safi);
+ static_install_route(rn, si, safi);
}
}
}
if (install)
- static_install_route(rn, safi);
+ static_install_route(rn, si, safi);
}
}
if (strcmp(svrf->vrf->name, si->nh_vrfname) != 0)
continue;
- static_uninstall_route(si->vrf_id, safi, rn);
+ static_uninstall_route(si->vrf_id, safi, rn, si);
}
}
}
for (rn = route_top(stable); rn; rn = route_next(rn))
for (si = rn->info; si; si = si->next)
- static_uninstall_route(si->vrf_id, safi, rn);
+ static_uninstall_route(si->vrf_id, safi, rn, si);
}
/*
si->nh_registered = reg;
}
-extern void static_zebra_route_add(struct route_node *rn, vrf_id_t vrf_id,
- safi_t safi, bool install)
+extern void static_zebra_route_add(struct route_node *rn,
+ struct static_route *si_changed,
+ vrf_id_t vrf_id, safi_t safi, bool install)
{
struct static_route *si = rn->info;
const struct prefix *p, *src_pp;
SET_FLAG(api.message, ZAPI_MESSAGE_SRCPFX);
memcpy(&api.src_prefix, src_pp, sizeof(api.src_prefix));
}
-
+ SET_FLAG(api.flags, ZEBRA_FLAG_RR_USE_DISTANCE);
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ if (si_changed->distance) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
+ api.distance = si_changed->distance;
+ }
+ if (si_changed->tag) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
+ api.tag = si_changed->tag;
+ }
+ api.tableid = si_changed->table_id;
+ zlog_debug("Distance sent down: %d %d", si_changed->distance, install);
for (/*loaded above*/; si; si = si->next) {
api_nh = &api.nexthops[nh_num];
if (si->nh_vrf_id == VRF_UNKNOWN)
continue;
- /*
- * If we create a ecmp static route the
- * last distance and tag entered wins. Why because
- * this cli choosen sucks
- */
- if (si->distance) {
- SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
- api.distance = si->distance;
- }
- if (si->tag) {
- SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
- api.tag = si->tag;
- }
-
- api.tableid = si->table_id;
+ if (si->distance != si_changed->distance)
+ continue;
api_nh->vrf_id = si->nh_vrf_id;
switch (si->type) {