Merge pull request #7703 from volta-networks/fix_ldpsync_remove_hello

ldpd, isisd, ospfd: Remove periodic ldp-sync hello message
This commit is contained in:
Donald Sharp 2020-12-09 20:21:11 -05:00 committed by GitHub
commit 6f4249f9b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 0 additions and 258 deletions

View File

@ -122,7 +122,6 @@ int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce)
/* LDP just started up: /* LDP just started up:
* set cost to LSInfinity * set cost to LSInfinity
* send request to LDP for LDP-SYNC state for each interface * send request to LDP for LDP-SYNC state for each interface
* start hello timer
*/ */
vrf = vrf_lookup_by_id(VRF_DEFAULT); vrf = vrf_lookup_by_id(VRF_DEFAULT);
FOR_ALL_INTERFACES (vrf, ifp) { FOR_ALL_INTERFACES (vrf, ifp) {
@ -135,62 +134,6 @@ int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce)
} }
} }
THREAD_OFF(isis->ldp_sync_cmd.t_hello);
isis->ldp_sync_cmd.sequence = 0;
isis_ldp_sync_hello_timer_add();
return 0;
}
int isis_ldp_sync_hello_update(struct ldp_igp_sync_hello hello)
{
struct isis_area *area;
struct listnode *node;
struct vrf *vrf;
struct interface *ifp;
struct isis_circuit *circuit;
struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
/* if isis is not enabled or LDP-SYNC is not configured ignore */
if (!isis ||
!CHECK_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE))
return 0;
if (hello.proto != ZEBRA_ROUTE_LDP)
return 0;
/* Received Hello from LDP:
* if current sequence number is greater than received hello
* sequence number then assume LDP restarted
* set cost to LSInfinity
* send request to LDP for LDP-SYNC state for each interface
* else all is fine just restart hello timer
*/
if (hello.sequence == 0)
/* rolled over */
isis->ldp_sync_cmd.sequence = 0;
if (isis->ldp_sync_cmd.sequence > hello.sequence) {
zlog_err("ldp_sync: LDP restarted");
vrf = vrf_lookup_by_id(VRF_DEFAULT);
FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node,
area)) {
circuit = circuit_lookup_by_ifp(ifp,
area->circuit_list);
if (circuit == NULL)
continue;
isis_ldp_sync_if_start(circuit, true);
}
}
} else {
THREAD_OFF(isis->ldp_sync_cmd.t_hello);
isis_ldp_sync_hello_timer_add();
}
isis->ldp_sync_cmd.sequence = hello.sequence;
return 0; return 0;
} }
@ -559,58 +502,6 @@ void isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info)
} }
} }
/*
* LDP-SYNC hello timer routines
*/
static int isis_ldp_sync_hello_timer(struct thread *thread)
{
struct isis_area *area;
struct listnode *node;
struct isis_circuit *circuit;
struct interface *ifp;
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
if (!isis)
return 0;
/* hello timer expired:
* didn't receive hello msg from LDP
* set cost of all interfaces to LSInfinity
*/
FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
circuit = circuit_lookup_by_ifp(ifp,
area->circuit_list);
if (circuit == NULL)
continue;
isis_ldp_sync_ldp_fail(circuit);
}
}
zlog_debug("ldp_sync: hello timer expired, LDP down");
return 0;
}
void isis_ldp_sync_hello_timer_add(void)
{
struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
/* Start hello timer:
* this timer is used to make sure LDP is up
* if expires set interface cost to LSInfinity
*/
if (!isis ||
!CHECK_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE))
return;
thread_add_timer(master, isis_ldp_sync_hello_timer,
NULL, LDP_IGP_SYNC_HELLO_TIMEOUT,
&isis->ldp_sync_cmd.t_hello);
}
/* /*
* LDP-SYNC routes used by set commands. * LDP-SYNC routes used by set commands.
*/ */
@ -699,13 +590,11 @@ void isis_ldp_sync_gbl_exit(bool remove)
LDP_IGP_SYNC_IF_STATE_UPDATE); LDP_IGP_SYNC_IF_STATE_UPDATE);
zclient_unregister_opaque(zclient, zclient_unregister_opaque(zclient,
LDP_IGP_SYNC_ANNOUNCE_UPDATE); LDP_IGP_SYNC_ANNOUNCE_UPDATE);
zclient_unregister_opaque(zclient, LDP_IGP_SYNC_HELLO_UPDATE);
/* disable LDP-SYNC globally */ /* disable LDP-SYNC globally */
UNSET_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); UNSET_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE);
UNSET_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_HOLDDOWN); UNSET_FLAG(isis->ldp_sync_cmd.flags, LDP_SYNC_FLAG_HOLDDOWN);
isis->ldp_sync_cmd.holddown = LDP_IGP_SYNC_HOLDDOWN_DEFAULT; isis->ldp_sync_cmd.holddown = LDP_IGP_SYNC_HOLDDOWN_DEFAULT;
THREAD_OFF(isis->ldp_sync_cmd.t_hello);
/* remove LDP-SYNC on all ISIS interfaces */ /* remove LDP-SYNC on all ISIS interfaces */
FOR_ALL_INTERFACES (vrf, ifp) { FOR_ALL_INTERFACES (vrf, ifp) {

View File

@ -40,11 +40,9 @@ extern void isis_ldp_sync_if_complete(struct isis_circuit *circuit);
extern void isis_ldp_sync_holddown_timer_add(struct isis_circuit *circuit); extern void isis_ldp_sync_holddown_timer_add(struct isis_circuit *circuit);
extern void extern void
isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info); isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info);
extern void isis_ldp_sync_hello_timer_add(void);
extern void isis_ldp_sync_ldp_fail(struct isis_circuit *circuit); extern void isis_ldp_sync_ldp_fail(struct isis_circuit *circuit);
extern int isis_ldp_sync_state_update(struct ldp_igp_sync_if_state state); extern int isis_ldp_sync_state_update(struct ldp_igp_sync_if_state state);
extern int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce); extern int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce);
extern int isis_ldp_sync_hello_update(struct ldp_igp_sync_hello hello);
extern void isis_ldp_sync_state_req_msg(struct isis_circuit *circuit); extern void isis_ldp_sync_state_req_msg(struct isis_circuit *circuit);
extern void isis_ldp_sync_set_if_metric(struct isis_circuit *circuit, extern void isis_ldp_sync_set_if_metric(struct isis_circuit *circuit,
bool run_regen); bool run_regen);

