Skip to content

treat '-f -' as a request to read commands from stdin in a way which … #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5,844 commits into from

Conversation

tjcw
Copy link

@tjcw tjcw commented Oct 26, 2021

…works

with a pipe or a file redirection

donaldsharp and others added 30 commits November 18, 2020 15:26
[7.5] vtysh: send quit command to watchfrr
When allocating memory for the `struct ospf_metric` we
were using `uint32_t` instead of the actual size of this
structure.  When we wrote to it we would be writing
into other people's memory.

Found-by: Amol Lad
Signed-off-by: Donald Sharp <[email protected]>
Remove py-ipaddr and ipsec-tools as deps in the Alpine build container,
as these were both Python 2 libraries and are not used here anymore

`ipsec-tools` is also no longer available in Alpine's test repos and was
causing breakage on this builder

Signed-off-by: Wesley Coakley <[email protected]>
[7.5]ospfd: Prevent crash by accessing memory not owned.
When we fail to properly lookup an error code, properly cleanup
on return.

Signed-off-by: Donald Sharp <[email protected]>
when deleting a whole l2vpn context in ldpd which also had pseudowires
in it, we were first deleting the l2vpn with a 'no l2vpn XXX' command,
and then adding it again by running 'l2vpn XXX\n no member pseudowire YYY'
which obviously was not needed. As a result the l2vpn would be reinstated.

Signed-off-by: Emanuele Di Pascale <[email protected]>
If we screw up and don't have the right flags we'll print
out garbage.  At the very least just print out nothing.

Signed-off-by: Donald Sharp <[email protected]>
OSPFv3 snmp code creates a list but never deletes the actual
list.  Do so.

Signed-off-by: Donald Sharp <[email protected]>
If we are attempting to store the bgp name for route
leaking and we find a match do not leak the memory.

Please note this is probably not really going to happen
ever.

Signed-off-by: Donald Sharp <[email protected]>
We were allocating but never freeing memory associated with the
ecommunity_ecom2str allocation.

Signed-off-by: Donald Sharp <[email protected]>
Allows users with multiple links using same IPv6 address (same VRF) to
work.

Reported-by: Matti Suuronen
Signed-off-by: Rafael Zalamena <[email protected]>
Apparently the person who wrote this code was big into
cut-n-paste.  Commit 710a61d
found the first instance, but upon code inspection this morning
it became evident that 2 other functions had the exact same
problem.

Fix.  Note I have not cleaned up the cut-n-paste code for
two reasons: a) I'm chasing something else b) this code
has been fairly un-maintained for a very long time.  No
need to start up now.

Signed-off-by: Donald Sharp <[email protected]>
Having 2 ABR in NSSA area where R3 is the elected translator

R3# show ip ospf
  We are an ABR and the NSSA Elected Translator.
R2# show ip ospf
  We are an ABR, but not the NSSA Elected Translator.

When R3 loses the Border condition by shutting down the interface
to the backbone, we end up with no translator in the NSSA area. It
is expected R2 to take over the translator role

R3# sh ip ospf
  It is not ABR, therefore not Translator.
R2# show ip ospf
   We are an ABR, but not the NSSA Elected Translator.

This PR forces the ABR to reevaluate the translator condition, so
R2 becomes the elected Translator

Signed-off-by: ckishimo <[email protected]>
When an ABR NSSA router is configured to be ALWAYS the translator:
  r22(config-router)# area 1 nssa translate-always

It will advertise this condition in the type-1 LSA setting the Nt
bit, taking over the translator role from r33

  r22# show ip ospf
     We are an ABR and always an NSSA Translator.
  r33# show ip ospf
     We are an ABR, but not the NSSA Elected Translator.

However when the command above is removed:
  r22(config-router)# no area 1 nssa translate-always

the bit Nt needs to be cleared otherwise we end up with no translator
in the area
  r22# show ip ospf
     We are an ABR, but not the NSSA Elected Translator.
  r33# show ip ospf
     We are an ABR, but not the NSSA Elected Translator.

