Skip to content

Commit

Permalink
add support for TLV 22 SubTLV 31 Adjacency SID generation, SID values…
Browse files Browse the repository at this point in the history
… randomized between 256-4096
  • Loading branch information
Maik Pfeil authored and GIC-de committed Aug 28, 2024
1 parent 6b6e125 commit a18f59e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
10 changes: 9 additions & 1 deletion code/bngblaster/src/bbl_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]))) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions code/bngblaster/src/isis/isis_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions code/bngblaster/src/isis/isis_lsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down
30 changes: 24 additions & 6 deletions code/bngblaster/src/isis/isis_pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -597,20 +615,20 @@ 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;
*(uint32_t*)tlv_cur = htobe32(sr_range);
*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++) {
Expand Down
2 changes: 1 addition & 1 deletion code/bngblaster/src/isis/isis_pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions docsrc/sources/configuration/isis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+----------------------------------+-------------------------------------------------------------------+

0 comments on commit a18f59e

Please sign in to comment.