View File

@ -2305,7 +2305,6 @@ int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args)
/* register with opaque client to recv LDP-IGP Sync msgs */ /* register with opaque client to recv LDP-IGP Sync msgs */
zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE);
zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE);
zclient_register_opaque(zclient, LDP_IGP_SYNC_HELLO_UPDATE);
if (!CHECK_FLAG(isis->ldp_sync_cmd.flags, if (!CHECK_FLAG(isis->ldp_sync_cmd.flags,
LDP_SYNC_FLAG_ENABLE)) { LDP_SYNC_FLAG_ENABLE)) {

View File

@ -670,7 +670,6 @@ static int isis_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
struct zapi_opaque_msg info; struct zapi_opaque_msg info;
struct ldp_igp_sync_if_state state; struct ldp_igp_sync_if_state state;
struct ldp_igp_sync_announce announce; struct ldp_igp_sync_announce announce;
struct ldp_igp_sync_hello hello;
int ret = 0; int ret = 0;
s = zclient->ibuf; s = zclient->ibuf;
@ -686,10 +685,6 @@ static int isis_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
STREAM_GET(&announce, s, sizeof(announce)); STREAM_GET(&announce, s, sizeof(announce));
ret = isis_ldp_sync_announce_update(announce); ret = isis_ldp_sync_announce_update(announce);
break; break;
case LDP_IGP_SYNC_HELLO_UPDATE:
STREAM_GET(&hello, s, sizeof(hello));
ret = isis_ldp_sync_hello_update(hello);
break;
default: default:
break; break;
} }

View File

