diff options
| author | Valerian_He <1826906282@qq.com> | 2023-08-08 10:47:29 +0000 |
|---|---|---|
| committer | Valerian_He <1826906282@qq.com> | 2023-08-08 10:48:07 +0000 |
| commit | 98efa5bc6bac9e3917afe2fa206ec795ddf86b87 (patch) | |
| tree | bec88bbb7b364d234860c17efe23aa73776bce69 /bgpd/rfapi/rfapi_vty.c | |
| parent | 49f04841131b917ac6218ecba933af36f51a7f91 (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/rfapi/rfapi_vty.c')
| -rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 29698846c3..252b6d632a 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -420,15 +420,20 @@ void rfapi_vty_out_vncinfo(struct vty *vty, const struct prefix *p, vty_out(vty, " label=%u", decode_label(&bpi->extra->label[0])); - if (bpi->extra->num_sids) { - vty_out(vty, " sid=%pI6", &bpi->extra->sid[0].sid); - - if (bpi->extra->sid[0].loc_block_len != 0) { + if (bpi->attr->srv6_l3vpn || bpi->attr->srv6_vpn) { + struct in6_addr *sid_tmp = + bpi->attr->srv6_l3vpn + ? (&bpi->attr->srv6_l3vpn->sid) + : (&bpi->attr->srv6_vpn->sid); + vty_out(vty, " sid=%pI6", sid_tmp); + + if (bpi->attr->srv6_l3vpn && + bpi->attr->srv6_l3vpn->loc_block_len != 0) { vty_out(vty, " sid_structure=[%d,%d,%d,%d]", - bpi->extra->sid[0].loc_block_len, - bpi->extra->sid[0].loc_node_len, - bpi->extra->sid[0].func_len, - bpi->extra->sid[0].arg_len); + bpi->attr->srv6_l3vpn->loc_block_len, + bpi->attr->srv6_l3vpn->loc_node_len, + bpi->attr->srv6_l3vpn->func_len, + bpi->attr->srv6_l3vpn->arg_len); } } } |
