zebra: Refactor 'struct rib' to be 'struct route_entry'

The 'struct rib' data structure is missnamed.  It really
is a 'struct route_entry' as part of the 'struct route_node'.
We have 1 'struct route_entry' per route src.  As such
1 route node can have multiple route entries if multiple
protocols attempt to install the same route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-06-01 07:26:25 -04:00
parent f0683d2227
commit f0f77c9a59
29 changed files with 1058 additions and 1073 deletions

View File

@ -252,7 +252,7 @@ rnh table:
struct rnh
{
u_char flags;
struct rib *state;
struct route_entry *state;
struct list *client_list;
struct route_node *node;
};

View File

@ -31,7 +31,7 @@
#include "zebra/rib.h"
int kernel_route_rib (struct prefix *a, struct prefix *b,
struct rib *old, struct rib *new) { return 0; }
struct route_entry *old, struct route_entry *new) { return 0; }
int kernel_address_add_ipv4 (struct interface *a, struct connected *b)
{

View File

@ -79,7 +79,7 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id)
struct prefix p;
struct route_table *table;
struct route_node *rn;
struct rib *newrib;
struct route_entry *newre;
for (afi = AFI_IP; afi <= AFI_IP6; afi++)
{
@ -95,10 +95,10 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id)
if (! rn)
continue;
RNODE_FOREACH_RIB (rn, newrib)
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
&& newrib->distance != DISTANCE_INFINITY)
zsend_redistribute_route (1, client, &rn->p, NULL, newrib);
RNODE_FOREACH_RE (rn, newre)
if (CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED)
&& newre->distance != DISTANCE_INFINITY)
zsend_redistribute_route (1, client, &rn->p, NULL, newre);
route_unlock_node (rn);
}
@ -108,7 +108,7 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id)
static void
zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t vrf_id, int afi)
{
struct rib *newrib;
struct route_entry *newre;
struct route_table *table;
struct route_node *rn;
@ -117,7 +117,7 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v
return;
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
RNODE_FOREACH_RE (rn, newre)
{
struct prefix *dst_p, *src_p;
srcdest_rnode_prefixes(rn, &dst_p, &src_p);
@ -125,21 +125,21 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, "
"zebra_check_addr=%d", __func__,
CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED),
newrib->type, newrib->distance,
CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED),
newre->type, newre->distance,
zebra_check_addr (dst_p));
if (! CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED))
if (! CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED))
continue;
if ((type != ZEBRA_ROUTE_ALL &&
(newrib->type != type || newrib->instance != instance)))
(newre->type != type || newre->instance != instance)))
continue;
if (newrib->distance == DISTANCE_INFINITY)
if (newre->distance == DISTANCE_INFINITY)
continue;
if (! zebra_check_addr (dst_p))
continue;
zsend_redistribute_route (1, client, dst_p, src_p, newrib);
zsend_redistribute_route (1, client, dst_p, src_p, newre);
}
}
@ -147,7 +147,7 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v
/* withdraw redistribution if add cannot be done for client */
void
redistribute_update (struct prefix *p, struct prefix *src_p,
struct rib *rib, struct rib *prev_rib)
struct route_entry *re, struct route_entry *prev_re)
{
struct listnode *node, *nnode;
struct zserv *client;
@ -158,9 +158,9 @@ redistribute_update (struct prefix *p, struct prefix *src_p,
if (IS_ZEBRA_DEBUG_RIB)
{
inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
zlog_debug ("%u:%s/%d: Redist update rib %p (type %d), old %p (type %d)",
rib->vrf_id, buf, p->prefixlen, rib, rib->type,
prev_rib, prev_rib ? prev_rib->type : -1);
zlog_debug ("%u:%s/%d: Redist update re %p (type %d), old %p (type %d)",
re->vrf_id, buf, p->prefixlen, re, re->type,
prev_re, prev_re ? prev_re->type : -1);
}
afi = family2afi(p->family);
@ -174,33 +174,33 @@ redistribute_update (struct prefix *p, struct prefix *src_p,
{
send_redistribute = 0;
if (is_default (p) && vrf_bitmap_check (client->redist_default, rib->vrf_id))
if (is_default (p) && vrf_bitmap_check (client->redist_default, re->vrf_id))
send_redistribute = 1;
else if (vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id))
else if (vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id))
send_redistribute = 1;
else if (rib->instance && redist_check_instance (&client->mi_redist[afi][rib->type],
rib->instance))
else if (re->instance && redist_check_instance (&client->mi_redist[afi][re->type],
re->instance))
send_redistribute = 1;
else if (vrf_bitmap_check (client->redist[afi][rib->type], rib->vrf_id))
else if (vrf_bitmap_check (client->redist[afi][re->type], re->vrf_id))
send_redistribute = 1;
if (send_redistribute)
{
zsend_redistribute_route (1, client, p, src_p, rib);
zsend_redistribute_route (1, client, p, src_p, re);
}
else if (prev_rib &&
((rib->instance &&
redist_check_instance(&client->mi_redist[afi][prev_rib->type],
rib->instance)) ||
vrf_bitmap_check (client->redist[afi][prev_rib->type], rib->vrf_id)))
else if (prev_re &&
((re->instance &&
redist_check_instance(&client->mi_redist[afi][prev_re->type],
re->instance)) ||
vrf_bitmap_check (client->redist[afi][prev_re->type], re->vrf_id)))
{
zsend_redistribute_route (0, client, p, src_p, prev_rib);
zsend_redistribute_route (0, client, p, src_p, prev_re);
}
}
}
void
redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib)
redistribute_delete (struct prefix *p, struct prefix *src_p, struct route_entry *re)
{
struct listnode *node, *nnode;
struct zserv *client;
@ -210,12 +210,12 @@ redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib)
if (IS_ZEBRA_DEBUG_RIB)
{
inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
zlog_debug ("%u:%s/%d: Redist delete rib %p (type %d)",
rib->vrf_id, buf, p->prefixlen, rib, rib->type);
zlog_debug ("%u:%s/%d: Redist delete re %p (type %d)",
re->vrf_id, buf, p->prefixlen, re, re->type);
}
/* Add DISTANCE_INFINITY check. */
if (rib->distance == DISTANCE_INFINITY)
if (re->distance == DISTANCE_INFINITY)
return;
afi = family2afi(p->family);
@ -228,14 +228,14 @@ redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib)
for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
{
if ((is_default (p) &&
vrf_bitmap_check (client->redist_default, rib->vrf_id)) ||
vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id) ||
(rib->instance &&
redist_check_instance(&client->mi_redist[afi][rib->type],
rib->instance)) ||
vrf_bitmap_check (client->redist[afi][rib->type], rib->vrf_id))
vrf_bitmap_check (client->redist_default, re->vrf_id)) ||
vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id) ||
(re->instance &&
redist_check_instance(&client->mi_redist[afi][re->type],
re->instance)) ||
vrf_bitmap_check (client->redist[afi][re->type], re->vrf_id))
{
zsend_redistribute_route (0, client, p, src_p, rib);
zsend_redistribute_route (0, client, p, src_p, re);
}
}
}
@ -490,18 +490,18 @@ zebra_interface_vrf_update_add (struct interface *ifp, vrf_id_t old_vrf_id)
}
int
zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char *rmap_name)
zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, const char *rmap_name)
{
struct rib *newrib;
struct rib *same;
struct route_entry *newre;
struct route_entry *same;
struct prefix p;
struct nexthop *nhop;
union g_addr *gate;
route_map_result_t ret = RMAP_MATCH;
if (rmap_name)
ret = zebra_import_table_route_map_check (AFI_IP, rib->type, &rn->p, rib->nexthop, rib->vrf_id,
rib->tag, rmap_name);
ret = zebra_import_table_route_map_check (AFI_IP, re->type, &rn->p, re->nexthop, re->vrf_id,
re->tag, rmap_name);
if (ret == RMAP_MATCH)
{
@ -511,13 +511,13 @@ zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char
p.prefixlen = rn->p.prefixlen;
p.u.prefix4 = rn->p.u.prefix4;
RNODE_FOREACH_RIB (rn, same)
RNODE_FOREACH_RE (rn, same)
{
if (CHECK_FLAG (same->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (same->status, ROUTE_ENTRY_REMOVED))
continue;
if (same->type == rib->type && same->instance == rib->instance
&& same->table == rib->table
if (same->type == re->type && same->instance == re->instance
&& same->table == re->table
&& same->type != ZEBRA_ROUTE_CONNECT)
break;
}
@ -526,51 +526,51 @@ zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char
zebra_del_import_table_entry (rn, same);
if (rib->nexthop_num == 1)
if (re->nexthop_num == 1)
{
nhop = rib->nexthop;
nhop = re->nexthop;
if (nhop->type == NEXTHOP_TYPE_IFINDEX)
gate = NULL;
else
gate = (union g_addr *)&nhop->gate.ipv4;
rib_add (AFI_IP, SAFI_UNICAST, rib->vrf_id, ZEBRA_ROUTE_TABLE,
rib->table, 0, &p, NULL, gate, (union g_addr *)&nhop->src.ipv4,
rib_add (AFI_IP, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE,
re->table, 0, &p, NULL, gate, (union g_addr *)&nhop->src.ipv4,
nhop->ifindex, zebrad.rtm_table_default,
rib->metric, rib->mtu,
zebra_import_table_distance[AFI_IP][rib->table]);
re->metric, re->mtu,
zebra_import_table_distance[AFI_IP][re->table]);
}
else if (rib->nexthop_num > 1)
else if (re->nexthop_num > 1)
{
newrib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
newrib->type = ZEBRA_ROUTE_TABLE;
newrib->distance = zebra_import_table_distance[AFI_IP][rib->table];
newrib->flags = rib->flags;
newrib->metric = rib->metric;
newrib->mtu = rib->mtu;
newrib->table = zebrad.rtm_table_default;
newrib->nexthop_num = 0;
newrib->uptime = time(NULL);
newrib->instance = rib->table;
newre = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
newre->type = ZEBRA_ROUTE_TABLE;
newre->distance = zebra_import_table_distance[AFI_IP][re->table];
newre->flags = re->flags;
newre->metric = re->metric;
newre->mtu = re->mtu;
newre->table = zebrad.rtm_table_default;
newre->nexthop_num = 0;
newre->uptime = time(NULL);
newre->instance = re->table;
/* Assuming these routes are never recursive */
for (nhop = rib->nexthop; nhop; nhop = nhop->next)
rib_copy_nexthops(newrib, nhop);
for (nhop = re->nexthop; nhop; nhop = nhop->next)
route_entry_copy_nexthops(newre, nhop);
rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newrib);
rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newre);
}
}
}
else
{
zebra_del_import_table_entry (rn, rib);
zebra_del_import_table_entry (rn, re);
}
/* DD: Add IPv6 code */
return 0;
}
int
zebra_del_import_table_entry (struct route_node *rn, struct rib *rib)
zebra_del_import_table_entry (struct route_node *rn, struct route_entry *re)
{
struct prefix p;
@ -580,8 +580,8 @@ zebra_del_import_table_entry (struct route_node *rn, struct rib *rib)
p.prefixlen = rn->p.prefixlen;
p.u.prefix4 = rn->p.u.prefix4;
rib_delete (AFI_IP, SAFI_UNICAST, rib->vrf_id, ZEBRA_ROUTE_TABLE,
rib->table, rib->flags, &p, NULL, NULL,
rib_delete (AFI_IP, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE,
re->table, re->flags, &p, NULL, NULL,
0, zebrad.rtm_table_default);
}
/* DD: Add IPv6 code */
@ -594,7 +594,7 @@ int
zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const char *rmap_name, int add)
{
struct route_table *table;
struct rib *rib;
struct route_entry *re;
struct route_node *rn;
if (!is_zebra_valid_kernel_table(table_id) ||
@ -647,23 +647,23 @@ zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const cha
if (!rn->info)
continue;
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
break;
}
if (!rib)
if (!re)
continue;
if (((afi == AFI_IP) && (rn->p.family == AF_INET)) ||
((afi == AFI_IP6) && (rn->p.family == AF_INET6)))
{
if (add)
zebra_add_import_table_entry (rn, rib, rmap_name);
zebra_add_import_table_entry (rn, re, rmap_name);
else
zebra_del_import_table_entry (rn, rib);
zebra_del_import_table_entry (rn, re);
}
}
return 0;
@ -713,7 +713,7 @@ zebra_import_table_rm_update ()
afi_t afi;
int i;
struct route_table *table;
struct rib *rib;
struct route_entry *re;
struct route_node *rn;
const char *rmap_name;
@ -736,19 +736,19 @@ zebra_import_table_rm_update ()
if (!rn->info)
continue;
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
break;
}
if (!rib)
if (!re)
continue;
if (((afi == AFI_IP) && (rn->p.family == AF_INET)) ||
((afi == AFI_IP6) && (rn->p.family == AF_INET6)))
zebra_add_import_table_entry (rn, rib, rmap_name);
zebra_add_import_table_entry (rn, re, rmap_name);
}
}
}

View File

