mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 20:59:36 +00:00
Merge pull request #1360 from donaldsharp/show_advertised_routes
Show advertised routes
This commit is contained in:
commit
633c7abd8f
@ -822,6 +822,32 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have some show commands that let you experimentally
|
||||||
|
* apply a route-map. When we apply the route-map
|
||||||
|
* we are reseting values but not saving them for
|
||||||
|
* posterity via intern'ing( because route-maps don't
|
||||||
|
* do that) but at this point in time we need
|
||||||
|
* to compare the new attr to the old and if the
|
||||||
|
* routemap has changed it we need to, as Snoop Dog says,
|
||||||
|
* Drop it like it's hot
|
||||||
|
*/
|
||||||
|
void bgp_attr_undup(struct attr *new, struct attr *old)
|
||||||
|
{
|
||||||
|
if (new->aspath != old->aspath)
|
||||||
|
aspath_free(new->aspath);
|
||||||
|
|
||||||
|
if (new->community != old->community)
|
||||||
|
community_free(new->community);
|
||||||
|
|
||||||
|
if (new->ecommunity != old->ecommunity)
|
||||||
|
ecommunity_free(&new->ecommunity);
|
||||||
|
|
||||||
|
if (new->lcommunity != old->lcommunity)
|
||||||
|
lcommunity_free(&new->lcommunity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Free bgp attribute and aspath. */
|
/* Free bgp attribute and aspath. */
|
||||||
void bgp_attr_unintern(struct attr **pattr)
|
void bgp_attr_unintern(struct attr **pattr)
|
||||||
{
|
{
|
||||||
|
@ -239,6 +239,7 @@ extern bgp_attr_parse_ret_t bgp_attr_parse(struct peer *, struct attr *,
|
|||||||
bgp_size_t, struct bgp_nlri *,
|
bgp_size_t, struct bgp_nlri *,
|
||||||
struct bgp_nlri *);
|
struct bgp_nlri *);
|
||||||
extern void bgp_attr_dup(struct attr *, struct attr *);
|
extern void bgp_attr_dup(struct attr *, struct attr *);
|
||||||
|
extern void bgp_attr_undup(struct attr *new, struct attr *old);
|
||||||
extern struct attr *bgp_attr_intern(struct attr *attr);
|
extern struct attr *bgp_attr_intern(struct attr *attr);
|
||||||
extern void bgp_attr_unintern_sub(struct attr *);
|
extern void bgp_attr_unintern_sub(struct attr *);
|
||||||
extern void bgp_attr_unintern(struct attr **);
|
extern void bgp_attr_unintern(struct attr **);
|
||||||
|
@ -1157,49 +1157,52 @@ static int bgp_output_modifier(struct peer *peer, struct prefix *p,
|
|||||||
struct attr *attr, afi_t afi, safi_t safi,
|
struct attr *attr, afi_t afi, safi_t safi,
|
||||||
const char *rmap_name)
|
const char *rmap_name)
|
||||||
{
|
{
|
||||||
struct bgp_filter *filter;
|
|
||||||
struct bgp_info info;
|
struct bgp_info info;
|
||||||
route_map_result_t ret;
|
route_map_result_t ret;
|
||||||
struct route_map *rmap = NULL;
|
struct route_map *rmap = NULL;
|
||||||
|
u_char rmap_type;
|
||||||
|
|
||||||
filter = &peer->filter[afi][safi];
|
/*
|
||||||
|
* So if we get to this point and have no rmap_name
|
||||||
|
* we want to just show the output as it currently
|
||||||
|
* exists.
|
||||||
|
*/
|
||||||
|
if (!rmap_name)
|
||||||
|
return RMAP_PERMIT;
|
||||||
|
|
||||||
/* Apply default weight value. */
|
/* Apply default weight value. */
|
||||||
if (peer->weight[afi][safi])
|
if (peer->weight[afi][safi])
|
||||||
attr->weight = peer->weight[afi][safi];
|
attr->weight = peer->weight[afi][safi];
|
||||||
|
|
||||||
if (rmap_name) {
|
|
||||||
rmap = route_map_lookup_by_name(rmap_name);
|
rmap = route_map_lookup_by_name(rmap_name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have a route map name and we do not find
|
||||||
|
* the routemap that means we have an implicit
|
||||||
|
* deny.
|
||||||
|
*/
|
||||||
if (rmap == NULL)
|
if (rmap == NULL)
|
||||||
return RMAP_DENY;
|
return RMAP_DENY;
|
||||||
} else {
|
|
||||||
if (ROUTE_MAP_OUT_NAME(filter)) {
|
|
||||||
rmap = ROUTE_MAP_OUT(filter);
|
|
||||||
|
|
||||||
if (rmap == NULL)
|
|
||||||
return RMAP_DENY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Route map apply. */
|
/* Route map apply. */
|
||||||
if (rmap) {
|
|
||||||
/* Duplicate current value to new strucutre for modification. */
|
/* Duplicate current value to new strucutre for modification. */
|
||||||
info.peer = peer;
|
info.peer = peer;
|
||||||
info.attr = attr;
|
info.attr = attr;
|
||||||
|
|
||||||
|
rmap_type = peer->rmap_type;
|
||||||
SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT);
|
SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT);
|
||||||
|
|
||||||
/* Apply BGP route map to the attribute. */
|
/* Apply BGP route map to the attribute. */
|
||||||
ret = route_map_apply(rmap, p, RMAP_BGP, &info);
|
ret = route_map_apply(rmap, p, RMAP_BGP, &info);
|
||||||
|
|
||||||
peer->rmap_type = 0;
|
peer->rmap_type = rmap_type;
|
||||||
|
|
||||||
if (ret == RMAP_DENYMATCH)
|
if (ret == RMAP_DENYMATCH)
|
||||||
/* caller has multiple error paths with bgp_attr_flush()
|
/*
|
||||||
|
* caller has multiple error paths with bgp_attr_flush()
|
||||||
*/
|
*/
|
||||||
return RMAP_DENY;
|
return RMAP_DENY;
|
||||||
}
|
|
||||||
return RMAP_PERMIT;
|
return RMAP_PERMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10180,8 +10183,10 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (adj = rn->adj_out; adj; adj = adj->next)
|
for (adj = rn->adj_out; adj; adj = adj->next)
|
||||||
SUBGRP_FOREACH_PEER (adj->subgroup, paf)
|
SUBGRP_FOREACH_PEER (adj->subgroup, paf) {
|
||||||
if (paf->peer == peer) {
|
if (paf->peer != peer)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (header1) {
|
if (header1) {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_int_add(
|
json_object_int_add(
|
||||||
@ -10242,6 +10247,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
|
|||||||
output_count++;
|
output_count++;
|
||||||
} else
|
} else
|
||||||
filtered_count++;
|
filtered_count++;
|
||||||
|
|
||||||
|
bgp_attr_undup(&attr,
|
||||||
|
adj->attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user