bgpd: Convert binfo to path

Convert the binfo variable to path.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-10-02 18:34:03 -04:00
parent 18ee831031
commit 9b6d8fcf29
23 changed files with 585 additions and 628 deletions

View File

@ -90,9 +90,9 @@ struct bgp_advertise *bgp_advertise_new(void)
void bgp_advertise_free(struct bgp_advertise *adv)
{
if (adv->binfo)
bgp_path_info_unlock(
adv->binfo); /* bgp_advertise bgp_path_info reference */
if (adv->pathi)
/* bgp_advertise bgp_path_info reference */
bgp_path_info_unlock(adv->pathi);
XFREE(MTYPE_BGP_ADVERTISE, adv);
}

View File

@ -62,7 +62,7 @@ struct bgp_advertise {
struct bgp_advertise_attr *baa;
/* BGP info. */
struct bgp_path_info *binfo;
struct bgp_path_info *pathi;
};
/* BGP adjacency out. */

View File

@ -128,7 +128,7 @@ static int bgp_reuse_timer(struct thread *t)
/* 3. if ( the saved list head pointer is non-empty ) */
for (; bdi; bdi = next) {
struct bgp *bgp = bdi->binfo->peer->bgp;
struct bgp *bgp = bdi->path->peer->bgp;
next = bdi->next;
@ -145,15 +145,15 @@ static int bgp_reuse_timer(struct thread *t)
/* if (figure-of-merit < reuse). */
if (bdi->penalty < damp->reuse_limit) {
/* Reuse the route. */
bgp_path_info_unset_flag(bdi->rn, bdi->binfo,
bgp_path_info_unset_flag(bdi->rn, bdi->path,
BGP_PATH_DAMPED);
bdi->suppress_time = 0;
if (bdi->lastrecord == BGP_RECORD_UPDATE) {
bgp_path_info_unset_flag(bdi->rn, bdi->binfo,
bgp_path_info_unset_flag(bdi->rn, bdi->path,
BGP_PATH_HISTORY);
bgp_aggregate_increment(bgp, &bdi->rn->p,
bdi->binfo, bdi->afi,
bdi->path, bdi->afi,
bdi->safi);
bgp_process(bgp, bdi->rn, bdi->afi, bdi->safi);
}
@ -172,7 +172,7 @@ static int bgp_reuse_timer(struct thread *t)
}
/* A route becomes unreachable (RFC2439 Section 4.8.2). */
int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
afi_t afi, safi_t safi, int attr_change)
{
time_t t_now;
@ -182,8 +182,8 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
t_now = bgp_clock();
/* Processing Unreachable Messages. */
if (binfo->extra)
bdi = binfo->extra->damp_info;
if (path->extra)
bdi = path->extra->damp_info;
if (bdi == NULL) {
/* If there is no previous stability history. */
@ -195,7 +195,7 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
bdi = XCALLOC(MTYPE_BGP_DAMP_INFO,
sizeof(struct bgp_damp_info));
bdi->binfo = binfo;
bdi->path = path;
bdi->rn = rn;
bdi->penalty =
(attr_change ? DEFAULT_PENALTY / 2 : DEFAULT_PENALTY);
@ -205,7 +205,7 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
bdi->index = -1;
bdi->afi = afi;
bdi->safi = safi;
(bgp_path_info_extra_get(binfo))->damp_info = bdi;
(bgp_path_info_extra_get(path))->damp_info = bdi;
BGP_DAMP_LIST_ADD(damp, bdi);
} else {
last_penalty = bdi->penalty;
@ -222,16 +222,16 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
bdi->flap++;
}
assert((rn == bdi->rn) && (binfo == bdi->binfo));
assert((rn == bdi->rn) && (path == bdi->path));
bdi->lastrecord = BGP_RECORD_WITHDRAW;
bdi->t_updated = t_now;
/* Make this route as historical status. */
bgp_path_info_set_flag(rn, binfo, BGP_PATH_HISTORY);
bgp_path_info_set_flag(rn, path, BGP_PATH_HISTORY);
/* Remove the route from a reuse list if it is on one. */
if (CHECK_FLAG(bdi->binfo->flags, BGP_PATH_DAMPED)) {
if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)) {
/* If decay rate isn't equal to 0, reinsert brn. */
if (bdi->penalty != last_penalty && bdi->index >= 0) {
bgp_reuse_list_delete(bdi);
@ -243,7 +243,7 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
/* If not suppressed before, do annonunce this withdraw and
insert into reuse_list. */
if (bdi->penalty >= damp->suppress_value) {
bgp_path_info_set_flag(rn, binfo, BGP_PATH_DAMPED);
bgp_path_info_set_flag(rn, path, BGP_PATH_DAMPED);
bdi->suppress_time = t_now;
BGP_DAMP_LIST_DEL(damp, bdi);
bgp_reuse_list_add(bdi);
@ -252,28 +252,28 @@ int bgp_damp_withdraw(struct bgp_path_info *binfo, struct bgp_node *rn,
return BGP_DAMP_USED;
}
int bgp_damp_update(struct bgp_path_info *binfo, struct bgp_node *rn, afi_t afi,
int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, afi_t afi,
safi_t safi)
{
time_t t_now;
struct bgp_damp_info *bdi;
int status;
if (!binfo->extra || !((bdi = binfo->extra->damp_info)))
if (!path->extra || !((bdi = path->extra->damp_info)))
return BGP_DAMP_USED;
t_now = bgp_clock();
bgp_path_info_unset_flag(rn, binfo, BGP_PATH_HISTORY);
bgp_path_info_unset_flag(rn, path, BGP_PATH_HISTORY);
bdi->lastrecord = BGP_RECORD_UPDATE;
bdi->penalty = bgp_damp_decay(t_now - bdi->t_updated, bdi->penalty);
if (!CHECK_FLAG(bdi->binfo->flags, BGP_PATH_DAMPED)
if (!CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
&& (bdi->penalty < damp->suppress_value))
status = BGP_DAMP_USED;
else if (CHECK_FLAG(bdi->binfo->flags, BGP_PATH_DAMPED)
else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
&& (bdi->penalty < damp->reuse_limit)) {
bgp_path_info_unset_flag(rn, binfo, BGP_PATH_DAMPED);
bgp_path_info_unset_flag(rn, path, BGP_PATH_DAMPED);
bgp_reuse_list_delete(bdi);
BGP_DAMP_LIST_ADD(damp, bdi);
bdi->suppress_time = 0;
@ -290,21 +290,21 @@ int bgp_damp_update(struct bgp_path_info *binfo, struct bgp_node *rn, afi_t afi,
}
/* Remove dampening information and history route. */
int bgp_damp_scan(struct bgp_path_info *binfo, afi_t afi, safi_t safi)
int bgp_damp_scan(struct bgp_path_info *path, afi_t afi, safi_t safi)
{
time_t t_now, t_diff;
struct bgp_damp_info *bdi;
assert(binfo->extra && binfo->extra->damp_info);
assert(path->extra && path->extra->damp_info);
t_now = bgp_clock();
bdi = binfo->extra->damp_info;
bdi = path->extra->damp_info;
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED)) {
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)) {
t_diff = t_now - bdi->suppress_time;
if (t_diff >= damp->max_suppress_time) {
bgp_path_info_unset_flag(bdi->rn, binfo,
bgp_path_info_unset_flag(bdi->rn, path,
BGP_PATH_DAMPED);
bgp_reuse_list_delete(bdi);
BGP_DAMP_LIST_ADD(damp, bdi);
@ -312,7 +312,7 @@ int bgp_damp_scan(struct bgp_path_info *binfo, afi_t afi, safi_t safi)
bdi->suppress_time = 0;
bdi->t_updated = t_now;
/* Need to announce UPDATE once this binfo is usable
/* Need to announce UPDATE once this path is usable
* again. */
if (bdi->lastrecord == BGP_RECORD_UPDATE)
return 1;
@ -324,7 +324,7 @@ int bgp_damp_scan(struct bgp_path_info *binfo, afi_t afi, safi_t safi)
bdi->penalty = bgp_damp_decay(t_diff, bdi->penalty);
if (bdi->penalty <= damp->reuse_limit / 2.0) {
/* release the bdi, bdi->binfo. */
/* release the bdi, bdi->path. */
bgp_damp_info_free(bdi, 1);
return 0;
} else
@ -335,24 +335,24 @@ int bgp_damp_scan(struct bgp_path_info *binfo, afi_t afi, safi_t safi)
void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw)
{
struct bgp_path_info *binfo;
struct bgp_path_info *path;
if (!bdi)
return;
binfo = bdi->binfo;
binfo->extra->damp_info = NULL;
path = bdi->path;
path->extra->damp_info = NULL;
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED))
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED))
bgp_reuse_list_delete(bdi);
else
BGP_DAMP_LIST_DEL(damp, bdi);
bgp_path_info_unset_flag(bdi->rn, binfo,
bgp_path_info_unset_flag(bdi->rn, path,
BGP_PATH_HISTORY | BGP_PATH_DAMPED);
if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw)
bgp_path_info_delete(bdi->rn, binfo);
bgp_path_info_delete(bdi->rn, path);
XFREE(MTYPE_BGP_DAMP_INFO, bdi);
}
@ -590,7 +590,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,
return buf;
}
void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *binfo,
void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path,
json_object *json_path)
{
struct bgp_damp_info *bdi;
@ -598,11 +598,11 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *binfo,
char timebuf[BGP_UPTIME_LEN];
int penalty;
if (!binfo->extra)
if (!path->extra)
return;
/* BGP dampening information. */
bdi = binfo->extra->damp_info;
bdi = path->extra->damp_info;
/* If dampening is not enabled or there is no dampening information,
return immediately. */
@ -620,8 +620,8 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *binfo,
peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 1,
json_path);
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
bgp_get_reuse_time(penalty, timebuf, BGP_UPTIME_LEN, 1,
json_path);
} else {
@ -631,8 +631,8 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *binfo,
peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 0,
json_path));
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
vty_out(vty, ", reuse in %s",
bgp_get_reuse_time(penalty, timebuf,
BGP_UPTIME_LEN, 0,
@ -642,20 +642,19 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *binfo,
}
}
const char *bgp_damp_reuse_time_vty(struct vty *vty,
struct bgp_path_info *binfo, char *timebuf,
size_t len, bool use_json,
const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path,
char *timebuf, size_t len, bool use_json,
json_object *json)
{
struct bgp_damp_info *bdi;
time_t t_now, t_diff;
int penalty;
if (!binfo->extra)
if (!path->extra)
return NULL;
/* BGP dampening information. */
bdi = binfo->extra->damp_info;
bdi = path->extra->damp_info;
/* If dampening is not enabled or there is no dampening information,
return immediately. */

View File

@ -44,7 +44,7 @@ struct bgp_damp_info {
time_t suppress_time;
/* Back reference to bgp_path_info. */
struct bgp_path_info *binfo;
struct bgp_path_info *path;
/* Back reference to bgp_node. */
struct bgp_node *rn;
@ -142,7 +142,7 @@ extern void bgp_config_write_damp(struct vty *);
extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path,
json_object *json_path);
extern const char *bgp_damp_reuse_time_vty(struct vty *vty,
struct bgp_path_info *binfo,
struct bgp_path_info *path,
char *timebuf, size_t len,
bool use_json, json_object *json);
extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t);

View File

@ -44,7 +44,7 @@ extern void bgp_fs_nlri_get_string(unsigned char *nlri_content, size_t len,
json_object *json_path);
extern void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
json_object *json_paths);
extern int bgp_fs_config_write_pbr(struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi);

View File

