2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/*
|
2004-05-18 20:57:06 +02:00
|
|
|
* Copyright (C) 2003 Yasuhiro Ohara
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "memory.h"
|
2023-03-07 20:22:48 +01:00
|
|
|
#include "frrevent.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "linklist.h"
|
|
|
|
#include "vty.h"
|
|
|
|
#include "command.h"
|
2021-04-14 17:37:01 +02:00
|
|
|
#include "lib/bfd.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_proto.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "ospf6_lsa.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_lsdb.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "ospf6_message.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_top.h"
|
|
|
|
#include "ospf6_area.h"
|
|
|
|
#include "ospf6_interface.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "ospf6_neighbor.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_intra.h"
|
2004-05-18 21:28:32 +02:00
|
|
|
#include "ospf6_flood.h"
|
2004-08-04 22:02:13 +02:00
|
|
|
#include "ospf6d.h"
|
2015-07-22 21:35:37 +02:00
|
|
|
#include "ospf6_bfd.h"
|
2015-11-03 19:37:25 +01:00
|
|
|
#include "ospf6_abr.h"
|
|
|
|
#include "ospf6_asbr.h"
|
|
|
|
#include "ospf6_lsa.h"
|
|
|
|
#include "ospf6_spf.h"
|
|
|
|
#include "ospf6_zebra.h"
|
2021-06-28 13:55:27 +02:00
|
|
|
#include "ospf6_gr.h"
|
2020-09-28 12:48:37 +02:00
|
|
|
#include "lib/json.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-09-23 17:21:09 +02:00
|
|
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor");
|
2021-03-22 19:31:56 +01:00
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
DEFINE_HOOK(ospf6_neighbor_change,
|
|
|
|
(struct ospf6_neighbor * on, int state, int next_state),
|
|
|
|
(on, state, next_state));
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
unsigned char conf_debug_ospf6_neighbor = 0;
|
|
|
|
|
2019-11-20 17:26:59 +01:00
|
|
|
const char *const ospf6_neighbor_state_str[] = {
|
2004-05-18 20:57:06 +02:00
|
|
|
"None", "Down", "Attempt", "Init", "Twoway",
|
|
|
|
"ExStart", "ExChange", "Loading", "Full", NULL};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-20 17:26:59 +01:00
|
|
|
const char *const ospf6_neighbor_event_str[] = {
|
|
|
|
"NoEvent", "HelloReceived", "2-WayReceived", "NegotiationDone",
|
|
|
|
"ExchangeDone", "LoadingDone", "AdjOK?", "SeqNumberMismatch",
|
|
|
|
"BadLSReq", "1-WayReceived", "InactivityTimer",
|
|
|
|
};
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
int ospf6_neighbor_cmp(void *va, void *vb)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va;
|
|
|
|
struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb;
|
2018-10-17 21:31:09 +02:00
|
|
|
|
|
|
|
if (ona->router_id == onb->router_id)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (ntohl(ona->router_id) < ntohl(onb->router_id)) ? -1 : 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id,
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_interface *oi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
struct listnode *n;
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, n, on))
|
|
|
|
if (on->router_id == router_id)
|
|
|
|
return on;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return (struct ospf6_neighbor *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-07-02 18:01:32 +02:00
|
|
|
struct ospf6_neighbor *ospf6_area_neighbor_lookup(struct ospf6_area *area,
|
|
|
|
uint32_t router_id)
|
|
|
|
{
|
|
|
|
struct ospf6_interface *oi;
|
|
|
|
struct ospf6_neighbor *nbr;
|
|
|
|
struct listnode *node;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(area->if_list, node, oi)) {
|
|
|
|
nbr = ospf6_neighbor_lookup(router_id, oi);
|
|
|
|
if (nbr)
|
|
|
|
return nbr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
static void ospf6_neighbor_clear_ls_lists(struct ospf6_neighbor *on)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
struct ospf6_lsa *lsanext;
|
|
|
|
|
|
|
|
ospf6_lsdb_remove_all(on->summary_list);
|
|
|
|
if (on->last_ls_req) {
|
|
|
|
ospf6_lsa_unlock(on->last_ls_req);
|
|
|
|
on->last_ls_req = NULL;
|
|
|
|
}
|
|
|
|
ospf6_lsdb_remove_all(on->request_list);
|
|
|
|
for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
|
|
|
|
ospf6_decrement_retrans_count(lsa);
|
|
|
|
ospf6_lsdb_remove(lsa, on->retrans_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* create ospf6_neighbor */
|
2018-03-27 21:13:34 +02:00
|
|
|
struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_interface *oi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
char buf[16];
|
2021-05-30 18:33:41 +02:00
|
|
|
int type;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-02-25 21:41:01 +01:00
|
|
|
on = XCALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor));
|
2004-05-18 20:57:06 +02:00
|
|
|
inet_ntop(AF_INET, &router_id, buf, sizeof(buf));
|
|
|
|
snprintf(on->name, sizeof(on->name), "%s%%%s", buf,
|
|
|
|
oi->interface->name);
|
|
|
|
on->ospf6_if = oi;
|
|
|
|
on->state = OSPF6_NEIGHBOR_DOWN;
|
2012-05-31 20:21:15 +02:00
|
|
|
on->state_change = 0;
|
2017-01-18 01:30:43 +01:00
|
|
|
monotime(&on->last_changed);
|
2004-05-18 20:57:06 +02:00
|
|
|
on->router_id = router_id;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-08-15 07:52:07 +02:00
|
|
|
on->summary_list = ospf6_lsdb_create(on);
|
|
|
|
on->request_list = ospf6_lsdb_create(on);
|
|
|
|
on->retrans_list = ospf6_lsdb_create(on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-08-15 07:52:07 +02:00
|
|
|
on->dbdesc_list = ospf6_lsdb_create(on);
|
|
|
|
on->lsupdate_list = ospf6_lsdb_create(on);
|
|
|
|
on->lsack_list = ospf6_lsdb_create(on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-05-30 18:33:41 +02:00
|
|
|
for (type = 0; type < OSPF6_MESSAGE_TYPE_MAX; type++) {
|
|
|
|
on->seqnum_l[type] = 0;
|
|
|
|
on->seqnum_h[type] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
on->auth_present = false;
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
listnode_add_sort(oi->neighbor_list, on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
Support of BFD status in Quagga
Ticket:CM-6802, CM-6952
Reviewed By: Donald, Kanna
Testing Done:
Double commit of b76943235e09472ec174edcf7204fc82d27fe966 from br2.5. But, manually resolved all the compilation errors. Also, modified the shows to support the json format which was not supported in br2.5.
CM-6802 – Currently, BFD session status can be monitored only through ptmctl. There is no way to check the BFD status of a peer/neighbor through Quagga. Debugging becomes easier if BFD status is shown in Quagga too. BFD status is relevant when it is shown against the BGP peer/OSPF neighbor. For, this following code changes have been done:
- Only down messages from PTM were being propagated from Zebra daemon to clients (bgpd, ospfd and ospf6d). Now, both up and down messages are redistributed to the clients from zebra. BFD status field has been added to the messaging. Handling of BFD session up messages has been added to the client code. BGP/OSPF neighbor is brought down only if the old BFD session status is ‘Up’ to handle extra/initial down messages.
- BFD status and last update timestamp fields have been added to the common BFD info structure. Also, common show functions for showing BFD information have been added to BFD lib.
- Modified the BGP neighbor show functions to call common BFD lib functions.
- For ospf and ospf6, BFD information was maintained only at interface level. To show BFD status per neighbor, BFD information has been added at neighbor level too. “show ip ospf interface”, “show ip ospf neighbor detail”, “show ipv6 ospf6 interface” and “show ipv6 ospf6 neighbor detail” output have been modified to show BFD information.
CM-6952 - IBGP peers were always assumed to be multi-hop since there was no easy way to determine whether an IBGP peer was single hop or multihop unlike EBGP. But, this is causing problem with IBGP link local peers since BFD doesn't allow multihop BFD session with link local IP addresses. Link local peers were discovered when the interface peering was enabled. Interface peering is always singlehop. So, added checks to treat all interface based peers as single hop irrespective of whether the peer is IBGP or EBGP.
2015-08-31 23:56:11 +02:00
|
|
|
ospf6_bfd_info_nbr_create(oi, on);
|
2004-05-18 20:57:06 +02:00
|
|
|
return on;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
void ospf6_neighbor_delete(struct ospf6_neighbor *on)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_remove_all(on->dbdesc_list);
|
|
|
|
ospf6_lsdb_remove_all(on->lsupdate_list);
|
|
|
|
ospf6_lsdb_remove_all(on->lsack_list);
|
|
|
|
|
|
|
|
ospf6_lsdb_delete(on->summary_list);
|
|
|
|
ospf6_lsdb_delete(on->request_list);
|
|
|
|
ospf6_lsdb_delete(on->retrans_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_delete(on->dbdesc_list);
|
|
|
|
ospf6_lsdb_delete(on->lsupdate_list);
|
|
|
|
ospf6_lsdb_delete(on->lsack_list);
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->inactivity_timer);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->last_dbdesc_release_timer);
|
2021-03-16 08:45:23 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
|
|
|
EVENT_OFF(on->thread_send_lsreq);
|
|
|
|
EVENT_OFF(on->thread_send_lsupdate);
|
|
|
|
EVENT_OFF(on->thread_send_lsack);
|
|
|
|
EVENT_OFF(on->thread_exchange_done);
|
|
|
|
EVENT_OFF(on->thread_adj_ok);
|
2023-07-01 17:18:06 +02:00
|
|
|
EVENT_OFF(on->event_loading_done);
|
2021-11-05 22:56:42 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->gr_helper_info.t_grace_timer);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2021-04-14 17:37:01 +02:00
|
|
|
bfd_sess_free(&on->bfd_session);
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_OSPF6_NEIGHBOR, on);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static void ospf6_neighbor_state_change(uint8_t next_state,
|
2013-08-26 05:40:16 +02:00
|
|
|
struct ospf6_neighbor *on, int event)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t prev_state;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
prev_state = on->state;
|
|
|
|
on->state = next_state;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (prev_state == next_state)
|
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 20:21:15 +02:00
|
|
|
on->state_change++;
|
2017-01-18 01:30:43 +01:00
|
|
|
monotime(&on->last_changed);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* log */
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) {
|
2022-04-06 21:15:57 +02:00
|
|
|
zlog_debug(
|
|
|
|
"Neighbor state change %s (Router-ID: %pI4): [%s]->[%s] (%s)",
|
|
|
|
on->name, &on->router_id,
|
|
|
|
ospf6_neighbor_state_str[prev_state],
|
|
|
|
ospf6_neighbor_state_str[next_state],
|
|
|
|
ospf6_neighbor_event_string(event));
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
/* Optionally notify about adjacency changes */
|
|
|
|
if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
|
|
|
|
OSPF6_LOG_ADJACENCY_CHANGES)
|
|
|
|
&& (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
|
|
|
|
OSPF6_LOG_ADJACENCY_DETAIL)
|
|
|
|
|| (next_state == OSPF6_NEIGHBOR_FULL)
|
|
|
|
|| (next_state < prev_state)))
|
2022-04-06 21:15:57 +02:00
|
|
|
zlog_notice(
|
|
|
|
"AdjChg: Nbr %pI4(%s) on %s: %s -> %s (%s)",
|
|
|
|
&on->router_id,
|
|
|
|
vrf_id_to_name(on->ospf6_if->interface->vrf->vrf_id),
|
|
|
|
on->name, ospf6_neighbor_state_str[prev_state],
|
|
|
|
ospf6_neighbor_state_str[next_state],
|
|
|
|
ospf6_neighbor_event_string(event));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (prev_state == OSPF6_NEIGHBOR_FULL
|
|
|
|
|| next_state == OSPF6_NEIGHBOR_FULL) {
|
2021-06-28 13:55:27 +02:00
|
|
|
if (!OSPF6_GR_IS_ACTIVE_HELPER(on)) {
|
|
|
|
OSPF6_ROUTER_LSA_SCHEDULE(on->ospf6_if->area);
|
|
|
|
if (on->ospf6_if->state == OSPF6_INTERFACE_DR) {
|
|
|
|
OSPF6_NETWORK_LSA_SCHEDULE(on->ospf6_if);
|
|
|
|
OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(
|
|
|
|
on->ospf6_if);
|
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2018-03-02 23:20:26 +01:00
|
|
|
if (next_state == OSPF6_NEIGHBOR_FULL)
|
|
|
|
on->ospf6_if->area->intra_prefix_originate = 1;
|
|
|
|
|
2021-06-28 13:55:27 +02:00
|
|
|
if (!OSPF6_GR_IS_ACTIVE_HELPER(on))
|
|
|
|
OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(
|
|
|
|
on->ospf6_if->area);
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
|
2021-06-28 13:55:27 +02:00
|
|
|
if ((prev_state == OSPF6_NEIGHBOR_LOADING
|
|
|
|
|| prev_state == OSPF6_NEIGHBOR_EXCHANGE)
|
|
|
|
&& next_state == OSPF6_NEIGHBOR_FULL) {
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if);
|
2018-02-12 22:22:04 +01:00
|
|
|
on->ospf6_if->area->full_nbrs++;
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
}
|
2018-02-12 22:22:04 +01:00
|
|
|
|
|
|
|
if (prev_state == OSPF6_NEIGHBOR_FULL)
|
|
|
|
on->ospf6_if->area->full_nbrs--;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if ((prev_state == OSPF6_NEIGHBOR_EXCHANGE
|
|
|
|
|| prev_state == OSPF6_NEIGHBOR_LOADING)
|
|
|
|
&& (next_state != OSPF6_NEIGHBOR_EXCHANGE
|
|
|
|
&& next_state != OSPF6_NEIGHBOR_LOADING))
|
2006-05-15 12:42:24 +02:00
|
|
|
ospf6_maxage_remove(on->ospf6_if->area->ospf6);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
hook_call(ospf6_neighbor_change, on, next_state, prev_state);
|
2015-07-22 21:35:37 +02:00
|
|
|
ospf6_bfd_trigger_event(on, prev_state, next_state);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* RFC2328 section 10.4 */
|
|
|
|
static int need_adjacency(struct ospf6_neighbor *on)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT
|
|
|
|
|| on->ospf6_if->state == OSPF6_INTERFACE_DR
|
|
|
|
|| on->ospf6_if->state == OSPF6_INTERFACE_BDR)
|
|
|
|
return 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (on->ospf6_if->drouter == on->router_id
|
|
|
|
|| on->ospf6_if->bdrouter == on->router_id)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void hello_received(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *HelloReceived*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
/* reset Inactivity Timer */
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->inactivity_timer);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_timer(master, inactivity_timer, on,
|
|
|
|
on->ospf6_if->dead_interval, &on->inactivity_timer);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (on->state <= OSPF6_NEIGHBOR_DOWN)
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void twoway_received(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (on->state > OSPF6_NEIGHBOR_INIT)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *2Way-Received*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (!need_adjacency(on)) {
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
|
2004-05-18 20:57:06 +02:00
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_dbdesc_send, on, 0,
|
|
|
|
&on->thread_send_dbdesc);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void negotiation_done(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
2020-08-17 14:25:12 +02:00
|
|
|
struct ospf6_lsa *lsa, *lsanext;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (on->state != OSPF6_NEIGHBOR_EXSTART)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* clear ls-list */
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Interface scoped LSAs */
|
2020-08-17 14:25:12 +02:00
|
|
|
for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
|
2004-08-15 07:52:07 +02:00
|
|
|
ospf6_increment_retrans_count(lsa);
|
2004-05-18 21:28:32 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Area scoped LSAs */
|
2020-08-17 14:25:12 +02:00
|
|
|
for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa, lsanext)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
|
2004-08-15 07:52:07 +02:00
|
|
|
ospf6_increment_retrans_count(lsa);
|
2004-05-18 21:28:32 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* AS scoped LSAs */
|
2020-08-17 14:25:12 +02:00
|
|
|
for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa, lsanext)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
|
2004-08-15 07:52:07 +02:00
|
|
|
ospf6_increment_retrans_count(lsa);
|
2004-05-18 21:28:32 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->summary_list);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
UNSET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXCHANGE, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
static void ospf6_neighbor_last_dbdesc_release(struct event *thread)
|
2021-03-16 08:45:23 +01:00
|
|
|
{
|
2022-12-25 16:26:52 +01:00
|
|
|
struct ospf6_neighbor *on = EVENT_ARG(thread);
|
2021-03-16 08:45:23 +01:00
|
|
|
|
|
|
|
assert(on);
|
|
|
|
memset(&on->dbdesc_last, 0, sizeof(struct ospf6_dbdesc));
|
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void exchange_done(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_lsdb_remove_all(on->dbdesc_list);
|
|
|
|
|
2021-03-16 08:45:23 +01:00
|
|
|
/* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
|
|
|
|
if (!CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)) {
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->last_dbdesc_release_timer);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_timer(master, ospf6_neighbor_last_dbdesc_release, on,
|
|
|
|
on->ospf6_if->dead_interval,
|
|
|
|
&on->last_dbdesc_release_timer);
|
2021-03-16 08:45:23 +01:00
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (on->request_list->count == 0)
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
|
2004-05-18 20:57:06 +02:00
|
|
|
else {
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
|
2013-08-24 09:55:07 +02:00
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_lsreq_send, on, 0,
|
|
|
|
&on->thread_send_lsreq);
|
2013-08-24 09:55:07 +02:00
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2013-08-24 09:55:07 +02:00
|
|
|
/* Check loading state. */
|
|
|
|
void ospf6_check_nbr_loading(struct ospf6_neighbor *on)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* RFC2328 Section 10.9: When the neighbor responds to these requests
|
|
|
|
with the proper Link State Update packet(s), the Link state request
|
|
|
|
list is truncated and a new Link State Request packet is sent.
|
|
|
|
*/
|
|
|
|
if ((on->state == OSPF6_NEIGHBOR_LOADING)
|
|
|
|
|| (on->state == OSPF6_NEIGHBOR_EXCHANGE)) {
|
|
|
|
if (on->request_list->count == 0)
|
2023-07-01 17:18:06 +02:00
|
|
|
event_add_event(master, loading_done, on, 0,
|
|
|
|
&on->event_loading_done);
|
2013-08-24 09:55:07 +02:00
|
|
|
else if (on->last_ls_req == NULL) {
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_lsreq);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_lsreq_send, on, 0,
|
|
|
|
&on->thread_send_lsreq);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2013-08-24 09:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void loading_done(struct event *thread)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (on->state != OSPF6_NEIGHBOR_LOADING)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *LoadingDone*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
assert(on->request_list->count == 0);
|
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_FULL, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void adj_ok(struct event *thread)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_neighbor *on;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *AdjOK?*", on->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency(on)) {
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_ADJ_OK);
|
2004-05-18 20:57:06 +02:00
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_dbdesc_send, on, 0,
|
|
|
|
&on->thread_send_dbdesc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
} else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) {
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_ADJ_OK);
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void seqnumber_mismatch(struct event *thread)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_neighbor *on;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *SeqNumberMismatch*", on->name);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH);
|
2004-05-18 20:57:06 +02:00
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
2013-08-25 05:03:15 +02:00
|
|
|
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
|
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_dbdesc_send, on, 0,
|
|
|
|
&on->thread_send_dbdesc);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void bad_lsreq(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *BadLSReq*", on->name);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_EXSTART, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_BAD_LSREQ);
|
2004-05-18 20:57:06 +02:00
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
|
|
|
|
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
2013-08-25 05:03:15 +02:00
|
|
|
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
|
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf6_dbdesc_send, on, 0,
|
|
|
|
&on->thread_send_dbdesc);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void oneway_received(struct event *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *1Way-Received*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2013-08-26 05:40:16 +02:00
|
|
|
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
ospf6d: Fixing memory leak in ospf6_lsa_create_headeronly for both master and slave.
Problem Statement:
=================
Memory leak backtraces
2022-11-23 01:51:10,525 - ERROR: ==842== 1,100 (1,000 direct, 100 indirect) bytes in 5 blocks are definitely lost in loss record 29 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_dbdesc_recv (ospf6_message.c:1038)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13B64B: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,526 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,526 - ERROR: ==842==
2022-11-23 01:51:10,524 - ERROR: Found memory leak in module ospf6d
2022-11-23 01:51:10,525 - ERROR: ==842== 220 (200 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 21 of 31
2022-11-23 01:51:10,525 - ERROR: ==842== at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E8A1BF: qcalloc (memory.c:111)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13555A: ospf6_lsa_alloc (ospf6_lsa.c:723)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x1355F3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x135702: ospf6_lsa_copy (ospf6_lsa.c:790)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv_master (ospf6_message.c:760)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_dbdesc_recv (ospf6_message.c:1036)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_read_helper (ospf6_message.c:1838)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x13BBCE: ospf6_receive (ospf6_message.c:1875)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4EB741B: thread_call (thread.c:1692)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x4E85B17: frr_run (libfrr.c:1068)
2022-11-23 01:51:10,525 - ERROR: ==842== by 0x119585: main (ospf6_main.c:228)
2022-11-23 01:51:10,525 - ERROR: ==842==
RCA:
====
These memory leaks are beacuse of last lsa in neighbour's request_list is not
getting freed beacuse of lsa lock. The last request has an addtional lock which
is added as a part of ospf6_make_lsreq, this lock needs to be removed
in order for the lsa to get freed.
Fix:
====
Check and remove the lock on the last request in all the functions.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-12-19 13:07:22 +01:00
|
|
|
ospf6_neighbor_clear_ls_lists(on);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(on->thread_send_dbdesc);
|
|
|
|
EVENT_OFF(on->thread_send_lsreq);
|
|
|
|
EVENT_OFF(on->thread_send_lsupdate);
|
|
|
|
EVENT_OFF(on->thread_send_lsack);
|
|
|
|
EVENT_OFF(on->thread_exchange_done);
|
|
|
|
EVENT_OFF(on->thread_adj_ok);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
void inactivity_timer(struct event *thread)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
|
2022-12-25 16:26:52 +01:00
|
|
|
on = (struct ospf6_neighbor *)EVENT_ARG(thread);
|
2004-05-18 20:57:06 +02:00
|
|
|
assert(on);
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Neighbor Event %s: *InactivityTimer*", on->name);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
on->drouter = on->prev_drouter = 0;
|
|
|
|
on->bdrouter = on->prev_bdrouter = 0;
|
|
|
|
|
2021-06-28 13:55:27 +02:00
|
|
|
if (!OSPF6_GR_IS_ACTIVE_HELPER(on)) {
|
|
|
|
on->drouter = on->prev_drouter = 0;
|
|
|
|
on->bdrouter = on->prev_bdrouter = 0;
|
|
|
|
|
|
|
|
ospf6_neighbor_state_change(
|
|
|
|
OSPF6_NEIGHBOR_DOWN, on,
|
|
|
|
OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
|
2021-06-28 13:55:27 +02:00
|
|
|
|
|
|
|
listnode_delete(on->ospf6_if->neighbor_list, on);
|
|
|
|
ospf6_neighbor_delete(on);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2021-06-28 13:55:27 +02:00
|
|
|
} else {
|
2021-07-01 16:09:38 +02:00
|
|
|
if (IS_DEBUG_OSPF6_GR)
|
2021-06-28 13:55:27 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s, Acting as HELPER for this neighbour, So restart the dead timer.",
|
|
|
|
__PRETTY_FUNCTION__);
|
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_timer(master, inactivity_timer, on,
|
|
|
|
on->ospf6_if->dead_interval,
|
|
|
|
&on->inactivity_timer);
|
2021-06-28 13:55:27 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* vty functions */
|
|
|
|
/* show neighbor structure */
|
2020-09-28 12:48:37 +02:00
|
|
|
static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on,
|
|
|
|
json_object *json_array, bool use_json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
char router_id[16];
|
2017-07-28 00:19:31 +02:00
|
|
|
char duration[64];
|
2017-01-17 22:46:07 +01:00
|
|
|
struct timeval res;
|
2004-05-18 20:57:06 +02:00
|
|
|
char nstate[16];
|
2017-07-28 00:19:31 +02:00
|
|
|
char deadtime[64];
|
2004-05-18 20:57:06 +02:00
|
|
|
long h, m, s;
|
2020-09-28 12:48:37 +02:00
|
|
|
json_object *json_route;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Router-ID (Name) */
|
|
|
|
inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id));
|
|
|
|
#ifdef HAVE_GETNAMEINFO
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /*HAVE_GETNAMEINFO*/
|
|
|
|
|
|
|
|
/* Dead time */
|
|
|
|
h = m = s = 0;
|
|
|
|
if (on->inactivity_timer) {
|
2017-01-17 22:46:07 +01:00
|
|
|
s = monotime_until(&on->inactivity_timer->u.sands, NULL)
|
|
|
|
/ 1000000LL;
|
2004-05-18 20:57:06 +02:00
|
|
|
h = s / 3600;
|
|
|
|
s -= h * 3600;
|
|
|
|
m = s / 60;
|
|
|
|
s -= m * 60;
|
|
|
|
}
|
|
|
|
snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Neighbor State */
|
2019-09-17 16:18:26 +02:00
|
|
|
if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT)
|
2004-05-18 20:57:06 +02:00
|
|
|
snprintf(nstate, sizeof(nstate), "PointToPoint");
|
|
|
|
else {
|
|
|
|
if (on->router_id == on->drouter)
|
|
|
|
snprintf(nstate, sizeof(nstate), "DR");
|
|
|
|
else if (on->router_id == on->bdrouter)
|
|
|
|
snprintf(nstate, sizeof(nstate), "BDR");
|
|
|
|
else
|
|
|
|
snprintf(nstate, sizeof(nstate), "DROther");
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Duration */
|
2017-01-17 22:46:07 +01:00
|
|
|
monotime_since(&on->last_changed, &res);
|
2004-05-18 20:57:06 +02:00
|
|
|
timerstring(&res, duration, sizeof(duration));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/*
|
2017-07-13 19:42:42 +02:00
|
|
|
vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
|
2020-09-28 12:48:37 +02:00
|
|
|
"Neighbor ID", "Pri", "DeadTime", "State", "IfState",
|
|
|
|
"Duration", "I/F", "State");
|
2004-05-18 20:57:06 +02:00
|
|
|
*/
|
2020-09-28 12:48:37 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_route = json_object_new_object();
|
|
|
|
|
|
|
|
json_object_string_add(json_route, "neighborId", router_id);
|
|
|
|
json_object_int_add(json_route, "priority", on->priority);
|
|
|
|
json_object_string_add(json_route, "deadTime", deadtime);
|
|
|
|
json_object_string_add(json_route, "state",
|
|
|
|
ospf6_neighbor_state_str[on->state]);
|
|
|
|
json_object_string_add(json_route, "ifState", nstate);
|
|
|
|
json_object_string_add(json_route, "duration", duration);
|
|
|
|
json_object_string_add(json_route, "interfaceName",
|
|
|
|
on->ospf6_if->interface->name);
|
|
|
|
json_object_string_add(
|
|
|
|
json_route, "interfaceState",
|
|
|
|
ospf6_interface_state_str[on->ospf6_if->state]);
|
|
|
|
|
|
|
|
json_object_array_add(json_array, json_route);
|
|
|
|
} else
|
|
|
|
vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
|
|
|
|
router_id, on->priority, deadtime,
|
|
|
|
ospf6_neighbor_state_str[on->state], nstate, duration,
|
|
|
|
on->ospf6_if->interface->name,
|
|
|
|
ospf6_interface_state_str[on->ospf6_if->state]);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_neighbor_show_drchoice(struct vty *vty,
|
2020-09-28 12:48:37 +02:00
|
|
|
struct ospf6_neighbor *on,
|
|
|
|
json_object *json_array, bool use_json)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
char router_id[16];
|
|
|
|
char drouter[16], bdrouter[16];
|
2017-07-28 00:19:31 +02:00
|
|
|
char duration[64];
|
2002-12-13 21:15:29 +01:00
|
|
|
struct timeval now, res;
|
2020-09-28 12:48:37 +02:00
|
|
|
json_object *json_route;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/*
|
2017-07-13 19:42:42 +02:00
|
|
|
vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
|
2002-12-13 21:15:29 +01:00
|
|
|
"RouterID", "State", "Duration", "DR", "BDR", "I/F",
|
2017-07-13 19:42:42 +02:00
|
|
|
"State");
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id));
|
|
|
|
inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter));
|
|
|
|
inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-01-18 01:30:43 +01:00
|
|
|
monotime(&now);
|
2004-05-18 20:57:06 +02:00
|
|
|
timersub(&now, &on->last_changed, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 12:48:37 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_route = json_object_new_object();
|
|
|
|
json_object_string_add(json_route, "routerId", router_id);
|
|
|
|
json_object_string_add(json_route, "state",
|
|
|
|
ospf6_neighbor_state_str[on->state]);
|
|
|
|
json_object_string_add(json_route, "duration", duration);
|
|
|
|
json_object_string_add(json_route, "dRouter", drouter);
|
|
|
|
json_object_string_add(json_route, "bdRouter", bdrouter);
|
|
|
|
json_object_string_add(json_route, "interfaceName",
|
|
|
|
on->ospf6_if->interface->name);
|
|
|
|
json_object_string_add(
|
|
|
|
json_route, "interfaceState",
|
|
|
|
ospf6_interface_state_str[on->ospf6_if->state]);
|
|
|
|
|
|
|
|
json_object_array_add(json_array, json_route);
|
|
|
|
} else
|
|
|
|
vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id,
|
|
|
|
ospf6_neighbor_state_str[on->state], duration, drouter,
|
|
|
|
bdrouter, on->ospf6_if->interface->name,
|
|
|
|
ospf6_interface_state_str[on->ospf6_if->state]);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_neighbor_show_detail(struct vty *vty,
|
2020-09-28 12:48:37 +02:00
|
|
|
struct ospf6_neighbor *on,
|
|
|
|
json_object *json, bool use_json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
char drouter[16], bdrouter[16];
|
|
|
|
char linklocal_addr[64], duration[32];
|
2002-12-13 21:15:29 +01:00
|
|
|
struct timeval now, res;
|
2020-08-17 14:25:12 +02:00
|
|
|
struct ospf6_lsa *lsa, *lsanext;
|
2020-09-28 12:48:37 +02:00
|
|
|
json_object *json_neighbor;
|
|
|
|
json_object *json_array;
|
|
|
|
char db_desc_str[20];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr,
|
|
|
|
sizeof(linklocal_addr));
|
|
|
|
inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter));
|
|
|
|
inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-01-18 01:30:43 +01:00
|
|
|
monotime(&now);
|
2004-05-18 20:57:06 +02:00
|
|
|
timersub(&now, &on->last_changed, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 12:48:37 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_neighbor = json_object_new_object();
|
|
|
|
json_object_string_add(json_neighbor, "area",
|
|
|
|
on->ospf6_if->area->name);
|
|
|
|
json_object_string_add(json_neighbor, "interface",
|
|
|
|
on->ospf6_if->interface->name);
|
|
|
|
json_object_int_add(json_neighbor, "interfaceIndex",
|
|
|
|
on->ospf6_if->interface->ifindex);
|
|
|
|
json_object_int_add(json_neighbor, "neighborInterfaceIndex",
|
|
|
|
on->ifindex);
|
|
|
|
json_object_string_add(json_neighbor, "linkLocalAddress",
|
|
|
|
linklocal_addr);
|
|
|
|
json_object_string_add(json_neighbor, "neighborState",
|
|
|
|
ospf6_neighbor_state_str[on->state]);
|
|
|
|
json_object_string_add(json_neighbor, "neighborStateDuration",
|
|
|
|
duration);
|
|
|
|
json_object_string_add(json_neighbor, "neighborDRouter",
|
|
|
|
drouter);
|
|
|
|
json_object_string_add(json_neighbor, "neighborBdRouter",
|
|
|
|
bdrouter);
|
|
|
|
snprintf(db_desc_str, sizeof(db_desc_str), "%s%s%s",
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
|
|
|
|
? "Initial "
|
|
|
|
: ""),
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
|
|
|
|
? "More"
|
|
|
|
: ""),
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
|
|
|
|
? "Master"
|
|
|
|
: "Slave"));
|
|
|
|
json_object_string_add(json_neighbor, "dbDescStatus",
|
|
|
|
db_desc_str);
|
|
|
|
|
|
|
|
json_object_int_add(json_neighbor, "dbDescSeqNumber",
|
|
|
|
(unsigned long)ntohl(on->dbdesc_seqnum));
|
|
|
|
|
|
|
|
json_array = json_object_new_array();
|
|
|
|
json_object_int_add(json_neighbor, "summaryListCount",
|
|
|
|
on->summary_list->count);
|
|
|
|
for (ALL_LSDB(on->summary_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "summaryListLsa",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
json_array = json_object_new_array();
|
|
|
|
json_object_int_add(json_neighbor, "requestListCount",
|
|
|
|
on->request_list->count);
|
|
|
|
for (ALL_LSDB(on->request_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "requestListLsa",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
json_array = json_object_new_array();
|
|
|
|
json_object_int_add(json_neighbor, "reTransListCount",
|
|
|
|
on->retrans_list->count);
|
|
|
|
for (ALL_LSDB(on->retrans_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "reTransListLsa",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_dbdesc))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
json_object_int_add(json_neighbor, "pendingLsaDbDescCount",
|
|
|
|
on->dbdesc_list->count);
|
|
|
|
json_object_string_add(json_neighbor, "pendingLsaDbDescTime",
|
|
|
|
duration);
|
2022-05-17 22:29:29 +02:00
|
|
|
json_object_string_add(
|
|
|
|
json_neighbor, "dbDescSendThread",
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_dbdesc) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
json_array = json_object_new_array();
|
|
|
|
for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "pendingLsaDbDesc",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsreq))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsreq->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
json_object_int_add(json_neighbor, "pendingLsaLsReqCount",
|
|
|
|
on->request_list->count);
|
|
|
|
json_object_string_add(json_neighbor, "pendingLsaLsReqTime",
|
|
|
|
duration);
|
2022-05-17 22:29:29 +02:00
|
|
|
json_object_string_add(
|
|
|
|
json_neighbor, "lsReqSendThread",
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsreq) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
json_array = json_object_new_array();
|
|
|
|
for (ALL_LSDB(on->request_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "pendingLsaLsReq",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsupdate))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsupdate->u.sands, &now,
|
|
|
|
&res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
json_object_int_add(json_neighbor, "pendingLsaLsUpdateCount",
|
|
|
|
on->lsupdate_list->count);
|
|
|
|
json_object_string_add(json_neighbor, "pendingLsaLsUpdateTime",
|
|
|
|
duration);
|
|
|
|
json_object_string_add(
|
|
|
|
json_neighbor, "lsUpdateSendThread",
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsupdate) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
json_array = json_object_new_array();
|
|
|
|
for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "pendingLsaLsUpdate",
|
|
|
|
json_array);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsack))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsack->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
json_object_int_add(json_neighbor, "pendingLsaLsAckCount",
|
|
|
|
on->lsack_list->count);
|
|
|
|
json_object_string_add(json_neighbor, "pendingLsaLsAckTime",
|
|
|
|
duration);
|
2022-05-17 22:29:29 +02:00
|
|
|
json_object_string_add(
|
|
|
|
json_neighbor, "lsAckSendThread",
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsack) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
json_array = json_object_new_array();
|
|
|
|
for (ALL_LSDB(on->lsack_list, lsa, lsanext))
|
|
|
|
json_object_array_add(
|
|
|
|
json_array, json_object_new_string(lsa->name));
|
|
|
|
json_object_object_add(json_neighbor, "pendingLsaLsAck",
|
|
|
|
json_array);
|
|
|
|
|
2021-04-14 17:37:01 +02:00
|
|
|
bfd_sess_show(vty, json_neighbor, on->bfd_session);
|
2020-09-28 12:48:37 +02:00
|
|
|
|
2021-05-30 18:33:41 +02:00
|
|
|
if (on->auth_present == true) {
|
|
|
|
json_object_string_add(json_neighbor, "authStatus",
|
|
|
|
"enabled");
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdHelloHigherSeqNo",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_HELLO]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdHelloLowerSeqNo",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_HELLO]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdDBDescHigherSeqNo",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_DBDESC]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdDBDescLowerSeqNo",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_DBDESC]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSReqHigherSeqNo",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSREQ]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSReqLowerSeqNo",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSREQ]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSUpdHigherSeqNo",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSUPDATE]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSUpdLowerSeqNo",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSUPDATE]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSAckHigherSeqNo",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSACK]);
|
|
|
|
json_object_int_add(
|
|
|
|
json_neighbor, "recvdLSAckLowerSeqNo",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSACK]);
|
|
|
|
} else
|
|
|
|
json_object_string_add(json_neighbor, "authStatus",
|
|
|
|
"disabled");
|
2020-09-28 12:48:37 +02:00
|
|
|
|
2021-05-30 18:33:41 +02:00
|
|
|
json_object_object_add(json, on->name, json_neighbor);
|
2020-09-28 12:48:37 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
vty_out(vty, " Neighbor %s\n", on->name);
|
|
|
|
vty_out(vty, " Area %s via interface %s (ifindex %d)\n",
|
|
|
|
on->ospf6_if->area->name, on->ospf6_if->interface->name,
|
|
|
|
on->ospf6_if->interface->ifindex);
|
|
|
|
vty_out(vty, " His IfIndex: %d Link-local address: %s\n",
|
|
|
|
on->ifindex, linklocal_addr);
|
|
|
|
vty_out(vty, " State %s for a duration of %s\n",
|
|
|
|
ospf6_neighbor_state_str[on->state], duration);
|
|
|
|
vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n",
|
|
|
|
drouter, bdrouter, on->priority);
|
|
|
|
vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n",
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
|
|
|
|
? "Initial "
|
|
|
|
: ""),
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
|
|
|
|
? "More "
|
|
|
|
: ""),
|
|
|
|
(CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
|
|
|
|
? "Master"
|
|
|
|
: "Slave"),
|
|
|
|
(unsigned long)ntohl(on->dbdesc_seqnum));
|
|
|
|
|
|
|
|
vty_out(vty, " Summary-List: %d LSAs\n",
|
|
|
|
on->summary_list->count);
|
|
|
|
for (ALL_LSDB(on->summary_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
vty_out(vty, " Request-List: %d LSAs\n",
|
|
|
|
on->request_list->count);
|
|
|
|
for (ALL_LSDB(on->request_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
vty_out(vty, " Retrans-List: %d LSAs\n",
|
|
|
|
on->retrans_list->count);
|
|
|
|
for (ALL_LSDB(on->retrans_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_dbdesc))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
vty_out(vty,
|
|
|
|
" %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
|
|
|
|
on->dbdesc_list->count, duration,
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_dbdesc) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsreq))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsreq->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
vty_out(vty,
|
|
|
|
" %d Pending LSAs for LSReq in Time %s [thread %s]\n",
|
|
|
|
on->request_list->count, duration,
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsreq) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
for (ALL_LSDB(on->request_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsupdate))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsupdate->u.sands, &now,
|
|
|
|
&res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
vty_out(vty,
|
|
|
|
" %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
|
|
|
|
on->lsupdate_list->count, duration,
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsupdate) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
|
|
|
timerclear(&res);
|
2022-12-11 16:51:58 +01:00
|
|
|
if (event_is_scheduled(on->thread_send_lsack))
|
2020-09-28 12:48:37 +02:00
|
|
|
timersub(&on->thread_send_lsack->u.sands, &now, &res);
|
|
|
|
timerstring(&res, duration, sizeof(duration));
|
|
|
|
vty_out(vty,
|
|
|
|
" %d Pending LSAs for LSAck in Time %s [thread %s]\n",
|
|
|
|
on->lsack_list->count, duration,
|
2022-12-11 16:51:58 +01:00
|
|
|
(event_is_scheduled(on->thread_send_lsack) ? "on"
|
|
|
|
: "off"));
|
2020-09-28 12:48:37 +02:00
|
|
|
for (ALL_LSDB(on->lsack_list, lsa, lsanext))
|
|
|
|
vty_out(vty, " %s\n", lsa->name);
|
|
|
|
|
2021-04-14 17:37:01 +02:00
|
|
|
bfd_sess_show(vty, NULL, on->bfd_session);
|
2021-05-30 18:33:41 +02:00
|
|
|
|
|
|
|
if (on->auth_present == true) {
|
|
|
|
vty_out(vty, " Authentication header present\n");
|
|
|
|
vty_out(vty,
|
|
|
|
"\t\t\t hello DBDesc LSReq LSUpd LSAck\n");
|
|
|
|
vty_out(vty,
|
|
|
|
" Higher sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_HELLO],
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_DBDESC],
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSREQ],
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSUPDATE],
|
|
|
|
on->seqnum_h[OSPF6_MESSAGE_TYPE_LSACK]);
|
|
|
|
vty_out(vty,
|
|
|
|
" Lower sequence no 0x%-10X 0x%-10X 0x%-10X 0x%-10X 0x%-10X\n",
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_HELLO],
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_DBDESC],
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSREQ],
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSUPDATE],
|
|
|
|
on->seqnum_l[OSPF6_MESSAGE_TYPE_LSACK]);
|
|
|
|
} else
|
|
|
|
vty_out(vty, " Authentication header not present\n");
|
2020-09-28 12:48:37 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-06-18 21:42:49 +02:00
|
|
|
static void ospf6_neighbor_show_detail_common(struct vty *vty,
|
|
|
|
struct ospf6 *ospf6, bool uj,
|
|
|
|
bool detail, bool drchoice)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
struct ospf6_interface *oi;
|
|
|
|
struct ospf6_area *oa;
|
2004-09-23 21:18:23 +02:00
|
|
|
struct listnode *i, *j, *k;
|
2020-09-28 12:48:37 +02:00
|
|
|
json_object *json = NULL;
|
|
|
|
json_object *json_array = NULL;
|
|
|
|
void (*showfunc)(struct vty *, struct ospf6_neighbor *,
|
|
|
|
json_object *json, bool use_json);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-06-18 21:42:49 +02:00
|
|
|
if (detail)
|
|
|
|
showfunc = ospf6_neighbor_show_detail;
|
|
|
|
else if (drchoice)
|
|
|
|
showfunc = ospf6_neighbor_show_drchoice;
|
|
|
|
else
|
|
|
|
showfunc = ospf6_neighbor_show;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 12:48:37 +02:00
|
|
|
if (uj) {
|
|
|
|
json = json_object_new_object();
|
|
|
|
json_array = json_object_new_array();
|
|
|
|
} else {
|
|
|
|
if (showfunc == ospf6_neighbor_show)
|
|
|
|
vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
|
|
|
|
"Neighbor ID", "Pri", "DeadTime", "State",
|
|
|
|
"IfState", "Duration", "I/F", "State");
|
|
|
|
else if (showfunc == ospf6_neighbor_show_drchoice)
|
|
|
|
vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
|
|
|
|
"RouterID", "State", "Duration", "DR", "BDR",
|
|
|
|
"I/F", "State");
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
|
2020-09-28 12:48:37 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
|
|
|
|
if (showfunc == ospf6_neighbor_show_detail)
|
|
|
|
(*showfunc)(vty, on, json, uj);
|
|
|
|
else
|
|
|
|
(*showfunc)(vty, on, json_array, uj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uj) {
|
|
|
|
if (showfunc != ospf6_neighbor_show_detail)
|
|
|
|
json_object_object_add(json, "neighbors", json_array);
|
|
|
|
else
|
|
|
|
json_object_free(json_array);
|
2021-11-25 16:50:37 +01:00
|
|
|
vty_json(vty, json);
|
2020-09-28 12:48:37 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd,
|
|
|
|
"show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]",
|
|
|
|
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
|
|
|
|
"All VRFs\n"
|
|
|
|
"Neighbor list\n"
|
|
|
|
"Display details\n"
|
|
|
|
"Display DR choices\n" JSON_STR)
|
|
|
|
{
|
|
|
|
struct ospf6 *ospf6;
|
|
|
|
struct listnode *node;
|
|
|
|
const char *vrf_name = NULL;
|
|
|
|
bool all_vrf = false;
|
|
|
|
int idx_vrf = 0;
|
2021-06-18 21:42:49 +02:00
|
|
|
int idx_type = 4;
|
|
|
|
bool uj = use_json(argc, argv);
|
|
|
|
bool detail = false;
|
|
|
|
bool drchoice = false;
|
2021-05-05 22:19:01 +02:00
|
|
|
|
|
|
|
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
2021-06-18 21:42:49 +02:00
|
|
|
|
|
|
|
if (argv_find(argv, argc, "detail", &idx_type))
|
|
|
|
detail = true;
|
|
|
|
else if (argv_find(argv, argc, "drchoice", &idx_type))
|
|
|
|
drchoice = true;
|
2021-05-05 22:19:01 +02:00
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
|
|
|
|
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
|
2021-06-18 21:42:49 +02:00
|
|
|
ospf6_neighbor_show_detail_common(vty, ospf6, uj,
|
|
|
|
detail, drchoice);
|
2021-05-05 22:19:01 +02:00
|
|
|
if (!all_vrf)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2022-01-11 10:21:05 +01:00
|
|
|
OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
|
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf6_neighbor_show_common(struct vty *vty, int argc,
|
|
|
|
struct cmd_token **argv,
|
2022-01-11 10:21:05 +01:00
|
|
|
struct ospf6 *ospf6, int idx_ipv4,
|
|
|
|
bool uj)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_neighbor *on;
|
|
|
|
struct ospf6_interface *oi;
|
|
|
|
struct ospf6_area *oa;
|
2004-09-23 21:18:23 +02:00
|
|
|
struct listnode *i, *j, *k;
|
2020-09-28 12:48:37 +02:00
|
|
|
void (*showfunc)(struct vty *, struct ospf6_neighbor *,
|
|
|
|
json_object *json, bool use_json);
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t router_id;
|
2020-09-28 12:48:37 +02:00
|
|
|
json_object *json = NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
showfunc = ospf6_neighbor_show_detail;
|
2020-09-28 12:48:37 +02:00
|
|
|
if (uj)
|
|
|
|
json = json_object_new_object();
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-23 21:56:31 +02:00
|
|
|
if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) {
|
2017-07-13 19:42:42 +02:00
|
|
|
vty_out(vty, "Router-ID is not parsable: %s\n",
|
|
|
|
argv[idx_ipv4]->arg);
|
2004-05-18 20:57:06 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
|
2020-12-04 10:40:33 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
|
|
|
|
if (router_id == on->router_id)
|
|
|
|
(*showfunc)(vty, on, json, uj);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-11-25 23:02:37 +01:00
|
|
|
if (uj)
|
2021-11-25 16:50:37 +01:00
|
|
|
vty_json(vty, json);
|
2021-05-05 22:19:01 +02:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN(show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd,
|
|
|
|
"show ipv6 ospf6 [vrf <NAME|all>] neighbor A.B.C.D [json]",
|
|
|
|
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
|
|
|
|
"All VRFs\n"
|
|
|
|
"Neighbor list\n"
|
|
|
|
"Specify Router-ID as IPv4 address notation\n" JSON_STR)
|
|
|
|
{
|
|
|
|
int idx_ipv4 = 4;
|
|
|
|
struct ospf6 *ospf6;
|
|
|
|
struct listnode *node;
|
|
|
|
const char *vrf_name = NULL;
|
|
|
|
bool all_vrf = false;
|
|
|
|
int idx_vrf = 0;
|
2022-01-11 10:21:05 +01:00
|
|
|
bool uj = use_json(argc, argv);
|
2021-05-05 22:19:01 +02:00
|
|
|
|
|
|
|
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
|
|
|
if (idx_vrf > 0)
|
|
|
|
idx_ipv4 += 2;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
|
|
|
|
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
|
|
|
|
ospf6_neighbor_show_common(vty, argc, argv, ospf6,
|
2022-01-11 10:21:05 +01:00
|
|
|
idx_ipv4, uj);
|
2021-05-05 22:19:01 +02:00
|
|
|
|
|
|
|
if (!all_vrf)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-11 10:21:05 +01:00
|
|
|
OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-08-15 14:45:30 +02:00
|
|
|
void ospf6_neighbor_init(void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
|
2016-12-05 20:28:24 +01:00
|
|
|
install_element(VIEW_NODE, &show_ipv6_ospf6_neighbor_one_cmd);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (debug_ospf6_neighbor,
|
|
|
|
debug_ospf6_neighbor_cmd,
|
2016-09-30 17:31:48 +02:00
|
|
|
"debug ospf6 neighbor [<state|event>]",
|
2004-05-18 20:57:06 +02:00
|
|
|
DEBUG_STR
|
|
|
|
OSPF6_STR
|
|
|
|
"Debug OSPFv3 Neighbor\n"
|
2016-09-30 03:27:05 +02:00
|
|
|
"Debug OSPFv3 Neighbor State Change\n"
|
|
|
|
"Debug OSPFv3 Neighbor Event\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2016-09-30 03:27:05 +02:00
|
|
|
int idx_type = 3;
|
2004-05-18 20:57:06 +02:00
|
|
|
unsigned char level = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-30 03:27:05 +02:00
|
|
|
if (argc == 4) {
|
|
|
|
if (!strncmp(argv[idx_type]->arg, "s", 1))
|
2004-05-18 20:57:06 +02:00
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_STATE;
|
2016-09-30 03:27:05 +02:00
|
|
|
else if (!strncmp(argv[idx_type]->arg, "e", 1))
|
2004-05-18 20:57:06 +02:00
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_EVENT;
|
|
|
|
} else
|
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
OSPF6_DEBUG_NEIGHBOR_ON(level);
|
|
|
|
return CMD_SUCCESS;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
DEFUN (no_debug_ospf6_neighbor,
|
|
|
|
no_debug_ospf6_neighbor_cmd,
|
2016-09-30 17:31:48 +02:00
|
|
|
"no debug ospf6 neighbor [<state|event>]",
|
2004-05-18 20:57:06 +02:00
|
|
|
NO_STR
|
|
|
|
DEBUG_STR
|
|
|
|
OSPF6_STR
|
|
|
|
"Debug OSPFv3 Neighbor\n"
|
2016-09-30 03:27:05 +02:00
|
|
|
"Debug OSPFv3 Neighbor State Change\n"
|
|
|
|
"Debug OSPFv3 Neighbor Event\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2016-09-30 03:27:05 +02:00
|
|
|
int idx_type = 4;
|
2004-05-18 20:57:06 +02:00
|
|
|
unsigned char level = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-30 03:27:05 +02:00
|
|
|
if (argc == 5) {
|
|
|
|
if (!strncmp(argv[idx_type]->arg, "s", 1))
|
2004-05-18 20:57:06 +02:00
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_STATE;
|
2016-09-30 03:27:05 +02:00
|
|
|
if (!strncmp(argv[idx_type]->arg, "e", 1))
|
2004-05-18 20:57:06 +02:00
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_EVENT;
|
|
|
|
} else
|
|
|
|
level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
OSPF6_DEBUG_NEIGHBOR_OFF(level);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-03 19:37:25 +01:00
|
|
|
DEFUN (no_debug_ospf6,
|
|
|
|
no_debug_ospf6_cmd,
|
|
|
|
"no debug ospf6",
|
|
|
|
NO_STR
|
|
|
|
DEBUG_STR
|
|
|
|
OSPF6_STR)
|
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned int i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-11-03 19:37:25 +01:00
|
|
|
OSPF6_DEBUG_ABR_OFF();
|
|
|
|
OSPF6_DEBUG_ASBR_OFF();
|
|
|
|
OSPF6_DEBUG_BROUTER_OFF();
|
|
|
|
OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF();
|
|
|
|
OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF();
|
|
|
|
OSPF6_DEBUG_FLOODING_OFF();
|
|
|
|
OSPF6_DEBUG_INTERFACE_OFF();
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-11-06 16:35:33 +01:00
|
|
|
ospf6_lsa_debug_set_all(false);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-11-03 19:37:25 +01:00
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
OSPF6_DEBUG_MESSAGE_OFF(i,
|
|
|
|
OSPF6_DEBUG_NEIGHBOR_STATE
|
|
|
|
| OSPF6_DEBUG_NEIGHBOR_EVENT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-11-03 19:37:25 +01:00
|
|
|
OSPF6_DEBUG_NEIGHBOR_OFF(OSPF6_DEBUG_NEIGHBOR_STATE
|
|
|
|
| OSPF6_DEBUG_NEIGHBOR_EVENT);
|
|
|
|
OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_TABLE);
|
|
|
|
OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTRA);
|
|
|
|
OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_INTER);
|
|
|
|
OSPF6_DEBUG_ROUTE_OFF(OSPF6_DEBUG_ROUTE_MEMORY);
|
|
|
|
OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_PROCESS);
|
|
|
|
OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_TIME);
|
|
|
|
OSPF6_DEBUG_SPF_OFF(OSPF6_DEBUG_SPF_DATABASE);
|
|
|
|
OSPF6_DEBUG_ZEBRA_OFF(OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-11-03 19:37:25 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
int config_write_ospf6_debug_neighbor(struct vty *vty)
|
|
|
|
{
|
|
|
|
if (IS_OSPF6_DEBUG_NEIGHBOR(STATE) && IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2017-07-13 19:12:39 +02:00
|
|
|
vty_out(vty, "debug ospf6 neighbor\n");
|
2004-05-18 20:57:06 +02:00
|
|
|
else if (IS_OSPF6_DEBUG_NEIGHBOR(STATE))
|
2017-07-13 19:12:39 +02:00
|
|
|
vty_out(vty, "debug ospf6 neighbor state\n");
|
2004-05-18 20:57:06 +02:00
|
|
|
else if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
|
2017-07-13 19:12:39 +02:00
|
|
|
vty_out(vty, "debug ospf6 neighbor event\n");
|
2004-05-18 20:57:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-15 14:45:30 +02:00
|
|
|
void install_element_ospf6_debug_neighbor(void)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
install_element(ENABLE_NODE, &debug_ospf6_neighbor_cmd);
|
|
|
|
install_element(ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
|
2015-11-03 19:37:25 +01:00
|
|
|
install_element(ENABLE_NODE, &no_debug_ospf6_cmd);
|
2004-05-18 20:57:06 +02:00
|
|
|
install_element(CONFIG_NODE, &debug_ospf6_neighbor_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
|
2015-11-03 19:37:25 +01:00
|
|
|
install_element(CONFIG_NODE, &no_debug_ospf6_cmd);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|