summaryrefslogtreecommitdiff
path: root/bgpd/bgp_flowspec_vty.c
diff options
context:
space:
mode:
authorValerian_He <1826906282@qq.com>2023-08-08 10:47:29 +0000
committerValerian_He <1826906282@qq.com>2023-08-08 10:48:07 +0000
commit98efa5bc6bac9e3917afe2fa206ec795ddf86b87 (patch)
treebec88bbb7b364d234860c17efe23aa73776bce69 /bgpd/bgp_flowspec_vty.c
parent49f04841131b917ac6218ecba933af36f51a7f91 (diff)
bgpd: bgp_path_info_extra memory optimization
Even if some of the attributes in bgp_path_info_extra are not used, their memory is still allocated every time. It cause a waste of memory. This commit code deletes all unnecessary attributes and changes the optional attributes to pointer storage. Memory will only be allocated when they are actually used. After optimization, extra info related memory is reduced by about half(~400B -> ~200B). Signed-off-by: Valerian_He <1826906282@qq.com>
Diffstat (limited to 'bgpd/bgp_flowspec_vty.c')
-rw-r--r--bgpd/bgp_flowspec_vty.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c
index 7df1423e59..a295ec5a14 100644
--- a/bgpd/bgp_flowspec_vty.c
+++ b/bgpd/bgp_flowspec_vty.c
@@ -355,7 +355,8 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
bgp_path_info_extra_get(path);
bool list_began = false;
- if (extra->bgp_fs_pbr && listcount(extra->bgp_fs_pbr)) {
+ if (extra->flowspec && extra->flowspec->bgp_fs_pbr &&
+ listcount(extra->flowspec->bgp_fs_pbr)) {
struct listnode *node;
struct bgp_pbr_match_entry *bpme;
struct bgp_pbr_match *bpm;
@@ -363,8 +364,8 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
list_bpm = list_new();
vty_out(vty, "\tinstalled in PBR");
- for (ALL_LIST_ELEMENTS_RO(extra->bgp_fs_pbr,
- node, bpme)) {
+ for (ALL_LIST_ELEMENTS_RO(extra->flowspec->bgp_fs_pbr, node,
+ bpme)) {
bpm = bpme->backpointer;
if (listnode_lookup(list_bpm, bpm))
continue;
@@ -378,13 +379,14 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
}
list_delete(&list_bpm);
}
- if (extra->bgp_fs_iprule && listcount(extra->bgp_fs_iprule)) {
+ if (extra->flowspec && extra->flowspec->bgp_fs_iprule &&
+ listcount(extra->flowspec->bgp_fs_iprule)) {
struct listnode *node;
struct bgp_pbr_rule *bpr;
if (!list_began)
vty_out(vty, "\tinstalled in PBR");
- for (ALL_LIST_ELEMENTS_RO(extra->bgp_fs_iprule,
+ for (ALL_LIST_ELEMENTS_RO(extra->flowspec->bgp_fs_iprule,
node, bpr)) {
if (!bpr->action)
continue;