This PR forces the ABR to send a type-1 LSA with the Nt bit updated
according to the translator role

Signed-off-by: ckishimo <[email protected]>
… max-paths

problem
1. run the bgp with -e1 option
2. c t
   router bgp 100
3. show running config
    !
     address-family ipv6 multicast
      maximum-paths 1
      maximum-paths ibgp 1
     exit-address-family
    !
address families should not dump maximum-paths if there
value is same as value provided at run time.

fix
if the maxpaths_ebgp value is same as multipath_num global
object, don't dump maximum-paths.

Signed-off-by: vishaldhingra <[email protected]>
The "ifp" variable returned by nb_running_get_entry() might be
NULL when using the transactional CLI mode. Make the required
modifications to avoid null pointer dereferences.

Signed-off-by: Renato Westphal <[email protected]>
vertex->N is an union whose "id" and "ip" fields are only valid
depending on the vertex type (IS adjacency or IP reachability
information). As such, add a vertex type check before consulting
vertex->N.id in order to prevent unexpected behavior from happening.

Signed-off-by: Renato Westphal <[email protected]>
We are using data after it has been freed and handed back to the
OS.
Address Sanitizer output:

error	23-Nov-2020 18:53:57	ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55f825998f58 bp 0x7fffa5b0f5b0 sp 0x7fffa5b0f5a0
error	23-Nov-2020 18:53:57	READ of size 4 at 0x631000024838 thread T0
error	23-Nov-2020 18:53:57	    #0 0x55f825998f57 in lde_imsg_compose_parent_sync ldpd/lde.c:226
error	23-Nov-2020 18:53:57	    sonic-net#1 0x55f8259ca9ed in vlog ldpd/log.c:48
error	23-Nov-2020 18:53:57	    sonic-net#2 0x55f8259cb1c8 in log_info ldpd/log.c:102
error	23-Nov-2020 18:53:57	    sonic-net#3 0x55f82599e841 in lde_shutdown ldpd/lde.c:208
error	23-Nov-2020 18:53:57	    sonic-net#4 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error	23-Nov-2020 18:53:57	    sonic-net#5 0x55f825ac3815 in thread_call lib/thread.c:1681
error	23-Nov-2020 18:53:57	    sonic-net#6 0x55f825998d5e in lde ldpd/lde.c:160
error	23-Nov-2020 18:53:57	    sonic-net#7 0x55f82598a289 in main ldpd/ldpd.c:320
error	23-Nov-2020 18:53:57	    sonic-net#8 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error	23-Nov-2020 18:53:57	    sonic-net#9 0x55f825982579 in _start (/usr/lib/frr/ldpd+0xb3579)
error	23-Nov-2020 18:53:57
error	23-Nov-2020 18:53:57	0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error	23-Nov-2020 18:53:57	freed by thread T0 here:
error	23-Nov-2020 18:53:57	    #0 0x7fe3f8a4d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error	23-Nov-2020 18:53:57	    sonic-net#1 0x55f82599e830 in lde_shutdown ldpd/lde.c:206
error	23-Nov-2020 18:53:57	    sonic-net#2 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error	23-Nov-2020 18:53:57	    sonic-net#3 0x55f825ac3815 in thread_call lib/thread.c:1681
error	23-Nov-2020 18:53:57	    sonic-net#4 0x55f825998d5e in lde ldpd/lde.c:160
error	23-Nov-2020 18:53:57	    sonic-net#5 0x55f82598a289 in main ldpd/ldpd.c:320
error	23-Nov-2020 18:53:57	    sonic-net#6 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error	23-Nov-2020 18:53:57
error	23-Nov-2020 18:53:57	previously allocated by thread T0 here:
error	23-Nov-2020 18:53:57	    #0 0x7fe3f8a4dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error	23-Nov-2020 18:53:57	    sonic-net#1 0x55f825998cb7 in lde ldpd/lde.c:151
error	23-Nov-2020 18:53:57	    sonic-net#2 0x55f82598a289 in main ldpd/ldpd.c:320
error	23-Nov-2020 18:53:57	    sonic-net#3 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error	23-Nov-2020 18:53:57

