summaryrefslogtreecommitdiff
path: root/zebra/redistribute.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/redistribute.c')
-rw-r--r--zebra/redistribute.c137
1 files changed, 67 insertions, 70 deletions
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index c59ff1bbec..fdd2c8405f 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -94,7 +94,7 @@ static void zebra_redistribute_default(struct zserv *client, vrf_id_t vrf_id)
if (CHECK_FLAG(newre->flags, ZEBRA_FLAG_SELECTED))
zsend_redistribute_route(
ZEBRA_REDISTRIBUTE_ROUTE_ADD, client,
- &rn->p, NULL, newre);
+ rn, newre);
}
route_unlock_node(rn);
@@ -116,20 +116,17 @@ static void zebra_redistribute(struct zserv *client, int type,
for (rn = route_top(table); rn; rn = srcdest_route_next(rn))
RNODE_FOREACH_RE (rn, newre) {
- const struct prefix *dst_p, *src_p;
-
- srcdest_rnode_prefixes(rn, &dst_p, &src_p);
-
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug(
- "%s: client %s %pFX(%u) checking: selected=%d, type=%d, distance=%d, metric=%d zebra_check_addr=%d",
+ "%s: client %s %pRN(%u:%u) checking: selected=%d, type=%d, distance=%d, metric=%d zebra_check_addr=%d",
__func__,
- zebra_route_string(client->proto),
- dst_p, vrf_id,
- CHECK_FLAG(newre->flags,
- ZEBRA_FLAG_SELECTED),
+ zebra_route_string(client->proto), rn,
+ vrf_id, newre->instance,
+ !!CHECK_FLAG(newre->flags,
+ ZEBRA_FLAG_SELECTED),
newre->type, newre->distance,
- newre->metric, zebra_check_addr(dst_p));
+ newre->metric,
+ zebra_check_addr(&rn->p));
if (!CHECK_FLAG(newre->flags, ZEBRA_FLAG_SELECTED))
continue;
@@ -137,11 +134,11 @@ static void zebra_redistribute(struct zserv *client, int type,
&& (newre->type != type
|| newre->instance != instance)))
continue;
- if (!zebra_check_addr(dst_p))
+ if (!zebra_check_addr(&rn->p))
continue;
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
- client, dst_p, src_p, newre);
+ client, rn, newre);
}
}
@@ -149,23 +146,25 @@ static void zebra_redistribute(struct zserv *client, int type,
* Function to check if prefix is candidate for
* redistribute.
*/
-static bool zebra_redistribute_check(const struct route_entry *re,
- struct zserv *client,
- const struct prefix *p, int afi)
+static bool zebra_redistribute_check(const struct route_node *rn,
+ const struct route_entry *re,
+ struct zserv *client)
{
struct zebra_vrf *zvrf;
+ afi_t afi;
/* Process only if there is valid re */
if (!re)
return false;
+ afi = family2afi(rn->p.family);
zvrf = vrf_info_lookup(re->vrf_id);
if (re->vrf_id == VRF_DEFAULT && zvrf->table_id != re->table)
return false;
/* If default route and redistributed */
- if (is_default_prefix(p)
- && vrf_bitmap_check(client->redist_default[afi], re->vrf_id))
+ if (is_default_prefix(&rn->p) &&
+ vrf_bitmap_check(client->redist_default[afi], re->vrf_id))
return true;
/* If redistribute in enabled for zebra route all */
@@ -176,10 +175,13 @@ static bool zebra_redistribute_check(const struct route_entry *re,
* If multi-instance then check for route
* redistribution for given instance.
*/
- if (re->instance
- && redist_check_instance(&client->mi_redist[afi][re->type],
- re->instance))
- return true;
+ if (re->instance) {
+ if (redist_check_instance(&client->mi_redist[afi][re->type],
+ re->instance))
+ return true;
+ else
+ return false;
+ }
/* If redistribution is enabled for give route type. */
if (vrf_bitmap_check(client->redist[afi][re->type], re->vrf_id))
@@ -190,49 +192,42 @@ static bool zebra_redistribute_check(const struct route_entry *re,
/* Either advertise a route for redistribution to registered clients or */
/* withdraw redistribution if add cannot be done for client */
-void redistribute_update(const struct prefix *p, const struct prefix *src_p,
+void redistribute_update(const struct route_node *rn,
const struct route_entry *re,
const struct route_entry *prev_re)
{
struct listnode *node, *nnode;
struct zserv *client;
- int afi;
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug(
- "(%u:%u):%pFX: Redist update re %p (%s), old %p (%s)",
- re->vrf_id, re->table, p, re,
+ "(%u:%u):%pRN(%u): Redist update re %p (%s), old %p (%s)",
+ re->vrf_id, re->table, rn, re->instance, re,
zebra_route_string(re->type), prev_re,
prev_re ? zebra_route_string(prev_re->type) : "None");
- afi = family2afi(p->family);
- if (!afi) {
- flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF,
- "%s: Unknown AFI/SAFI prefix received", __func__);
- return;
- }
- if (!zebra_check_addr(p)) {
+ if (!zebra_check_addr(&rn->p)) {
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug("Redist update filter prefix %pFX", p);
+ zlog_debug("Redist update filter prefix %pRN", rn);
return;
}
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
- if (zebra_redistribute_check(re, client, p, afi)) {
+ if (zebra_redistribute_check(rn, re, client)) {
if (IS_ZEBRA_DEBUG_RIB) {
zlog_debug(
- "%s: client %s %pFX(%u:%u), type=%d, distance=%d, metric=%d",
+ "%s: client %s %pRN(%u:%u), type=%d, distance=%d, metric=%d",
__func__,
- zebra_route_string(client->proto), p,
+ zebra_route_string(client->proto), rn,
re->vrf_id, re->table, re->type,
re->distance, re->metric);
}
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
- client, p, src_p, re);
- } else if (zebra_redistribute_check(prev_re, client, p, afi))
+ client, rn, re);
+ } else if (zebra_redistribute_check(rn, prev_re, client))
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
- client, p, src_p, prev_re);
+ client, rn, prev_re);
}
}
@@ -244,13 +239,12 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
* may have seen a redist for 'old_re', but will not see
* the redist for 'new_re'.
*/
-void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
+void redistribute_delete(const struct route_node *rn,
const struct route_entry *old_re,
const struct route_entry *new_re)
{
struct listnode *node, *nnode;
struct zserv *client;
- int afi;
vrf_id_t vrfid;
if (old_re)
@@ -261,27 +255,34 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
return;
if (IS_ZEBRA_DEBUG_RIB) {
- zlog_debug("%u:%pFX: Redist del: re %p (%s), new re %p (%s)",
- vrfid, p, old_re,
- old_re ? zebra_route_string(old_re->type) : "None",
- new_re,
- new_re ? zebra_route_string(new_re->type) : "None");
- }
+ uint8_t old_inst, new_inst;
+ uint32_t table = 0;
- afi = family2afi(p->family);
- if (!afi) {
- flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF,
- "%s: Unknown AFI/SAFI prefix received",
- __func__);
- return;
+ old_inst = new_inst = 0;
+
+ if (old_re) {
+ old_inst = old_re->instance;
+ table = old_re->table;
+ }
+ if (new_re) {
+ new_inst = new_re->instance;
+ table = new_re->table;
+ }
+
+ zlog_debug(
+ "%u:%u%pRN: Redist del: re %p (%u:%s), new re %p (%u:%s)",
+ vrfid, table, rn, old_re, old_inst,
+ old_re ? zebra_route_string(old_re->type) : "None",
+ new_re, new_inst,
+ new_re ? zebra_route_string(new_re->type) : "None");
}
/* Skip invalid (e.g. linklocal) prefix */
- if (!zebra_check_addr(p)) {
+ if (!zebra_check_addr(&rn->p)) {
if (IS_ZEBRA_DEBUG_RIB) {
zlog_debug(
- "%u:%pFX: Redist del old: skipping invalid prefix",
- vrfid, p);
+ "%u:%pRN: Redist del old: skipping invalid prefix",
+ vrfid, rn);
}
return;
}
@@ -294,13 +295,13 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
* Skip this client if it will receive an update for the
* 'new' re
*/
- if (zebra_redistribute_check(new_re, client, p, afi))
+ if (zebra_redistribute_check(rn, new_re, client))
continue;
/* Send a delete for the 'old' re to any subscribed client. */
- if (zebra_redistribute_check(old_re, client, p, afi))
+ if (zebra_redistribute_check(rn, old_re, client))
zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
- client, p, src_p, old_re);
+ client, rn, old_re);
}
}
@@ -533,14 +534,12 @@ void zebra_interface_address_add_update(struct interface *ifp,
{
struct listnode *node, *nnode;
struct zserv *client;
- struct prefix *p;
- if (IS_ZEBRA_DEBUG_EVENT) {
- p = ifc->address;
+ if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
"MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %pFX on %s vrf %s(%u)",
- p, ifp->name, ifp->vrf->name, ifp->vrf->vrf_id);
- }
+ ifc->address, ifp->name, ifp->vrf->name,
+ ifp->vrf->vrf_id);
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
flog_warn(
@@ -570,14 +569,12 @@ void zebra_interface_address_delete_update(struct interface *ifp,
{
struct listnode *node, *nnode;
struct zserv *client;
- struct prefix *p;
- if (IS_ZEBRA_DEBUG_EVENT) {
- p = ifc->address;
+ if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
"MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %pFX on %s vrf %s(%u)",
- p, ifp->name, ifp->vrf->name, ifp->vrf->vrf_id);
- }
+ ifc->address, ifp->name, ifp->vrf->name,
+ ifp->vrf->vrf_id);
zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 0);