Skip to content

Commit d9884a7

Browse files
committed
isisd: Prepare IS-IS for Link State support
In order to provide Link State Traffic Engineering features to IS-IS, this patch adds some modifications to base IS-IS: - Solve bug in lsp iterate function to avoid infinite loop in isis_lsp.c by adding condition to recurse call - Add new trigger event to parse LSP in isis_lsp.c - Add new TE debug flag to track Traffic Engineering events in isisd.[c,h] - Correct small bug in isis_tlvs.c where delay and min/max delay are not correctly handle - Handle Opaque LSA Traffic Engineering Zebra API in isis_zebra.[c,h] Signed-off-by: Olivier Dugeon <[email protected]>
1 parent 8693b4d commit d9884a7

File tree

5 files changed

+114
-17
lines changed

5 files changed

+114
-17
lines changed

isisd/isis_lsp.c

+35-16
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ static void lsp_destroy(struct isis_lsp *lsp)
124124

125125
ISIS_FLAGS_CLEAR_ALL(lsp->SSNflags);
126126

127+
isis_te_lsp_event(lsp, LSP_DEL);
128+
127129
lsp_clear_data(lsp);
128130

129131
if (!LSP_FRAGMENT(lsp->hdr.lsp_id)) {
@@ -335,6 +337,7 @@ void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno)
335337

336338
lsp_pack_pdu(lsp);
337339
isis_spf_schedule(lsp->area, lsp->level);
340+
isis_te_lsp_event(lsp, LSP_INC);
338341
}
339342

340343
static void lsp_purge_add_poi(struct isis_lsp *lsp,
@@ -570,8 +573,10 @@ void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr,
570573
lsp_link_fragment(lsp, lsp0);
571574
}
572575

573-
if (lsp->hdr.seqno)
576+
if (lsp->hdr.seqno) {
574577
isis_spf_schedule(lsp->area, lsp->level);
578+
isis_te_lsp_event(lsp, LSP_UPD);
579+
}
575580
}
576581

577582
/* creation of LSP directly from what we received */
@@ -636,8 +641,10 @@ struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id,
636641
void lsp_insert(struct lspdb_head *head, struct isis_lsp *lsp)
637642
{
638643
lspdb_add(head, lsp);
639-
if (lsp->hdr.seqno)
644+
if (lsp->hdr.seqno) {
640645
isis_spf_schedule(lsp->area, lsp->level);
646+
isis_te_lsp_event(lsp, LSP_ADD);
647+
}
641648
}
642649

643650
/*
@@ -1030,6 +1037,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
10301037
cap.srlb.lower_bound = srdb->config.srlb_lower_bound;
10311038
/* And finally MSD */
10321039
cap.msd = srdb->config.msd;
1040+
} else {
1041+
/* Disable SR Algorithm */
1042+
cap.algo[0] = SR_ALGORITHM_UNSET;
1043+
cap.algo[1] = SR_ALGORITHM_UNSET;
10331044
}
10341045

10351046
isis_tlvs_set_router_capability(lsp->tlvs, &cap);
@@ -2012,6 +2023,7 @@ int lsp_tick(struct thread *thread)
20122023
/* 7.3.16.4 c) record the time to purge
20132024
* FIXME */
20142025
isis_spf_schedule(lsp->area, lsp->level);
2026+
isis_te_lsp_event(lsp, LSP_TICK);
20152027
}
20162028

20172029
if (lsp->age_out == 0) {
@@ -2166,7 +2178,7 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid,
21662178
if (lsp->hdr.seqno == 0 || lsp->hdr.rem_lifetime == 0)
21672179
return LSP_ITER_CONTINUE;
21682180

2169-
/* Parse main LSP. */
2181+
/* Parse LSP */
21702182
if (lsp->tlvs) {
21712183
if (!fabricd && !pseudo_lsp && family == AF_INET
21722184
&& mtid == ISIS_MT_IPV4_UNICAST) {
@@ -2236,13 +2248,17 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid,
22362248
}
22372249
}
22382250

2239-
/* Parse LSP fragments. */
2240-
for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
2241-
if (!frag->tlvs)
2242-
continue;
2251+
/* Parse LSP fragments if it is not a fragment itself */
2252+
if (!LSP_FRAGMENT(lsp->hdr.lsp_id))
2253+
for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
2254+
if (!frag->tlvs)
2255+
continue;
22432256

2244-
isis_lsp_iterate_ip_reach(frag, family, mtid, cb, arg);
2245-
}
2257+
if (isis_lsp_iterate_ip_reach(frag, family, mtid, cb,
2258+
arg)
2259+
== LSP_ITER_STOP)
2260+
return LSP_ITER_STOP;
2261+
}
22462262

22472263
return LSP_ITER_CONTINUE;
22482264
}
@@ -2263,7 +2279,7 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid,
22632279
if (lsp->hdr.seqno == 0 || lsp->hdr.rem_lifetime == 0)
22642280
return LSP_ITER_CONTINUE;
22652281