@ -36,8 +36,8 @@ extern void zebra_redistribute_default_delete (int, struct zserv *, int,
struct zebra_vrf *zvrf);
extern void redistribute_update (struct prefix *, struct prefix *,
struct rib *, struct rib *);
extern void redistribute_delete (struct prefix *, struct prefix *, struct rib *);
struct route_entry *, struct route_entry *);
extern void redistribute_delete (struct prefix *, struct prefix *, struct route_entry *);
extern void zebra_interface_up_update (struct interface *);
extern void zebra_interface_down_update (struct interface *);
@ -57,9 +57,9 @@ extern int zebra_import_table (afi_t afi, u_int32_t table_id,
u_int32_t distance, const char *rmap_name, int add);
extern int zebra_add_import_table_entry (struct route_node *rn,
struct rib *rib, const char *rmap_name);
struct route_entry *re, const char *rmap_name);
extern int zebra_del_import_table_entry (struct route_node *rn,
struct rib *rib);
struct route_entry *re);
extern int is_zebra_import_table_enabled(afi_t, u_int32_t table_id);
extern int zebra_import_table_config(struct vty *);

View File

@ -39,9 +39,9 @@ void zebra_redistribute_default_delete (int a, struct zserv *b, int c,
{ return; }
void redistribute_update (struct prefix *a, struct prefix *b,
struct rib *c, struct rib *d)
struct route_entry *c, struct route_entry *d)
{ return; }
void redistribute_delete (struct prefix *a, struct prefix *b, struct rib *c)
void redistribute_delete (struct prefix *a, struct prefix *b, struct route_entry *c)
{ return; }
void zebra_interface_up_update (struct interface *a)
@ -75,10 +75,10 @@ int zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance,
const char *rmap_name, int add)
{ return 0; }
int zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char *rmap_name)
int zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, const char *rmap_name)
{ return 0; }
int zebra_del_import_table_entry (struct route_node *rn, struct rib *rib)
int zebra_del_import_table_entry (struct route_node *rn, struct route_entry *re)
{ return 0; }
int is_zebra_import_table_enabled(afi_t afi, u_int32_t table_id)

View File

@ -37,11 +37,11 @@
#define DISTANCE_INFINITY 255
#define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */
struct rib
struct route_entry
{
/* Link list. */
struct rib *next;
struct rib *prev;
struct route_entry *next;
struct route_entry *prev;
/* Nexthop structure */
struct nexthop *nexthop;
@ -85,11 +85,11 @@ struct rib
/* RIB internal status */
u_char status;
#define RIB_ENTRY_REMOVED 0x1
#define ROUTE_ENTRY_REMOVED 0x1
/* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */
#define RIB_ENTRY_NEXTHOPS_CHANGED 0x2
#define RIB_ENTRY_CHANGED 0x4
#define RIB_ENTRY_SELECTED_FIB 0x8
#define ROUTE_ENTRY_NEXTHOPS_CHANGED 0x2
#define ROUTE_ENTRY_CHANGED 0x4
#define ROUTE_ENTRY_SELECTED_FIB 0x8
/* Nexthop information. */
u_char nexthop_num;
@ -125,7 +125,7 @@ typedef struct rib_dest_t_
/*
* Doubly-linked list of routes for this prefix.
*/
struct rib *routes;
struct route_entry *routes;
/*
* Flags, see below.
@ -161,22 +161,22 @@ typedef struct rib_dest_t_
/*
* Macro to iterate over each route for a destination (prefix).
*/
#define RIB_DEST_FOREACH_ROUTE(dest, rib) \
for ((rib) = (dest) ? (dest)->routes : NULL; (rib); (rib) = (rib)->next)
#define RE_DEST_FOREACH_ROUTE(dest, re) \
for ((re) = (dest) ? (dest)->routes : NULL; (re); (re) = (re)->next)
/*
* Same as above, but allows the current node to be unlinked.
*/
#define RIB_DEST_FOREACH_ROUTE_SAFE(dest, rib, next) \
for ((rib) = (dest) ? (dest)->routes : NULL; \
(rib) && ((next) = (rib)->next, 1); \
(rib) = (next))
#define RE_DEST_FOREACH_ROUTE_SAFE(dest, re, next) \
for ((re) = (dest) ? (dest)->routes : NULL; \
(re) && ((next) = (re)->next, 1); \
(re) = (next))
#define RNODE_FOREACH_RIB(rn, rib) \
RIB_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), rib)
#define RNODE_FOREACH_RE(rn, re) \
RE_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), re)
#define RNODE_FOREACH_RIB_SAFE(rn, rib, next) \
RIB_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), rib, next)
#define RNODE_FOREACH_RE_SAFE(rn, re, next) \
RE_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), re, next)
/* The following for loop allows to iterate over the nexthop
* structure of routes.
@ -283,17 +283,28 @@ typedef enum
RIB_UPDATE_OTHER
} rib_update_event_t;
extern struct nexthop *rib_nexthop_ifindex_add (struct rib *, ifindex_t);
extern struct nexthop *rib_nexthop_blackhole_add (struct rib *);
extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *,
struct in_addr *);
extern struct nexthop *rib_nexthop_ipv4_ifindex_add (struct rib *,
struct in_addr *,
struct in_addr *,
ifindex_t);
extern void rib_nexthop_add (struct rib *rib, struct nexthop *nexthop);
extern void rib_copy_nexthops (struct rib *rib, struct nexthop *nh);
extern struct nexthop *route_entry_nexthop_ifindex_add (struct route_entry *, ifindex_t);
extern struct nexthop *route_entry_nexthop_blackhole_add (struct route_entry *);
extern struct nexthop *route_entry_nexthop_ipv4_add (struct route_entry *,
struct in_addr *,
struct in_addr *);
extern struct nexthop *route_entry_nexthop_ipv4_ifindex_add (struct route_entry *,
struct in_addr *,
struct in_addr *,
ifindex_t);
extern void route_entry_nexthop_delete (struct route_entry *re, struct nexthop *nexthop);
extern struct nexthop *route_entry_nexthop_ipv6_add (struct route_entry *,
struct in6_addr *);
extern struct nexthop *route_entry_nexthop_ipv6_ifindex_add (struct route_entry *re,
struct in6_addr *ipv6,
ifindex_t ifindex);
extern void route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop);
extern void route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh);
#define route_entry_dump(prefix, src, re) _route_entry_dump(__func__, prefix, src, re)
extern void _route_entry_dump (const char *,
union prefixconstptr,
union prefixconstptr, const struct route_entry *);
/* RPF lookup behaviour */
enum multicast_mode
{
@ -309,13 +320,9 @@ enum multicast_mode
extern void multicast_mode_ipv4_set (enum multicast_mode mode);
extern enum multicast_mode multicast_mode_ipv4_get (void);
extern int nexthop_has_fib_child(struct nexthop *);
extern void rib_lookup_and_dump (struct prefix_ipv4 *, vrf_id_t);
extern void rib_lookup_and_pushup (struct prefix_ipv4 *, vrf_id_t);
#define rib_dump(prefix, src, rib) _rib_dump(__func__, prefix, src, rib)
extern void _rib_dump (const char *,
union prefixconstptr,
union prefixconstptr, const struct rib *);
extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *,
vrf_id_t);
#define ZEBRA_RIB_LOOKUP_ERROR -1
@ -324,20 +331,16 @@ extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *,
#define ZEBRA_RIB_FOUND_CONNECTED 2
#define ZEBRA_RIB_NOTFOUND 3
extern void rib_nexthop_delete (struct rib *rib, struct nexthop *nexthop);
extern struct nexthop *rib_nexthop_ipv6_add (struct rib *, struct in6_addr *);
extern struct nexthop *rib_nexthop_ipv6_ifindex_add (struct rib *rib,
struct in6_addr *ipv6,
ifindex_t ifindex);
extern int is_zebra_valid_kernel_table(u_int32_t table_id);
extern int is_zebra_main_routing_table(u_int32_t table_id);
extern int zebra_check_addr (struct prefix *p);
extern void rib_addnode (struct route_node *rn, struct rib *rib, int process);
extern void rib_delnode (struct route_node *rn, struct rib *rib);
extern int rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old);
extern int rib_uninstall_kernel (struct route_node *rn, struct rib *rib);
extern void rib_addnode (struct route_node *rn, struct route_entry *re, int process);
extern void rib_delnode (struct route_node *rn, struct route_entry *re);
extern int rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_entry *old);
extern int rib_uninstall_kernel (struct route_node *rn, struct route_entry *re);
/* NOTE:
* All rib_add function will not just add prefix into RIB, but
@ -349,19 +352,19 @@ extern int rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
u_int32_t, u_int32_t, u_char);
extern int rib_add_multipath (afi_t afi, safi_t safi, struct prefix *,
struct prefix_ipv6 *src_p, struct rib *);
struct prefix_ipv6 *src_p, struct route_entry *);
extern void rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
u_short instance, int flags, struct prefix *p,
struct prefix_ipv6 *src_p, union g_addr *gate,
ifindex_t ifindex, u_int32_t table_id);
extern struct rib *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *,
extern struct route_entry *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *,
struct route_node **rn_out);
extern struct rib *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr,
extern struct route_entry *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr,
struct route_node **rn_out);
extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t);
extern struct route_entry *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t);
extern void rib_update (vrf_id_t, rib_update_event_t);
extern void rib_weed_tables (void);
@ -371,10 +374,10 @@ extern void rib_init (void);
extern unsigned long rib_score_proto (u_char proto, u_short instance);
extern void rib_queue_add (struct route_node *rn);
extern void meta_queue_free (struct meta_queue *mq);
extern int zebra_rib_labeled_unicast (struct rib *rib);
extern int zebra_rib_labeled_unicast (struct route_entry *re);
extern struct route_table *rib_table_ipv6;
extern void rib_unlink (struct route_node *, struct rib *);
extern void rib_unlink (struct route_node *, struct route_entry *);
extern int rib_gc_dest (struct route_node *rn);
extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter);
@ -408,7 +411,7 @@ rib_dest_from_rnode (struct route_node *rn)
* Returns a pointer to the list of routes corresponding to the given
* route_node.
*/
static inline struct rib *
static inline struct route_entry *
rnode_to_ribs (struct route_node *rn)
{
rib_dest_t *dest;

View File

@ -29,7 +29,7 @@
#include "zebra/zebra_mpls.h"
extern int kernel_route_rib (struct prefix *, struct prefix *,
struct rib *, struct rib *);
struct route_entry *, struct route_entry *);
extern int kernel_address_add_ipv4 (struct interface *, struct connected *);
extern int kernel_address_delete_ipv4 (struct interface *, struct connected *);

View File