The fix is to put this in global space.

Signed-off-by: Donald Sharp <[email protected]>
error	26-Nov-2020 14:35:02	ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55cefae977e9 bp 0x7ffdd3546860 sp 0x7ffdd3546850
error	26-Nov-2020 14:35:02	READ of size 4 at 0x631000024838 thread T0
error	26-Nov-2020 14:35:02	    #0 0x55cefae977e8 in ldpe_imsg_compose_parent_sync ldpd/ldpe.c:256
error	26-Nov-2020 14:35:02	    sonic-net#1 0x55cefae9ab13 in vlog ldpd/log.c:53
error	26-Nov-2020 14:35:02	    sonic-net#2 0x55cefae9b21f in log_info ldpd/log.c:102
error	26-Nov-2020 14:35:02	    sonic-net#3 0x55cefae96eae in ldpe_shutdown ldpd/ldpe.c:237
error	26-Nov-2020 14:35:02	    sonic-net#4 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error	26-Nov-2020 14:35:02	    sonic-net#5 0x55cefaf93875 in thread_call lib/thread.c:1681
error	26-Nov-2020 14:35:02	    sonic-net#6 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error	26-Nov-2020 14:35:02	    sonic-net#7 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error	26-Nov-2020 14:35:02	    sonic-net#8 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error	26-Nov-2020 14:35:02	    sonic-net#9 0x55cefae525e9 in _start (/usr/lib/frr/ldpd+0xb35e9)
error	26-Nov-2020 14:35:02
error	26-Nov-2020 14:35:02	0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error	26-Nov-2020 14:35:02	freed by thread T0 here:
error	26-Nov-2020 14:35:02	    #0 0x7f4ef21e37a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error	26-Nov-2020 14:35:02	    sonic-net#1 0x55cefae96e91 in ldpe_shutdown ldpd/ldpe.c:234
error	26-Nov-2020 14:35:02	    sonic-net#2 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error	26-Nov-2020 14:35:02	    sonic-net#3 0x55cefaf93875 in thread_call lib/thread.c:1681
error	26-Nov-2020 14:35:02	    sonic-net#4 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error	26-Nov-2020 14:35:02	    sonic-net#5 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error	26-Nov-2020 14:35:02	    sonic-net#6 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error	26-Nov-2020 14:35:02
error	26-Nov-2020 14:35:02	previously allocated by thread T0 here:
error	26-Nov-2020 14:35:02	    #0 0x7f4ef21e3d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error	26-Nov-2020 14:35:02	    sonic-net#1 0x55cefae9725d in ldpe ldpd/ldpe.c:127
error	26-Nov-2020 14:35:02	    sonic-net#2 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error	26-Nov-2020 14:35:02	    sonic-net#3 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Clean this problem up in the same way as the previous commit

Signed-off-by: Donald Sharp <[email protected]>
Source value must be a choice between host, network and any, not a set
of all three.

Fixes #7599.

Signed-off-by: Igor Ryzhov <[email protected]>
[7.5] yang: fix cisco access list source value
OSPF instance initialization was moved from "router ospf" vty command to
ospf_get function some time ago but the same thing must be done in
ospf_get_instance function used when multi-instance mode is enabled.

Signed-off-by: Igor Ryzhov <[email protected]>
[7.5] ospf: fix instance initialization when using multi-instance mode
local-address is optional for both IPv4 and IPv6.

Signed-off-by: Igor Ryzhov <[email protected]>
idryzhov and others added 21 commits April 22, 2021 12:48
Fixes: #8521
Signed-off-by: Igor Ryzhov <[email protected]>
If the last message in a batched logging operation isn't printed due to
priority, this skips the code that flushes prepared messages through
writev() and can trigger the assert() at the end of zlog_fd().