@ -51,8 +51,6 @@ static void ldp_zebra_opaque_register(void);
static void ldp_zebra_opaque_unregister(void); static void ldp_zebra_opaque_unregister(void);
static int ldp_sync_zebra_send_announce(void); static int ldp_sync_zebra_send_announce(void);
static int ldp_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS); static int ldp_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS);
static void ldp_sync_zebra_start_hello_timer(void);
static int ldp_sync_zebra_hello(struct thread *thread);
static void ldp_sync_zebra_init(void); static void ldp_sync_zebra_init(void);
static struct zclient *zclient; static struct zclient *zclient;
@ -175,40 +173,12 @@ stream_failure:
return 0; return 0;
} }
static void
ldp_sync_zebra_start_hello_timer(void)
{
thread_add_timer_msec(master, ldp_sync_zebra_hello, NULL, 250, NULL);
}
static int
ldp_sync_zebra_hello(struct thread *thread)
{
static unsigned int sequence = 0;
struct ldp_igp_sync_hello hello;
sequence++;
hello.proto = ZEBRA_ROUTE_LDP;
hello.sequence = sequence;
zclient_send_opaque(zclient, LDP_IGP_SYNC_HELLO_UPDATE,
(const uint8_t *) &hello, sizeof(hello));
ldp_sync_zebra_start_hello_timer();
return (0);
}
static void static void
ldp_sync_zebra_init(void) ldp_sync_zebra_init(void)
{ {
ldp_sync_zebra_send_announce(); ldp_sync_zebra_send_announce();
ldp_sync_zebra_start_hello_timer();
} }
static int static int
ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr) ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr)
{ {

View File

@ -39,14 +39,10 @@ extern "C" {
#define LDP_IGP_SYNC_HOLDDOWN_DEFAULT 0 #define LDP_IGP_SYNC_HOLDDOWN_DEFAULT 0
#define LDP_IGP_SYNC_HELLO_TIMEOUT 5
/* LDP-IGP Sync structures */ /* LDP-IGP Sync structures */
struct ldp_sync_info_cmd { struct ldp_sync_info_cmd {
uint16_t flags; uint16_t flags;
uint16_t holddown; /* timer value */ uint16_t holddown; /* timer value */
uint32_t sequence; /* hello sequence number */
struct thread *t_hello; /* hello timer for detecting LDP going down */
}; };
struct ldp_sync_info { struct ldp_sync_info {
@ -79,11 +75,6 @@ struct ldp_igp_sync_if_state_req {
char name[INTERFACE_NAMSIZ]; char name[INTERFACE_NAMSIZ];
}; };
struct ldp_igp_sync_hello {
int proto;
unsigned int sequence;
};
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1085,8 +1085,6 @@ enum zapi_opaque_registry {
LDP_IGP_SYNC_IF_STATE_UPDATE = 4, LDP_IGP_SYNC_IF_STATE_UPDATE = 4,
/* Announce that LDP is up */ /* Announce that LDP is up */
LDP_IGP_SYNC_ANNOUNCE_UPDATE = 5, LDP_IGP_SYNC_ANNOUNCE_UPDATE = 5,
/* Heartbeat indicating that LDP is running */
LDP_IGP_SYNC_HELLO_UPDATE = 6,
}; };
/* Send the hello message. /* Send the hello message.

View File

@ -93,57 +93,11 @@ int ospf_ldp_sync_announce_update(struct ldp_igp_sync_announce announce)
/* LDP just started up: /* LDP just started up:
* set cost to LSInfinity * set cost to LSInfinity
* send request to LDP for LDP-SYNC state for each interface * send request to LDP for LDP-SYNC state for each interface
* start hello timer
*/ */
vrf = vrf_lookup_by_id(ospf->vrf_id); vrf = vrf_lookup_by_id(ospf->vrf_id);
FOR_ALL_INTERFACES (vrf, ifp) FOR_ALL_INTERFACES (vrf, ifp)
ospf_ldp_sync_if_start(ifp, true); ospf_ldp_sync_if_start(ifp, true);
THREAD_OFF(ospf->ldp_sync_cmd.t_hello);
ospf->ldp_sync_cmd.sequence = 0;
ospf_ldp_sync_hello_timer_add(ospf);
return 0;
}
int ospf_ldp_sync_hello_update(struct ldp_igp_sync_hello hello)
{
struct ospf *ospf;
struct vrf *vrf;
struct interface *ifp;
/* if ospf is not enabled or LDP-SYNC is not configured ignore */
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
if (ospf == NULL ||
!CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE))
return 0;
if (hello.proto != ZEBRA_ROUTE_LDP)
return 0;
/* Received Hello from LDP:
* if current sequence number is greater than received hello
* sequence number then assume LDP restarted
* set cost to LSInfinity
* send request to LDP for LDP-SYNC state for each interface
* else all is fine just restart hello timer
*/
if (hello.sequence == 0)
/* rolled over */
ospf->ldp_sync_cmd.sequence = 0;
if (ospf->ldp_sync_cmd.sequence > hello.sequence) {
zlog_err("ldp_sync: LDP restarted");
vrf = vrf_lookup_by_id(ospf->vrf_id);
FOR_ALL_INTERFACES (vrf, ifp)
ospf_ldp_sync_if_start(ifp, true);
} else {
THREAD_OFF(ospf->ldp_sync_cmd.t_hello);
ospf_ldp_sync_hello_timer_add(ospf);
}
ospf->ldp_sync_cmd.sequence = hello.sequence;
return 0; return 0;
} }
@ -447,46 +401,6 @@ void ospf_ldp_sync_holddown_timer_add(struct interface *ifp)
&ldp_sync_info->t_holddown); &ldp_sync_info->t_holddown);
} }
/*
* LDP-SYNC hello timer routines
*/
static int ospf_ldp_sync_hello_timer(struct thread *thread)
{
struct ospf *ospf;
struct vrf *vrf;
struct interface *ifp;
/* hello timer expired:
* didn't receive hello msg from LDP
* set cost of all interfaces to LSInfinity
*/
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
if (ospf) {
vrf = vrf_lookup_by_id(ospf->vrf_id);
FOR_ALL_INTERFACES (vrf, ifp)
ospf_ldp_sync_ldp_fail(ifp);
zlog_err("ldp_sync: hello timer expired, LDP down");
}
return 0;
}
void ospf_ldp_sync_hello_timer_add(struct ospf *ospf)
{
/* Start hello timer:
* this timer is used to make sure LDP is up
* if expires set interface cost to LSInfinity
*/
if (!CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE))
return;
thread_add_timer(master, ospf_ldp_sync_hello_timer,
NULL, LDP_IGP_SYNC_HELLO_TIMEOUT,
&ospf->ldp_sync_cmd.t_hello);
}
/* /*
* LDP-SYNC exit routes. * LDP-SYNC exit routes.
*/ */
@ -496,7 +410,6 @@ void ospf_ldp_sync_gbl_exit(struct ospf *ospf, bool remove)
struct vrf *vrf; struct vrf *vrf;
/* ospf is being removed /* ospf is being removed
* stop hello timer
* stop any holddown timers * stop any holddown timers
*/ */
if (CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { if (CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) {
@ -505,15 +418,12 @@ void ospf_ldp_sync_gbl_exit(struct ospf *ospf, bool remove)
LDP_IGP_SYNC_IF_STATE_UPDATE); LDP_IGP_SYNC_IF_STATE_UPDATE);
zclient_unregister_opaque(zclient, zclient_unregister_opaque(zclient,
LDP_IGP_SYNC_ANNOUNCE_UPDATE); LDP_IGP_SYNC_ANNOUNCE_UPDATE);
zclient_unregister_opaque(zclient, LDP_IGP_SYNC_HELLO_UPDATE);
/* disable LDP globally */ /* disable LDP globally */
UNSET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); UNSET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE);
UNSET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_HOLDDOWN); UNSET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_HOLDDOWN);
ospf->ldp_sync_cmd.holddown = LDP_IGP_SYNC_HOLDDOWN_DEFAULT; ospf->ldp_sync_cmd.holddown = LDP_IGP_SYNC_HOLDDOWN_DEFAULT;
THREAD_OFF(ospf->ldp_sync_cmd.t_hello);
/* turn off LDP-IGP Sync on all OSPF interfaces */ /* turn off LDP-IGP Sync on all OSPF interfaces */
vrf = vrf_lookup_by_id(ospf->vrf_id); vrf = vrf_lookup_by_id(ospf->vrf_id);
FOR_ALL_INTERFACES (vrf, ifp) FOR_ALL_INTERFACES (vrf, ifp)
@ -856,7 +766,6 @@ DEFPY (ospf_mpls_ldp_sync,
/* register with opaque client to recv LDP-IGP Sync msgs */ /* register with opaque client to recv LDP-IGP Sync msgs */
zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE);
zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE);
zclient_register_opaque(zclient, LDP_IGP_SYNC_HELLO_UPDATE);
if (!CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { if (!CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) {
SET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); SET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE);

View File

@ -40,7 +40,6 @@ extern void ospf_ldp_sync_if_remove(struct interface *ifp, bool remove);
extern void ospf_ldp_sync_if_down(struct interface *ifp); extern void ospf_ldp_sync_if_down(struct interface *ifp);
extern void ospf_ldp_sync_if_complete(struct interface *ifp); extern void ospf_ldp_sync_if_complete(struct interface *ifp);
extern void ospf_ldp_sync_holddown_timer_add(struct interface *ifp); extern void ospf_ldp_sync_holddown_timer_add(struct interface *ifp);
extern void ospf_ldp_sync_hello_timer_add(struct ospf *ospf);
extern void ospf_ldp_sync_ldp_fail(struct interface *ifp); extern void ospf_ldp_sync_ldp_fail(struct interface *ifp);
extern void ospf_ldp_sync_show_info(struct vty *vty, struct ospf *ospf, extern void ospf_ldp_sync_show_info(struct vty *vty, struct ospf *ospf,
json_object *json_vrf, bool use_json); json_object *json_vrf, bool use_json);
@ -49,7 +48,6 @@ extern void ospf_ldp_sync_if_write_config(struct vty *vty,
struct ospf_if_params *params); struct ospf_if_params *params);
extern int ospf_ldp_sync_state_update(struct ldp_igp_sync_if_state state); extern int ospf_ldp_sync_state_update(struct ldp_igp_sync_if_state state);
extern int ospf_ldp_sync_announce_update(struct ldp_igp_sync_announce announce); extern int ospf_ldp_sync_announce_update(struct ldp_igp_sync_announce announce);
extern int ospf_ldp_sync_hello_update(struct ldp_igp_sync_hello hello);
extern void extern void
ospf_ldp_sync_handle_client_close(struct zapi_client_close_info *info); ospf_ldp_sync_handle_client_close(struct zapi_client_close_info *info);
extern void ospf_ldp_sync_state_req_msg(struct interface *ifp); extern void ospf_ldp_sync_state_req_msg(struct interface *ifp);

View File

@ -1956,7 +1956,6 @@ static int ospf_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
struct zapi_opaque_msg info; struct zapi_opaque_msg info;
struct ldp_igp_sync_if_state state; struct ldp_igp_sync_if_state state;
struct ldp_igp_sync_announce announce; struct ldp_igp_sync_announce announce;
struct ldp_igp_sync_hello hello;
int ret = 0; int ret = 0;
s = zclient->ibuf; s = zclient->ibuf;
@ -1973,10 +1972,6 @@ static int ospf_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
STREAM_GET(&announce, s, sizeof(announce)); STREAM_GET(&announce, s, sizeof(announce));
ret = ospf_ldp_sync_announce_update(announce); ret = ospf_ldp_sync_announce_update(announce);
break; break;
case LDP_IGP_SYNC_HELLO_UPDATE:
STREAM_GET(&hello, s, sizeof(hello));
ret = ospf_ldp_sync_hello_update(hello);
break;
default: default:
break; break;
} }