@ -342,22 +342,22 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h,
{
/* This is a multipath route */
struct rib *rib;
struct route_entry *re;
struct rtnexthop *rtnh =
(struct rtnexthop *) RTA_DATA (tb[RTA_MULTIPATH]);
len = RTA_PAYLOAD (tb[RTA_MULTIPATH]);
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
rib->type = ZEBRA_ROUTE_KERNEL;
rib->distance = 0;
rib->flags = flags;
rib->metric = metric;
rib->mtu = mtu;
rib->vrf_id = vrf_id;
rib->table = table;
rib->nexthop_num = 0;
rib->uptime = time (NULL);
re = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
re->type = ZEBRA_ROUTE_KERNEL;
re->distance = 0;
re->flags = flags;
re->metric = metric;
re->mtu = mtu;
re->vrf_id = vrf_id;
re->table = table;
re->nexthop_num = 0;
re->uptime = time (NULL);
for (;;)
{
@ -380,31 +380,31 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (rtm->rtm_family == AF_INET)
{
if (index)
rib_nexthop_ipv4_ifindex_add (rib, gate, prefsrc, index);
route_entry_nexthop_ipv4_ifindex_add (re, gate, prefsrc, index);
else
rib_nexthop_ipv4_add (rib, gate, prefsrc);
route_entry_nexthop_ipv4_add (re, gate, prefsrc);
}
else if (rtm->rtm_family == AF_INET6)
{
if (index)
rib_nexthop_ipv6_ifindex_add (rib, gate, index);
route_entry_nexthop_ipv6_ifindex_add (re, gate, index);
else
rib_nexthop_ipv6_add (rib,gate);
route_entry_nexthop_ipv6_add (re,gate);
}
}
else
rib_nexthop_ifindex_add (rib, index);
route_entry_nexthop_ifindex_add (re, index);
len -= NLMSG_ALIGN(rtnh->rtnh_len);
rtnh = RTNH_NEXT(rtnh);
}
zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
rib->nexthop_num);
if (rib->nexthop_num == 0)
XFREE (MTYPE_RIB, rib);
re->nexthop_num);
if (re->nexthop_num == 0)
XFREE (MTYPE_RE, re);
else
rib_add_multipath (AFI_IP, SAFI_UNICAST, &p, NULL, rib);
rib_add_multipath (AFI_IP, SAFI_UNICAST, &p, NULL, re);
}
}
else
@ -1168,7 +1168,7 @@ netlink_neigh_update (int cmd, int ifindex, uint32_t addr, char *lla, int llalen
/* Update flag indicates whether this is a "replace" or not. */
static int
netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
struct rib *rib, int update)
struct route_entry *re, int update)
{
int bytelen;
struct sockaddr_nl snl;
@ -1189,7 +1189,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
} req;
struct zebra_ns *zns = zebra_ns_lookup (NS_DEFAULT);
struct zebra_vrf *zvrf = vrf_info_lookup (rib->vrf_id);
struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id);
memset (&req, 0, sizeof req - NL_PKT_BUF_SIZE);
@ -1203,10 +1203,10 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
req.r.rtm_family = family;
req.r.rtm_dst_len = p->prefixlen;
req.r.rtm_src_len = src_p ? src_p->prefixlen : 0;
req.r.rtm_protocol = get_rt_proto(rib->type);
req.r.rtm_protocol = get_rt_proto(re->type);
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT))
discard = 1;
else
discard = 0;
@ -1215,9 +1215,9 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
{
if (discard)
{
if (rib->flags & ZEBRA_FLAG_BLACKHOLE)
if (re->flags & ZEBRA_FLAG_BLACKHOLE)
req.r.rtm_type = RTN_BLACKHOLE;
else if (rib->flags & ZEBRA_FLAG_REJECT)
else if (re->flags & ZEBRA_FLAG_REJECT)
req.r.rtm_type = RTN_UNREACHABLE;
else
assert (RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */
@ -1238,21 +1238,21 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
addattr32 (&req.n, sizeof req, RTA_PRIORITY, NL_DEFAULT_ROUTE_METRIC);
/* Table corresponding to this route. */
if (rib->table < 256)
req.r.rtm_table = rib->table;
if (re->table < 256)
req.r.rtm_table = re->table;
else
{
req.r.rtm_table = RT_TABLE_UNSPEC;
addattr32(&req.n, sizeof req, RTA_TABLE, rib->table);
addattr32(&req.n, sizeof req, RTA_TABLE, re->table);
}
if (rib->mtu || rib->nexthop_mtu)
if (re->mtu || re->nexthop_mtu)
{
char buf[NL_PKT_BUF_SIZE];
struct rtattr *rta = (void *) buf;
u_int32_t mtu = rib->mtu;
if (!mtu || (rib->nexthop_mtu && rib->nexthop_mtu < mtu))
mtu = rib->nexthop_mtu;
u_int32_t mtu = re->mtu;
if (!mtu || (re->nexthop_mtu && re->nexthop_mtu < mtu))
mtu = re->nexthop_mtu;
rta->rta_type = RTA_METRICS;
rta->rta_len = RTA_LENGTH(0);
rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTAX_MTU, &mtu, sizeof mtu);
@ -1263,7 +1263,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
if (discard)
{
if (cmd == RTM_NEWROUTE)
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
/* We shouldn't encounter recursive nexthops on discard routes,
* but it is probably better to handle that case correctly anyway.
@ -1277,7 +1277,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
/* Count overall nexthops so we can decide whether to use singlepath
* or multipath case. */
nexthop_num = 0;
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
continue;
@ -1293,7 +1293,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
if (nexthop_num == 1 || multipath_num == 1)
{
nexthop_num = 0;
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
{
@ -1364,7 +1364,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
rtnh = RTA_DATA (rta);
nexthop_num = 0;
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (nexthop_num >= multipath_num)
break;
@ -1497,7 +1497,7 @@ kernel_get_ipmr_sg_stats (void *in)
int
kernel_route_rib (struct prefix *p, struct prefix *src_p,
struct rib *old, struct rib *new)
struct route_entry *old, struct route_entry *new)
{
if (!old && new)
return netlink_route_multipath (RTM_NEWROUTE, p, src_p, new, 0);

View File

@ -71,7 +71,7 @@ sin_masklen (struct in_addr mask)
/* Interface between zebra message and rtm message. */
static int
kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib)
kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re)
{
struct sockaddr_in *mask = NULL;
@ -106,7 +106,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib)
#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
/* Make gateway. */
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
continue;
@ -172,16 +172,16 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib)
gate ? (union sockunion *)&sin_gate : NULL,
smplsp,
ifindex,
rib->flags,
rib->metric);
re->flags,
re->metric);
if (IS_ZEBRA_DEBUG_RIB)
{
if (!gate)
{
zlog_debug ("%s: %s: attention! gate not found for rib %p",
__func__, prefix_buf, rib);
rib_dump (p, NULL, rib);
zlog_debug ("%s: %s: attention! gate not found for re %p",
__func__, prefix_buf, re);
route_entry_dump (p, NULL, re);
}
else
inet_ntop (AF_INET, &sin_gate.sin_addr, gate_buf, INET_ADDRSTRLEN);
@ -230,7 +230,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib)
/* If there was no useful nexthop, then complain. */
if (nexthop_num == 0 && IS_ZEBRA_DEBUG_KERNEL)
zlog_debug ("%s: No useful nexthops were found in RIB entry %p", __func__, rib);
zlog_debug ("%s: No useful nexthops were found in RIB entry %p", __func__, re);
return 0; /*XXX*/
}
@ -262,7 +262,7 @@ sin6_masklen (struct in6_addr mask)
/* Interface between zebra message and rtm message. */
static int
kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib)
kernel_rtm_ipv6 (int cmd, struct prefix *p, struct route_entry *re)
{
struct sockaddr_in6 *mask;
struct sockaddr_in6 sin_dest, sin_mask, sin_gate;
@ -289,7 +289,7 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib)
#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
/* Make gateway. */
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
continue;
@ -349,8 +349,8 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib)
gate ? (union sockunion *)&sin_gate : NULL,
NULL,
ifindex,
rib->flags,
rib->metric);
re->flags,
re->metric);
#if 0
if (error)
@ -377,21 +377,21 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib)
}
static int
kernel_rtm (int cmd, struct prefix *p, struct rib *rib)
kernel_rtm (int cmd, struct prefix *p, struct route_entry *re)
{
switch (PREFIX_FAMILY(p))
{
case AF_INET:
return kernel_rtm_ipv4 (cmd, p, rib);
return kernel_rtm_ipv4 (cmd, p, re);
case AF_INET6:
return kernel_rtm_ipv6 (cmd, p, rib);
return kernel_rtm_ipv6 (cmd, p, re);
}
return 0;
}
int
kernel_route_rib (struct prefix *p, struct prefix *src_p,
struct rib *old, struct rib *new)
struct route_entry *old, struct route_entry *new)
{
int route = 0;

View File

@ -866,7 +866,7 @@ zfpm_writes_pending (void)
* value indicates an error.
*/
static inline int
zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf,
zfpm_encode_route (rib_dest_t *dest, struct route_entry *re, char *in_buf,
size_t in_buf_len, fpm_msg_type_e *msg_type)
{
size_t len;
@ -881,7 +881,7 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf,
case ZFPM_MSG_FORMAT_PROTOBUF:
#ifdef HAVE_PROTOBUF
len = zfpm_protobuf_encode_route (dest, rib, (uint8_t *) in_buf,
len = zfpm_protobuf_encode_route (dest, re, (uint8_t *) in_buf,
in_buf_len);
*msg_type = FPM_MSG_TYPE_PROTOBUF;
#endif
@ -890,8 +890,8 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf,
case ZFPM_MSG_FORMAT_NETLINK:
#ifdef HAVE_NETLINK
*msg_type = FPM_MSG_TYPE_NETLINK;
cmd = rib ? RTM_NEWROUTE : RTM_DELROUTE;
len = zfpm_netlink_encode_route (cmd, dest, rib, in_buf, in_buf_len);
cmd = re ? RTM_NEWROUTE : RTM_DELROUTE;
len = zfpm_netlink_encode_route (cmd, dest, re, in_buf, in_buf_len);
assert(fpm_msg_align(len) == len);
*msg_type = FPM_MSG_TYPE_NETLINK;
#endif /* HAVE_NETLINK */
@ -908,19 +908,19 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf,
/*
* zfpm_route_for_update
*
* Returns the rib that is to be sent to the FPM for a given dest.
* Returns the re that is to be sent to the FPM for a given dest.
*/
struct rib *
struct route_entry *
zfpm_route_for_update (rib_dest_t *dest)
{
struct rib *rib;
struct route_entry *re;
RIB_DEST_FOREACH_ROUTE (dest, rib)
RE_DEST_FOREACH_ROUTE (dest, re)
{
if (!CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
if (!CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB))
continue;
return rib;
return re;
}
/*
@ -944,7 +944,7 @@ zfpm_build_updates (void)
size_t msg_len;
size_t data_len;
fpm_msg_hdr_t *hdr;
struct rib *rib;
struct route_entry *re;
int is_add, write_msg;
fpm_msg_type_e msg_type;
@ -974,8 +974,8 @@ zfpm_build_updates (void)
data = fpm_msg_data (hdr);
rib = zfpm_route_for_update (dest);
is_add = rib ? 1 : 0;
re = zfpm_route_for_update (dest);
is_add = re ? 1 : 0;
write_msg = 1;
@ -990,7 +990,7 @@ zfpm_build_updates (void)
}
if (write_msg) {
data_len = zfpm_encode_route (dest, rib, (char *) data, buf_end - data,
data_len = zfpm_encode_route (dest, re, (char *) data, buf_end - data,
&msg_type);
assert (data_len);

View File

@ -67,13 +67,13 @@ extern int zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv);
* Selects a suitable rib destination for fpm interface tests.
*/
static int
zfpm_dt_find_route (rib_dest_t **dest_p, struct rib **rib_p)
zfpm_dt_find_route (rib_dest_t **dest_p, struct route_entry **re_p)
{
struct route_node *rnode;
route_table_iter_t iter;
struct route_table *table;
rib_dest_t *dest;
struct rib *rib;
struct route_entry *re;
int ret;
table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
@ -88,15 +88,15 @@ zfpm_dt_find_route (rib_dest_t **dest_p, struct rib **rib_p)
if (!dest)
continue;
rib = zfpm_route_for_update(dest);
if (!rib)
re = zfpm_route_for_update(dest);
if (!re)
continue;
if (rib->nexthop_active_num <= 0)
if (re->nexthop_active_num <= 0)
continue;
*dest_p = dest;
*rib_p = rib;
*re_p = re;
ret = 1;
goto done;
}
@ -117,7 +117,7 @@ zfpm_dt_benchmark_netlink_encode (int argc, const char **argv)
{
int times, i, len;
rib_dest_t *dest;
struct rib *rib;
struct route_entry *re;
char buf[4096];
times = 100000;
@ -125,12 +125,12 @@ zfpm_dt_benchmark_netlink_encode (int argc, const char **argv)
times = atoi(argv[0]);
}
if (!zfpm_dt_find_route(&dest, &rib)) {
if (!zfpm_dt_find_route(&dest, &re)) {
return 1;
}
for (i = 0; i < times; i++) {
len = zfpm_netlink_encode_route(RTM_NEWROUTE, dest, rib, buf, sizeof(buf));
len = zfpm_netlink_encode_route(RTM_NEWROUTE, dest, re, buf, sizeof(buf));
if (len <= 0) {
return 2;
}
@ -150,7 +150,7 @@ zfpm_dt_benchmark_protobuf_encode (int argc, const char **argv)
{
int times, i, len;
rib_dest_t *dest;
struct rib *rib;
struct route_entry *re;
uint8_t buf[4096];
times = 100000;
@ -158,12 +158,12 @@ zfpm_dt_benchmark_protobuf_encode (int argc, const char **argv)
times = atoi(argv[0]);
}
if (!zfpm_dt_find_route(&dest, &rib)) {
if (!zfpm_dt_find_route(&dest, &re)) {
return 1;
}
for (i = 0; i < times; i++) {
len = zfpm_protobuf_encode_route(dest, rib, buf, sizeof(buf));
len = zfpm_protobuf_encode_route(dest, re, buf, sizeof(buf));
if (len <= 0) {
return 2;
}
@ -229,7 +229,7 @@ zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv)
{
int times, i, len;
rib_dest_t *dest;
struct rib *rib;
struct route_entry *re;
uint8_t msg_buf[4096];
QPB_DECLARE_STACK_ALLOCATOR (allocator, 8192);
Fpm__Message *fpm_msg;
@ -240,13 +240,13 @@ zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv)
if (argc > 0)
times = atoi(argv[0]);
if (!zfpm_dt_find_route (&dest, &rib))
if (!zfpm_dt_find_route (&dest, &re))
return 1;
/*
* Encode the route into the message buffer once only.
*/
len = zfpm_protobuf_encode_route (dest, rib, msg_buf, sizeof (msg_buf));
len = zfpm_protobuf_encode_route (dest, re, msg_buf, sizeof (msg_buf));
if (len <= 0)
return 2;

View File

@ -231,7 +231,7 @@ netlink_proto_from_route_type (int type)
*/
static int
netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
rib_dest_t *dest, struct rib *rib)
rib_dest_t *dest, struct route_entry *re)
{
struct nexthop *nexthop, *tnexthop;
int recursing;
@ -250,18 +250,18 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
* An RTM_DELROUTE need not be accompanied by any nexthops,
* particularly in our communication with the FPM.
*/
if (cmd == RTM_DELROUTE && !rib)
if (cmd == RTM_DELROUTE && !re)
return 1;
if (!rib)
if (!re)
{
zfpm_debug ("%s: Expected non-NULL rib pointer", __PRETTY_FUNCTION__);
zfpm_debug ("%s: Expected non-NULL re pointer", __PRETTY_FUNCTION__);
return 0;
}
ri->rtm_protocol = netlink_proto_from_route_type (rib->type);
ri->rtm_protocol = netlink_proto_from_route_type (re->type);
if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT))
discard = 1;
else
discard = 0;
@ -270,9 +270,9 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
{
if (discard)
{
if (rib->flags & ZEBRA_FLAG_BLACKHOLE)
if (re->flags & ZEBRA_FLAG_BLACKHOLE)
ri->rtm_type = RTN_BLACKHOLE;
else if (rib->flags & ZEBRA_FLAG_REJECT)
else if (re->flags & ZEBRA_FLAG_REJECT)
ri->rtm_type = RTN_UNREACHABLE;
else
assert (0);
@ -281,12 +281,12 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
ri->rtm_type = RTN_UNICAST;
}
ri->metric = &rib->metric;
ri->metric = &re->metric;
if (discard)
return 1;
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (ri->num_nhs >= multipath_num)
break;
@ -474,14 +474,14 @@ zfpm_log_route_info (netlink_route_info_t *ri, const char *label)
* value indicates an error.
*/
int
zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct rib *rib,
zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct route_entry *re,
char *in_buf, size_t in_buf_len)
{
netlink_route_info_t ri_space, *ri;
ri = &ri_space;
if (!netlink_route_info_fill (ri, cmd, dest, rib))
if (!netlink_route_info_fill (ri, cmd, dest, re))
return 0;
zfpm_log_route_info (ri, __FUNCTION__);

View File

@ -49,12 +49,12 @@ static inline void zfpm_debug(const char *format, ...) { return; }
* Externs
*/
extern int
zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct rib *rib,
zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct route_entry *re,
char *in_buf, size_t in_buf_len);
extern int
zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib,
zfpm_protobuf_encode_route (rib_dest_t *dest, struct route_entry *re,
uint8_t *in_buf, size_t in_buf_len);
extern struct rib *zfpm_route_for_update (rib_dest_t *dest);
extern struct route_entry *zfpm_route_for_update (rib_dest_t *dest);
#endif /* _ZEBRA_FPM_PRIVATE_H */

View File

@ -41,7 +41,7 @@
*/
static Fpm__DeleteRoute *
create_delete_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
struct rib *rib)
struct route_entry *re)
{
Fpm__DeleteRoute *msg;
@ -141,7 +141,7 @@ add_nexthop (qpb_allocator_t *allocator, Fpm__AddRoute *msg, rib_dest_t *dest,
*/
static Fpm__AddRoute *
create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
struct rib *rib)
struct route_entry *re)
{
Fpm__AddRoute *msg;
int discard;
@ -167,18 +167,18 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
*/
msg->sub_address_family = QPB__SUB_ADDRESS_FAMILY__UNICAST;
msg->key = fpm_route_key_create (allocator, rib_dest_prefix(dest));
qpb_protocol_set (&msg->protocol, rib->type);
qpb_protocol_set (&msg->protocol, re->type);
if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT))
discard = 1;
else
discard = 0;
if (discard)
{
if (rib->flags & ZEBRA_FLAG_BLACKHOLE) {
if (re->flags & ZEBRA_FLAG_BLACKHOLE) {
msg->route_type = FPM__ROUTE_TYPE__BLACKHOLE;
} else if (rib->flags & ZEBRA_FLAG_REJECT) {
} else if (re->flags & ZEBRA_FLAG_REJECT) {
msg->route_type = FPM__ROUTE_TYPE__UNREACHABLE;
} else {
assert (0);
@ -189,13 +189,13 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
msg->route_type = FPM__ROUTE_TYPE__NORMAL;
}
msg->metric = rib->metric;
msg->metric = re->metric;
/*
* Figure out the set of nexthops to be added to the message.
*/
num_nhs = 0;
for (ALL_NEXTHOPS_RO (rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO (re->nexthop, nexthop, tnexthop, recursing))
{
if (num_nhs >= multipath_num)
break;
@ -245,7 +245,7 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
*/
static Fpm__Message *
create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
struct rib *rib)
struct route_entry *re)
{
Fpm__Message *msg;
@ -257,9 +257,9 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
fpm__message__init(msg);
if (!rib) {
if (!re) {
msg->type = FPM__MESSAGE__TYPE__DELETE_ROUTE;
msg->delete_route = create_delete_route_message(allocator, dest, rib);
msg->delete_route = create_delete_route_message(allocator, dest, re);
if (!msg->delete_route) {
assert(0);
return NULL;
@ -268,7 +268,7 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
}
msg->type = FPM__MESSAGE__TYPE__ADD_ROUTE;
msg->add_route = create_add_route_message(allocator, dest, rib);
msg->add_route = create_add_route_message(allocator, dest, re);
if (!msg->add_route) {
assert(0);
return NULL;
@ -287,7 +287,7 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest,
* value indicates an error.
*/
int
zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib,
zfpm_protobuf_encode_route (rib_dest_t *dest, struct route_entry *re,
uint8_t *in_buf, size_t in_buf_len)
{
Fpm__Message *msg;
@ -296,7 +296,7 @@ zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib,
QPB_INIT_STACK_ALLOCATOR (allocator);
msg = create_route_message(&allocator, dest, rib);
msg = create_route_message(&allocator, dest, re);
if (!msg) {
assert(0);
return 0;

View File

@ -28,7 +28,7 @@
DEFINE_MGROUP(ZEBRA, "zebra")
DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
DEFINE_MTYPE(ZEBRA, RIB, "RIB")
DEFINE_MTYPE(ZEBRA, RE, "Route Entry")
DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue")
DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route")
DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination")

View File

@ -28,7 +28,7 @@ DECLARE_MGROUP(ZEBRA)
DECLARE_MTYPE(RTADV_PREFIX)
DECLARE_MTYPE(ZEBRA_NS)
DECLARE_MTYPE(ZEBRA_VRF)
DECLARE_MTYPE(RIB)
DECLARE_MTYPE(RE)
DECLARE_MTYPE(RIB_QUEUE)
DECLARE_MTYPE(STATIC_ROUTE)
DECLARE_MTYPE(RIB_DEST)

View File

@ -65,7 +65,7 @@ static u_int32_t
fec_derive_label_from_index (struct zebra_vrf *vrf, zebra_fec_t *fec);
static int
lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
struct route_node *rn, struct rib *rib);
struct route_node *rn, struct route_entry *re);
static int
lsp_uninstall (struct zebra_vrf *zvrf, mpls_label_t label);
static int
@ -168,7 +168,7 @@ mpls_processq_init (struct zebra_t *zebra);
*/
static int
lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
struct route_node *rn, struct rib *rib)
struct route_node *rn, struct route_entry *re)
{
struct hash *lsp_table;
zebra_ile_t tmp_ile;
@ -184,7 +184,7 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
if (!lsp_table)
return -1;
lsp_type = lsp_type_from_rib_type (rib->type);
lsp_type = lsp_type_from_re_type (re->type);
added = changed = 0;
/* Locate or allocate LSP entry. */
@ -198,7 +198,7 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
* the label advertised by the recursive nexthop (plus we don't have the
* logic yet to push multiple labels).
*/
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
{
/* Skip inactive and recursive entries. */
if (!CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
@ -441,7 +441,7 @@ fec_change_update_lsp (struct zebra_vrf *zvrf, zebra_fec_t *fec, mpls_label_t ol
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
afi_t afi;
/* Uninstall label forwarding entry, if previously installed. */
@ -464,16 +464,16 @@ fec_change_update_lsp (struct zebra_vrf *zvrf, zebra_fec_t *fec, mpls_label_t ol
if (!rn)
return 0;
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
break;
}
if (!rib || !zebra_rib_labeled_unicast (rib))
if (!re || !zebra_rib_labeled_unicast (re))
return 0;
if (lsp_install (zvrf, fec->label, rn, rib))
if (lsp_install (zvrf, fec->label, rn, re))
return -1;
return 0;
@ -656,7 +656,7 @@ nhlfe_nexthop_active_ipv4 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop)
struct route_table *table;
struct prefix_ipv4 p;
struct route_node *rn;
struct rib *match;
struct route_entry *match;
struct nexthop *match_nh;
table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
@ -676,9 +676,9 @@ nhlfe_nexthop_active_ipv4 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop)
route_unlock_node (rn);
/* Locate a valid connected route. */
RNODE_FOREACH_RIB (rn, match)
RNODE_FOREACH_RE (rn, match)
{
if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED) ||
if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED) ||
!CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED))
continue;
@ -708,7 +708,7 @@ nhlfe_nexthop_active_ipv6 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop)
struct route_table *table;
struct prefix_ipv6 p;
struct route_node *rn;
struct rib *match;
struct route_entry *match;
table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
if (!table)
@ -727,10 +727,10 @@ nhlfe_nexthop_active_ipv6 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop)
route_unlock_node (rn);
/* Locate a valid connected route. */
RNODE_FOREACH_RIB (rn, match)
RNODE_FOREACH_RE (rn, match)
{
if ((match->type == ZEBRA_ROUTE_CONNECT) &&
!CHECK_FLAG (match->status, RIB_ENTRY_REMOVED) &&
!CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED) &&
CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED))
break;
}
@ -1809,7 +1809,7 @@ mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
* Install dynamic LSP entry.
*/
int
zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib)
zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re)
{
struct route_table *table;
zebra_fec_t *fec;
@ -1829,7 +1829,7 @@ zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct ri
if (fec->label == MPLS_IMP_NULL_LABEL)
return 0;
if (lsp_install (zvrf, fec->label, rn, rib))
if (lsp_install (zvrf, fec->label, rn, re))
return -1;
return 0;
@ -1839,7 +1839,7 @@ zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct ri
* Uninstall dynamic LSP entry, if any.
*/
int
zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib)
zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re)
{
struct route_table *table;
zebra_fec_t *fec;
@ -2296,7 +2296,7 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
struct nexthop *nexthop;
/* Lookup table. */
@ -2306,18 +2306,18 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
/* Lookup existing route */
rn = route_node_get (table, prefix);
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
if (rib->distance == distance)
if (re->distance == distance)
break;
}
if (rib == NULL)
if (re == NULL)
return -1;
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
{
switch (nexthop->type)
{
@ -2356,8 +2356,8 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
else
return 0;
SET_FLAG (rib->status, RIB_ENTRY_CHANGED);
SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
SET_FLAG (re->status, ROUTE_ENTRY_CHANGED);
SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED);
rib_queue_add (rn);
return 0;
@ -2534,7 +2534,7 @@ mpls_ldp_ftn_uninstall_all (struct zebra_vrf *zvrf, int afi)
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
struct nexthop *nexthop;
int update;
@ -2546,13 +2546,13 @@ mpls_ldp_ftn_uninstall_all (struct zebra_vrf *zvrf, int afi)
for (rn = route_top (table); rn; rn = route_next (rn))
{
update = 0;
RNODE_FOREACH_RIB (rn, rib)
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
RNODE_FOREACH_RE (rn, re)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
if (nexthop->nh_label_type == ZEBRA_LSP_LDP)
{
nexthop_del_labels (nexthop);
SET_FLAG (rib->status, RIB_ENTRY_CHANGED);
SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
SET_FLAG (re->status, ROUTE_ENTRY_CHANGED);
SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED);
update = 1;
}

View File

@ -208,13 +208,13 @@ zebra_mpls_write_label_block_config (struct vty *vty, struct zebra_vrf *vrf);
* Install dynamic LSP entry.
*/
int
zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib);
zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re);
/*
* Uninstall dynamic LSP entry, if any.
*/
int
zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib);
zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re);
/*
* Registration from a client for the label binding for a FEC. If a binding
@ -449,9 +449,9 @@ lsp_distance (enum lsp_types_t type)
* are converted into LSPs.
*/
static inline enum lsp_types_t
lsp_type_from_rib_type (int rib_type)
lsp_type_from_re_type (int re_type)
{
switch (rib_type)
switch (re_type)
{
case ZEBRA_ROUTE_STATIC:
return ZEBRA_LSP_STATIC;

File diff suppressed because it is too large Load Diff

View File

@ -48,8 +48,8 @@
#include "zebra/interface.h"
#include "zebra/zebra_memory.h"
static void free_state(vrf_id_t vrf_id, struct rib *rib, struct route_node *rn);
static void copy_state(struct rnh *rnh, struct rib *rib,
static void free_state(vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn);
static void copy_state(struct rnh *rnh, struct route_entry *re,
struct route_node *rn);
#define lookup_rnh_table(v, f) \
({ \
@ -61,7 +61,7 @@ static void copy_state(struct rnh *rnh, struct rib *rib,
t; \
})
static int compare_state(struct rib *r1, struct rib *r2);
static int compare_state(struct route_entry *r1, struct route_entry *r2);
static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type,
vrf_id_t vrf_id);
static void print_rnh(struct route_node *rn, struct vty *vty);
@ -305,7 +305,7 @@ zebra_deregister_rnh_static_nexthops (vrf_id_t vrf_id, struct nexthop *nexthop,
*/
static int
zebra_rnh_apply_nht_rmap(int family, struct route_node *prn,
struct rib *rib, int proto)
struct route_entry *re, int proto)
{
int at_least_one = 0;
int rmap_family; /* Route map has diff AF family enum */
@ -314,11 +314,11 @@ zebra_rnh_apply_nht_rmap(int family, struct route_node *prn,
rmap_family = (family == AF_INET) ? AFI_IP : AFI_IP6;
if (prn && rib)
if (prn && re)
{
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
{
ret = zebra_nht_route_map_check(rmap_family, proto, &prn->p, rib,
ret = zebra_nht_route_map_check(rmap_family, proto, &prn->p, re,
nexthop);
if (ret != RMAP_DENYMATCH)
{
@ -335,17 +335,17 @@ zebra_rnh_apply_nht_rmap(int family, struct route_node *prn,
}
/*
* Determine appropriate route (RIB entry) resolving a tracked entry
* Determine appropriate route (RE entry) resolving a tracked entry
* (nexthop or BGP route for import).
*/
static struct rib *
static struct route_entry *
zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type,
struct route_node *nrn, struct rnh *rnh,
struct route_node **prn)
{
struct route_table *route_table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
*prn = NULL;
@ -363,29 +363,29 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type,
if ((type == RNH_NEXTHOP_TYPE) &&
(is_default_prefix (&rn->p) &&
!nh_resolve_via_default(rn->p.family)))
rib = NULL;
re = NULL;
else if ((type == RNH_IMPORT_CHECK_TYPE) &&
CHECK_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH) &&
!prefix_same(&nrn->p, &rn->p))
rib = NULL;
re = NULL;
else
{
/* Identify appropriate route entry. */
RNODE_FOREACH_RIB(rn, rib)
RNODE_FOREACH_RE(rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
if (! CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
if (! CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB))
continue;
if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED))
{
if (rib->type == ZEBRA_ROUTE_CONNECT)
if (re->type == ZEBRA_ROUTE_CONNECT)
break;
if (rib->type == ZEBRA_ROUTE_NHRP)
if (re->type == ZEBRA_ROUTE_NHRP)
{
struct nexthop *nexthop;
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
if (nexthop->type == NEXTHOP_TYPE_IFINDEX)
break;
if (nexthop)
@ -393,7 +393,7 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type,
}
}
else if ((type == RNH_IMPORT_CHECK_TYPE) &&
(rib->type == ZEBRA_ROUTE_BGP))
(re->type == ZEBRA_ROUTE_BGP))
continue;
else
break;
@ -402,9 +402,9 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type,
/* Need to unlock route node */
route_unlock_node(rn);
if (rib)
if (re)
*prn = rn;
return rib;
return re;
}
/*
@ -414,7 +414,7 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type,
static void
zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force,
struct route_node *nrn, struct rnh *rnh,
struct rib *rib)
struct route_entry *re)
{
int state_changed = 0;
struct zserv *client;
@ -423,20 +423,20 @@ zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force,
struct nexthop *nexthop, *tnexthop;
int recursing;
if (rib && (rnh->state == NULL))
if (re && (rnh->state == NULL))
{
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{
state_changed = 1;
break;
}
}
else if (!rib && (rnh->state != NULL))
else if (!re && (rnh->state != NULL))
state_changed = 1;
if (compare_state(rib, rnh->state))
copy_state(rnh, rib, nrn);
if (compare_state(re, rnh->state))
copy_state(rnh, re, nrn);
if (state_changed || force)
{
@ -461,7 +461,7 @@ zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force,
static void
zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family,
struct route_node *nrn, struct rnh *rnh,
struct route_node *prn, struct rib *rib)
struct route_node *prn, struct route_entry *re)
{
struct listnode *node;
struct zserv *client;
@ -472,7 +472,7 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family,
if (IS_ZEBRA_DEBUG_NHT)
{
prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN);
if (prn && rib)
if (prn && re)
{
prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN);
zlog_debug("%u:%s: NH resolved over route %s", vrfid, bufn, bufp);
@ -483,12 +483,12 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family,
for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client))
{
if (prn && rib)
if (prn && re)
{
/* Apply route-map for this client to route resolving this
* nexthop to see if it is filtered or not.
*/
num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, rib,
num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, re,
client->proto);
if (num_resolving_nh)
rnh->filtered[client->proto] = 0;
@ -515,12 +515,12 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family,
static void
zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
struct route_node *nrn, struct rnh *rnh,
struct route_node *prn, struct rib *rib)
struct route_node *prn, struct route_entry *re)
{
struct listnode *node;
int num_resolving_nh = 0;
struct route_node *static_rn;
struct rib *srib;
struct route_entry *sre;
struct nexthop *nexthop;
char bufn[INET6_ADDRSTRLEN];
char bufp[INET6_ADDRSTRLEN];
@ -533,12 +533,12 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN);
}
if (prn && rib)
if (prn && re)
{
/* Apply route-map for "static" to route resolving this
* nexthop to see if it is filtered or not.
*/
num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, rib,
num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, re,
ZEBRA_ROUTE_STATIC);
if (num_resolving_nh)
rnh->filtered[ZEBRA_ROUTE_STATIC] = 0;
@ -552,15 +552,15 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
for (ALL_LIST_ELEMENTS_RO(rnh->zebra_static_route_list, node,
static_rn))
{
RNODE_FOREACH_RIB(static_rn, srib)
RNODE_FOREACH_RE(static_rn, sre)
{
if (srib->type != ZEBRA_ROUTE_STATIC)
if (sre->type != ZEBRA_ROUTE_STATIC)
continue;
/* Set the filter flag for the correct nexthop - static route may
* be having multiple. We care here only about registered nexthops.
*/
for (nexthop = srib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = sre->nexthop; nexthop; nexthop = nexthop->next)
{
switch (nexthop->type)
{
@ -593,7 +593,7 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
if (IS_ZEBRA_DEBUG_NHT)
{
prefix2str(&static_rn->p, bufs, INET6_ADDRSTRLEN);
if (prn && rib)
if (prn && re)
zlog_debug("%u:%s: NH change %s, scheduling static route %s",
vrfid, bufn, num_resolving_nh ?
"" : "(filtered by route-map)", bufs);
@ -602,8 +602,8 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
vrfid, bufn, bufs);
}
SET_FLAG(srib->status, RIB_ENTRY_CHANGED);
SET_FLAG(srib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
SET_FLAG(sre->status, ROUTE_ENTRY_CHANGED);
SET_FLAG(sre->status, ROUTE_ENTRY_NEXTHOPS_CHANGED);
}
rib_queue_add(static_rn);
@ -618,7 +618,7 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family,
static void
zebra_rnh_eval_nexthop_entry (vrf_id_t vrfid, int family, int force,
struct route_node *nrn, struct rnh *rnh,
struct route_node *prn, struct rib *rib)
struct route_node *prn, struct route_entry *re)
{
int state_changed = 0;
@ -633,12 +633,12 @@ zebra_rnh_eval_nexthop_entry (vrf_id_t vrfid, int family, int force,
else
memset(&rnh->resolved_route, 0, sizeof(struct prefix));
copy_state(rnh, rib, nrn);
copy_state(rnh, re, nrn);
state_changed = 1;
}
else if (compare_state(rib, rnh->state))
else if (compare_state(re, rnh->state))
{
copy_state(rnh, rib, nrn);
copy_state(rnh, re, nrn);
state_changed = 1;
}
@ -663,7 +663,7 @@ zebra_rnh_evaluate_entry (vrf_id_t vrfid, int family, int force, rnh_type_t type
struct route_node *nrn)
{
struct rnh *rnh;
struct rib *rib;
struct route_entry *re;
struct route_node *prn;
char bufn[INET6_ADDRSTRLEN];
@ -676,31 +676,31 @@ zebra_rnh_evaluate_entry (vrf_id_t vrfid, int family, int force, rnh_type_t type
rnh = nrn->info;
/* Identify route entry (RIB) resolving this tracked entry. */
rib = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn);
/* Identify route entry (RE) resolving this tracked entry. */
re = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn);
/* If the entry cannot be resolved and that is also the existing state,
* there is nothing further to do.
*/
if (!rib && rnh->state == NULL && !force)
if (!re && rnh->state == NULL && !force)
return;
/* Process based on type of entry. */
if (type == RNH_IMPORT_CHECK_TYPE)
zebra_rnh_eval_import_check_entry (vrfid, family, force,
nrn, rnh, rib);
nrn, rnh, re);
else
zebra_rnh_eval_nexthop_entry (vrfid, family, force,
nrn, rnh, prn, rib);
nrn, rnh, prn, re);
}
/*
* Clear the RIB_ENTRY_NEXTHOPS_CHANGED flag
* from the rib entries.
* Clear the ROUTE_ENTRY_NEXTHOPS_CHANGED flag
* from the re entries.
*
* Please note we are doing this *after* we have
* notified the world about each nexthop as that
* we can have a situation where one rib entry
* we can have a situation where one re entry
* covers multiple nexthops we are interested in.
*/
static void
@ -708,15 +708,15 @@ zebra_rnh_clear_nhc_flag (vrf_id_t vrfid, int family, rnh_type_t type,
struct route_node *nrn)
{
struct rnh *rnh;
struct rib *rib;
struct route_entry *re;
struct route_node *prn;
rnh = nrn->info;
rib = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn);
re = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn);
if (rib)
UNSET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
if (re)
UNSET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED);
}
/* Evaluate all tracked entries (nexthops or routes for import into BGP)
@ -812,25 +812,25 @@ zebra_cleanup_rnh_client (vrf_id_t vrf_id, int family, struct zserv *client,
}
/**
* free_state - free up the rib structure associated with the rnh.
* free_state - free up the re structure associated with the rnh.
*/
static void
free_state (vrf_id_t vrf_id, struct rib *rib, struct route_node *rn)
free_state (vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn)
{
if (!rib)
if (!re)
return;
/* free RIB and nexthops */
zebra_deregister_rnh_static_nexthops (vrf_id, rib->nexthop, rn);
nexthops_free(rib->nexthop);
XFREE (MTYPE_RIB, rib);
/* free RE and nexthops */
zebra_deregister_rnh_static_nexthops (vrf_id, re->nexthop, rn);
nexthops_free(re->nexthop);
XFREE (MTYPE_RE, re);
}
static void
copy_state (struct rnh *rnh, struct rib *rib, struct route_node *rn)
copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn)
{
struct rib *state;
struct route_entry *state;
struct nexthop *nh;
if (rnh->state)
@ -839,20 +839,20 @@ copy_state (struct rnh *rnh, struct rib *rib, struct route_node *rn)
rnh->state = NULL;
}
if (!rib)
if (!re)
return;
state = XCALLOC (MTYPE_RIB, sizeof (struct rib));
state->type = rib->type;
state->metric = rib->metric;
state = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
state->type = re->type;
state->metric = re->metric;
for (nh = rib->nexthop; nh; nh = nh->next)
rib_copy_nexthops(state, nh);
for (nh = re->nexthop; nh; nh = nh->next)
route_entry_copy_nexthops(state, nh);
rnh->state = state;
}
static int
compare_state (struct rib *r1, struct rib *r2)
compare_state (struct route_entry *r1, struct route_entry *r2)
{
if (!r1 && !r2)
@ -867,7 +867,7 @@ compare_state (struct rib *r1, struct rib *r2)
if (r1->nexthop_num != r2->nexthop_num)
return 1;
if (CHECK_FLAG(r1->status, RIB_ENTRY_NEXTHOPS_CHANGED))
if (CHECK_FLAG(r1->status, ROUTE_ENTRY_NEXTHOPS_CHANGED))
return 1;
return 0;
@ -877,7 +877,7 @@ static int
send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vrf_id)
{
struct stream *s;
struct rib *rib;
struct route_entry *re;
unsigned long nump;
u_char num;
struct nexthop *nexthop;
@ -886,7 +886,7 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr
? ZEBRA_IMPORT_CHECK_UPDATE : ZEBRA_NEXTHOP_UPDATE;
rn = rnh->node;
rib = rnh->state;
re = rnh->state;
/* Get output stream. */
s = client->obuf;
@ -910,14 +910,14 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr
__FUNCTION__, rn->p.family);
break;
}
if (rib)
if (re)
{
stream_putc (s, rib->distance);
stream_putl (s, rib->metric);
stream_putc (s, re->distance);
stream_putl (s, re->metric);
num = 0;
nump = stream_get_endp(s);
stream_putc (s, 0);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
if ((CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ||
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) &&
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))