Since any logmsg above info priority triggers a buffer flush, running
into this situation requires a log file target configured for info
priority, at least 1 message of info priority buffered, a debug message
buffered after that, and then a buffer flush (explicit or due to buffer
full).

I haven't seen this chain of events happen in the wild, but it needs
fixing anyway.

Signed-off-by: David Lamparter <[email protected]>
(cherry picked from commit db2baed)
The (legacy) code for reading split configs tries to execute config
commands in parent nodes, but doesn't call the node_exit function when
it goes up to a parent node.  This breaks BGP RPKI setup (and extended
syslog, which is in the next commit.)

Doing this correctly is a slight bit involved since the node_exit
callbacks should only be called if the command is actually executed on a
parent node.

Signed-off-by: David Lamparter <[email protected]>
(cherry picked from commit e347606)
…s error

vtysh will return an informational message to the user that changing any
graceful-shutdown related parameter will require a peer reset. This is should
not be treated as an error message (resulting in a return code of 1) but
rather as a simple information to the user.

This fixes GitHub issue FRRouting/frr#8403

$ vtysh -c configure -c 'router bgp 100' -c 'bgp graceful-restart'
Graceful restart configuration changed, reset all peers to take effect
$ echo $?
0

Signed-off-by: Christian Poessinger <[email protected]>

(cherry picked from commit 5b899e9)
When the user adds the route + nexthop pair that already exists with a
different distance, we should replace it instead of adding a new one.

Likewise, when the user wants to delete the route + nexthop pair without
explicitly entering the distance, we should delete the route.

Fixes #8695.

Signed-off-by: Igor Ryzhov <[email protected]>
Prior to this commit, updating a prefix-list that is referenced by a
route-map clause will unconditionally delete the root node of that
route-map's prefix-tree (used with route-map optimization).
This is problematic because routes not matching a more specific node
in the tree (i.e. other prefix-list sequences) will not fall-back to
the default node, thus they will not hit any route-map sequences.
This commit ensures that an update to a prefix-list will only delete
the default node while adding the first/only seq to the list.

Example config:
========
ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16
ip prefix-list peer475-out-pfxlist seq 50 permit 0.0.0.0/0
!
route-map peer475-out permit 5
 match ip address prefix-list peer475-out-pfxlist

Before:
========
ub20# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
BGP:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5
    2.138.0.0/16 (2)
(P) 0.0.0.0/0
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
ub20# conf t
ub20(config)# ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16 le 32
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    2.138.0.0/16 (2)
(P)
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
BGP:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    2.138.0.0/16 (2)
(P)
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
ub20(config)#

After:
========
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

ub20(config)# ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16 le 32
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

ub20(config)#

Fixes: 8410
Signed-off-by: Trey Aspelund <[email protected]>
(cherry picked from commit 4718791)
[7.5] lib: fix handling of rmap prefix-tree default node
Backport the fix for #8695 to 7.5
Almost all functions currently marked with pure attribute acquire a
route_node lock. By marking them pure we allow compiler to optimize the
code and not call them when it already knows the return value. This is
completely incorrect.

Only two of eleven functions can be marked as pure. And they still won't
be optimized because they are never called from the same function twice.
Let's remove the ext_pure macro completely to reduce the chance of
repeating this mistake in the future.

Fixes #8866, #8809, #8595, #6992.

Signed-off-by: Igor Ryzhov <[email protected]>
(cherry picked from commit 4f08c71)
Currently, if the routemap already exists, we delete the pointer to it
when it is updated. We should delete the pointer only if the route-map
is actually deleted.

