summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorPascal Mathis <mail@pascalmathis.com>2018-05-16 21:55:55 +0200
committerPascal Mathis <mail@pascalmathis.com>2018-05-16 22:20:44 +0200
commitb755861b95142446bac05f0f2506647bbca5d2d8 (patch)
tree55b2955640ef694b17e59f355a0cfc5e0a84a88f /bgpd
parentbgpd: Implement new adjacent route show commands (diff)
downloadfrr-b755861b95142446bac05f0f2506647bbca5d2d8.tar.xz
frr-b755861b95142446bac05f0f2506647bbca5d2d8.zip
bgpd: Fix memleak, adapt adv- to recv-routes code
This commit tries to adapt a similar codeflow within the `show bgp [afi] [safi] neighbor <neighbor> advertised-routes` command compared to its `received-routes` and `filtered-routes` opponents. Some branching code has been restructured to achieve this. Additionally, this commit fixes a memory leak within `received-routes` (and `filtered-routes`, although the issue has been present before the previous commit!) where the previous implementation forgot to deduplicate the BGP attributes. When a user called `<...> received-routes route-map <RM-TEST>` and that routemap changed any AS path or community parameters, the duplicated memory for these parameters was never freed. This has been fixed by ensuring to call `bgp_attr_undup()` accordingly. Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_route.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 31aca9edd..84ea33b58 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -10365,8 +10365,10 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
afi, safi, rmap_name);
if (type == bgp_show_adj_route_filtered
- && ret != RMAP_DENY)
+ && ret != RMAP_DENY) {
+ bgp_attr_undup(&attr, ain->attr);
continue;
+ }
if (type == bgp_show_adj_route_received
&& ret == RMAP_DENY)
@@ -10374,12 +10376,13 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
route_vty_out_tmp(vty, &rn->p, &attr, safi,
use_json, json_ar);
+ bgp_attr_undup(&attr, ain->attr);
output_count++;
}
} else if (type == bgp_show_adj_route_advertised) {
for (adj = rn->adj_out; adj; adj = adj->next)
SUBGRP_FOREACH_PEER (adj->subgroup, paf) {
- if (paf->peer != peer)
+ if (paf->peer != peer || !adj->attr)
continue;
if (header1) {
@@ -10427,7 +10430,6 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
}
header1 = 0;
}
-
if (header2) {
if (!use_json)
vty_out(vty,
@@ -10435,24 +10437,22 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
header2 = 0;
}
- if (adj->attr) {
- bgp_attr_dup(&attr, adj->attr);
- ret = bgp_output_modifier(
- peer, &rn->p, &attr,
- afi, safi, rmap_name);
- if (ret != RMAP_DENY) {
- route_vty_out_tmp(
- vty, &rn->p,
- &attr, safi,
- use_json,
- json_ar);
- output_count++;
- } else
- filtered_count++;
-
- bgp_attr_undup(&attr,
- adj->attr);
+ bgp_attr_dup(&attr, adj->attr);
+ ret = bgp_output_modifier(
+ peer, &rn->p, &attr, afi, safi,
+ rmap_name);
+
+ if (ret != RMAP_DENY) {
+ route_vty_out_tmp(vty, &rn->p,
+ &attr, safi,
+ use_json,
+ json_ar);
+ output_count++;
+ } else {
+ filtered_count++;
}
+
+ bgp_attr_undup(&attr, adj->attr);
}
}
}