diff --git a/code/bngblaster/src/bbl_config.c b/code/bngblaster/src/bbl_config.c index 7f0d1737..f19972ca 100644 --- a/code/bngblaster/src/bbl_config.c +++ b/code/bngblaster/src/bbl_config.c @@ -1541,7 +1541,8 @@ json_parse_isis_config(json_t *isis, isis_config_s *isis_config) "hostname", "router-id", "system-id", "area", "sr-base", "sr-range", "sr-node-sid", "teardown-time", "external", - "external-auto-refresh", "lsp-buffer-size", "sr-algo" + "external-auto-refresh", "lsp-buffer-size", "sr-algo", + "adjacency-sid" }; if(!schema_validate(isis, "isis", schema, sizeof(schema)/sizeof(schema[0]))) { @@ -1798,6 +1799,13 @@ json_parse_isis_config(json_t *isis, isis_config_s *isis_config) isis_config->sr_algo_count = 0; } + JSON_OBJ_GET_BOOL(isis, value, "isis", "adjacency-sid"); + if(value) { + isis_config->adjacency_sid = json_boolean_value(value); + } else { + isis_config->adjacency_sid = false; + } + value = json_object_get(isis, "teardown-time"); JSON_OBJ_GET_NUMBER(isis, value, "isis", "teardown-time", 0, 65535); if(value) { diff --git a/code/bngblaster/src/isis/isis_def.h b/code/bngblaster/src/isis/isis_def.h index ca46a4a3..792c6e83 100644 --- a/code/bngblaster/src/isis/isis_def.h +++ b/code/bngblaster/src/isis/isis_def.h @@ -253,6 +253,7 @@ typedef struct isis_config_ { uint32_t sr_node_sid; uint8_t *sr_algo; uint8_t sr_algo_count; + bool adjacency_sid; /* External */ bool external_purge; diff --git a/code/bngblaster/src/isis/isis_lsp.c b/code/bngblaster/src/isis/isis_lsp.c index 7f3ef171..13c181cb 100644 --- a/code/bngblaster/src/isis/isis_lsp.c +++ b/code/bngblaster/src/isis/isis_lsp.c @@ -639,12 +639,12 @@ isis_lsp_self_dis(isis_adjacency_s *adjacency) if(!lsp) return; pdu = &lsp->pdu; - isis_pdu_add_tlv_ext_reachability(pdu, config->system_id, 0, 0); + isis_pdu_add_tlv_ext_reachability(pdu, config->system_id, 0, 0, config->adjacency_sid); peer = adjacency->peer; while(peer) { if(peer->state == ISIS_PEER_STATE_UP && ISIS_PDU_REMAINING(pdu) >= 13) { - isis_pdu_add_tlv_ext_reachability(pdu, peer->system_id, 0, 0); + isis_pdu_add_tlv_ext_reachability(pdu, peer->system_id, 0, 0, config->adjacency_sid); } peer = peer->next; } @@ -739,20 +739,20 @@ isis_lsp_self_update(isis_instance_s *instance, uint8_t level) if(adjacency->p2p) { isis_pdu_add_tlv_ext_reachability(pdu, adjacency->peer->system_id, 0, - adjacency->metric); + adjacency->metric, config->adjacency_sid); } else { if(adjacency->dis) { isis_pdu_add_tlv_ext_reachability(pdu, adjacency->dis->system_id, adjacency->dis->pseudo_node_id, - adjacency->metric); + adjacency->metric, config->adjacency_sid); isis_lsp_self_dis_purge(adjacency); } else { isis_pdu_add_tlv_ext_reachability(pdu, config->system_id, adjacency->pseudo_node_id, - adjacency->metric); + adjacency->metric, config->adjacency_sid); isis_lsp_self_dis(adjacency); } @@ -775,7 +775,7 @@ isis_lsp_self_update(isis_instance_s *instance, uint8_t level) isis_pdu_add_tlv_ext_reachability(pdu, external_connection->system_id, 0, - external_connection->level[level-1].metric); + external_connection->level[level-1].metric, config->adjacency_sid); external_connection = external_connection->next; } diff --git a/code/bngblaster/src/isis/isis_pdu.c b/code/bngblaster/src/isis/isis_pdu.c index 3135bb80..d9dc5b5e 100644 --- a/code/bngblaster/src/isis/isis_pdu.c +++ b/code/bngblaster/src/isis/isis_pdu.c @@ -567,18 +567,36 @@ isis_pdu_add_tlv_auth(isis_pdu_s *pdu, isis_auth_type auth, char *key) void isis_pdu_add_tlv_ext_reachability(isis_pdu_s *pdu, uint8_t *system_id, uint8_t pseudo_node, - uint32_t metric) + uint32_t metric, bool adjacency_sid) { isis_tlv_s *tlv = (isis_tlv_s *)ISIS_PDU_CURSOR(pdu); uint8_t *tlv_cur = tlv->value; tlv->type = ISIS_TLV_EXT_REACHABILITY; - tlv->len = 11; + if(adjacency_sid && pseudo_node == 0) { + tlv->len = 18; + } else { + tlv->len = 11; + } memcpy(tlv_cur, system_id, ISIS_SYSTEM_ID_LEN); tlv_cur += ISIS_SYSTEM_ID_LEN; *(uint32_t*)tlv_cur = htobe32(metric); *tlv_cur = pseudo_node; tlv_cur += sizeof(metric); - *tlv_cur = 0; + /* implementation only for SubTLV 31 (non-DIS case), TODO for SubTLV 32 */ + if(adjacency_sid && pseudo_node == 0) { + *tlv_cur = 7; + tlv_cur += sizeof(uint8_t); + *tlv_cur++ = 31; + *tlv_cur++ = 5; + /* set V and L flag always */ + *tlv_cur++ = 0x30; + *tlv_cur++ = 0; + /* generate random adjacency SID but avoid reserved ranges 0-255 */ + *tlv_cur++ = 0; + *(uint16_t*)tlv_cur = htobe16(rand() % 4096 + 256); + } else { + *tlv_cur = 0; + } ISIS_PDU_BUMP_WRITE_BUFFER(pdu, sizeof(isis_tlv_s)+tlv->len); } @@ -597,7 +615,7 @@ isis_pdu_add_tlv_router_cap(isis_pdu_s *pdu, ipv4addr_t router_id, tlv->len = 16; } *(ipv4addr_t*)tlv_cur = router_id; - tlv_cur+=sizeof(ipv4addr_t); + tlv_cur += sizeof(ipv4addr_t); *tlv_cur++ = 0; *tlv_cur++ = 2; *tlv_cur++ = 9; @@ -605,12 +623,12 @@ isis_pdu_add_tlv_router_cap(isis_pdu_s *pdu, ipv4addr_t router_id, *tlv_cur = 0; if(ipv4) *tlv_cur |= 128; if(ipv6) *tlv_cur |= 64; - tlv_cur+=sizeof(uint32_t); + tlv_cur += sizeof(uint32_t); *tlv_cur++ = 1; *(uint32_t*)tlv_cur = htobe32(sr_base); *tlv_cur = 3; if(sr_algo_count > 0) { - tlv_cur+=sizeof(uint32_t); + tlv_cur += sizeof(uint32_t); *tlv_cur++ = 19; *tlv_cur++ = sr_algo_count; for(int i = 0; i < sr_algo_count; i++) { diff --git a/code/bngblaster/src/isis/isis_pdu.h b/code/bngblaster/src/isis/isis_pdu.h index 8ab985ee..85a6796a 100644 --- a/code/bngblaster/src/isis/isis_pdu.h +++ b/code/bngblaster/src/isis/isis_pdu.h @@ -107,7 +107,7 @@ void isis_pdu_add_tlv_auth(isis_pdu_s *pdu, isis_auth_type auth, char *key); void -isis_pdu_add_tlv_ext_reachability(isis_pdu_s *pdu, uint8_t *system_id, uint8_t pseudo_node, uint32_t metric); +isis_pdu_add_tlv_ext_reachability(isis_pdu_s *pdu, uint8_t *system_id, uint8_t pseudo_node, uint32_t metric, bool adjacency_sid); void isis_pdu_add_tlv_router_cap(isis_pdu_s *pdu, ipv4addr_t router_id, diff --git a/docsrc/sources/configuration/isis.rst b/docsrc/sources/configuration/isis.rst index ab6f2a3b..f8b20ebd 100644 --- a/docsrc/sources/configuration/isis.rst +++ b/docsrc/sources/configuration/isis.rst @@ -90,6 +90,9 @@ | **sr-node-sid** | | ISIS SR node SID. | | | | Default: 0 Range: 0 - 1048575 | +----------------------------------+-------------------------------------------------------------------+ +| **adjacency-sid** | | Enable/disable Adjacency SID generation. | +| | | Default: false | ++----------------------------------+-------------------------------------------------------------------+ | **teardown-time** | | ISIS teardown time in seconds. | | | | Default: 5 Range: 0 - 65535 | +----------------------------------+-------------------------------------------------------------------+