View File

@ -37,7 +37,7 @@ struct rnh
/* VRF identifier. */
vrf_id_t vrf_id;
struct rib *state;
struct route_entry *state;
struct prefix resolved_route;
struct list *client_list;
struct list *zebra_static_route_list; /* static routes dependent on this NH */

View File

@ -1351,7 +1351,7 @@ zebra_del_import_table_route_map (afi_t afi, uint32_t table)
}
route_map_result_t
zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
zebra_import_table_route_map_check (int family, int re_type, struct prefix *p,
struct nexthop *nexthop, vrf_id_t vrf_id, route_tag_t tag, const char *rmap_name)
{
struct route_map *rmap = NULL;
@ -1360,11 +1360,11 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
nh_obj.nexthop = nexthop;
nh_obj.vrf_id = vrf_id;
nh_obj.source_protocol = rib_type;
nh_obj.source_protocol = re_type;
nh_obj.metric = 0;
nh_obj.tag = tag;
if (rib_type >= 0 && rib_type < ZEBRA_ROUTE_MAX)
if (re_type >= 0 && re_type < ZEBRA_ROUTE_MAX)
rmap = route_map_lookup_by_name (rmap_name);
if (rmap) {
ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
@ -1375,17 +1375,17 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
route_map_result_t
zebra_nht_route_map_check (int family, int client_proto, struct prefix *p,
struct rib * rib, struct nexthop *nexthop)
struct route_entry * re, struct nexthop *nexthop)
{
struct route_map *rmap = NULL;
route_map_result_t ret = RMAP_MATCH;
struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop;
nh_obj.vrf_id = rib->vrf_id;
nh_obj.source_protocol = rib->type;
nh_obj.metric = rib->metric;
nh_obj.tag = rib->tag;
nh_obj.vrf_id = re->vrf_id;
nh_obj.source_protocol = re->type;
nh_obj.metric = re->metric;
nh_obj.tag = re->tag;
if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX)
rmap = route_map_lookup_by_name (nht_rm[family][client_proto]);

View File

@ -43,7 +43,7 @@ extern route_map_result_t zebra_route_map_check (int family, int rib_type,
extern route_map_result_t zebra_nht_route_map_check (int family,
int client_proto,
struct prefix *p,
struct rib *,
struct route_entry *,
struct nexthop *nexthop);

View File

@ -143,7 +143,7 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len,
static int result;
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED)
return NULL;
@ -155,7 +155,7 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len,
/* Return number of routing entries. */
result = 0;
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
result++;
return (u_char *)&result;
@ -168,7 +168,7 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len,
static int result;
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED)
return NULL;
@ -180,7 +180,7 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len,
/* Return number of routing entries. */
result = 0;
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
result++;
return (u_char *)&result;
@ -256,15 +256,15 @@ proto_trans(int type)
}
static void
check_replace(struct route_node *np2, struct rib *rib2,
struct route_node **np, struct rib **rib)
check_replace(struct route_node *np2, struct route_entry *re2,
struct route_node **np, struct route_entry **re)
{
int proto, proto2;
if (!*np)
{
*np = np2;
*rib = rib2;
*re = re2;
return;
}
@ -273,39 +273,39 @@ check_replace(struct route_node *np2, struct rib *rib2,
if (in_addr_cmp(&(*np)->p.u.prefix, &np2->p.u.prefix) > 0)
{
*np = np2;
*rib = rib2;
*re = re2;
return;
}
proto = proto_trans((*rib)->type);
proto2 = proto_trans(rib2->type);
proto = proto_trans((*re)->type);
proto2 = proto_trans(re2->type);
if (proto2 > proto)
return;
if (proto2 < proto)
{
*np = np2;
*rib = rib2;
*re = re2;
return;
}
if (in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4,
(u_char *)&rib2->nexthop->gate.ipv4) <= 0)
if (in_addr_cmp((u_char *)&(*re)->nexthop->gate.ipv4,
(u_char *)&re2->nexthop->gate.ipv4) <= 0)
return;
*np = np2;
*rib = rib2;
*re = re2;
return;
}
static void
get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
int exact, struct route_node **np, struct rib **rib)
int exact, struct route_node **np, struct route_entry **re)
{
struct in_addr dest;
struct route_table *table;
struct route_node *np2;
struct rib *rib2;
struct route_entry *re2;
int proto;
int policy;
struct in_addr nexthop;
@ -328,7 +328,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
/* Init return variables */
*np = NULL;
*rib = NULL;
*re = NULL;
/* Short circuit exact matches of wrong length */
@ -374,11 +374,11 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
{
if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest))
{
RNODE_FOREACH_RIB (*np, *rib)
RNODE_FOREACH_RE (*np, *re)
{
if (!in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4,
if (!in_addr_cmp((u_char *)&(*re)->nexthop->gate.ipv4,
(u_char *)&nexthop))
if (proto == proto_trans((*rib)->type))
if (proto == proto_trans((*re)->type))
return;
}
}
@ -393,34 +393,34 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
/* Check destination first */
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0)
RNODE_FOREACH_RIB (np2, rib2)
check_replace(np2, rib2, np, rib);
RNODE_FOREACH_RE (np2, re2)
check_replace(np2, re2, np, re);
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) == 0)
{ /* have to look at each rib individually */
RNODE_FOREACH_RIB (np2, rib2)
{ /* have to look at each re individually */
RNODE_FOREACH_RE (np2, re2)
{
int proto2, policy2;
proto2 = proto_trans(rib2->type);
proto2 = proto_trans(re2->type);
policy2 = 0;
if ((policy < policy2)
|| ((policy == policy2) && (proto < proto2))
|| ((policy == policy2) && (proto == proto2)
&& (in_addr_cmp((u_char *)&rib2->nexthop->gate.ipv4,
&& (in_addr_cmp((u_char *)&re2->nexthop->gate.ipv4,
(u_char *) &nexthop) >= 0)
))
check_replace(np2, rib2, np, rib);
check_replace(np2, re2, np, re);
}
}
}
if (!*rib)
if (!*re)
return;
policy = 0;
proto = proto_trans((*rib)->type);
proto = proto_trans((*re)->type);
*objid_len = v->namelen + 10;
pnt = (u_char *) &(*np)->p.u.prefix;
@ -433,7 +433,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
{
struct nexthop *nexthop;
nexthop = (*rib)->nexthop;
nexthop = (*re)->nexthop;
if (nexthop)
{
pnt = (u_char *) &nexthop->gate.ipv4;
@ -450,7 +450,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
int exact, size_t *val_len, WriteMethod **write_method)
{
struct route_node *np;
struct rib *rib;
struct route_entry *re;
static int result;
static int resarr[2];
static struct in_addr netmask;
@ -460,11 +460,11 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
== MATCH_FAILED)
return NULL;
get_fwtable_route_node(v, objid, objid_len, exact, &np, &rib);
get_fwtable_route_node(v, objid, objid_len, exact, &np, &re);
if (!np)
return NULL;
nexthop = rib->nexthop;
nexthop = re->nexthop;
if (! nexthop)
return NULL;
@ -501,7 +501,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
return (u_char *)&result;
break;
case IPFORWARDPROTO:
result = proto_trans(rib->type);
result = proto_trans(re->type);
*val_len = sizeof(int);
return (u_char *)&result;
break;

View File

@ -40,7 +40,7 @@ void
static_install_route (afi_t afi, safi_t safi, struct prefix *p,
struct prefix_ipv6 *src_p, struct static_route *si)
{
struct rib *rib;
struct route_entry *re;
struct route_node *rn;
struct route_table *table;
struct prefix nh_p;
@ -55,20 +55,20 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
/* Lookup existing route */
rn = srcdest_rnode_get (table, p, src_p);
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance)
if (re->type == ZEBRA_ROUTE_STATIC && re->distance == si->distance)
break;
}
if (rib)
if (re)
{
/* if tag value changed , update old value in RIB */
if (rib->tag != si->tag)
rib->tag = si->tag;
if (re->tag != si->tag)
re->tag = si->tag;
/* Same distance static route is there. Update it with new
nexthop. */
@ -76,27 +76,27 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
nexthop = rib_nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
nexthop = route_entry_nexthop_ipv4_add (re, &si->addr.ipv4, NULL);
nh_p.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
case STATIC_IFINDEX:
nexthop = rib_nexthop_ifindex_add (rib, si->ifindex);
nexthop = route_entry_nexthop_ifindex_add (re, si->ifindex);
break;
case STATIC_BLACKHOLE:
nexthop = rib_nexthop_blackhole_add (rib);
nexthop = route_entry_nexthop_blackhole_add (re);
break;
case STATIC_IPV6_GATEWAY:
nexthop = rib_nexthop_ipv6_add (rib, &si->addr.ipv6);
nexthop = route_entry_nexthop_ipv6_add (re, &si->addr.ipv6);
nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
case STATIC_IPV6_GATEWAY_IFINDEX:
nexthop = rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6,
nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &si->addr.ipv6,
si->ifindex);
break;
}
@ -111,8 +111,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
if (IS_ZEBRA_DEBUG_RIB)
{
inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
zlog_debug ("%u:%s/%d: Modifying route rn %p, rib %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, rib, rib->type);
zlog_debug ("%u:%s/%d: Modifying route rn %p, re %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, re, re->type);
}
}
/* Schedule route for processing or invoke NHT, as appropriate. */
@ -125,42 +125,42 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
else
{
/* This is new static route. */
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
re = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
rib->type = ZEBRA_ROUTE_STATIC;
rib->instance = 0;
rib->distance = si->distance;
rib->metric = 0;
rib->mtu = 0;
rib->vrf_id = si->vrf_id;
rib->table = si->vrf_id ? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id : zebrad.rtm_table_default;
rib->nexthop_num = 0;
rib->tag = si->tag;
re->type = ZEBRA_ROUTE_STATIC;
re->instance = 0;
re->distance = si->distance;
re->metric = 0;
re->mtu = 0;
re->vrf_id = si->vrf_id;
re->table = si->vrf_id ? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id : zebrad.rtm_table_default;
re->nexthop_num = 0;
re->tag = si->tag;
switch (si->type)
{
case STATIC_IPV4_GATEWAY:
nexthop = rib_nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
nexthop = route_entry_nexthop_ipv4_add (re, &si->addr.ipv4, NULL);
nh_p.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
case STATIC_IFINDEX:
nexthop = rib_nexthop_ifindex_add (rib, si->ifindex);
nexthop = route_entry_nexthop_ifindex_add (re, si->ifindex);
break;
case STATIC_BLACKHOLE:
nexthop = rib_nexthop_blackhole_add (rib);
nexthop = route_entry_nexthop_blackhole_add (re);
break;
case STATIC_IPV6_GATEWAY:
nexthop = rib_nexthop_ipv6_add (rib, &si->addr.ipv6);
nexthop = route_entry_nexthop_ipv6_add (re, &si->addr.ipv6);
nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
case STATIC_IPV6_GATEWAY_IFINDEX:
nexthop = rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6,
nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &si->addr.ipv6,
si->ifindex);
break;
}
@ -170,7 +170,7 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
&si->snh_label.label[0]);
/* Save the flags of this static routes (reject, blackhole) */
rib->flags = si->flags;
re->flags = si->flags;
if (IS_ZEBRA_DEBUG_RIB)
{
@ -178,21 +178,21 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p,
if (IS_ZEBRA_DEBUG_RIB)
{
inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
zlog_debug ("%u:%s/%d: Inserting route rn %p, rib %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, rib, rib->type);
zlog_debug ("%u:%s/%d: Inserting route rn %p, re %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, re, re->type);
}
}
/* Link this rib to the tree. Schedule for processing or invoke NHT,
/* Link this re to the tree. Schedule for processing or invoke NHT,
* as appropriate.
*/
if (si->type == STATIC_IPV4_GATEWAY ||
si->type == STATIC_IPV6_GATEWAY)
{
rib_addnode (rn, rib, 0);
rib_addnode (rn, re, 0);
zebra_evaluate_rnh(si->vrf_id, nh_p.family, 1, RNH_NEXTHOP_TYPE, &nh_p);
}
else
rib_addnode (rn, rib, 1);
rib_addnode (rn, re, 1);
}
}
@ -230,7 +230,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p,
struct prefix_ipv6 *src_p, struct static_route *si)
{
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
struct nexthop *nexthop;
struct route_table *table;
struct prefix nh_p;
@ -245,24 +245,24 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p,
if (! rn)
return;
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED))
continue;
if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance &&
rib->tag == si->tag)
if (re->type == ZEBRA_ROUTE_STATIC && re->distance == si->distance &&
re->tag == si->tag)
break;
}
if (! rib)
if (! re)
{
route_unlock_node (rn);
return;
}
/* Lookup nexthop. */
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
if (static_nexthop_same (nexthop, si))
break;
@ -274,8 +274,8 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p,
}
/* Check nexthop. */
if (rib->nexthop_num == 1)
rib_delnode (rn, rib);
if (re->nexthop_num == 1)
rib_delnode (rn, re);
else
{
/* Mark this nexthop as inactive and reinstall the route. Then, delete
@ -288,31 +288,31 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p,
if (IS_ZEBRA_DEBUG_RIB)
{
inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
zlog_debug ("%u:%s/%d: Modifying route rn %p, rib %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, rib, rib->type);
zlog_debug ("%u:%s/%d: Modifying route rn %p, re %p (type %d)",
si->vrf_id, buf, p->prefixlen, rn, re, re->type);
}
}
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{
/* If there are other active nexthops, do an update. */
if (rib->nexthop_active_num > 1)
if (re->nexthop_active_num > 1)
{
/* Update route in kernel if it's in fib */
if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
rib_install_kernel (rn, rib, rib);
if (CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB))
rib_install_kernel (rn, re, re);
/* Update redistribution if it's selected */
if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED))
redistribute_update (p, (struct prefix*)src_p, rib, NULL);
if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
redistribute_update (p, (struct prefix*)src_p, re, NULL);
}
else
{
/* Remove from redistribute if selected route becomes inactive */
if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED))
redistribute_delete (p, (struct prefix*)src_p, rib);
if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
redistribute_delete (p, (struct prefix*)src_p, re);
/* Remove from kernel if fib route becomes inactive */
if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
rib_uninstall_kernel (rn, rib);
if (CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB))
rib_uninstall_kernel (rn, re);
}
}
@ -329,7 +329,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p,
nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = nexthop->gate.ipv6;
}
rib_nexthop_delete (rib, nexthop);
route_entry_nexthop_delete (re, nexthop);
zebra_deregister_rnh_static_nh(si->vrf_id, &nh_p, rn);
nexthop_free (nexthop);
}