@ -253,7 +253,7 @@ void bgp_fs_nlri_get_string(unsigned char *nlri_content, size_t len,
}
void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
json_object *json_paths)
{
struct attr *attr;
@ -274,9 +274,9 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
else
json_nlri_path = json_paths;
}
if (display == NLRI_STRING_FORMAT_LARGE && binfo)
if (display == NLRI_STRING_FORMAT_LARGE && path)
vty_out(vty, "BGP flowspec entry: (flags 0x%x)\n",
binfo->flags);
path->flags);
bgp_fs_nlri_get_string((unsigned char *)
p->u.prefix_flowspec.ptr,
p->u.prefix_flowspec.prefixlen,
@ -292,11 +292,11 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
else if (json_paths && display == NLRI_STRING_FORMAT_JSON)
json_object_array_add(json_paths, json_nlri_path);
}
if (!binfo)
if (!path)
return;
if (binfo->attr && binfo->attr->ecommunity) {
if (path->attr && path->attr->ecommunity) {
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
s = ecommunity_ecom2str(attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
if (!s)
@ -318,7 +318,7 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
vty_out(vty, "\tNH %-16s\n", inet_ntoa(attr->nexthop));
XFREE(MTYPE_ECOMMUNITY_STR, s);
}
peer_uptime(binfo->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
if (display == NLRI_STRING_FORMAT_LARGE) {
vty_out(vty, "\treceived for %8s\n", timebuf);
} else if (json_paths) {
@ -330,7 +330,7 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
}
if (display == NLRI_STRING_FORMAT_LARGE) {
struct bgp_path_info_extra *extra =
bgp_path_info_extra_get(binfo);
bgp_path_info_extra_get(path);
if (extra->bgp_fs_pbr) {
struct listnode *node;

View File

@ -289,17 +289,17 @@ void bgp_path_info_mpath_free(struct bgp_path_info_mpath **mpath)
* doing lazy allocation.
*/
static struct bgp_path_info_mpath *
bgp_path_info_mpath_get(struct bgp_path_info *binfo)
bgp_path_info_mpath_get(struct bgp_path_info *path)
{
struct bgp_path_info_mpath *mpath;
if (!binfo->mpath) {
if (!path->mpath) {
mpath = bgp_path_info_mpath_new();
if (!mpath)
return NULL;
binfo->mpath = mpath;
mpath->mp_info = binfo;
path->mpath = mpath;
mpath->mp_info = path;
}
return binfo->mpath;
return path->mpath;
}
/*
@ -309,12 +309,12 @@ bgp_path_info_mpath_get(struct bgp_path_info *binfo)
* list entry
*/
static void bgp_path_info_mpath_enqueue(struct bgp_path_info *prev_info,
struct bgp_path_info *binfo)
struct bgp_path_info *path)
{
struct bgp_path_info_mpath *prev, *mpath;
prev = bgp_path_info_mpath_get(prev_info);
mpath = bgp_path_info_mpath_get(binfo);
mpath = bgp_path_info_mpath_get(path);
if (!prev || !mpath)
return;
@ -324,7 +324,7 @@ static void bgp_path_info_mpath_enqueue(struct bgp_path_info *prev_info,
prev->mp_next->mp_prev = mpath;
prev->mp_next = mpath;
SET_FLAG(binfo->flags, BGP_PATH_MULTIPATH);
SET_FLAG(path->flags, BGP_PATH_MULTIPATH);
}
/*
@ -332,9 +332,9 @@ static void bgp_path_info_mpath_enqueue(struct bgp_path_info *prev_info,
*
* Remove a path from the multipath list
*/
void bgp_path_info_mpath_dequeue(struct bgp_path_info *binfo)
void bgp_path_info_mpath_dequeue(struct bgp_path_info *path)
{
struct bgp_path_info_mpath *mpath = binfo->mpath;
struct bgp_path_info_mpath *mpath = path->mpath;
if (!mpath)
return;
if (mpath->mp_prev)
@ -342,7 +342,7 @@ void bgp_path_info_mpath_dequeue(struct bgp_path_info *binfo)
if (mpath->mp_next)
mpath->mp_next->mp_prev = mpath->mp_prev;
mpath->mp_next = mpath->mp_prev = NULL;
UNSET_FLAG(binfo->flags, BGP_PATH_MULTIPATH);
UNSET_FLAG(path->flags, BGP_PATH_MULTIPATH);
}
/*
@ -350,11 +350,11 @@ void bgp_path_info_mpath_dequeue(struct bgp_path_info *binfo)
*
* Given a bgp_path_info, return the next multipath entry
*/
struct bgp_path_info *bgp_path_info_mpath_next(struct bgp_path_info *binfo)
struct bgp_path_info *bgp_path_info_mpath_next(struct bgp_path_info *path)
{
if (!binfo->mpath || !binfo->mpath->mp_next)
if (!path->mpath || !path->mpath->mp_next)
return NULL;
return binfo->mpath->mp_next->mp_info;
return path->mpath->mp_next->mp_info;
}
/*
@ -362,9 +362,9 @@ struct bgp_path_info *bgp_path_info_mpath_next(struct bgp_path_info *binfo)
*
* Given bestpath bgp_path_info, return the first multipath entry.
*/
struct bgp_path_info *bgp_path_info_mpath_first(struct bgp_path_info *binfo)
struct bgp_path_info *bgp_path_info_mpath_first(struct bgp_path_info *path)
{
return bgp_path_info_mpath_next(binfo);
return bgp_path_info_mpath_next(path);
}
/*
@ -372,11 +372,11 @@ struct bgp_path_info *bgp_path_info_mpath_first(struct bgp_path_info *binfo)
*
* Given the bestpath bgp_path_info, return the number of multipath entries
*/
uint32_t bgp_path_info_mpath_count(struct bgp_path_info *binfo)
uint32_t bgp_path_info_mpath_count(struct bgp_path_info *path)
{
if (!binfo->mpath)
if (!path->mpath)
return 0;
return binfo->mpath->mp_count;
return path->mpath->mp_count;
}
/*
@ -384,13 +384,13 @@ uint32_t bgp_path_info_mpath_count(struct bgp_path_info *binfo)
*
* Sets the count of multipaths into bestpath's mpath element
*/
static void bgp_path_info_mpath_count_set(struct bgp_path_info *binfo,
static void bgp_path_info_mpath_count_set(struct bgp_path_info *path,
uint32_t count)
{
struct bgp_path_info_mpath *mpath;
if (!count && !binfo->mpath)
if (!count && !path->mpath)
return;
mpath = bgp_path_info_mpath_get(binfo);
mpath = bgp_path_info_mpath_get(path);
if (!mpath)
return;
mpath->mp_count = count;
@ -402,11 +402,11 @@ static void bgp_path_info_mpath_count_set(struct bgp_path_info *binfo,
* Given bestpath bgp_path_info, return aggregated attribute set used
* for advertising the multipath route
*/
struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *binfo)
struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *path)
{
if (!binfo->mpath)
if (!path->mpath)
return NULL;
return binfo->mpath->mp_attr;
return path->mpath->mp_attr;
}
/*
@ -414,13 +414,13 @@ struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *binfo)
*
* Sets the aggregated attribute into bestpath's mpath element
*/
static void bgp_path_info_mpath_attr_set(struct bgp_path_info *binfo,
static void bgp_path_info_mpath_attr_set(struct bgp_path_info *path,
struct attr *attr)
{
struct bgp_path_info_mpath *mpath;
if (!attr && !binfo->mpath)
if (!attr && !path->mpath)
return;
mpath = bgp_path_info_mpath_get(binfo);
mpath = bgp_path_info_mpath_get(path);
if (!mpath)
return;
mpath->mp_attr = attr;

View File

@ -227,7 +227,7 @@ struct bgp_pbr_or_filter {
};
static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
struct bgp_path_info *binfo,
struct bgp_path_info *path,
struct bgp_pbr_filter *bpf,
struct nexthop *nh,
float *rate);
@ -1223,16 +1223,16 @@ static void bgp_pbr_flush_entry(struct bgp *bgp, struct bgp_pbr_action *bpa,
bgp_send_pbr_ipset_entry_match(bpme, false);
bpme->installed = false;
bpme->backpointer = NULL;
if (bpme->bgp_info) {
struct bgp_path_info *bgp_info;
if (bpme->path) {
struct bgp_path_info *path;
struct bgp_path_info_extra *extra;
/* unlink bgp_path_info to bpme */
bgp_info = (struct bgp_path_info *)bpme->bgp_info;
extra = bgp_path_info_extra_get(bgp_info);
path = (struct bgp_path_info *)bpme->path;
extra = bgp_path_info_extra_get(path);
if (extra->bgp_fs_pbr)
listnode_delete(extra->bgp_fs_pbr, bpme);
bpme->bgp_info = NULL;
bpme->path = NULL;
}
}
hash_release(bpm->entry_hash, bpme);
@ -1304,10 +1304,8 @@ static int bgp_pbr_get_remaining_entry(struct hash_backet *backet, void *arg)
return HASHWALK_ABORT;
}
static void
bgp_pbr_policyroute_remove_from_zebra_unit(struct bgp *bgp,
struct bgp_path_info *binfo,
struct bgp_pbr_filter *bpf)
static void bgp_pbr_policyroute_remove_from_zebra_unit(
struct bgp *bgp, struct bgp_path_info *path, struct bgp_pbr_filter *bpf)
{
struct bgp_pbr_match temp;
struct bgp_pbr_match_entry temp2;
@ -1439,7 +1437,7 @@ static uint8_t bgp_pbr_next_type_entry(uint8_t type_entry)
return 0;
}
static void bgp_pbr_icmp_action(struct bgp *bgp, struct bgp_path_info *binfo,
static void bgp_pbr_icmp_action(struct bgp *bgp, struct bgp_path_info *path,
struct bgp_pbr_filter *bpf,
struct bgp_pbr_or_filter *bpof, bool add,
struct nexthop *nh, float *rate)
@ -1464,11 +1462,11 @@ static void bgp_pbr_icmp_action(struct bgp *bgp, struct bgp_path_info *binfo,
for (ALL_LIST_ELEMENTS_RO(bpof->icmp_code, cnode, icmp_code)) {
dstp.min_port = icmp_code->val;
if (add)
bgp_pbr_policyroute_add_to_zebra_unit(bgp, binfo,
bpf, nh, rate);
bgp_pbr_policyroute_add_to_zebra_unit(
bgp, path, bpf, nh, rate);
else
bgp_pbr_policyroute_remove_from_zebra_unit(
bgp, binfo, bpf);
bgp, path, bpf);
}
return;
}
@ -1485,30 +1483,27 @@ static void bgp_pbr_icmp_action(struct bgp *bgp, struct bgp_path_info *binfo,
dstp.max_port = 255;
if (add)
bgp_pbr_policyroute_add_to_zebra_unit(
bgp, binfo,
bpf, nh, rate);
bgp, path, bpf, nh, rate);
else
bgp_pbr_policyroute_remove_from_zebra_unit(bgp,
binfo, bpf);
bgp_pbr_policyroute_remove_from_zebra_unit(
bgp, path, bpf);
continue;
}
for (ALL_LIST_ELEMENTS_RO(bpof->icmp_code, cnode, icmp_code)) {
dstp.min_port = icmp_code->val;
if (add)
bgp_pbr_policyroute_add_to_zebra_unit(
bgp, binfo,
bpf, nh, rate);
bgp, path, bpf, nh, rate);
else
bgp_pbr_policyroute_remove_from_zebra_unit(
bgp, binfo, bpf);
bgp, path, bpf);
}
}
}
static void bgp_pbr_policyroute_remove_from_zebra_recursive(
struct bgp *bgp, struct bgp_path_info *binfo,
struct bgp_pbr_filter *bpf, struct bgp_pbr_or_filter *bpof,
uint8_t type_entry)
struct bgp *bgp, struct bgp_path_info *path, struct bgp_pbr_filter *bpf,
struct bgp_pbr_or_filter *bpof, uint8_t type_entry)
{
struct listnode *node, *nnode;
struct bgp_pbr_val_mask *valmask;
@ -1517,8 +1512,8 @@ static void bgp_pbr_policyroute_remove_from_zebra_recursive(
struct bgp_pbr_val_mask **target_val;
if (type_entry == 0)
return bgp_pbr_policyroute_remove_from_zebra_unit(bgp,
binfo, bpf);
return bgp_pbr_policyroute_remove_from_zebra_unit(bgp, path,
bpf);
next_type_entry = bgp_pbr_next_type_entry(type_entry);
if (type_entry == FLOWSPEC_TCP_FLAGS && bpof->tcpflags) {
orig_list = bpof->tcpflags;
@ -1535,52 +1530,43 @@ static void bgp_pbr_policyroute_remove_from_zebra_recursive(
} else if (type_entry == FLOWSPEC_ICMP_TYPE &&
(bpof->icmp_type || bpof->icmp_code)) {
/* enumerate list for icmp - must be last one */
bgp_pbr_icmp_action(bgp, binfo, bpf, bpof, false, NULL, NULL);
bgp_pbr_icmp_action(bgp, path, bpf, bpof, false, NULL, NULL);
return;
} else {
return bgp_pbr_policyroute_remove_from_zebra_recursive(bgp,
binfo,
bpf, bpof,
next_type_entry);
return bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, next_type_entry);
}
for (ALL_LIST_ELEMENTS(orig_list, node, nnode, valmask)) {
*target_val = valmask;
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
next_type_entry);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, next_type_entry);
}
}
static void bgp_pbr_policyroute_remove_from_zebra(
struct bgp *bgp, struct bgp_path_info *binfo,
struct bgp_pbr_filter *bpf, struct bgp_pbr_or_filter *bpof)
struct bgp *bgp, struct bgp_path_info *path, struct bgp_pbr_filter *bpf,
struct bgp_pbr_or_filter *bpof)
{
if (!bpof)
return bgp_pbr_policyroute_remove_from_zebra_unit(bgp,
binfo,
return bgp_pbr_policyroute_remove_from_zebra_unit(bgp, path,
bpf);
if (bpof->tcpflags)
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
FLOWSPEC_TCP_FLAGS);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, FLOWSPEC_TCP_FLAGS);
else if (bpof->dscp)
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
FLOWSPEC_DSCP);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, FLOWSPEC_DSCP);
else if (bpof->pkt_len)
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
FLOWSPEC_PKT_LEN);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, FLOWSPEC_PKT_LEN);
else if (bpof->fragment)
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
FLOWSPEC_FRAGMENT);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, FLOWSPEC_FRAGMENT);
else if (bpof->icmp_type || bpof->icmp_code)
bgp_pbr_policyroute_remove_from_zebra_recursive(bgp, binfo,
bpf, bpof,
FLOWSPEC_ICMP_TYPE);
bgp_pbr_policyroute_remove_from_zebra_recursive(
bgp, path, bpf, bpof, FLOWSPEC_ICMP_TYPE);
else
bgp_pbr_policyroute_remove_from_zebra_unit(bgp, binfo, bpf);
bgp_pbr_policyroute_remove_from_zebra_unit(bgp, path, bpf);
/* flush bpof */
if (bpof->tcpflags)
list_delete_all_node(bpof->tcpflags);
@ -1688,7 +1674,7 @@ static void bgp_pbr_dump_entry(struct bgp_pbr_filter *bpf, bool add)
}
static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
struct bgp_path_info *binfo,
struct bgp_path_info *path,
struct bgp_pbr_filter *bpf,
struct nexthop *nh,
float *rate)
@ -1844,20 +1830,21 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
bpme->installed = false;
bpme->install_in_progress = false;
/* link bgp info to bpme */
bpme->bgp_info = (void *)binfo;
bpme->path = (void *)path;
} else
bpme_found = true;
/* already installed */
if (bpme_found) {
struct bgp_path_info_extra *extra =
bgp_path_info_extra_get(binfo);
bgp_path_info_extra_get(path);
if (extra && extra->bgp_fs_pbr &&
listnode_lookup(extra->bgp_fs_pbr, bpme)) {
if (BGP_DEBUG(pbr, PBR_ERROR))
zlog_err("%s: entry %p/%p already installed in bgp pbr",
__func__, binfo, bpme);
zlog_err(
"%s: entry %p/%p already installed in bgp pbr",
__func__, path, bpme);
return;
}
}
@ -1909,9 +1896,9 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
}
static void bgp_pbr_policyroute_add_to_zebra_recursive(
struct bgp *bgp, struct bgp_path_info *binfo,
struct bgp_pbr_filter *bpf, struct bgp_pbr_or_filter *bpof,
struct nexthop *nh, float *rate, uint8_t type_entry)
struct bgp *bgp, struct bgp_path_info *path, struct bgp_pbr_filter *bpf,
struct bgp_pbr_or_filter *bpof, struct nexthop *nh, float *rate,
uint8_t type_entry)
{
struct listnode *node, *nnode;
struct bgp_pbr_val_mask *valmask;
@ -1920,8 +1907,8 @@ static void bgp_pbr_policyroute_add_to_zebra_recursive(
struct bgp_pbr_val_mask **target_val;
if (type_entry == 0)
return bgp_pbr_policyroute_add_to_zebra_unit(bgp, binfo, bpf,
nh, rate);
return bgp_pbr_policyroute_add_to_zebra_unit(bgp, path, bpf, nh,
rate);
next_type_entry = bgp_pbr_next_type_entry(type_entry);
if (type_entry == FLOWSPEC_TCP_FLAGS && bpof->tcpflags) {
orig_list = bpof->tcpflags;
@ -1938,58 +1925,45 @@ static void bgp_pbr_policyroute_add_to_zebra_recursive(
} else if (type_entry == FLOWSPEC_ICMP_TYPE &&
(bpof->icmp_type || bpof->icmp_code)) {
/* enumerate list for icmp - must be last one */
bgp_pbr_icmp_action(bgp, binfo, bpf, bpof, true, nh, rate);
bgp_pbr_icmp_action(bgp, path, bpf, bpof, true, nh, rate);
return;
} else {
return bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof, nh, rate,
next_type_entry);
return bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, next_type_entry);
}
for (ALL_LIST_ELEMENTS(orig_list, node, nnode, valmask)) {
*target_val = valmask;
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof,
nh, rate,
next_type_entry);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, next_type_entry);
}
}
static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
struct bgp_path_info *binfo,
struct bgp_path_info *path,
struct bgp_pbr_filter *bpf,
struct bgp_pbr_or_filter *bpof,
struct nexthop *nh, float *rate)
{
if (!bpof)
return bgp_pbr_policyroute_add_to_zebra_unit(bgp, binfo,
bpf, nh, rate);
return bgp_pbr_policyroute_add_to_zebra_unit(bgp, path, bpf, nh,
rate);
if (bpof->tcpflags)
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof,
nh, rate,
FLOWSPEC_TCP_FLAGS);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, FLOWSPEC_TCP_FLAGS);
else if (bpof->dscp)
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof,
nh, rate,
FLOWSPEC_DSCP);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, FLOWSPEC_DSCP);
else if (bpof->pkt_len)
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof,
nh, rate,
FLOWSPEC_PKT_LEN);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, FLOWSPEC_PKT_LEN);
else if (bpof->fragment)
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof,
nh, rate,
FLOWSPEC_FRAGMENT);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, FLOWSPEC_FRAGMENT);
else if (bpof->icmp_type || bpof->icmp_code)
bgp_pbr_policyroute_add_to_zebra_recursive(bgp, binfo,
bpf, bpof, nh, rate,
FLOWSPEC_ICMP_TYPE);
bgp_pbr_policyroute_add_to_zebra_recursive(
bgp, path, bpf, bpof, nh, rate, FLOWSPEC_ICMP_TYPE);
else
bgp_pbr_policyroute_add_to_zebra_unit(bgp, binfo, bpf,
nh, rate);
bgp_pbr_policyroute_add_to_zebra_unit(bgp, path, bpf, nh, rate);
/* flush bpof */
if (bpof->tcpflags)
list_delete_all_node(bpof->tcpflags);
@ -2005,7 +1979,7 @@ static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
list_delete_all_node(bpof->icmp_code);
}
static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *binfo,
static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path,
struct bgp_pbr_entry_main *api, bool add)
{
struct nexthop nh;
@ -2142,9 +2116,8 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *binfo,
bpf.src_port = srcp;
bpf.dst_port = dstp;
if (!add)
return bgp_pbr_policyroute_remove_from_zebra(bgp,
binfo,
&bpf, &bpof);
return bgp_pbr_policyroute_remove_from_zebra(bgp, path, &bpf,
&bpof);
/* no action for add = true */
for (i = 0; i < api->action_num; i++) {
switch (api->actions[i].action) {
@ -2153,9 +2126,8 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *binfo,
if (api->actions[i].u.r.rate == 0) {
nh.vrf_id = api->vrf_id;
nh.type = NEXTHOP_TYPE_BLACKHOLE;
bgp_pbr_policyroute_add_to_zebra(bgp, binfo,
&bpf, &bpof,
&nh, &rate);
bgp_pbr_policyroute_add_to_zebra(
bgp, path, &bpf, &bpof, &nh, &rate);
} else {
/* update rate. can be reentrant */
rate = api->actions[i].u.r.rate;
@ -2195,8 +2167,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *binfo,
nh.gate.ipv4.s_addr =
api->actions[i].u.zr.redirect_ip_v4.s_addr;
nh.vrf_id = api->vrf_id;
bgp_pbr_policyroute_add_to_zebra(bgp, binfo,
&bpf, &bpof,
bgp_pbr_policyroute_add_to_zebra(bgp, path, &bpf, &bpof,
&nh, &rate);
/* XXX combination with REDIRECT_VRF
* + REDIRECT_NH_IP not done
@ -2206,8 +2177,7 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *binfo,
case ACTION_REDIRECT:
nh.vrf_id = api->actions[i].u.redirect_vrf;
nh.type = NEXTHOP_TYPE_IPV4;
bgp_pbr_policyroute_add_to_zebra(bgp, binfo,
&bpf, &bpof,
bgp_pbr_policyroute_add_to_zebra(bgp, path, &bpf, &bpof,
&nh, &rate);
continue_loop = 0;
break;

View File

@ -219,7 +219,7 @@ struct bgp_pbr_match_entry {
uint16_t dst_port_max;
uint8_t proto;
void *bgp_info;
void *path;
bool installed;
bool install_in_progress;

View File

@ -239,49 +239,49 @@ struct bgp_path_info *bgp_path_info_new(void)
}
/* Free bgp route information. */
static void bgp_path_info_free(struct bgp_path_info *binfo)
static void bgp_path_info_free(struct bgp_path_info *path)
{
if (binfo->attr)
bgp_attr_unintern(&binfo->attr);
if (path->attr)
bgp_attr_unintern(&path->attr);
bgp_unlink_nexthop(binfo);
bgp_path_info_extra_free(&binfo->extra);
bgp_path_info_mpath_free(&binfo->mpath);
bgp_unlink_nexthop(path);
bgp_path_info_extra_free(&path->extra);
bgp_path_info_mpath_free(&path->mpath);
peer_unlock(binfo->peer); /* bgp_path_info peer reference */
peer_unlock(path->peer); /* bgp_path_info peer reference */
XFREE(MTYPE_BGP_ROUTE, binfo);
XFREE(MTYPE_BGP_ROUTE, path);
}
struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *binfo)
struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path)
{
binfo->lock++;
return binfo;
path->lock++;
return path;
}
struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *binfo)
struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path)
{
assert(binfo && binfo->lock > 0);
binfo->lock--;
assert(path && path->lock > 0);
path->lock--;
if (binfo->lock == 0) {
if (path->lock == 0) {
#if 0
zlog_debug ("%s: unlocked and freeing", __func__);
zlog_backtrace (LOG_DEBUG);
#endif
bgp_path_info_free(binfo);
bgp_path_info_free(path);
return NULL;
}
#if 0
if (binfo->lock == 1)
if (path->lock == 1)
{
zlog_debug ("%s: unlocked to 1", __func__);
zlog_backtrace (LOG_DEBUG);
}
#endif
return binfo;
return path;
}
void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *ri)
@ -6355,41 +6355,41 @@ enum bgp_display_type {
/* Print the short form route status for a bgp_path_info */
static void route_vty_short_status_out(struct vty *vty,
struct bgp_path_info *binfo,
struct bgp_path_info *path,
json_object *json_path)
{
if (json_path) {
/* Route status display. */
if (CHECK_FLAG(binfo->flags, BGP_PATH_REMOVED))
if (CHECK_FLAG(path->flags, BGP_PATH_REMOVED))
json_object_boolean_true_add(json_path, "removed");
if (CHECK_FLAG(binfo->flags, BGP_PATH_STALE))
if (CHECK_FLAG(path->flags, BGP_PATH_STALE))
json_object_boolean_true_add(json_path, "stale");
if (binfo->extra && binfo->extra->suppress)
if (path->extra && path->extra->suppress)
json_object_boolean_true_add(json_path, "suppressed");
if (CHECK_FLAG(binfo->flags, BGP_PATH_VALID)
&& !CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
if (CHECK_FLAG(path->flags, BGP_PATH_VALID)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
json_object_boolean_true_add(json_path, "valid");
/* Selected */
if (CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
if (CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
json_object_boolean_true_add(json_path, "history");
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED))
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED))
json_object_boolean_true_add(json_path, "damped");
if (CHECK_FLAG(binfo->flags, BGP_PATH_SELECTED))
if (CHECK_FLAG(path->flags, BGP_PATH_SELECTED))
json_object_boolean_true_add(json_path, "bestpath");
if (CHECK_FLAG(binfo->flags, BGP_PATH_MULTIPATH))
if (CHECK_FLAG(path->flags, BGP_PATH_MULTIPATH))
json_object_boolean_true_add(json_path, "multipath");
/* Internal route. */
if ((binfo->peer->as)
&& (binfo->peer->as == binfo->peer->local_as))
if ((path->peer->as)
&& (path->peer->as == path->peer->local_as))
json_object_string_add(json_path, "pathFrom",
"internal");
else
@ -6400,33 +6400,33 @@ static void route_vty_short_status_out(struct vty *vty,
}
/* Route status display. */
if (CHECK_FLAG(binfo->flags, BGP_PATH_REMOVED))
if (CHECK_FLAG(path->flags, BGP_PATH_REMOVED))
vty_out(vty, "R");
else if (CHECK_FLAG(binfo->flags, BGP_PATH_STALE))
else if (CHECK_FLAG(path->flags, BGP_PATH_STALE))
vty_out(vty, "S");
else if (binfo->extra && binfo->extra->suppress)
else if (path->extra && path->extra->suppress)
vty_out(vty, "s");
else if (CHECK_FLAG(binfo->flags, BGP_PATH_VALID)
&& !CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
else if (CHECK_FLAG(path->flags, BGP_PATH_VALID)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
vty_out(vty, "*");
else
vty_out(vty, " ");
/* Selected */
if (CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY))
if (CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
vty_out(vty, "h");
else if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED))
else if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED))
vty_out(vty, "d");
else if (CHECK_FLAG(binfo->flags, BGP_PATH_SELECTED))
else if (CHECK_FLAG(path->flags, BGP_PATH_SELECTED))
vty_out(vty, ">");
else if (CHECK_FLAG(binfo->flags, BGP_PATH_MULTIPATH))
else if (CHECK_FLAG(path->flags, BGP_PATH_MULTIPATH))
vty_out(vty, "=");
else
vty_out(vty, " ");
/* Internal route. */
if (binfo->peer && (binfo->peer->as)
&& (binfo->peer->as == binfo->peer->local_as))
if (path->peer && (path->peer->as)
&& (path->peer->as == path->peer->local_as))
vty_out(vty, "i");
else
vty_out(vty, " ");
@ -6434,7 +6434,7 @@ static void route_vty_short_status_out(struct vty *vty,
/* called from terminal list command */
void route_vty_out(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display, safi_t safi,
struct bgp_path_info *path, int display, safi_t safi,
json_object *json_paths)
{
struct attr *attr;
@ -6444,7 +6444,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
json_object *json_nexthop_ll = NULL;
char vrf_id_str[VRF_NAMSIZ] = {0};
bool nexthop_self =
CHECK_FLAG(binfo->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
bool nexthop_othervrf = false;
vrf_id_t nexthop_vrfid = VRF_DEFAULT;
const char *nexthop_vrfname = "Default";
@ -6453,7 +6453,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
json_path = json_object_new_object();
/* short status lead text */
route_vty_short_status_out(vty, binfo, json_path);
route_vty_short_status_out(vty, path, json_path);
if (!json_paths) {
/* print prefix and mask */
@ -6466,7 +6466,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
}
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
if (!attr) {
if (json_paths)
json_object_array_add(json_paths, json_path);
@ -6480,26 +6480,26 @@ void route_vty_out(struct vty *vty, struct prefix *p,
* If vrf id of nexthop is different from that of prefix,
* set up printable string to append
*/
if (binfo->extra && binfo->extra->bgp_orig) {
if (path->extra && path->extra->bgp_orig) {
const char *self = "";
if (nexthop_self)
self = "<";
nexthop_othervrf = true;
nexthop_vrfid = binfo->extra->bgp_orig->vrf_id;
nexthop_vrfid = path->extra->bgp_orig->vrf_id;
if (binfo->extra->bgp_orig->vrf_id == VRF_UNKNOWN)
if (path->extra->bgp_orig->vrf_id == VRF_UNKNOWN)
snprintf(vrf_id_str, sizeof(vrf_id_str),
"@%s%s", VRFID_NONE_STR, self);
else
snprintf(vrf_id_str, sizeof(vrf_id_str), "@%u%s",
binfo->extra->bgp_orig->vrf_id, self);
path->extra->bgp_orig->vrf_id, self);
if (binfo->extra->bgp_orig->inst_type !=
BGP_INSTANCE_TYPE_DEFAULT)
if (path->extra->bgp_orig->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT)
nexthop_vrfname = binfo->extra->bgp_orig->name;
nexthop_vrfname = path->extra->bgp_orig->name;
} else {
const char *self = "";
@ -6625,7 +6625,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
/* We display both LL & GL if both have been
* received */
if ((attr->mp_nexthop_len == 32)
|| (binfo->peer->conf_if)) {
|| (path->peer->conf_if)) {
json_nexthop_ll = json_object_new_object();
json_object_string_add(
json_nexthop_ll, "ip",
@ -6654,10 +6654,10 @@ void route_vty_out(struct vty *vty, struct prefix *p,
* prefer-global is set */
if (((attr->mp_nexthop_len == 32)
&& !attr->mp_nexthop_prefer_global)
|| (binfo->peer->conf_if)) {
if (binfo->peer->conf_if) {
|| (path->peer->conf_if)) {
if (path->peer->conf_if) {
len = vty_out(vty, "%s",
binfo->peer->conf_if);
path->peer->conf_if);
len = 16 - len; /* len of IPv6
addr + max
len of def
@ -6727,7 +6727,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
char buf[BUFSIZ];
json_object_string_add(
json_path, "peerId",
sockunion2str(&binfo->peer->su, buf, SU_ADDRSTRLEN));
sockunion2str(&path->peer->su, buf, SU_ADDRSTRLEN));
}
/* Print aspath */
@ -6784,7 +6784,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
/* prints an additional line, indented, with VNC info, if
* present */
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
rfapi_vty_out_vncinfo(vty, p, binfo, safi);
rfapi_vty_out_vncinfo(vty, p, path, safi);
#endif
}
}
@ -6926,21 +6926,21 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
}
void route_vty_out_tag(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display, safi_t safi,
struct bgp_path_info *path, int display, safi_t safi,
json_object *json)
{
json_object *json_out = NULL;
struct attr *attr;
mpls_label_t label = MPLS_INVALID_LABEL;
if (!binfo->extra)
if (!path->extra)
return;
if (json)
json_out = json_object_new_object();
/* short status lead text */
route_vty_short_status_out(vty, binfo, json_out);
route_vty_short_status_out(vty, path, json_out);
/* print prefix and mask */
if (json == NULL) {
@ -6951,7 +6951,7 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p,
}
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
if (attr) {
if (((p->family == AF_INET)
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
@ -7027,7 +7027,7 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p,
}
}
label = decode_label(&binfo->extra->label[0]);
label = decode_label(&path->extra->label[0]);
if (bgp_is_valid_label(&label)) {
if (json) {
@ -7041,7 +7041,7 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p,
}
void route_vty_out_overlay(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
json_object *json_paths)
{
struct attr *attr;
@ -7051,11 +7051,11 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
if (json_paths)
json_path = json_object_new_object();
if (!binfo->extra)
if (!path->extra)
return;
/* short status lead text */
route_vty_short_status_out(vty, binfo, json_path);
route_vty_short_status_out(vty, path, json_path);
/* print prefix and mask */
if (!display)
@ -7064,7 +7064,7 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
vty_out(vty, "%*s", 17, " ");
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
if (attr) {
char buf1[BUFSIZ];
int af = NEXTHOP_FAMILY(attr->mp_nexthop_len);
@ -7119,7 +7119,7 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
/* dampening route */
static void damp_route_vty_out(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
safi_t safi, bool use_json, json_object *json)
{
struct attr *attr;
@ -7127,7 +7127,7 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,
char timebuf[BGP_UPTIME_LEN];
/* short status lead text */
route_vty_short_status_out(vty, binfo, json);
route_vty_short_status_out(vty, path, json);
/* print prefix and mask */
if (!use_json) {
@ -7137,7 +7137,7 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,
vty_out(vty, "%*s", 17, " ");
}
len = vty_out(vty, "%s", binfo->peer->host);
len = vty_out(vty, "%s", path->peer->host);
len = 17 - len;
if (len < 1) {
if (!use_json)
@ -7150,15 +7150,16 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,
}
if (use_json)
bgp_damp_reuse_time_vty(vty, binfo, timebuf, BGP_UPTIME_LEN,
bgp_damp_reuse_time_vty(vty, path, timebuf, BGP_UPTIME_LEN,
use_json, json);
else
vty_out(vty, "%s ", bgp_damp_reuse_time_vty(vty, binfo, timebuf,
BGP_UPTIME_LEN,
use_json, json));
vty_out(vty, "%s ",
bgp_damp_reuse_time_vty(vty, path, timebuf,
BGP_UPTIME_LEN, use_json,
json));
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
if (attr) {
/* Print aspath */
if (attr->aspath) {
@ -7182,7 +7183,7 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,
/* flap route */
static void flap_route_vty_out(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
safi_t safi, bool use_json, json_object *json)
{
struct attr *attr;
@ -7190,13 +7191,13 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,
char timebuf[BGP_UPTIME_LEN];
int len;
if (!binfo->extra)
if (!path->extra)
return;
bdi = binfo->extra->damp_info;
bdi = path->extra->damp_info;
/* short status lead text */
route_vty_short_status_out(vty, binfo, json);
route_vty_short_status_out(vty, path, json);
/* print prefix and mask */
if (!use_json) {
@ -7206,7 +7207,7 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,
vty_out(vty, "%*s", 17, " ");
}
len = vty_out(vty, "%s", binfo->peer->host);
len = vty_out(vty, "%s", path->peer->host);
len = 16 - len;
if (len < 1) {
if (!use_json)
@ -7237,14 +7238,14 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,
vty_out(vty, "%s ", peer_uptime(bdi->start_time, timebuf,
BGP_UPTIME_LEN, 0, NULL));
if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY)) {
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY)) {
if (use_json)
bgp_damp_reuse_time_vty(vty, binfo, timebuf,
bgp_damp_reuse_time_vty(vty, path, timebuf,
BGP_UPTIME_LEN, use_json, json);
else
vty_out(vty, "%s ",
bgp_damp_reuse_time_vty(vty, binfo, timebuf,
bgp_damp_reuse_time_vty(vty, path, timebuf,
BGP_UPTIME_LEN,
use_json, json));
} else {
@ -7253,7 +7254,7 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,
}
/* Print attribute */
attr = binfo->attr;
attr = path->attr;
if (attr) {
/* Print aspath */
if (attr->aspath) {
@ -7330,7 +7331,7 @@ static void route_vty_out_advertised_to(struct vty *vty, struct peer *peer,
}
void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
struct bgp_path_info *binfo, afi_t afi, safi_t safi,
struct bgp_path_info *path, afi_t afi, safi_t safi,
json_object *json_paths)
{
char buf[INET6_ADDRSTRLEN];
@ -7359,7 +7360,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
int has_adj;
unsigned int first_as;
bool nexthop_self =
CHECK_FLAG(binfo->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
if (json_paths) {
json_path = json_object_new_object();
@ -7373,19 +7374,18 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
bgp_evpn_route2str((struct prefix_evpn *)p, buf2, sizeof(buf2));
vty_out(vty, " Route %s", buf2);
tag_buf[0] = '\0';
if (binfo->extra && binfo->extra->num_labels) {
bgp_evpn_label2str(binfo->extra->label,
binfo->extra->num_labels, tag_buf,
if (path->extra && path->extra->num_labels) {
bgp_evpn_label2str(path->extra->label,
path->extra->num_labels, tag_buf,
sizeof(tag_buf));
vty_out(vty, " VNI %s", tag_buf);
}
vty_out(vty, "\n");
if (binfo->extra && binfo->extra->parent) {
if (path->extra && path->extra->parent) {
struct bgp_path_info *parent_ri;
struct bgp_node *rn, *prn;
parent_ri =
(struct bgp_path_info *)binfo->extra->parent;
parent_ri = (struct bgp_path_info *)path->extra->parent;
rn = parent_ri->net;
if (rn && rn->prn) {
prn = rn->prn;
@ -7398,7 +7398,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
}
attr = binfo->attr;
attr = path->attr;
if (attr) {
/* Line1 display AS-path, Aggregator */
@ -7418,7 +7418,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
}
if (CHECK_FLAG(binfo->flags, BGP_PATH_REMOVED)) {
if (CHECK_FLAG(path->flags, BGP_PATH_REMOVED)) {
if (json_paths)
json_object_boolean_true_add(json_path,
"removed");
@ -7426,7 +7426,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", (removed)");
}
if (CHECK_FLAG(binfo->flags, BGP_PATH_STALE)) {
if (CHECK_FLAG(path->flags, BGP_PATH_STALE)) {
if (json_paths)
json_object_boolean_true_add(json_path,
"stale");
@ -7449,7 +7449,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
}
if (CHECK_FLAG(binfo->peer->af_flags[afi][safi],
if (CHECK_FLAG(path->peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT)) {
if (json_paths)
json_object_boolean_true_add(
@ -7458,7 +7458,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", (Received from a RR-client)");
}
if (CHECK_FLAG(binfo->peer->af_flags[afi][safi],
if (CHECK_FLAG(path->peer->af_flags[afi][safi],
PEER_FLAG_RSERVER_CLIENT)) {
if (json_paths)
json_object_boolean_true_add(
@ -7467,13 +7467,13 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", (Received from a RS-client)");
}
if (CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY)) {
if (CHECK_FLAG(path->flags, BGP_PATH_HISTORY)) {
if (json_paths)
json_object_boolean_true_add(
json_path, "dampeningHistoryEntry");
else
vty_out(vty, ", (history entry)");
} else if (CHECK_FLAG(binfo->flags, BGP_PATH_DAMPED)) {
} else if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)) {
if (json_paths)
json_object_boolean_true_add(
json_path, "dampeningSuppressed");
@ -7535,21 +7535,21 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
/* Display the IGP cost or 'inaccessible' */
if (!CHECK_FLAG(binfo->flags, BGP_PATH_VALID)) {
if (!CHECK_FLAG(path->flags, BGP_PATH_VALID)) {
if (json_paths)
json_object_boolean_false_add(
json_nexthop_global, "accessible");
else
vty_out(vty, " (inaccessible)");
} else {
if (binfo->extra && binfo->extra->igpmetric) {
if (path->extra && path->extra->igpmetric) {
if (json_paths)
json_object_int_add(
json_nexthop_global, "metric",
binfo->extra->igpmetric);
path->extra->igpmetric);
else
vty_out(vty, " (metric %u)",
binfo->extra->igpmetric);
path->extra->igpmetric);
}
/* IGP cost is 0, display this only for json */
@ -7566,7 +7566,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
/* Display peer "from" output */
/* This path was originated locally */
if (binfo->peer == bgp->peer_self) {
if (path->peer == bgp->peer_self) {
if (safi == SAFI_EVPN
|| (p->family == AF_INET
@ -7598,53 +7598,52 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
if (json_paths) {
json_object_string_add(
json_peer, "peerId",
sockunion2str(&binfo->peer->su, buf,
sockunion2str(&path->peer->su, buf,
SU_ADDRSTRLEN));
json_object_string_add(
json_peer, "routerId",
inet_ntop(AF_INET,
&binfo->peer->remote_id, buf1,
&path->peer->remote_id, buf1,
sizeof(buf1)));
if (binfo->peer->hostname)
if (path->peer->hostname)
json_object_string_add(
json_peer, "hostname",
binfo->peer->hostname);
path->peer->hostname);
if (binfo->peer->domainname)
if (path->peer->domainname)
json_object_string_add(
json_peer, "domainname",
binfo->peer->domainname);
path->peer->domainname);
if (binfo->peer->conf_if)
if (path->peer->conf_if)
json_object_string_add(
json_peer, "interface",
binfo->peer->conf_if);
path->peer->conf_if);
} else {
if (binfo->peer->conf_if) {
if (binfo->peer->hostname
if (path->peer->conf_if) {
if (path->peer->hostname
&& bgp_flag_check(
binfo->peer->bgp,
path->peer->bgp,
BGP_FLAG_SHOW_HOSTNAME))
vty_out(vty, " from %s(%s)",
binfo->peer->hostname,
binfo->peer->conf_if);
path->peer->hostname,
path->peer->conf_if);
else
vty_out(vty, " from %s",
binfo->peer->conf_if);
path->peer->conf_if);
} else {
if (binfo->peer->hostname
if (path->peer->hostname
&& bgp_flag_check(
binfo->peer->bgp,
path->peer->bgp,
BGP_FLAG_SHOW_HOSTNAME))
vty_out(vty, " from %s(%s)",
binfo->peer->hostname,
binfo->peer->host);
path->peer->hostname,
path->peer->host);
else
vty_out(vty, " from %s",
sockunion2str(
&binfo->peer
->su,
&path->peer->su,
buf,
SU_ADDRSTRLEN));
}
@ -7657,7 +7656,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, " (%s)",
inet_ntop(
AF_INET,
&binfo->peer->remote_id,
&path->peer->remote_id,
buf1, sizeof(buf1)));
}
}
@ -7665,18 +7664,18 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
/*
* Note when vrfid of nexthop is different from that of prefix
*/
if (binfo->extra && binfo->extra->bgp_orig) {
vrf_id_t nexthop_vrfid = binfo->extra->bgp_orig->vrf_id;
if (path->extra && path->extra->bgp_orig) {
vrf_id_t nexthop_vrfid = path->extra->bgp_orig->vrf_id;
if (json_paths) {
const char *vn;
if (binfo->extra->bgp_orig->inst_type ==
BGP_INSTANCE_TYPE_DEFAULT)
if (path->extra->bgp_orig->inst_type
== BGP_INSTANCE_TYPE_DEFAULT)
vn = "Default";
else
vn = binfo->extra->bgp_orig->name;
vn = path->extra->bgp_orig->name;
json_object_string_add(json_path, "nhVrfName",
vn);
@ -7793,13 +7792,13 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
attr->tag);
}
if (!CHECK_FLAG(binfo->flags, BGP_PATH_VALID)) {
if (!CHECK_FLAG(path->flags, BGP_PATH_VALID)) {
if (json_paths)
json_object_boolean_false_add(json_path,
"valid");
else
vty_out(vty, ", invalid");
} else if (!CHECK_FLAG(binfo->flags, BGP_PATH_HISTORY)) {
} else if (!CHECK_FLAG(path->flags, BGP_PATH_HISTORY)) {
if (json_paths)
json_object_boolean_true_add(json_path,
"valid");
@ -7807,8 +7806,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", valid");
}
if (binfo->peer != bgp->peer_self) {
if (binfo->peer->as == binfo->peer->local_as) {
if (path->peer != bgp->peer_self) {
if (path->peer->as == path->peer->local_as) {
if (CHECK_FLAG(bgp->config,
BGP_CONFIG_CONFEDERATION)) {
if (json_paths)
@ -7828,7 +7827,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
} else {
if (bgp_confederation_peers_check(
bgp, binfo->peer->as)) {
bgp, path->peer->as)) {
if (json_paths)
json_object_string_add(
json_peer, "type",
@ -7845,7 +7844,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", external");
}
}
} else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) {
} else if (path->sub_type == BGP_ROUTE_AGGREGATE) {
if (json_paths) {
json_object_boolean_true_add(json_path,
"aggregated");
@ -7854,7 +7853,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
} else {
vty_out(vty, ", aggregated, local");
}
} else if (binfo->type != ZEBRA_ROUTE_BGP) {
} else if (path->type != ZEBRA_ROUTE_BGP) {
if (json_paths)
json_object_boolean_true_add(json_path,
"sourced");
@ -7879,9 +7878,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, ", atomic-aggregate");
}
if (CHECK_FLAG(binfo->flags, BGP_PATH_MULTIPATH)
|| (CHECK_FLAG(binfo->flags, BGP_PATH_SELECTED)
&& bgp_path_info_mpath_count(binfo))) {
if (CHECK_FLAG(path->flags, BGP_PATH_MULTIPATH)
|| (CHECK_FLAG(path->flags, BGP_PATH_SELECTED)
&& bgp_path_info_mpath_count(path))) {
if (json_paths)
json_object_boolean_true_add(json_path,
"multipath");
@ -7890,7 +7889,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
// Mark the bestpath(s)
if (CHECK_FLAG(binfo->flags, BGP_PATH_DMED_SELECTED)) {
if (CHECK_FLAG(path->flags, BGP_PATH_DMED_SELECTED)) {
first_as = aspath_get_first_as(attr->aspath);
if (json_paths) {
@ -7909,7 +7908,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
}
if (CHECK_FLAG(binfo->flags, BGP_PATH_SELECTED)) {
if (CHECK_FLAG(path->flags, BGP_PATH_SELECTED)) {
if (json_paths) {
if (!json_bestpath)
json_bestpath =
@ -8039,14 +8038,13 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, "\n");
}
if (binfo->extra && binfo->extra->damp_info)
bgp_damp_info_vty(vty, binfo, json_path);
if (path->extra && path->extra->damp_info)
bgp_damp_info_vty(vty, path, json_path);
/* Remote Label */
if (binfo->extra && bgp_is_valid_label(&binfo->extra->label[0])
if (path->extra && bgp_is_valid_label(&path->extra->label[0])
&& safi != SAFI_EVPN) {
mpls_label_t label =
label_pton(&binfo->extra->label[0]);
mpls_label_t label = label_pton(&path->extra->label[0]);
if (json_paths)
json_object_int_add(json_path, "remoteLabel",
label);
@ -8065,16 +8063,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
/* Line 8 display Addpath IDs */
if (binfo->addpath_rx_id || binfo->addpath_tx_id) {
if (path->addpath_rx_id || path->addpath_tx_id) {
if (json_paths) {
json_object_int_add(json_path, "addpathRxId",
binfo->addpath_rx_id);
path->addpath_rx_id);
json_object_int_add(json_path, "addpathTxId",
binfo->addpath_tx_id);
path->addpath_tx_id);
} else {
vty_out(vty, " AddPath ID: RX %u, TX %u\n",
binfo->addpath_rx_id,
binfo->addpath_tx_id);
path->addpath_rx_id,
path->addpath_tx_id);
}
}
@ -8087,11 +8085,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
addpath_capable =
bgp_addpath_encode_tx(peer, afi, safi);
has_adj = bgp_adj_out_lookup(
peer, binfo->net, binfo->addpath_tx_id);
peer, path->net, path->addpath_tx_id);
if ((addpath_capable && has_adj)
|| (!addpath_capable && has_adj
&& CHECK_FLAG(binfo->flags,
&& CHECK_FLAG(path->flags,
BGP_PATH_SELECTED))) {
if (json_path && !json_adv_to)
json_adv_to =
@ -8118,7 +8116,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
}
/* Line 9 display Uptime */
tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
tbuf = time(NULL) - (bgp_clock() - path->uptime);
if (json_paths) {
json_last_update = json_object_new_object();
json_object_int_add(json_last_update, "epoch", tbuf);
@ -8283,17 +8281,17 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
}
if (type == bgp_show_type_route_map) {
struct route_map *rmap = output_arg;
struct bgp_path_info binfo;
struct bgp_path_info path;
struct attr dummy_attr;
int ret;
bgp_attr_dup(&dummy_attr, ri->attr);
binfo.peer = ri->peer;
binfo.attr = &dummy_attr;
path.peer = ri->peer;
path.attr = &dummy_attr;
ret = route_map_apply(rmap, &rn->p, RMAP_BGP,
&binfo);
&path);
if (ret == RMAP_DENYMATCH)
continue;
}

View File

@ -452,7 +452,7 @@ extern void route_vty_out_tmp(struct vty *vty, struct prefix *p,
struct attr *attr, safi_t safi, bool use_json,
json_object *json_ar);
extern void route_vty_out_overlay(struct vty *vty, struct prefix *p,
struct bgp_path_info *binfo, int display,
struct bgp_path_info *path, int display,
json_object *json);
extern int subgroup_process_announce_selected(struct update_subgroup *subgrp,
@ -495,7 +495,7 @@ extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct prefix_rd *prd, afi_t afi,
safi_t safi, json_object *json);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct prefix *p, struct bgp_path_info *binfo,
struct prefix *p, struct bgp_path_info *path,
afi_t afi, safi_t safi,
json_object *json_paths);
extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,

View File

@ -477,13 +477,13 @@ static route_map_result_t route_match_ip_next_hop(void *rule,
void *object)
{
struct access_list *alist;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct prefix_ipv4 p;
if (type == RMAP_BGP && prefix->family == AF_INET) {
bgp_info = object;
path = object;
p.family = AF_INET;
p.prefix = bgp_info->attr->nexthop;
p.prefix = path->attr->nexthop;
p.prefixlen = IPV4_MAX_BITLEN;
alist = access_list_lookup(AFI_IP, (char *)rule);
@ -524,13 +524,13 @@ static route_map_result_t route_match_ip_route_source(void *rule,
void *object)
{
struct access_list *alist;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct peer *peer;
struct prefix_ipv4 p;
if (type == RMAP_BGP && pfx->family == AF_INET) {
bgp_info = object;
peer = bgp_info->peer;
path = object;
peer = path->peer;
if (!peer || sockunion_family(&peer->su) != AF_INET)
return RMAP_NOMATCH;
@ -610,13 +610,13 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
struct prefix_list *plist;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct prefix_ipv4 p;
if (type == RMAP_BGP && prefix->family == AF_INET) {
bgp_info = object;
path = object;
p.family = AF_INET;
p.prefix = bgp_info->attr->nexthop;
p.prefix = path->attr->nexthop;
p.prefixlen = IPV4_MAX_BITLEN;
plist = prefix_list_lookup(AFI_IP, (char *)rule);
@ -651,19 +651,19 @@ static route_map_result_t
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP && prefix->family == AF_INET) {
bgp_info = (struct bgp_path_info *)object;
if (!bgp_info || !bgp_info->attr)
path = (struct bgp_path_info *)object;
if (!path || !path->attr)
return RMAP_DENYMATCH;
/* If nexthop interface's index can't be resolved and nexthop is
set to any address then mark it as type `blackhole`.
This logic works for matching kernel/static routes like:
`ip route add blackhole 10.0.0.1`. */
if (bgp_info->attr->nexthop.s_addr == INADDR_ANY
&& !bgp_info->attr->nh_ifindex)
if (path->attr->nexthop.s_addr == INADDR_ANY
&& !path->attr->nh_ifindex)
return RMAP_MATCH;
}
return RMAP_NOMATCH;
@ -692,13 +692,13 @@ route_match_ip_route_source_prefix_list(void *rule,
route_map_object_t type, void *object)
{
struct prefix_list *plist;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct peer *peer;
struct prefix_ipv4 p;
if (type == RMAP_BGP && prefix->family == AF_INET) {
bgp_info = object;
peer = bgp_info->peer;
path = object;
peer = path->peer;
if (!peer || sockunion_family(&peer->su) != AF_INET)
return RMAP_NOMATCH;
@ -810,16 +810,16 @@ static route_map_result_t route_match_vni(void *rule,
route_map_object_t type, void *object)
{
vni_t vni = 0;
struct bgp_path_info *bgp_info = NULL;
struct bgp_path_info *path = NULL;
if (type == RMAP_BGP) {
vni = *((vni_t *)rule);
bgp_info = (struct bgp_path_info *)object;
path = (struct bgp_path_info *)object;
if (bgp_info->extra == NULL)
if (path->extra == NULL)
return RMAP_NOMATCH;
if (vni == label2vni(&bgp_info->extra->label[0]))
if (vni == label2vni(&path->extra->label[0]))
return RMAP_MATCH;
}
@ -914,13 +914,13 @@ static route_map_result_t route_match_local_pref(void *rule,
void *object)
{
uint32_t *local_pref;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
local_pref = rule;
bgp_info = object;
path = object;
if (bgp_info->attr->local_pref == *local_pref)
if (path->attr->local_pref == *local_pref)
return RMAP_MATCH;
else
return RMAP_NOMATCH;
@ -974,12 +974,12 @@ static route_map_result_t route_match_metric(void *rule,
void *object)
{
struct rmap_value *rv;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
rv = rule;
bgp_info = object;
return route_value_match(rv, bgp_info->attr->med);
path = object;
return route_value_match(rv, path->attr->med);
}
return RMAP_NOMATCH;
}
@ -999,17 +999,17 @@ static route_map_result_t route_match_aspath(void *rule,
{
struct as_list *as_list;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
as_list = as_list_lookup((char *)rule);
if (as_list == NULL)
return RMAP_NOMATCH;
bgp_info = object;
path = object;
/* Perform match. */
return ((as_list_apply(as_list, bgp_info->attr->aspath)
return ((as_list_apply(as_list, path->attr->aspath)
== AS_FILTER_DENY)
? RMAP_NOMATCH
: RMAP_MATCH);
@ -1047,11 +1047,11 @@ static route_map_result_t route_match_community(void *rule,
void *object)
{
struct community_list *list;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct rmap_community *rcom;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
rcom = rule;
list = community_list_lookup(bgp_clist, rcom->name,
@ -1060,12 +1060,11 @@ static route_map_result_t route_match_community(void *rule,
return RMAP_NOMATCH;
if (rcom->exact) {
if (community_list_exact_match(
bgp_info->attr->community, list))
if (community_list_exact_match(path->attr->community,
list))
return RMAP_MATCH;
} else {
if (community_list_match(bgp_info->attr->community,
list))
if (community_list_match(path->attr->community, list))
return RMAP_MATCH;
}
}
@ -1115,11 +1114,11 @@ static route_map_result_t route_match_lcommunity(void *rule,
void *object)
{
struct community_list *list;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct rmap_community *rcom;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
rcom = rule;
list = community_list_lookup(bgp_clist, rcom->name,
@ -1127,7 +1126,7 @@ static route_map_result_t route_match_lcommunity(void *rule,
if (!list)
return RMAP_NOMATCH;
if (lcommunity_list_match(bgp_info->attr->lcommunity, list))
if (lcommunity_list_match(path->attr->lcommunity, list))
return RMAP_MATCH;
}
return RMAP_NOMATCH;
@ -1176,17 +1175,17 @@ static route_map_result_t route_match_ecommunity(void *rule,
void *object)
{
struct community_list *list;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
list = community_list_lookup(bgp_clist, (char *)rule,
EXTCOMMUNITY_LIST_MASTER);
if (!list)
return RMAP_NOMATCH;
if (ecommunity_list_match(bgp_info->attr->ecommunity, list))
if (ecommunity_list_match(path->attr->ecommunity, list))
return RMAP_MATCH;
}
return RMAP_NOMATCH;
@ -1219,13 +1218,13 @@ static route_map_result_t route_match_origin(void *rule,
void *object)
{
uint8_t *origin;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
origin = rule;
bgp_info = object;
path = object;
if (bgp_info->attr->origin == *origin)
if (path->attr->origin == *origin)
return RMAP_MATCH;
}
@ -1368,14 +1367,13 @@ static route_map_result_t route_match_tag(void *rule,
route_map_object_t type, void *object)
{
route_tag_t *tag;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
tag = rule;
bgp_info = object;
path = object;
return ((bgp_info->attr->tag == *tag) ? RMAP_MATCH
: RMAP_NOMATCH);
return ((path->attr->tag == *tag) ? RMAP_MATCH : RMAP_NOMATCH);
}
return RMAP_NOMATCH;
@ -1402,15 +1400,15 @@ static route_map_result_t route_set_ip_nexthop(void *rule,
void *object)
{
struct rmap_ip_nexthop_set *rins = rule;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct peer *peer;
if (type == RMAP_BGP) {
bgp_info = object;
peer = bgp_info->peer;
path = object;
peer = path->peer;
if (rins->unchanged) {
SET_FLAG(bgp_info->attr->rmap_change_flags,
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_NEXTHOP_UNCHANGED);
} else if (rins->peer_address) {
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
@ -1418,9 +1416,9 @@ static route_map_result_t route_set_ip_nexthop(void *rule,
PEER_RMAP_TYPE_IMPORT))
&& peer->su_remote
&& sockunion_family(peer->su_remote) == AF_INET) {
bgp_info->attr->nexthop.s_addr =
path->attr->nexthop.s_addr =
sockunion2ip(peer->su_remote);
bgp_info->attr->flag |=
path->attr->flag |=
ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
} else if (CHECK_FLAG(peer->rmap_type,
PEER_RMAP_TYPE_OUT)) {
@ -1430,20 +1428,19 @@ static route_map_result_t route_set_ip_nexthop(void *rule,
* needs to be done.
* Also, clear the value.
*/
SET_FLAG(bgp_info->attr->rmap_change_flags,
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
bgp_info->attr->nexthop.s_addr = 0;
path->attr->nexthop.s_addr = 0;
}
} else {
/* Set next hop value. */
bgp_info->attr->flag |=
ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
bgp_info->attr->nexthop = *rins->address;
SET_FLAG(bgp_info->attr->rmap_change_flags,
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
path->attr->nexthop = *rins->address;
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV4_NHOP_CHANGED);
/* case for MP-BGP : MPLS VPN */
bgp_info->attr->mp_nexthop_global_in = *rins->address;
bgp_info->attr->mp_nexthop_len = sizeof(*rins->address);
path->attr->mp_nexthop_global_in = *rins->address;
path->attr->mp_nexthop_len = sizeof(*rins->address);
}
}
@ -1510,21 +1507,21 @@ static route_map_result_t route_set_local_pref(void *rule,
void *object)
{
struct rmap_value *rv;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
uint32_t locpref = 0;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
rv = rule;
bgp_info = object;
path = object;
/* Set local preference value. */
if (bgp_info->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
locpref = bgp_info->attr->local_pref;
if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
locpref = path->attr->local_pref;
bgp_info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
bgp_info->attr->local_pref =
route_value_adjust(rv, locpref, bgp_info->peer);
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
path->attr->local_pref =
route_value_adjust(rv, locpref, path->peer);
}
return RMAP_OKAY;
@ -1545,16 +1542,15 @@ static route_map_result_t route_set_weight(void *rule,
void *object)
{
struct rmap_value *rv;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
rv = rule;
bgp_info = object;
path = object;
/* Set weight value. */
bgp_info->attr->weight =
route_value_adjust(rv, 0, bgp_info->peer);
path->attr->weight = route_value_adjust(rv, 0, path->peer);
}
return RMAP_OKAY;
@ -1574,21 +1570,19 @@ static route_map_result_t route_set_metric(void *rule,
void *object)
{
struct rmap_value *rv;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
uint32_t med = 0;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
rv = rule;
bgp_info = object;
path = object;
if (bgp_info->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
med = bgp_info->attr->med;
if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
med = path->attr->med;
bgp_info->attr->med =
route_value_adjust(rv, med, bgp_info->peer);
bgp_info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
path->attr->med = route_value_adjust(rv, med, path->peer);
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
}
return RMAP_OKAY;
}
@ -1608,15 +1602,15 @@ static route_map_result_t route_set_aspath_prepend(void *rule,
{
struct aspath *aspath;
struct aspath *new;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
binfo = object;
path = object;
if (binfo->attr->aspath->refcnt)
new = aspath_dup(binfo->attr->aspath);
if (path->attr->aspath->refcnt)
new = aspath_dup(path->attr->aspath);
else
new = binfo->attr->aspath;
new = path->attr->aspath;
if ((uintptr_t)rule > 10) {
aspath = rule;
@ -1624,11 +1618,11 @@ static route_map_result_t route_set_aspath_prepend(void *rule,
} else {
as_t as = aspath_leftmost(new);
if (!as)
as = binfo->peer->as;
as = path->peer->as;
new = aspath_add_seq_n(new, as, (uintptr_t)rule);
}
binfo->attr->aspath = new;
path->attr->aspath = new;
}
return RMAP_OKAY;
@ -1670,16 +1664,16 @@ static route_map_result_t route_set_aspath_exclude(void *rule,
void *object)
{
struct aspath *new_path, *exclude_path;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
exclude_path = rule;
binfo = object;
if (binfo->attr->aspath->refcnt)
new_path = aspath_dup(binfo->attr->aspath);
path = object;
if (path->attr->aspath->refcnt)
new_path = aspath_dup(path->attr->aspath);
else
new_path = binfo->attr->aspath;
binfo->attr->aspath =
new_path = path->attr->aspath;
path->attr->aspath =
aspath_filter_exclude(new_path, exclude_path);
}
return RMAP_OKAY;
@ -1705,7 +1699,7 @@ static route_map_result_t route_set_community(void *rule,
void *object)
{
struct rmap_com_set *rcs;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
struct attr *attr;
struct community *new = NULL;
struct community *old;
@ -1713,8 +1707,8 @@ static route_map_result_t route_set_community(void *rule,
if (type == RMAP_BGP) {
rcs = rule;
binfo = object;
attr = binfo->attr;
path = object;
attr = path->attr;
old = attr->community;
/* "none" case. */
@ -1821,7 +1815,7 @@ static route_map_result_t route_set_lcommunity(void *rule,
void *object)
{
struct rmap_lcom_set *rcs;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
struct attr *attr;
struct lcommunity *new = NULL;
struct lcommunity *old;
@ -1829,8 +1823,8 @@ static route_map_result_t route_set_lcommunity(void *rule,
if (type == RMAP_BGP) {
rcs = rule;
binfo = object;
attr = binfo->attr;
path = object;
attr = path->attr;
old = attr->lcommunity;
/* "none" case. */
@ -1937,16 +1931,16 @@ static route_map_result_t route_set_lcommunity_delete(void *rule,
struct lcommunity *merge;
struct lcommunity *new;
struct lcommunity *old;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
if (!rule)
return RMAP_OKAY;
binfo = object;
path = object;
list = community_list_lookup(bgp_clist, rule,
LARGE_COMMUNITY_LIST_MASTER);
old = binfo->attr->lcommunity;
old = path->attr->lcommunity;
if (list && old) {
merge = lcommunity_list_match_delete(
@ -1963,13 +1957,13 @@ static route_map_result_t route_set_lcommunity_delete(void *rule,
lcommunity_free(&old);
if (new->size == 0) {
binfo->attr->lcommunity = NULL;
binfo->attr->flag &= ~ATTR_FLAG_BIT(
path->attr->lcommunity = NULL;
path->attr->flag &= ~ATTR_FLAG_BIT(
BGP_ATTR_LARGE_COMMUNITIES);
lcommunity_free(&new);
} else {
binfo->attr->lcommunity = new;
binfo->attr->flag |= ATTR_FLAG_BIT(
path->attr->lcommunity = new;
path->attr->flag |= ATTR_FLAG_BIT(
BGP_ATTR_LARGE_COMMUNITIES);
}
}
@ -2022,16 +2016,16 @@ static route_map_result_t route_set_community_delete(
struct community *merge;
struct community *new;
struct community *old;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
if (!rule)
return RMAP_OKAY;
binfo = object;
path = object;
list = community_list_lookup(bgp_clist, rule,
COMMUNITY_LIST_MASTER);
old = binfo->attr->community;
old = path->attr->community;
if (list && old) {
merge = community_list_match_delete(community_dup(old),
@ -2048,13 +2042,13 @@ static route_map_result_t route_set_community_delete(
community_free(old);
if (new->size == 0) {
binfo->attr->community = NULL;
binfo->attr->flag &=
path->attr->community = NULL;
path->attr->flag &=
~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
community_free(new);
} else {
binfo->attr->community = new;
binfo->attr->flag |=
path->attr->community = new;
path->attr->flag |=
ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
}
}
@ -2104,17 +2098,17 @@ static route_map_result_t route_set_ecommunity(void *rule,
struct ecommunity *ecom;
struct ecommunity *new_ecom;
struct ecommunity *old_ecom;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
ecom = rule;
bgp_info = object;
path = object;
if (!ecom)
return RMAP_OKAY;
/* We assume additive for Extended Community. */
old_ecom = bgp_info->attr->ecommunity;
old_ecom = path->attr->ecommunity;
if (old_ecom) {
new_ecom = ecommunity_merge(ecommunity_dup(old_ecom),
@ -2130,9 +2124,9 @@ static route_map_result_t route_set_ecommunity(void *rule,
new_ecom = ecommunity_dup(ecom);
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
bgp_info->attr->ecommunity = new_ecom;
path->attr->ecommunity = new_ecom;
bgp_info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
}
return RMAP_OKAY;
}
@ -2190,13 +2184,13 @@ static route_map_result_t route_set_origin(void *rule,
void *object)
{
uint8_t *origin;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
origin = rule;
bgp_info = object;
path = object;
bgp_info->attr->origin = *origin;
path->attr->origin = *origin;
}
return RMAP_OKAY;
@ -2239,12 +2233,11 @@ static route_map_result_t route_set_atomic_aggregate(void *rule,
route_map_object_t type,
void *object)
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
bgp_info = object;
bgp_info->attr->flag |=
ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE);
path = object;
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE);
}
return RMAP_OKAY;
@ -2279,16 +2272,16 @@ static route_map_result_t route_set_aggregator_as(void *rule,
route_map_object_t type,
void *object)
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct aggregator *aggregator;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
aggregator = rule;
bgp_info->attr->aggregator_as = aggregator->as;
bgp_info->attr->aggregator_addr = aggregator->address;
bgp_info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR);
path->attr->aggregator_as = aggregator->as;
path->attr->aggregator_addr = aggregator->address;
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR);
}
return RMAP_OKAY;
@ -2333,14 +2326,14 @@ static route_map_result_t route_set_tag(void *rule,
route_map_object_t type, void *object)
{
route_tag_t *tag;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
tag = rule;
bgp_info = object;
path = object;
/* Set tag value */
bgp_info->attr->tag = *tag;
path->attr->tag = *tag;
}
return RMAP_OKAY;
@ -2359,20 +2352,19 @@ static route_map_result_t route_set_label_index(void *rule,
void *object)
{
struct rmap_value *rv;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
uint32_t label_index;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
rv = rule;
bgp_info = object;
path = object;
/* Set label-index value. */
label_index = rv->value;
if (label_index) {
bgp_info->attr->label_index = label_index;
bgp_info->attr->flag |=
ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID);
path->attr->label_index = label_index;
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID);
}
}
@ -2429,17 +2421,17 @@ static route_map_result_t route_match_ipv6_next_hop(void *rule,
void *object)
{
struct in6_addr *addr = rule;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
if (IPV6_ADDR_SAME(&bgp_info->attr->mp_nexthop_global, addr))
if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr))
return RMAP_MATCH;
if (bgp_info->attr->mp_nexthop_len
if (path->attr->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
&& IPV6_ADDR_SAME(&bgp_info->attr->mp_nexthop_local, rule))
&& IPV6_ADDR_SAME(&path->attr->mp_nexthop_local, rule))
return RMAP_MATCH;
return RMAP_NOMATCH;
@ -2514,16 +2506,16 @@ static route_map_result_t
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct in6_addr *addr = rule;
if (type == RMAP_BGP && prefix->family == AF_INET6) {
bgp_info = (struct bgp_path_info *)object;
if (!bgp_info || !bgp_info->attr)
path = (struct bgp_path_info *)object;
if (!path || !path->attr)
return RMAP_DENYMATCH;
if (IPV6_ADDR_SAME(&bgp_info->attr->mp_nexthop_global, addr)
&& !bgp_info->attr->nh_ifindex)
if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr)
&& !path->attr->nh_ifindex)
return RMAP_MATCH;
}
return RMAP_NOMATCH;
@ -2564,22 +2556,21 @@ static route_map_result_t route_set_ipv6_nexthop_global(void *rule,
void *object)
{
struct in6_addr *address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
address = rule;
bgp_info = object;
path = object;
/* Set next hop value. */
bgp_info->attr->mp_nexthop_global = *address;
path->attr->mp_nexthop_global = *address;
/* Set nexthop length. */
if (bgp_info->attr->mp_nexthop_len == 0)
bgp_info->attr->mp_nexthop_len =
BGP_ATTR_NHLEN_IPV6_GLOBAL;
if (path->attr->mp_nexthop_len == 0)
path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
SET_FLAG(bgp_info->attr->rmap_change_flags,
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED);
}
@ -2622,25 +2613,25 @@ static route_map_result_t
route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct peer *peer;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
bgp_info = object;
peer = bgp_info->peer;
path = object;
peer = path->peer;
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
|| CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
&& peer->su_remote
&& sockunion_family(peer->su_remote) == AF_INET6) {
/* Set next hop preference to global */
bgp_info->attr->mp_nexthop_prefer_global = TRUE;
SET_FLAG(bgp_info->attr->rmap_change_flags,
path->attr->mp_nexthop_prefer_global = TRUE;
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
} else {
bgp_info->attr->mp_nexthop_prefer_global = FALSE;
SET_FLAG(bgp_info->attr->rmap_change_flags,
path->attr->mp_nexthop_prefer_global = FALSE;
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
}
}
@ -2678,23 +2669,23 @@ static route_map_result_t route_set_ipv6_nexthop_local(void *rule,
void *object)
{
struct in6_addr *address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
address = rule;
bgp_info = object;
path = object;
/* Set next hop value. */
bgp_info->attr->mp_nexthop_local = *address;
path->attr->mp_nexthop_local = *address;
/* Set nexthop length. */
if (bgp_info->attr->mp_nexthop_len
if (path->attr->mp_nexthop_len
!= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
bgp_info->attr->mp_nexthop_len =
path->attr->mp_nexthop_len =
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
SET_FLAG(bgp_info->attr->rmap_change_flags,
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_LL_NHOP_CHANGED);
}
@ -2741,13 +2732,13 @@ static route_map_result_t route_set_ipv6_nexthop_peer(void *rule,
void *object)
{
struct in6_addr peer_address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct peer *peer;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
bgp_info = object;
peer = bgp_info->peer;
path = object;
peer = path->peer;
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
|| CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
@ -2756,14 +2747,13 @@ static route_map_result_t route_set_ipv6_nexthop_peer(void *rule,
peer_address = peer->su_remote->sin6.sin6_addr;
/* Set next hop value and length in attribute. */
if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
bgp_info->attr->mp_nexthop_local = peer_address;
if (bgp_info->attr->mp_nexthop_len != 32)
bgp_info->attr->mp_nexthop_len = 32;
path->attr->mp_nexthop_local = peer_address;
if (path->attr->mp_nexthop_len != 32)
path->attr->mp_nexthop_len = 32;
} else {
bgp_info->attr->mp_nexthop_global =
peer_address;
if (bgp_info->attr->mp_nexthop_len == 0)
bgp_info->attr->mp_nexthop_len = 16;
path->attr->mp_nexthop_global = peer_address;
if (path->attr->mp_nexthop_len == 0)
path->attr->mp_nexthop_len = 16;
}
} else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
@ -2776,12 +2766,12 @@ static route_map_result_t route_set_ipv6_nexthop_peer(void *rule,
* nexthops, whether we send one or both is determined
* elsewhere.
*/
SET_FLAG(bgp_info->attr->rmap_change_flags,
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
/* clear next hop value. */
memset(&(bgp_info->attr->mp_nexthop_global), 0,
memset(&(path->attr->mp_nexthop_global), 0,
sizeof(struct in6_addr));
memset(&(bgp_info->attr->mp_nexthop_local), 0,
memset(&(path->attr->mp_nexthop_local), 0,
sizeof(struct in6_addr));
}
}
@ -2820,16 +2810,16 @@ static route_map_result_t route_set_vpnv4_nexthop(void *rule,
void *object)
{
struct in_addr *address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
address = rule;
bgp_info = object;
path = object;
/* Set next hop value. */
bgp_info->attr->mp_nexthop_global_in = *address;
bgp_info->attr->mp_nexthop_len = 4;
path->attr->mp_nexthop_global_in = *address;
path->attr->mp_nexthop_len = 4;
}
return RMAP_OKAY;
@ -2860,17 +2850,17 @@ static route_map_result_t route_set_vpnv6_nexthop(void *rule,
void *object)
{
struct in6_addr *address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
/* Fetch routemap's rule information. */
address = rule;
bgp_info = object;
path = object;
/* Set next hop value. */
memcpy(&bgp_info->attr->mp_nexthop_global, address,
memcpy(&path->attr->mp_nexthop_global, address,
sizeof(struct in6_addr));
bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
}
return RMAP_OKAY;
@ -2916,14 +2906,14 @@ static route_map_result_t route_set_originator_id(void *rule,
void *object)
{
struct in_addr *address;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
address = rule;
bgp_info = object;
path = object;
bgp_info->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID);
bgp_info->attr->originator_id = *address;
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID);
path->attr->originator_id = *address;
}
return RMAP_OKAY;

View File

@ -217,12 +217,12 @@ static route_map_result_t route_match(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
int *rpki_status = rule;
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
if (type == RMAP_BGP) {
bgp_info = object;
path = object;
if (rpki_validate_prefix(bgp_info->peer, bgp_info->attr, prefix)
if (rpki_validate_prefix(path->peer, path->attr, prefix)
== *rpki_status) {
return RMAP_MATCH;
}
@ -418,13 +418,13 @@ static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
for (ain = bgp_node->adj_in; ain; ain = ain->next) {
int ret;
struct bgp_path_info *bgp_info = bgp_node->info;
struct bgp_path_info *path = bgp_node->info;
mpls_label_t *label = NULL;
uint32_t num_labels = 0;
if (bgp_info && bgp_info->extra) {
label = bgp_info->extra->label;
num_labels = bgp_info->extra->num_labels;
if (path && path->extra) {
label = path->extra->label;
num_labels = path->extra->num_labels;
}
ret = bgp_update(ain->peer, &bgp_node->p, ain->addpath_rx_id,
ain->attr, afi, safi, ZEBRA_ROUTE_BGP,

View File

@ -681,7 +681,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
{
oid *offset;
int offsetlen;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
struct bgp_path_info *min;
struct bgp_node *rn;
union sockunion su;
@ -715,9 +715,9 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
if (rn) {
bgp_unlock_node(rn);
for (binfo = rn->info; binfo; binfo = binfo->next)
if (sockunion_same(&binfo->peer->su, &su))
return binfo;
for (path = rn->info; path; path = path->next)
if (sockunion_same(&path->peer->su, &su))
return path;
}
} else {
offset = name + v->namelen;
@ -762,22 +762,22 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
do {
min = NULL;
for (binfo = rn->info; binfo; binfo = binfo->next) {
if (binfo->peer->su.sin.sin_family == AF_INET
for (path = rn->info; path; path = path->next) {
if (path->peer->su.sin.sin_family == AF_INET
&& ntohl(paddr.s_addr)
< ntohl(binfo->peer->su.sin
< ntohl(path->peer->su.sin
.sin_addr
.s_addr)) {
if (min) {
if (ntohl(binfo->peer->su.sin
if (ntohl(path->peer->su.sin
.sin_addr
.s_addr)
< ntohl(min->peer->su.sin
.sin_addr
.s_addr))
min = binfo;
min = path;
} else
min = binfo;
min = path;
}
}
@ -813,7 +813,7 @@ static uint8_t *bgp4PathAttrTable(struct variable *v, oid name[],
WriteMethod **write_method)
{
struct bgp *bgp;
struct bgp_path_info *binfo;
struct bgp_path_info *path;
struct prefix_ipv4 addr;
bgp = bgp_get_default();
@ -825,13 +825,13 @@ static uint8_t *bgp4PathAttrTable(struct variable *v, oid name[],
return NULL;
memset(&addr, 0, sizeof(struct prefix_ipv4));
binfo = bgp4PathAttrLookup(v, name, length, bgp, &addr, exact);
if (!binfo)
path = bgp4PathAttrLookup(v, name, length, bgp, &addr, exact);
if (!path)
return NULL;
switch (v->magic) {
case BGP4PATHATTRPEER: /* 1 */
return SNMP_IPADDRESS(binfo->peer->su.sin.sin_addr);
return SNMP_IPADDRESS(path->peer->su.sin.sin_addr);
break;
case BGP4PATHATTRIPADDRPREFIXLEN: /* 2 */
return SNMP_INTEGER(addr.prefixlen);
@ -840,28 +840,28 @@ static uint8_t *bgp4PathAttrTable(struct variable *v, oid name[],
return SNMP_IPADDRESS(addr.prefix);
break;
case BGP4PATHATTRORIGIN: /* 4 */
return SNMP_INTEGER(binfo->attr->origin);
return SNMP_INTEGER(path->attr->origin);
break;
case BGP4PATHATTRASPATHSEGMENT: /* 5 */
return aspath_snmp_pathseg(binfo->attr->aspath, var_len);
return aspath_snmp_pathseg(path->attr->aspath, var_len);
break;
case BGP4PATHATTRNEXTHOP: /* 6 */
return SNMP_IPADDRESS(binfo->attr->nexthop);
return SNMP_IPADDRESS(path->attr->nexthop);
break;
case BGP4PATHATTRMULTIEXITDISC: /* 7 */
return SNMP_INTEGER(binfo->attr->med);
return SNMP_INTEGER(path->attr->med);
break;
case BGP4PATHATTRLOCALPREF: /* 8 */
return SNMP_INTEGER(binfo->attr->local_pref);
return SNMP_INTEGER(path->attr->local_pref);
break;
case BGP4PATHATTRATOMICAGGREGATE: /* 9 */
return SNMP_INTEGER(1);
break;
case BGP4PATHATTRAGGREGATORAS: /* 10 */
return SNMP_INTEGER(binfo->attr->aggregator_as);
return SNMP_INTEGER(path->attr->aggregator_as);
break;
case BGP4PATHATTRAGGREGATORADDR: /* 11 */
return SNMP_IPADDRESS(binfo->attr->aggregator_addr);
return SNMP_IPADDRESS(path->attr->aggregator_addr);
break;
case BGP4PATHATTRCALCLOCALPREF: /* 12 */
return SNMP_INTEGER(-1);
@ -869,7 +869,7 @@ static uint8_t *bgp4PathAttrTable(struct variable *v, oid name[],
case BGP4PATHATTRBEST: /* 13 */
#define BGP4_PathAttrBest_false 1
#define BGP4_PathAttrBest_true 2
if (CHECK_FLAG(binfo->flags, BGP_INFO_SELECTED))
if (CHECK_FLAG(path->flags, BGP_INFO_SELECTED))
return SNMP_INTEGER(BGP4_PathAttrBest_true);
else
return SNMP_INTEGER(BGP4_PathAttrBest_false);

View File

@ -104,7 +104,7 @@ struct bgp_table *bgp_table_init(struct bgp *bgp, afi_t afi, safi_t safi)
route_table_set_info(rt->route_table, rt);
/*
* pointer to bgp instance allows working back from bgp_info to bgp
* pointer to bgp instance allows working back from bgp_path_info to bgp
*/
rt->bgp = bgp;

View File

@ -456,7 +456,7 @@ extern void bgp_adj_out_remove_subgroup(struct bgp_node *rn,
extern void bgp_adj_out_set_subgroup(struct bgp_node *rn,
struct update_subgroup *subgrp,
struct attr *attr,
struct bgp_path_info *binfo);
struct bgp_path_info *path);
extern void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
struct update_subgroup *subgrp,
char withdraw, uint32_t addpath_tx_id);

View File

@ -429,7 +429,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
void bgp_adj_out_set_subgroup(struct bgp_node *rn,
struct update_subgroup *subgrp, struct attr *attr,
struct bgp_path_info *binfo)
struct bgp_path_info *path)
{
struct bgp_adj_out *adj = NULL;
struct bgp_advertise *adv;
@ -438,10 +438,10 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
return;
/* Look for adjacency information. */
adj = adj_lookup(rn, subgrp, binfo->addpath_tx_id);
adj = adj_lookup(rn, subgrp, path->addpath_tx_id);
if (!adj) {
adj = bgp_adj_out_alloc(subgrp, rn, binfo->addpath_tx_id);
adj = bgp_adj_out_alloc(subgrp, rn, path->addpath_tx_id);
if (!adj)
return;
}
@ -452,9 +452,9 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
adv = adj->adv;
adv->rn = rn;
assert(adv->binfo == NULL);
assert(adv->pathi == NULL);
/* bgp_path_info adj_out reference */
adv->binfo = bgp_path_info_lock(binfo);
adv->pathi = bgp_path_info_lock(path);
if (attr)
adv->baa = bgp_advertise_intern(subgrp->hash, attr);

View File

@ -687,7 +687,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
struct bgp_adj_out *adj;
struct bgp_advertise *adv;
struct bgp_node *rn = NULL;
struct bgp_path_info *binfo = NULL;
struct bgp_path_info *path = NULL;
bgp_size_t total_attr_len = 0;
unsigned long attrlen_pos = 0;
size_t mpattrlen_pos = 0;
@ -731,7 +731,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
rn = adv->rn;
adj = adv->adj;
addpath_tx_id = adj->addpath_tx_id;
binfo = adv->binfo;
path = adv->pathi;
space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
@ -747,8 +747,8 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if (stream_empty(s)) {
struct peer *from = NULL;
if (binfo)
from = binfo->peer;
if (path)
from = path->peer;
/* 1: Write the BGP message header - 16 bytes marker, 2
* bytes length,
@ -821,13 +821,13 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
prd = (struct prefix_rd *)&rn->prn->p;
if (safi == SAFI_LABELED_UNICAST) {
label = bgp_adv_label(rn, binfo, peer, afi,
label = bgp_adv_label(rn, path, peer, afi,
safi);
label_pnt = &label;
num_labels = 1;
} else if (binfo && binfo->extra) {
label_pnt = &binfo->extra->label[0];
num_labels = binfo->extra->num_labels;
} else if (path && path->extra) {
label_pnt = &path->extra->label[0];
num_labels = path->extra->num_labels;
}
if (stream_empty(snlri))

View File

@ -2080,7 +2080,7 @@ static int ipset_entry_notify_owner(int command, struct zclient *zclient,
break;
case ZAPI_IPSET_ENTRY_INSTALLED:
{
struct bgp_path_info *bgp_info;
struct bgp_path_info *path;
struct bgp_path_info_extra *extra;
bgp_pbime->installed = true;
@ -2088,9 +2088,9 @@ static int ipset_entry_notify_owner(int command, struct zclient *zclient,
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: Received IPSET_ENTRY_INSTALLED",
__PRETTY_FUNCTION__);
/* link bgp_info to bpme */
bgp_info = (struct bgp_path_info *)bgp_pbime->bgp_info;
extra = bgp_path_info_extra_get(bgp_info);
/* link bgp_path_info to bpme */
path = (struct bgp_path_info *)bgp_pbime->path;
extra = bgp_path_info_extra_get(path);
if (extra->bgp_fs_pbr == NULL)
extra->bgp_fs_pbr = list_new();
listnode_add(extra->bgp_fs_pbr, bgp_pbime);

View File

@ -499,7 +499,7 @@ int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bi, struct prefix *p)
/*
* Make a new bgp_info from gathered parameters
* Make a new bgp_path_info from gathered parameters
*/
static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr,
struct peer *peer, void *rfd,
@ -532,7 +532,7 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr,
}
/*
* Frees bgp_info as used in import tables (parts are not
* Frees bgp_path_info as used in import tables (parts are not
* allocated exactly the way they are in the main RIBs)
*/
static void rfapiBgpInfoFree(struct bgp_path_info *goner)
@ -930,9 +930,9 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it)
* Each route_node has:
* aggregate: points to rfapi_it_extra with monitor
* chain(s)
* info: points to chain of bgp_info
* info: points to chain of bgp_path_info
*/
/* free bgp_info and its children */
/* free bgp_path_info and its children */
rfapiBgpInfoChainFree(rn->info);
rn->info = NULL;
@ -941,7 +941,7 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it)
for (rn = agg_route_top(it->imported_encap[afi]); rn;
rn = agg_route_next(rn)) {
/* free bgp_info and its children */
/* free bgp_path_info and its children */
rfapiBgpInfoChainFree(rn->info);
rn->info = NULL;
@ -2934,7 +2934,7 @@ static int rfapiGetNexthop(struct attr *attr, struct prefix *prefix)
}
/*
* import a bgp_info if its route target list intersects with the
* import a bgp_path_info if its route target list intersects with the
* import table's route target list
*/
static void rfapiBgpInfoFilteredImportEncap(
@ -2943,10 +2943,10 @@ static void rfapiBgpInfoFilteredImportEncap(
struct prefix *p,
struct prefix *aux_prefix, /* Unused for encap routes */
afi_t afi, struct prefix_rd *prd,
struct attr *attr, /* part of bgp_info */
uint8_t type, /* part of bgp_info */
uint8_t sub_type, /* part of bgp_info */
uint32_t *label) /* part of bgp_info */
struct attr *attr, /* part of bgp_path_info */
uint8_t type, /* part of bgp_path_info */
uint8_t sub_type, /* part of bgp_path_info */
uint32_t *label) /* part of bgp_path_info */
{
struct agg_table *rt = NULL;
struct agg_node *rn;
@ -3071,7 +3071,7 @@ static void rfapiBgpInfoFilteredImportEncap(
for (bi = rn->info; bi; bi = bi->next) {
/*
* Does this bgp_info refer to the same route
* Does this bgp_path_info refer to the same route
* as we are trying to add?
*/
vnc_zlog_debug_verbose("%s: comparing BI %p", __func__,
@ -3395,7 +3395,7 @@ static void rfapiExpireVpnNow(struct rfapi_import_table *it,
/*
* import a bgp_info if its route target list intersects with the
* import a bgp_path_info if its route target list intersects with the
* import table's route target list
*/
void rfapiBgpInfoFilteredImportVPN(
@ -3404,10 +3404,10 @@ void rfapiBgpInfoFilteredImportVPN(
struct prefix *p,
struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */
afi_t afi, struct prefix_rd *prd,
struct attr *attr, /* part of bgp_info */
uint8_t type, /* part of bgp_info */
uint8_t sub_type, /* part of bgp_info */
uint32_t *label) /* part of bgp_info */
struct attr *attr, /* part of bgp_path_info */
uint8_t type, /* part of bgp_path_info */
uint8_t sub_type, /* part of bgp_path_info */
uint32_t *label) /* part of bgp_path_info */
{
struct agg_table *rt = NULL;
struct agg_node *rn;
@ -3882,10 +3882,10 @@ static void rfapiBgpInfoFilteredImportBadSafi(
struct prefix *p,
struct prefix *aux_prefix, /* AFI_L2VPN: optional IP */
afi_t afi, struct prefix_rd *prd,
struct attr *attr, /* part of bgp_info */
uint8_t type, /* part of bgp_info */
uint8_t sub_type, /* part of bgp_info */
uint32_t *label) /* part of bgp_info */
struct attr *attr, /* part of bgp_path_info */
uint8_t type, /* part of bgp_path_info */
uint8_t sub_type, /* part of bgp_path_info */
uint32_t *label) /* part of bgp_path_info */
{
vnc_zlog_debug_verbose("%s: Error, bad safi", __func__);
}

View File

@ -31,7 +31,7 @@
/*
* These are per-rt-import-list
*
* routes are not segregated by RD - the RD is stored in bgp_info_extra
* routes are not segregated by RD - the RD is stored in bgp_path_info_extra
* and is needed to determine if two prefixes are the same.
*/
struct rfapi_import_table {
@ -94,7 +94,7 @@ extern void rfapiImportTableRefDelByIt(struct bgp *bgp,
* Construct an rfapi nexthop list based on the routes attached to
* the specified node.
*
* If there are any routes that do NOT have BGP_INFO_REMOVED set,
* If there are any routes that do NOT have BGP_PATH_REMOVED set,
* return those only. If there are ONLY routes with BGP_INFO_REMOVED,
* then return those, and also include all the non-removed routes from the
* next less-specific node (i.e., this node's parent) at the end.

View File

@ -1010,13 +1010,13 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
if (rmap) {
struct bgp_path_info binfo;
struct bgp_path_info path;
route_map_result_t ret;
memset(&binfo, 0, sizeof(binfo));
binfo.peer = peer;
binfo.attr = &hattr;
ret = route_map_apply(rmap, prefix, RMAP_BGP, &binfo);
memset(&path, 0, sizeof(path));
path.peer = peer;
path.attr = &hattr;
ret = route_map_apply(rmap, prefix, RMAP_BGP, &path);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(

View File

@ -16,7 +16,7 @@
# ...
# (gdb) cont
# Breakpoint 3, bgp_write_packet (peer=0x7fa885199080) at bgp_packet.c:614
# 614 if (CHECK_FLAG (adv->binfo->peer->cap,PEER_CAP_RESTART_RCV)
# 614 if (CHECK_FLAG (adv->path->peer->cap,PEER_CAP_RESTART_RCV)
# (gdb) dump_prefix4 &adv->rn->p
# IPv4:10.1.1.0/24
# (gdb) dump_prefix &adv->rn->p