2266-
/* Parse main LSP. */
2282+
/* Parse LSP */
22672283
if (lsp->tlvs) {
22682284
if (pseudo_lsp || mtid == ISIS_MT_IPV4_UNICAST) {
22692285
head = lsp->tlvs->oldstyle_reach.head;
@@ -2295,13 +2311,16 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid,
22952311
}
22962312
}
22972313

2298-
/* Parse LSP fragments. */
2299-
for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
2300-
if (!frag->tlvs)
2301-
continue;
2314+
/* Parse LSP fragments if it not a fragment itself. */
2315+
if (!LSP_FRAGMENT(lsp->hdr.lsp_id))
2316+
for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
2317+
if (!frag->tlvs)
2318+
continue;
23022319

2303-
isis_lsp_iterate_is_reach(frag, mtid, cb, arg);
2304-
}
2320+
if (isis_lsp_iterate_is_reach(frag, mtid, cb, arg)
2321+
== LSP_ITER_STOP)
2322+
return LSP_ITER_STOP;
2323+
}
23052324

23062325
return LSP_ITER_CONTINUE;
23072326
}

isisd/isis_zebra.c

+28
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "vrf.h"
3939
#include "libfrr.h"
4040
#include "bfd.h"
41+
#include "link_state.h"
4142

4243
#include "isisd/isis_constants.h"
4344
#include "isisd/isis_common.h"
@@ -747,13 +748,33 @@ static void isis_zebra_connected(struct zclient *zclient)
747748
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
748749
}
749750