View File

@ -334,10 +334,10 @@ zebra_vrf_table_with_table_id (afi_t afi, safi_t safi,
static void
zebra_rtable_node_cleanup (struct route_table *table, struct route_node *node)
{
struct rib *rib, *next;
struct route_entry *re, *next;
RNODE_FOREACH_RIB_SAFE (node, rib, next)
rib_unlink (node, rib);
RNODE_FOREACH_RE_SAFE (node, re, next)
rib_unlink (node, re);
if (node->info)
XFREE (MTYPE_RIB_DEST, node->info);

View File

@ -321,7 +321,7 @@ DEFUN (show_ip_rpf_addr,
int idx_ipv4 = 3;
struct in_addr addr;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
int ret;
ret = inet_aton (argv[idx_ipv4]->arg, &addr);
@ -331,9 +331,9 @@ DEFUN (show_ip_rpf_addr,
return CMD_WARNING;
}
rib = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
re = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
if (rib)
if (re)
vty_show_ip_route_detail (vty, rn, 1);
else
vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
@ -640,13 +640,13 @@ DEFUN (no_ip_route_mask_flags,
static void
vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
{
struct rib *rib;
struct route_entry *re;
struct nexthop *nexthop, *tnexthop;
int recursing;
char buf[SRCDEST2STR_BUFFER];
struct zebra_vrf *zvrf;
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
const char *mcast_info = "";
if (mcast)
@ -660,42 +660,42 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
vty_out (vty, "Routing entry for %s%s%s",
srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info,
VTY_NEWLINE);
vty_out (vty, " Known via \"%s", zebra_route_string (rib->type));
if (rib->instance)
vty_out (vty, "[%d]", rib->instance);
vty_out (vty, " Known via \"%s", zebra_route_string (re->type));
if (re->instance)
vty_out (vty, "[%d]", re->instance);
vty_out (vty, "\"");
vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
if (rib->tag)
vty_out (vty, ", tag %d", rib->tag);
if (rib->mtu)
vty_out (vty, ", mtu %u", rib->mtu);
if (rib->vrf_id != VRF_DEFAULT)
vty_out (vty, ", distance %u, metric %u", re->distance, re->metric);
if (re->tag)
vty_out (vty, ", tag %d", re->tag);
if (re->mtu)
vty_out (vty, ", mtu %u", re->mtu);
if (re->vrf_id != VRF_DEFAULT)
{
zvrf = vrf_info_lookup(rib->vrf_id);
zvrf = vrf_info_lookup(re->vrf_id);
vty_out (vty, ", vrf %s", zvrf_name (zvrf));
}
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
vty_out (vty, ", best");
if (rib->refcnt)
vty_out (vty, ", refcnt %ld", rib->refcnt);
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
if (re->refcnt)
vty_out (vty, ", refcnt %ld", re->refcnt);
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
vty_out (vty, ", blackhole");
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
vty_out (vty, ", reject");
vty_out (vty, "%s", VTY_NEWLINE);
if (rib->type == ZEBRA_ROUTE_RIP
|| rib->type == ZEBRA_ROUTE_OSPF
|| rib->type == ZEBRA_ROUTE_ISIS
|| rib->type == ZEBRA_ROUTE_NHRP
|| rib->type == ZEBRA_ROUTE_TABLE
|| rib->type == ZEBRA_ROUTE_BGP)
if (re->type == ZEBRA_ROUTE_RIP
|| re->type == ZEBRA_ROUTE_OSPF
|| re->type == ZEBRA_ROUTE_ISIS
|| re->type == ZEBRA_ROUTE_NHRP
|| re->type == ZEBRA_ROUTE_TABLE
|| re->type == ZEBRA_ROUTE_BGP)
{
time_t uptime;
struct tm *tm;
uptime = time (NULL);
uptime -= rib->uptime;
uptime -= re->uptime;
tm = gmtime (&uptime);
vty_out (vty, " Last update ");
@ -713,7 +713,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
vty_out (vty, " ago%s", VTY_NEWLINE);
}
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
char addrstr[32];
@ -728,7 +728,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
if (nexthop->ifindex)
vty_out (vty, ", via %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@ -736,11 +736,11 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex)
vty_out (vty, ", via %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out (vty, " directly connected, %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " directly connected, Null0");
@ -796,7 +796,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
}
static void
vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *re,
json_object *json)
{
struct nexthop *nexthop, *tnexthop;
@ -814,41 +814,41 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
json_nexthops = json_object_new_array();
json_object_string_add(json_route, "prefix", srcdest_rnode2str (rn, buf, sizeof buf));
json_object_string_add(json_route, "protocol", zebra_route_string(rib->type));
json_object_string_add(json_route, "protocol", zebra_route_string(re->type));
if (rib->instance)
json_object_int_add(json_route, "instance", rib->instance);
if (re->instance)
json_object_int_add(json_route, "instance", re->instance);
if (rib->vrf_id)
json_object_int_add(json_route, "vrfId", rib->vrf_id);
if (re->vrf_id)
json_object_int_add(json_route, "vrfId", re->vrf_id);
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
json_object_boolean_true_add(json_route, "selected");
if (rib->type != ZEBRA_ROUTE_CONNECT && rib->type != ZEBRA_ROUTE_KERNEL)
if (re->type != ZEBRA_ROUTE_CONNECT && re->type != ZEBRA_ROUTE_KERNEL)
{
json_object_int_add(json_route, "distance", rib->distance);
json_object_int_add(json_route, "metric", rib->metric);
json_object_int_add(json_route, "distance", re->distance);
json_object_int_add(json_route, "metric", re->metric);
}
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
json_object_boolean_true_add(json_route, "blackhole");
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
json_object_boolean_true_add(json_route, "reject");
if (rib->type == ZEBRA_ROUTE_RIP
|| rib->type == ZEBRA_ROUTE_OSPF
|| rib->type == ZEBRA_ROUTE_ISIS
|| rib->type == ZEBRA_ROUTE_NHRP
|| rib->type == ZEBRA_ROUTE_TABLE
|| rib->type == ZEBRA_ROUTE_BGP)
if (re->type == ZEBRA_ROUTE_RIP
|| re->type == ZEBRA_ROUTE_OSPF
|| re->type == ZEBRA_ROUTE_ISIS
|| re->type == ZEBRA_ROUTE_NHRP
|| re->type == ZEBRA_ROUTE_TABLE
|| re->type == ZEBRA_ROUTE_BGP)
{
time_t uptime;
struct tm *tm;
uptime = time (NULL);
uptime -= rib->uptime;
uptime -= re->uptime;
tm = gmtime (&uptime);
if (uptime < ONE_DAY_SECOND)
@ -861,7 +861,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
json_object_string_add(json_route, "uptime", buf);
}
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
json_nexthop = json_object_new_object();
@ -878,7 +878,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
if (nexthop->ifindex)
{
json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
}
break;
case NEXTHOP_TYPE_IPV6:
@ -889,14 +889,14 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
if (nexthop->ifindex)
{
json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
}
break;
case NEXTHOP_TYPE_IFINDEX:
json_object_boolean_true_add(json_nexthop, "directlyConnected");
json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
json_object_boolean_true_add(json_nexthop, "blackhole");
@ -955,26 +955,26 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
}
/* Nexthop information. */
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
{
if (nexthop == rib->nexthop)
if (nexthop == re->nexthop)
{
/* Prefix information. */
len = vty_out (vty, "%c", zebra_route_char (rib->type));
if (rib->instance)
len += vty_out (vty, "[%d]", rib->instance);
len = vty_out (vty, "%c", zebra_route_char (re->type));
if (re->instance)
len += vty_out (vty, "[%d]", re->instance);
len += vty_out (vty, "%c%c %s",
CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)
? '>' : ' ',
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
? '*' : ' ',
srcdest_rnode2str (rn, buf, sizeof buf));
/* Distance and metric display. */
if (rib->type != ZEBRA_ROUTE_CONNECT
&& rib->type != ZEBRA_ROUTE_KERNEL)
len += vty_out (vty, " [%d/%d]", rib->distance,
rib->metric);
if (re->type != ZEBRA_ROUTE_CONNECT
&& re->type != ZEBRA_ROUTE_KERNEL)
len += vty_out (vty, " [%d/%d]", re->distance,
re->metric);
}
else
vty_out (vty, " %c%*c",
@ -989,7 +989,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
if (nexthop->ifindex)
vty_out (vty, ", %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@ -997,12 +997,12 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex)
vty_out (vty, ", %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out (vty, " is directly connected, %s",
ifindex2ifname (nexthop->ifindex, rib->vrf_id));
ifindex2ifname (nexthop->ifindex, re->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out (vty, " is directly connected, Null0");
@ -1049,23 +1049,23 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
nexthop->nh_label->label, buf, BUFSIZ, 1));
}
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
vty_out (vty, ", bh");
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
vty_out (vty, ", rej");
if (rib->type == ZEBRA_ROUTE_RIP
|| rib->type == ZEBRA_ROUTE_OSPF
|| rib->type == ZEBRA_ROUTE_ISIS
|| rib->type == ZEBRA_ROUTE_NHRP
|| rib->type == ZEBRA_ROUTE_TABLE
|| rib->type == ZEBRA_ROUTE_BGP)
if (re->type == ZEBRA_ROUTE_RIP
|| re->type == ZEBRA_ROUTE_OSPF
|| re->type == ZEBRA_ROUTE_ISIS
|| re->type == ZEBRA_ROUTE_NHRP
|| re->type == ZEBRA_ROUTE_TABLE
|| re->type == ZEBRA_ROUTE_BGP)
{
time_t uptime;
struct tm *tm;
uptime = time (NULL);
uptime -= rib->uptime;
uptime -= re->uptime;
tm = gmtime (&uptime);
if (uptime < ONE_DAY_SECOND)
@ -1097,7 +1097,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi,
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
int first = 1;
struct zebra_vrf *zvrf = NULL;
char buf[BUFSIZ];
@ -1137,12 +1137,12 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi,
/* Show all routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
{
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
if (use_fib && !CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB))
continue;
if (tag && rib->tag != tag)
if (tag && re->tag != tag)
continue;
if (longer_prefix_p && ! prefix_match (longer_prefix_p, &rn->p))
@ -1163,10 +1163,10 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi,
continue;
}
if (type && rib->type != type)
if (type && re->type != type)
continue;
if (ospf_instance_id && (rib->type != ZEBRA_ROUTE_OSPF || rib->instance != ospf_instance_id))
if (ospf_instance_id && (re->type != ZEBRA_ROUTE_OSPF || re->instance != ospf_instance_id))
continue;
if (use_json)
@ -1190,7 +1190,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi,
}
}
vty_show_ip_route (vty, rn, rib, json_prefix);
vty_show_ip_route (vty, rn, re, json_prefix);
}
if (json_prefix)
@ -1567,7 +1567,7 @@ static void
vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
{
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
@ -1578,25 +1578,25 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
memset (&rib_cnt, 0, sizeof(rib_cnt));
memset (&fib_cnt, 0, sizeof(fib_cnt));
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
is_ibgp = (rib->type == ZEBRA_ROUTE_BGP &&
CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP));
is_ibgp = (re->type == ZEBRA_ROUTE_BGP &&
CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP));
rib_cnt[ZEBRA_ROUTE_TOTAL]++;
if (is_ibgp)
rib_cnt[ZEBRA_ROUTE_IBGP]++;
else
rib_cnt[rib->type]++;
rib_cnt[re->type]++;
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
{
fib_cnt[ZEBRA_ROUTE_TOTAL]++;
if (is_ibgp)
fib_cnt[ZEBRA_ROUTE_IBGP]++;
else
fib_cnt[rib->type]++;
fib_cnt[re->type]++;
}
}
@ -1642,7 +1642,7 @@ static void
vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
{
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
struct nexthop *nexthop;
#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
@ -1654,25 +1654,25 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
memset (&rib_cnt, 0, sizeof(rib_cnt));
memset (&fib_cnt, 0, sizeof(fib_cnt));
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
/*
* In case of ECMP, count only once.
*/
cnt = 0;
for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
for (nexthop = re->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
{
cnt++;
rib_cnt[ZEBRA_ROUTE_TOTAL]++;
rib_cnt[rib->type]++;
rib_cnt[re->type]++;
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{
fib_cnt[ZEBRA_ROUTE_TOTAL]++;
fib_cnt[rib->type]++;
fib_cnt[re->type]++;
}
if (rib->type == ZEBRA_ROUTE_BGP &&
CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
if (re->type == ZEBRA_ROUTE_BGP &&
CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP))
{
rib_cnt[ZEBRA_ROUTE_IBGP]++;
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@ -2816,7 +2816,7 @@ DEFUN (show_ipv6_mroute,
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
@ -2829,14 +2829,14 @@ DEFUN (show_ipv6_mroute,
/* Show all IPv6 route. */
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
first = 0;
}
vty_show_ip_route (vty, rn, rib, NULL);
vty_show_ip_route (vty, rn, re, NULL);
}
return CMD_SUCCESS;
}
@ -2959,7 +2959,7 @@ DEFUN (show_ipv6_mroute_vrf_all,
{
struct route_table *table;
struct route_node *rn;
struct rib *rib;
struct route_entry *re;
struct vrf *vrf;
struct zebra_vrf *zvrf;
int first = 1;
@ -2972,14 +2972,14 @@ DEFUN (show_ipv6_mroute_vrf_all,
/* Show all IPv6 route. */
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
RNODE_FOREACH_RE (rn, re)
{
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
first = 0;
}
vty_show_ip_route (vty, rn, rib, NULL);
vty_show_ip_route (vty, rn, re, NULL);
}
}
return CMD_SUCCESS;

View File

@ -608,7 +608,7 @@ zsend_interface_update (int cmd, struct zserv *client, struct interface *ifp)
*/
int
zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
struct prefix *src_p, struct rib *rib)
struct prefix *src_p, struct route_entry *re)
{
afi_t afi;
int cmd;
@ -658,12 +658,12 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
stream_reset (s);
memset(&dummy_nh, 0, sizeof(struct nexthop));
zserv_create_header (s, cmd, rib->vrf_id);
zserv_create_header (s, cmd, re->vrf_id);
/* Put type and nexthop. */
stream_putc (s, rib->type);
stream_putw (s, rib->instance);
stream_putl (s, rib->flags);
stream_putc (s, re->type);
stream_putw (s, re->instance);
stream_putl (s, re->flags);
/* marker for message flags field */
messmark = stream_get_endp (s);
@ -682,10 +682,10 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
stream_write (s, (u_char *) & src_p->u.prefix, psize);
}
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
{
/* We don't send any nexthops when there's a multipath */
if (rib->nexthop_active_num > 1 && client->proto != ZEBRA_ROUTE_LDP)
if (re->nexthop_active_num > 1 && client->proto != ZEBRA_ROUTE_LDP)
{
SET_FLAG (zapi_flags, ZAPI_MESSAGE_NEXTHOP);
SET_FLAG (zapi_flags, ZAPI_MESSAGE_IFINDEX);
@ -764,22 +764,22 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
/* Distance */
SET_FLAG (zapi_flags, ZAPI_MESSAGE_DISTANCE);
stream_putc (s, rib->distance);
stream_putc (s, re->distance);
/* Metric */
SET_FLAG (zapi_flags, ZAPI_MESSAGE_METRIC);
stream_putl (s, rib->metric);
stream_putl (s, re->metric);
/* Tag */
if (rib->tag)
if (re->tag)
{
SET_FLAG(zapi_flags, ZAPI_MESSAGE_TAG);
stream_putl(s, rib->tag);
stream_putl(s, re->tag);
}
/* MTU */
SET_FLAG (zapi_flags, ZAPI_MESSAGE_MTU);
stream_putl (s, rib->mtu);
stream_putl (s, re->mtu);
/* write real message flags value */
stream_putc_at (s, messmark, zapi_flags);
@ -1044,7 +1044,7 @@ zserv_fec_unregister (struct zserv *client, int sock, u_short length)
Returns both route metric and protocol distance.
*/
static int
zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struct rib *rib, struct zebra_vrf *zvrf)
zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struct route_entry *re, struct zebra_vrf *zvrf)
{
struct stream *s;
unsigned long nump;
@ -1059,17 +1059,17 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc
zserv_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id (zvrf));
stream_put_in_addr (s, &addr);
if (rib)
if (re)
{
stream_putc (s, rib->distance);
stream_putl (s, rib->metric);
stream_putc (s, re->distance);
stream_putl (s, re->metric);
num = 0;
nump = stream_get_endp(s); /* remember position for nexthop_num */
stream_putc (s, 0); /* reserve room for nexthop_num */
/* Only non-recursive routes are elegible to resolve the nexthop we
* are looking up. Therefore, we will just iterate over the top
* chain of nexthops. */
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
num += zsend_write_nexthop (s, nexthop);
@ -1169,14 +1169,14 @@ zserv_nexthop_num_warn (const char *caller, const struct prefix *p, const unsign
/* This function support multiple nexthop. */
/*
* Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update rib and
* Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update re and
* add kernel route.
*/
static int
zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
{
int i;
struct rib *rib;
struct route_entry *re;
struct prefix p;
u_char message;
struct in_addr nhop_addr;
@ -1192,16 +1192,16 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
/* Get input stream. */
s = client->ibuf;
/* Allocate new rib. */
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
/* Allocate new re. */
re = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
/* Type, flags, message. */
rib->type = stream_getc (s);
rib->instance = stream_getw (s);
rib->flags = stream_getl (s);
re->type = stream_getc (s);
re->instance = stream_getw (s);
re->flags = stream_getl (s);
message = stream_getc (s);
safi = stream_getw (s);
rib->uptime = time (NULL);
re->uptime = time (NULL);
/* IPv4 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv4));
@ -1210,7 +1210,7 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen));
/* VRF ID */
rib->vrf_id = zvrf_id (zvrf);
re->vrf_id = zvrf_id (zvrf);
/* Nexthop parse. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP))
@ -1226,11 +1226,11 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
{
case NEXTHOP_TYPE_IFINDEX:
ifindex = stream_getl (s);
rib_nexthop_ifindex_add (rib, ifindex);
route_entry_nexthop_ifindex_add (re, ifindex);
break;
case NEXTHOP_TYPE_IPV4:
nhop_addr.s_addr = stream_get_ipv4 (s);
nexthop = rib_nexthop_ipv4_add (rib, &nhop_addr, NULL);
nexthop = route_entry_nexthop_ipv4_add (re, &nhop_addr, NULL);
/* For labeled-unicast, each nexthop is followed by label. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL))
{
@ -1241,13 +1241,13 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
case NEXTHOP_TYPE_IPV4_IFINDEX:
nhop_addr.s_addr = stream_get_ipv4 (s);
ifindex = stream_getl (s);
rib_nexthop_ipv4_ifindex_add (rib, &nhop_addr, NULL, ifindex);
route_entry_nexthop_ipv4_ifindex_add (re, &nhop_addr, NULL, ifindex);
break;
case NEXTHOP_TYPE_IPV6:
stream_forward_getp (s, IPV6_MAX_BYTELEN);
break;
case NEXTHOP_TYPE_BLACKHOLE:
rib_nexthop_blackhole_add (rib);
route_entry_nexthop_blackhole_add (re);
break;
}
}
@ -1255,27 +1255,27 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
/* Distance. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
rib->distance = stream_getc (s);
re->distance = stream_getc (s);
/* Metric. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
rib->metric = stream_getl (s);
re->metric = stream_getl (s);
/* Tag */
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
rib->tag = stream_getl (s);
re->tag = stream_getl (s);
else
rib->tag = 0;
re->tag = 0;
if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU))
rib->mtu = stream_getl (s);
re->mtu = stream_getl (s);
else
rib->mtu = 0;
re->mtu = 0;
/* Table */
rib->table = zvrf->table_id;
re->table = zvrf->table_id;
ret = rib_add_multipath (AFI_IP, safi, &p, NULL, rib);
ret = rib_add_multipath (AFI_IP, safi, &p, NULL, re);
/* Stats */
if (ret > 0)
@ -1384,11 +1384,11 @@ static int
zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
{
struct in_addr addr;
struct rib *rib;
struct route_entry *re;
addr.s_addr = stream_get_ipv4 (client->ibuf);
rib = rib_match_ipv4_multicast (zvrf_id (zvrf), addr, NULL);
return zsend_ipv4_nexthop_lookup_mrib (client, addr, rib, zvrf);
re = rib_match_ipv4_multicast (zvrf_id (zvrf), addr, NULL);
return zsend_ipv4_nexthop_lookup_mrib (client, addr, re, zvrf);
}
/* Zebra server IPv6 prefix add function. */
@ -1398,7 +1398,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct
unsigned int i;
struct stream *s;
struct in6_addr nhop_addr;
struct rib *rib;
struct route_entry *re;
u_char message;
u_char nexthop_num;
u_char nexthop_type;
@ -1416,16 +1416,16 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct
memset (&nhop_addr, 0, sizeof (struct in6_addr));
/* Allocate new rib. */
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
/* Allocate new re. */
re = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
/* Type, flags, message. */
rib->type = stream_getc (s);
rib->instance = stream_getw (s);
rib->flags = stream_getl (s);
re->type = stream_getc (s);
re->instance = stream_getw (s);
re->flags = stream_getl (s);
message = stream_getc (s);
safi = stream_getw (s);
rib->uptime = time (NULL);
re->uptime = time (NULL);
/* IPv4 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv4));
@ -1434,10 +1434,10 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct
stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen));
/* VRF ID */
rib->vrf_id = zvrf_id (zvrf);
re->vrf_id = zvrf_id (zvrf);
/* We need to give nh-addr, nh-ifindex with the same next-hop object
* to the rib to ensure that IPv6 multipathing works; need to coalesce
* to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of
* next-hop-addr/next-hop-ifindices. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP))
@ -1474,7 +1474,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct
}
break;
case NEXTHOP_TYPE_BLACKHOLE:
rib_nexthop_blackhole_add (rib);
route_entry_nexthop_blackhole_add (re);
break;
}
}
@ -1484,43 +1484,43 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct
{
if ((i < nh_count) && !IN6_IS_ADDR_UNSPECIFIED (&nexthops[i])) {
if ((i < if_count) && ifindices[i])
nexthop = rib_nexthop_ipv6_ifindex_add (rib, &nexthops[i], ifindices[i]);
nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &nexthops[i], ifindices[i]);
else
nexthop = rib_nexthop_ipv6_add (rib, &nexthops[i]);
nexthop = route_entry_nexthop_ipv6_add (re, &nexthops[i]);
if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels (nexthop, nexthop->nh_label_type, 1, &labels[i]);
}
else {
if ((i < if_count) && ifindices[i])
rib_nexthop_ifindex_add (rib, ifindices[i]);
route_entry_nexthop_ifindex_add (re, ifindices[i]);
}
}
}
/* Distance. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
rib->distance = stream_getc (s);
re->distance = stream_getc (s);
/* Metric. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
rib->metric = stream_getl (s);
re->metric = stream_getl (s);
/* Tag */
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
rib->tag = stream_getl (s);
re->tag = stream_getl (s);
else
rib->tag = 0;
re->tag = 0;
if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU))
rib->mtu = stream_getl (s);
re->mtu = stream_getl (s);
else
rib->mtu = 0;
re->mtu = 0;
/* Table */
rib->table = zvrf->table_id;
re->table = zvrf->table_id;
ret = rib_add_multipath (AFI_IP6, safi, &p, NULL, rib);
ret = rib_add_multipath (AFI_IP6, safi, &p, NULL, re);
/* Stats */
if (ret > 0)
client->v4_route_add_cnt++;
@ -1536,7 +1536,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
unsigned int i;
struct stream *s;
struct in6_addr nhop_addr;
struct rib *rib;
struct route_entry *re;
u_char message;
u_char nexthop_num;
u_char nexthop_type;
@ -1555,16 +1555,16 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
memset (&nhop_addr, 0, sizeof (struct in6_addr));
/* Allocate new rib. */
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
/* Allocate new re. */
re = XCALLOC (MTYPE_RE, sizeof (struct route_entry));
/* Type, flags, message. */
rib->type = stream_getc (s);
rib->instance = stream_getw (s);
rib->flags = stream_getl (s);
re->type = stream_getc (s);
re->instance = stream_getw (s);
re->flags = stream_getl (s);
message = stream_getc (s);
safi = stream_getw (s);
rib->uptime = time (NULL);
re->uptime = time (NULL);
/* IPv6 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv6));
@ -1584,7 +1584,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
src_pp = NULL;
/* We need to give nh-addr, nh-ifindex with the same next-hop object
* to the rib to ensure that IPv6 multipathing works; need to coalesce
* to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of
* next-hop-addr/next-hop-ifindices. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP))
@ -1620,7 +1620,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
}
break;
case NEXTHOP_TYPE_BLACKHOLE:
rib_nexthop_blackhole_add (rib);
route_entry_nexthop_blackhole_add (re);
break;
}
}
@ -1630,43 +1630,43 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
{
if ((i < nh_count) && !IN6_IS_ADDR_UNSPECIFIED (&nexthops[i])) {
if ((i < if_count) && ifindices[i])
nexthop = rib_nexthop_ipv6_ifindex_add (rib, &nexthops[i], ifindices[i]);
nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &nexthops[i], ifindices[i]);
else
nexthop = rib_nexthop_ipv6_add (rib, &nexthops[i]);
nexthop = route_entry_nexthop_ipv6_add (re, &nexthops[i]);
if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels (nexthop, nexthop->nh_label_type, 1, &labels[i]);
}
else {
if ((i < if_count) && ifindices[i])
rib_nexthop_ifindex_add (rib, ifindices[i]);
route_entry_nexthop_ifindex_add (re, ifindices[i]);
}
}
}
/* Distance. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
rib->distance = stream_getc (s);
re->distance = stream_getc (s);
/* Metric. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
rib->metric = stream_getl (s);
re->metric = stream_getl (s);
/* Tag */
if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG))
rib->tag = stream_getl (s);
re->tag = stream_getl (s);
else
rib->tag = 0;
re->tag = 0;
if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU))
rib->mtu = stream_getl (s);
re->mtu = stream_getl (s);
else
rib->mtu = 0;
re->mtu = 0;
/* VRF ID */
rib->vrf_id = zvrf_id (zvrf);
rib->table = zvrf->table_id;
re->vrf_id = zvrf_id (zvrf);
re->table = zvrf->table_id;
ret = rib_add_multipath (AFI_IP6, safi, &p, src_pp, rib);
ret = rib_add_multipath (AFI_IP6, safi, &p, src_pp, re);
/* Stats */
if (ret > 0)
client->v6_route_add_cnt++;

View File

@ -162,7 +162,7 @@ extern void nbr_connected_add_ipv6 (struct interface *, struct in6_addr *);
extern void nbr_connected_delete_ipv6 (struct interface *, struct in6_addr *);
extern int zsend_interface_update (int, struct zserv *, struct interface *);
extern int zsend_redistribute_route (int, struct zserv *, struct prefix *,
struct prefix *, struct rib *);
struct prefix *, struct route_entry *);
extern int zsend_router_id_update (struct zserv *, struct prefix *,
vrf_id_t);
extern int zsend_interface_vrf_update (struct zserv *, struct interface *,