1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ldp_sync.c: LDP-SYNC handling routines
4 * Copyright (C) 2020 Volta Networks, Inc.
21 DEFINE_MTYPE_STATIC(LIB
, LDP_SYNC_INFO
, "LDP SYNC info");
24 * ldp_sync_info_create - Allocate the LDP_SYNC information
26 struct ldp_sync_info
*ldp_sync_info_create(void)
28 struct ldp_sync_info
*ldp_sync_info
;
30 ldp_sync_info
= XCALLOC(MTYPE_LDP_SYNC_INFO
,
31 sizeof(struct ldp_sync_info
));
32 assert(ldp_sync_info
);
34 ldp_sync_info
->flags
= 0;
35 ldp_sync_info
->enabled
= LDP_IGP_SYNC_DEFAULT
;
36 ldp_sync_info
->state
= LDP_IGP_SYNC_STATE_NOT_REQUIRED
;
37 ldp_sync_info
->holddown
= LDP_IGP_SYNC_HOLDDOWN_DEFAULT
;
38 ldp_sync_info
->t_holddown
= NULL
;
43 * ldp_sync_info_free - Free the LDP_SYNC information.
45 void ldp_sync_info_free(struct ldp_sync_info
**ldp_sync_info
)
48 XFREE(MTYPE_LDP_SYNC_INFO
, *ldp_sync_info
);
51 bool ldp_sync_if_is_enabled(struct ldp_sync_info
*ldp_sync_info
)
53 /* return true if LDP-SYNC is configured on this interface */
55 ldp_sync_info
->enabled
== LDP_IGP_SYNC_ENABLED
&&
56 ldp_sync_info
->state
== LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP
)
62 bool ldp_sync_if_down(struct ldp_sync_info
*ldp_sync_info
)
64 /* Stop LDP-SYNC on this interface:
65 * if holddown timer is running stop it
68 if (ldp_sync_info
&& ldp_sync_info
->enabled
== LDP_IGP_SYNC_ENABLED
) {
69 THREAD_OFF(ldp_sync_info
->t_holddown
);
71 if (ldp_sync_info
->state
== LDP_IGP_SYNC_STATE_REQUIRED_UP
)
72 ldp_sync_info
->state
=
73 LDP_IGP_SYNC_STATE_REQUIRED_NOT_UP
;