751+
/**
752+
* Register / unregister Link State ZAPI Opaque Message
753+
*
754+
* @param up True to register, false to unregister
755+
*
756+
* @return 0 if success, -1 otherwise
757+
*/
758+
int isis_zebra_ls_register(bool up)
759+
{
760+
int rc;
761+
762+
if (up)
763+
rc = ls_register(zclient, true);
764+
else
765+
rc = ls_unregister(zclient, true);
766+
767+
return rc;
768+
}
769+
750770
/*
751771
* opaque messages between processes
752772
*/
753773
static int isis_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
754774
{
755775
struct stream *s;
756776
struct zapi_opaque_msg info;
777+
struct zapi_opaque_reg_info dst;
757778
struct ldp_igp_sync_if_state state;
758779
struct ldp_igp_sync_announce announce;
759780
struct zapi_rlfa_response rlfa;
@@ -764,6 +785,13 @@ static int isis_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
764785
return -1;
765786

766787
switch (info.type) {
788+
case LINK_STATE_SYNC:
789+
STREAM_GETC(s, dst.proto);
790+
STREAM_GETW(s, dst.instance);
791+
STREAM_GETL(s, dst.session_id);
792+
dst.type = LINK_STATE_SYNC;
793+
ret = isis_te_sync_ted(dst);
794+
break;
767795
case LDP_IGP_SYNC_IF_STATE_UPDATE:
768796
STREAM_GET(&state, s, sizeof(state));
769797
ret = isis_ldp_sync_state_update(state);

isisd/isis_zebra.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ int isis_zebra_request_label_range(uint32_t base, uint32_t chunk_size);
6767
int isis_zebra_release_label_range(uint32_t start, uint32_t end);
6868
void isis_zebra_vrf_register(struct isis *isis);
6969
void isis_zebra_vrf_deregister(struct isis *isis);
70+
int isis_zebra_ls_register(bool up);
7071

7172
#endif /* _ZEBRA_ISIS_ZEBRA_H */

isisd/isisd.c

+42
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ unsigned long debug_tx_queue;
8181
unsigned long debug_sr;
8282
unsigned long debug_ldp_sync;
8383
unsigned long debug_lfa;
84+
unsigned long debug_te;
8485

8586
DEFINE_MGROUP(ISISD, "isisd");
8687

@@ -1419,6 +1420,10 @@ void print_debug(struct vty *vty, int flags, int onoff)
14191420
if (flags & DEBUG_SR)
14201421
vty_out(vty, "IS-IS Segment Routing events debugging is %s\n",
14211422
onoffs);
1423+
if (flags & DEBUG_TE)
1424+
vty_out(vty,
1425+
"IS-IS Traffic Engineering events debugging is %s\n",
1426+
onoffs);
14221427
if (flags & DEBUG_LFA)
14231428
vty_out(vty, "IS-IS LFA events debugging is %s\n", onoffs);
14241429
if (flags & DEBUG_UPDATE_PACKETS)
@@ -1461,6 +1466,8 @@ DEFUN_NOSH (show_debugging,
14611466
print_debug(vty, DEBUG_SPF_EVENTS, 1);
14621467
if (IS_DEBUG_SR)
14631468
print_debug(vty, DEBUG_SR, 1);
1469+
if (IS_DEBUG_TE)
1470+
print_debug(vty, DEBUG_TE, 1);
14641471
if (IS_DEBUG_UPDATE_PACKETS)
14651472
print_debug(vty, DEBUG_UPDATE_PACKETS, 1);
14661473
if (IS_DEBUG_RTE_EVENTS)
@@ -1518,6 +1525,10 @@ static int config_write_debug(struct vty *vty)
15181525
vty_out(vty, "debug " PROTO_NAME " sr-events\n");
15191526
write++;
15201527
}
1528+
if (IS_DEBUG_TE) {
1529+
vty_out(vty, "debug " PROTO_NAME " te-events\n");
1530+
write++;
1531+
}
15211532
if (IS_DEBUG_LFA) {
15221533
vty_out(vty, "debug " PROTO_NAME " lfa\n");
15231534
write++;
@@ -1752,6 +1763,33 @@ DEFUN (no_debug_isis_srevents,
17521763
return CMD_SUCCESS;
17531764
}
17541765

1766+
DEFUN (debug_isis_teevents,
1767+
debug_isis_teevents_cmd,
1768+
"debug " PROTO_NAME " te-events",
1769+
DEBUG_STR
1770+
PROTO_HELP
1771+
"IS-IS Traffic Engineering Events\n")
1772+
{
1773+
debug_te |= DEBUG_TE;
1774+
print_debug(vty, DEBUG_TE, 1);
1775+
1776+
return CMD_SUCCESS;
1777+
}
1778+
1779+
DEFUN (no_debug_isis_teevents,
1780+
no_debug_isis_teevents_cmd,
1781+
"no debug " PROTO_NAME " te-events",
1782+
NO_STR
1783+
UNDEBUG_STR
1784+
PROTO_HELP
1785+
"IS-IS Traffic Engineering Events\n")
1786+
{
1787+
debug_te &= ~DEBUG_TE;
1788+
print_debug(vty, DEBUG_TE, 0);
1789+
1790+
return CMD_SUCCESS;
1791+
}
1792+
17551793
DEFUN (debug_isis_lfa,
17561794
debug_isis_lfa_cmd,
17571795
"debug " PROTO_NAME " lfa",
@@ -3140,6 +3178,8 @@ void isis_init(void)
31403178
install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd);
31413179
install_element(ENABLE_NODE, &debug_isis_srevents_cmd);
31423180
install_element(ENABLE_NODE, &no_debug_isis_srevents_cmd);
3181+
install_element(ENABLE_NODE, &debug_isis_teevents_cmd);
3182+
install_element(ENABLE_NODE, &no_debug_isis_teevents_cmd);
31433183
install_element(ENABLE_NODE, &debug_isis_lfa_cmd);
31443184
install_element(ENABLE_NODE, &no_debug_isis_lfa_cmd);
31453185
install_element(ENABLE_NODE, &debug_isis_rtevents_cmd);
@@ -3171,6 +3211,8 @@ void isis_init(void)
31713211
install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd);
31723212
install_element(CONFIG_NODE, &debug_isis_srevents_cmd);
31733213
install_element(CONFIG_NODE, &no_debug_isis_srevents_cmd);
3214+
install_element(CONFIG_NODE, &debug_isis_teevents_cmd);
3215+
install_element(CONFIG_NODE, &no_debug_isis_teevents_cmd);
31743216
install_element(CONFIG_NODE, &debug_isis_lfa_cmd);
31753217
install_element(CONFIG_NODE, &no_debug_isis_lfa_cmd);
31763218
install_element(CONFIG_NODE, &debug_isis_rtevents_cmd);

isisd/isisd.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ extern unsigned long debug_tx_queue;
331331
extern unsigned long debug_sr;
332332
extern unsigned long debug_ldp_sync;
333333
extern unsigned long debug_lfa;
334+
extern unsigned long debug_te;
334335

335336
#define DEBUG_ADJ_PACKETS (1<<0)
336337
#define DEBUG_SNP_PACKETS (1<<1)
@@ -347,6 +348,7 @@ extern unsigned long debug_lfa;
347348
#define DEBUG_SR (1<<12)
348349
#define DEBUG_LDP_SYNC (1<<13)
349350
#define DEBUG_LFA (1<<14)
351+
#define DEBUG_TE (1<<15)
350352

351353
/* Debug related macro. */
352354
#define IS_DEBUG_ADJ_PACKETS (debug_adj_pkt & DEBUG_ADJ_PACKETS)
@@ -364,6 +366,7 @@ extern unsigned long debug_lfa;
364366
#define IS_DEBUG_SR (debug_sr & DEBUG_SR)
365367
#define IS_DEBUG_LDP_SYNC (debug_ldp_sync & DEBUG_LDP_SYNC)
366368
#define IS_DEBUG_LFA (debug_lfa & DEBUG_LFA)
369+
#define IS_DEBUG_TE (debug_te & DEBUG_TE)
367370

368371
#define lsp_debug(...) \
369372
do { \
@@ -383,6 +386,10 @@ extern unsigned long debug_lfa;
383386
zlog_debug(__VA_ARGS__); \
384387
} while (0)
385388

386-
#define DEBUG_TE DEBUG_LSP_GEN
389+
#define te_debug(...) \
390+
do { \
391+
if (IS_DEBUG_TE) \
392+
zlog_debug(__VA_ARGS__); \
393+
} while (0)
387394

388395
#endif /* ISISD_H */

0 commit comments

Comments
 (0)