Signed-off-by: Igor Ryzhov <[email protected]>
(cherry picked from commit 0fddd86)
lib: remove pure attribute from functions that modify memory (backport #8876)
Signed-off-by: Emanuele Di Pascale <[email protected]>
Signed-off-by: Christian Poessinger <[email protected]>

(cherry picked from commit ee96c52)
zebra was crashing when the command was run on a non-existent VNI.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
root@torm-12:mgmt:~# net show evpn es-evi vni 16777215
VNI 16777215 doesn't exist
root@torm-12:mgmt:~# net show evpn es-evi vni 16777215 detail
VNI 16777215 doesn't exist
root@torm-12:mgmt:~# net show evpn es-evi vni 16777215 json
[
]
root@torm-12:mgmt:~# net show evpn es-evi vni 16777215 detail json
[
]
root@torm-12:mgmt:~#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Ticket: CM-30232

Signed-off-by: Anuradha Karuppiah <[email protected]>
zebra: [7.5] handle "show evpn es-evi" a non-existent VNI
There exists some rare situations where fpm will attempt
to send a route update with no valid nexthops.  In that
case an assert would be hit.  This is not good for
trying to keep your routing daemons up and running
when we can safely just recover the situation.

Fixes #7588
Signed-off-by: batmancn <[email protected]>
<fixed commit message, and used zlog_err>
Signed-off-by: Donald Sharp <[email protected]>
(cherry picked from commit 5306e6c)
zebra: bugfix of error quit of zebra, due to no nexthop ACTIVE (backport #9214)
@ghost
Copy link

ghost commented Oct 29, 2021

CLA assistant check
All CLA requirements met.

@tjcw tjcw force-pushed the tjcw-vtysh-f-stdin branch from 6e62c20 to 26938ab Compare October 29, 2021 13:27
…works

with a pipe or a file redirection

Write to stdout if in a pipe

Need to update the header for vtysh_read_file

Try without a comment
@tjcw tjcw force-pushed the tjcw-vtysh-f-stdin branch from 26938ab to 2e10d64 Compare November 1, 2021 10:46
@lgtm-com
Copy link

lgtm-com bot commented Nov 1, 2021

This pull request introduces 8 alerts when merging 2e10d64 into 88351c8 - view on LGTM.com

new alerts:

  • 2 for `__eq__` not overridden when adding attributes
  • 2 for Unused local variable
  • 2 for Unused import
  • 1 for Incomplete ordering
  • 1 for Inconsistent equality and hashing

@tjcw
Copy link
Author

tjcw commented Nov 2, 2021

Wrong place to make this commit. Closing.

@tjcw tjcw closed this Nov 2, 2021
marcosfsch pushed a commit to marcosfsch/sonic-frr that referenced this pull request Jan 30, 2024
This commit ensures proper cleanup by deleting the gm_join_list when a PIM interface is deleted. The gm_join_list was previously not being freed, causing a memory leak.

The ASan leak log for reference:
```
***********************************************************************************
Address Sanitizer Error detected in multicast_mld_join_topo1.test_multicast_mld_local_join/r1.asan.pim6d.28070

=================================================================
==28070==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105
    sonic-net#2 0x56230372180f in list_new lib/linklist.c:49
    sonic-net#3 0x56230361b589 in pim_if_gm_join_add pimd/pim_iface.c:1313
    sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    sonic-net#13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221
    sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591
    sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995
    sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213
    sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184
    sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 192 byte(s) in 4 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105
    sonic-net#2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288
    sonic-net#3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326
    sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    sonic-net#13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221
    sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591
    sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995
    sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213
    sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184
    sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 96 byte(s) in 4 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105
    sonic-net#2 0x562303721651 in listnode_new lib/linklist.c:71
    sonic-net#3 0x56230372182b in listnode_add lib/linklist.c:92
    sonic-net#4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295
    sonic-net#5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326
    sonic-net#6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    sonic-net#7 0x562303767280 in nb_callback_create lib/northbound.c:1235
    sonic-net#8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    sonic-net#9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    sonic-net#10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    sonic-net#11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    sonic-net#12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    sonic-net#13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    sonic-net#14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    sonic-net#15 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    sonic-net#16 0x5623036c6392 in cmd_execute lib/command.c:1221
    sonic-net#17 0x5623037e75da in vty_command lib/vty.c:591
    sonic-net#18 0x5623037e7a74 in vty_execute lib/vty.c:1354
    sonic-net#19 0x5623037f0253 in vtysh_read lib/vty.c:2362
    sonic-net#20 0x5623037db4e8 in event_call lib/event.c:1995
    sonic-net#21 0x562303720f97 in frr_run lib/libfrr.c:1213
    sonic-net#22 0x56230368615d in main pimd/pim6_main.c:184
    sonic-net#23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105
    sonic-net#2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288
    sonic-net#3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326
    sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    sonic-net#13 0x5623036c5f6f in cmd_execute_command lib/command.c:1072
    sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221
    sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591
    sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995
    sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213
    sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184
    sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105
    sonic-net#2 0x562303721651 in listnode_new lib/linklist.c:71
    sonic-net#3 0x56230372182b in listnode_add lib/linklist.c:92
    sonic-net#4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295
    sonic-net#5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326
    sonic-net#6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    sonic-net#7 0x562303767280 in nb_callback_create lib/northbound.c:1235
    sonic-net#8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    sonic-net#9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    sonic-net#10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    sonic-net#11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    sonic-net#12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    sonic-net#13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    sonic-net#14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    sonic-net#15 0x5623036c5f6f in cmd_execute_command lib/command.c:1072
    sonic-net#16 0x5623036c6392 in cmd_execute lib/command.c:1221
    sonic-net#17 0x5623037e75da in vty_command lib/vty.c:591
    sonic-net#18 0x5623037e7a74 in vty_execute lib/vty.c:1354
    sonic-net#19 0x5623037f0253 in vtysh_read lib/vty.c:2362
    sonic-net#20 0x5623037db4e8 in event_call lib/event.c:1995
    sonic-net#21 0x562303720f97 in frr_run lib/libfrr.c:1213
    sonic-net#22 0x56230368615d in main pimd/pim6_main.c:184
    sonic-net#23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 400 byte(s) leaked in 11 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <[email protected]>
eddieruan-alibaba pushed a commit to eddieruan-alibaba/sonic-frr that referenced this pull request Mar 11, 2025
The following ASAN error can be seen.

> ERROR: AddressSanitizer: attempting to call malloc_usable_size() for pointer which is not owned: 0x608000036c20
>     #0 0x7f3d7a4b5425 in __interceptor_malloc_usable_size ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:198
>     sonic-net#1 0x7f3d7a426a16 in __sanitizer::BufferedStackTrace::Unwind(unsigned long, unsigned long, void*, bool, unsigned int) ../../../../src/libsanitizer/sanitizer_common
> /sanitizer_stacktrace.h:122
>     sonic-net#2 0x7f3d7a426a16 in __asan::asan_malloc_usable_size(void const*, unsigned long, unsigned long) ../../../../src/libsanitizer/asan/asan_allocator.cpp:1074
>     sonic-net#3 0x7f3d7a03f330 in mt_count_free lib/memory.c:78
>     sonic-net#4 0x7f3d7a03f330 in qfree lib/memory.c:130
>     sonic-net#5 0x7f3d76ccf89b in bmp_peer_status_changed bgpd/bgp_bmp.c:982
>     sonic-net#6 0x560ae2aa6a94 in hook_call_peer_status_changed bgpd/bgp_fsm.c:47
>     sonic-net#7 0x560ae2aa6a94 in bgp_fsm_change_status bgpd/bgp_fsm.c:1287
>     sonic-net#8 0x560ae2c4f2e5 in peer_delete bgpd/bgpd.c:2777
>     sonic-net#9 0x560ae2c58d24 in bgp_delete bgpd/bgpd.c:4140
>     sonic-net#10 0x560ae2bbb47e in no_router_bgp bgpd/bgp_vty.c:1764
>     sonic-net#11 0x7f3d79fb74ed in cmd_execute_command_real lib/command.c:1003
>     sonic-net#12 0x7f3d79fb78a3 in cmd_execute_command lib/command.c:1062
>     sonic-net#13 0x7f3d79fb7e03 in cmd_execute lib/command.c:1228
>     sonic-net#14 0x7f3d7a107b53 in vty_command lib/vty.c:625
>     sonic-net#15 0x7f3d7a109902 in vty_execute lib/vty.c:1388
>     sonic-net#16 0x7f3d7a10cc32 in vtysh_read lib/vty.c:2400
>     sonic-net#17 0x7f3d7a0f848b in event_call lib/event.c:2019
>     sonic-net#18 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232
>     sonic-net#19 0x560ae29e0037 in main bgpd/bgp_main.c:555
>     sonic-net#20 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
>     sonic-net#21 0x7f3d79a29e3f in __libc_start_main_impl ../csu/libc-start.c:392
>     sonic-net#22 0x560ae29e4ef4 in _start (/usr/lib/frr/bgpd+0x2eeef4)
>
> 0x608000036c20 is located 0 bytes inside of 81-byte region [0x608000036c20,0x608000036c71)
> freed by thread T0 here:
>     #0 0x7f3d7a4b4537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127
>     sonic-net#1 0x7f3d76ccf85f in bmp_peer_status_changed bgpd/bgp_bmp.c:981
>     sonic-net#2 0x560ae2aa6a94 in hook_call_peer_status_changed bgpd/bgp_fsm.c:47
>     sonic-net#3 0x560ae2aa6a94 in bgp_fsm_change_status bgpd/bgp_fsm.c:1287
>     sonic-net#4 0x560ae2c4f2e5 in peer_delete bgpd/bgpd.c:2777
>     sonic-net#5 0x560ae2c58d24 in bgp_delete bgpd/bgpd.c:4140
>     sonic-net#6 0x560ae2bbb47e in no_router_bgp bgpd/bgp_vty.c:1764
>     sonic-net#7 0x7f3d79fb74ed in cmd_execute_command_real lib/command.c:1003
>     sonic-net#8 0x7f3d79fb78a3 in cmd_execute_command lib/command.c:1062
>     sonic-net#9 0x7f3d79fb7e03 in cmd_execute lib/command.c:1228
>     sonic-net#10 0x7f3d7a107b53 in vty_command lib/vty.c:625
>     sonic-net#11 0x7f3d7a109902 in vty_execute lib/vty.c:1388
>     sonic-net#12 0x7f3d7a10cc32 in vtysh_read lib/vty.c:2400
>     sonic-net#13 0x7f3d7a0f848b in event_call lib/event.c:2019
>     sonic-net#14 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232
>     sonic-net#15 0x560ae29e0037 in main bgpd/bgp_main.c:555
>     sonic-net#16 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
>
> previously allocated by thread T0 here:
>     #0 0x7f3d7a4b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
>     sonic-net#1 0x7f3d7a03f0e9 in qmalloc lib/memory.c:101
>     sonic-net#2 0x7f3d76cd0166 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2194
>     sonic-net#3 0x7f3d76cd0166 in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2236
>     sonic-net#4 0x7f3d76cd29b8 in bmp_vrf_state_changed bgpd/bgp_bmp.c:3479
>     sonic-net#5 0x560ae2c45b34 in hook_call_bgp_instance_state bgpd/bgpd.c:88
>     sonic-net#6 0x560ae2c4d158 in bgp_instance_up bgpd/bgpd.c:3936
>     sonic-net#7 0x560ae29e5ed1 in bgp_vrf_enable bgpd/bgp_main.c:299
>     sonic-net#8 0x7f3d7a0ff8b1 in vrf_enable lib/vrf.c:286
>     sonic-net#9 0x7f3d7a0ff8b1 in vrf_enable lib/vrf.c:275
>     sonic-net#10 0x7f3d7a12ab66 in zclient_vrf_add lib/zclient.c:2561
>     sonic-net#11 0x7f3d7a12eb43 in zclient_read lib/zclient.c:4624
>     sonic-net#12 0x7f3d7a0f848b in event_call lib/event.c:2019
>     sonic-net#13 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232
>     sonic-net#14 0x560ae29e0037 in main bgpd/bgp_main.c:555
>     sonic-net#15 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Signed-off-by: Philippe Guibert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.