Merge pull request #14135 from squirrelking57/fix_isis_adj_level

isisd:change ngh lvl when int circuit type setted
This commit is contained in:
Russ White 2023-11-14 08:49:35 -05:00 committed by GitHub
commit 072a0b5839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 113 additions and 70 deletions

View File

@ -111,6 +111,7 @@ struct iih_info {
bool v6_usable; bool v6_usable;
struct isis_tlvs *tlvs; struct isis_tlvs *tlvs;
int calculated_type;
}; };
static int process_p2p_hello(struct iih_info *iih) static int process_p2p_hello(struct iih_info *iih)
@ -151,6 +152,76 @@ static int process_p2p_hello(struct iih_info *iih)
struct isis_adjacency *adj = iih->circuit->u.p2p.neighbor; struct isis_adjacency *adj = iih->circuit->u.p2p.neighbor;
/* If an adjacency exists, check it is with the source of the hello /* If an adjacency exists, check it is with the source of the hello
* packets */ * packets */
if (((iih->circuit->area->is_type == IS_LEVEL_1) &&
((iih->circuit->is_type_config == IS_LEVEL_1_AND_2) ||
(iih->circuit->is_type_config == IS_LEVEL_1))) ||
((iih->circuit->area->is_type == IS_LEVEL_1_AND_2) &&
(iih->circuit->is_type_config == IS_LEVEL_1) &&
((iih->circ_type == IS_LEVEL_1) ||
(iih->circ_type == IS_LEVEL_1_AND_2))) ||
((iih->circuit->area->is_type == IS_LEVEL_1_AND_2) &&
(iih->circuit->is_type_config == IS_LEVEL_1_AND_2) &&
(iih->circ_type == IS_LEVEL_1))) {
if (!isis_tlvs_area_addresses_match(iih->tlvs,
iih->circuit->area
->area_addrs)) {
if (IS_DEBUG_ADJ_PACKETS) {
zlog_debug("ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s, cir id %u, length %u",
iih->circuit->area->area_tag,
iih->circuit->interface->name,
circuit_t2string(
iih->circuit->is_type),
iih->circuit->circuit_id,
iih->pdu_len);
}
return ISIS_WARNING;
}
iih->calculated_type = IS_LEVEL_1;
}
else if (((iih->circuit->area->is_type == IS_LEVEL_2) &&
((iih->circuit->is_type_config == IS_LEVEL_1_AND_2) ||
(iih->circuit->is_type_config == IS_LEVEL_2))) ||
((iih->circuit->area->is_type == IS_LEVEL_1_AND_2) &&
(iih->circuit->is_type_config == IS_LEVEL_2) &&
((iih->circ_type == IS_LEVEL_2) ||
(iih->circ_type == IS_LEVEL_1_AND_2))) ||
((iih->circuit->area->is_type == IS_LEVEL_1_AND_2) &&
(iih->circuit->is_type_config == IS_LEVEL_1_AND_2) &&
(iih->circ_type == IS_LEVEL_2))) {
iih->calculated_type = IS_LEVEL_2;
}
else if ((iih->circuit->area->is_type == IS_LEVEL_1_AND_2) &&
(iih->circuit->is_type_config == IS_LEVEL_1_AND_2) &&
(iih->circ_type == IS_LEVEL_1_AND_2)) {
iih->calculated_type = IS_LEVEL_1_AND_2;
if (!isis_tlvs_area_addresses_match(iih->tlvs,
iih->circuit->area
->area_addrs)) {
iih->calculated_type = IS_LEVEL_2;
}
}
else {
if (IS_DEBUG_ADJ_PACKETS) {
if (IS_DEBUG_ADJ_PACKETS) {
zlog_debug("ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s, cir id %u, length %u",
iih->circuit->area->area_tag,
iih->circuit->interface->name,
circuit_t2string(
iih->circuit->is_type),
iih->circuit->circuit_id,
iih->pdu_len);
}
}
return ISIS_WARNING;
}
if (adj) { if (adj) {
if (memcmp(iih->sys_id, adj->sysid, ISIS_SYS_ID_LEN)) { if (memcmp(iih->sys_id, adj->sysid, ISIS_SYS_ID_LEN)) {
zlog_debug( zlog_debug(
@ -160,12 +231,13 @@ static int process_p2p_hello(struct iih_info *iih)
return ISIS_OK; return ISIS_OK;
} }
} }
if (!adj || adj->level != iih->circ_type) { if (!adj || adj->level != iih->calculated_type) {
if (!adj) { if (!adj) {
adj = isis_new_adj(iih->sys_id, NULL, iih->circ_type, adj = isis_new_adj(iih->sys_id, NULL,
iih->circuit); iih->calculated_type, iih->circuit);
} else { } else {
adj->level = iih->circ_type; adj->level = iih->calculated_type;
} }
iih->circuit->u.p2p.neighbor = adj; iih->circuit->u.p2p.neighbor = adj;
/* Build lsp with the new neighbor entry when a new /* Build lsp with the new neighbor entry when a new
@ -174,7 +246,7 @@ static int process_p2p_hello(struct iih_info *iih)
* when an adjacency is up. This will result in the new * when an adjacency is up. This will result in the new
* adjacency entry getting added to the lsp tlv neighbor list. * adjacency entry getting added to the lsp tlv neighbor list.
*/ */
adj->circuit_t = iih->circ_type; adj->circuit_t = iih->calculated_type;
isis_adj_state_change(&adj, ISIS_ADJ_INITIALIZING, NULL); isis_adj_state_change(&adj, ISIS_ADJ_INITIALIZING, NULL);
adj->sys_type = ISIS_SYSTYPE_UNKNOWN; adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
} }
@ -205,45 +277,35 @@ static int process_p2p_hello(struct iih_info *iih)
/* 8.2.5.2 a) a match was detected */ /* 8.2.5.2 a) a match was detected */
if (isis_tlvs_area_addresses_match(iih->tlvs, if (isis_tlvs_area_addresses_match(iih->tlvs,
iih->circuit->area->area_addrs)) { iih->circuit->area->area_addrs)) {
/* 8.2.5.2 a) 2) If the system is L1 - table 5 */ /* 8.2.5.2 a) 2) If the calculated type is L1 - table 5 */
if (iih->circuit->area->is_type == IS_LEVEL_1) { if (iih->calculated_type == IS_LEVEL_1) {
switch (iih->circ_type) { switch (iih->circ_type) {
case IS_LEVEL_1: case IS_LEVEL_1:
case IS_LEVEL_1_AND_2: isis_adj_process_threeway(adj, tw_adj,
if (adj->adj_state != ISIS_ADJ_UP iih->calculated_type);
|| adj->adj_usage == ISIS_ADJ_LEVEL1) {
isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL1);
}
break; break;
case IS_LEVEL_2: case IS_LEVEL_1_AND_2:
if (adj->adj_state != ISIS_ADJ_UP) { if ((adj->adj_state != ISIS_ADJ_UP) ||
/* (7) reject - wrong system type event (adj->adj_usage == ISIS_ADJ_LEVEL1) ||
*/ (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)) {
zlog_warn("wrongSystemType"); isis_adj_process_threeway(adj, tw_adj,
return ISIS_WARNING; iih->calculated_type);
} else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
/* (6) down - wrong system */
isis_adj_state_change(&adj,
ISIS_ADJ_DOWN,
"Wrong System");
} }
break; break;
} }
} }
/* 8.2.5.2 a) 3) If the system is L1L2 - table 6 */ /* 8.2.5.2 a) 3) If the calculated type is L1L2 - table 6 */
if (iih->circuit->area->is_type == IS_LEVEL_1_AND_2) { if (iih->calculated_type == IS_LEVEL_1_AND_2) {
switch (iih->circ_type) { switch (iih->circ_type) {
case IS_LEVEL_1: case IS_LEVEL_1:
if (adj->adj_state != ISIS_ADJ_UP if (adj->adj_state != ISIS_ADJ_UP
|| adj->adj_usage == ISIS_ADJ_LEVEL1) { || adj->adj_usage == ISIS_ADJ_LEVEL1) {
isis_adj_process_threeway(adj, tw_adj, isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL1); iih->calculated_type);
} else if ((adj->adj_usage } else if ((adj->adj_usage == ISIS_ADJ_LEVEL2) ||
== ISIS_ADJ_LEVEL1AND2) (adj->adj_usage ==
|| (adj->adj_usage ISIS_ADJ_LEVEL1AND2)) {
== ISIS_ADJ_LEVEL2)) {
/* (8) down - wrong system */ /* (8) down - wrong system */
isis_adj_state_change(&adj, isis_adj_state_change(&adj,
ISIS_ADJ_DOWN, ISIS_ADJ_DOWN,
@ -254,10 +316,10 @@ static int process_p2p_hello(struct iih_info *iih)
if (adj->adj_state != ISIS_ADJ_UP if (adj->adj_state != ISIS_ADJ_UP
|| adj->adj_usage == ISIS_ADJ_LEVEL2) { || adj->adj_usage == ISIS_ADJ_LEVEL2) {
isis_adj_process_threeway(adj, tw_adj, isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL2); iih->calculated_type);
} else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
|| (adj->adj_usage (adj->adj_usage ==
== ISIS_ADJ_LEVEL1AND2)) { ISIS_ADJ_LEVEL1AND2)) {
/* (8) down - wrong system */ /* (8) down - wrong system */
isis_adj_state_change(&adj, isis_adj_state_change(&adj,
ISIS_ADJ_DOWN, ISIS_ADJ_DOWN,
@ -268,10 +330,9 @@ static int process_p2p_hello(struct iih_info *iih)
if (adj->adj_state != ISIS_ADJ_UP if (adj->adj_state != ISIS_ADJ_UP
|| adj->adj_usage == ISIS_ADJ_LEVEL1AND2) { || adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
isis_adj_process_threeway(adj, tw_adj, isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL1AND2); iih->calculated_type);
} else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
|| (adj->adj_usage (adj->adj_usage == ISIS_ADJ_LEVEL2)) {
== ISIS_ADJ_LEVEL2)) {
/* (8) down - wrong system */ /* (8) down - wrong system */
isis_adj_state_change(&adj, isis_adj_state_change(&adj,
ISIS_ADJ_DOWN, ISIS_ADJ_DOWN,
@ -282,44 +343,26 @@ static int process_p2p_hello(struct iih_info *iih)
} }
/* 8.2.5.2 a) 4) If the system is L2 - table 7 */ /* 8.2.5.2 a) 4) If the system is L2 - table 7 */
if (iih->circuit->area->is_type == IS_LEVEL_2) { if (iih->calculated_type == IS_LEVEL_2) {
switch (iih->circ_type) { switch (iih->circ_type) {
case IS_LEVEL_1: case IS_LEVEL_1_AND_2:
if (adj->adj_state != ISIS_ADJ_UP) { if (adj->adj_state != ISIS_ADJ_UP ||
/* (5) reject - wrong system type event adj->adj_usage == ISIS_ADJ_LEVEL2 ||
*/ adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
zlog_warn("wrongSystemType"); isis_adj_process_threeway(adj, tw_adj,
return ISIS_WARNING; iih->calculated_type);
} else if ((adj->adj_usage
== ISIS_ADJ_LEVEL1AND2)
|| (adj->adj_usage
== ISIS_ADJ_LEVEL2)) {
/* (6) down - wrong system */
isis_adj_state_change(&adj,
ISIS_ADJ_DOWN,
"Wrong System");
} }
break; break;
case IS_LEVEL_1_AND_2:
case IS_LEVEL_2: case IS_LEVEL_2:
if (adj->adj_state != ISIS_ADJ_UP isis_adj_process_threeway(adj, tw_adj,
|| adj->adj_usage == ISIS_ADJ_LEVEL2) { iih->calculated_type);
isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL2);
} else if (adj->adj_usage
== ISIS_ADJ_LEVEL1AND2) {
/* (6) down - wrong system */
isis_adj_state_change(&adj,
ISIS_ADJ_DOWN,
"Wrong System");
}
break; break;
} }
} }
} }
/* 8.2.5.2 b) if no match was detected */ /* 8.2.5.2 b) if no match was detected */
else if (listcount(iih->circuit->area->area_addrs) > 0) { else if (listcount(iih->circuit->area->area_addrs) > 0) {
if (iih->circuit->area->is_type == IS_LEVEL_1) { if (iih->calculated_type == IS_LEVEL_1) {
/* 8.2.5.2 b) 1) is_type L1 and adj is not up */ /* 8.2.5.2 b) 1) is_type L1 and adj is not up */
if (adj->adj_state != ISIS_ADJ_UP) { if (adj->adj_state != ISIS_ADJ_UP) {
isis_adj_state_change(&adj, ISIS_ADJ_DOWN, isis_adj_state_change(&adj, ISIS_ADJ_DOWN,
@ -359,7 +402,7 @@ static int process_p2p_hello(struct iih_info *iih)
if (adj->adj_state != ISIS_ADJ_UP if (adj->adj_state != ISIS_ADJ_UP
|| adj->adj_usage == ISIS_ADJ_LEVEL2) { || adj->adj_usage == ISIS_ADJ_LEVEL2) {
isis_adj_process_threeway(adj, tw_adj, isis_adj_process_threeway(adj, tw_adj,
ISIS_ADJ_LEVEL2); iih->calculated_type);
} else if (adj->adj_usage == ISIS_ADJ_LEVEL1) { } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
/* (7) down - wrong system */ /* (7) down - wrong system */
isis_adj_state_change(&adj, isis_adj_state_change(&adj,

View File

@ -9,7 +9,7 @@
"adjacencies": { "adjacencies": {
"adjacency": [ "adjacency": [
{ {
"neighbor-sys-type": "level-1-2", "neighbor-sys-type": "level-1",
"neighbor-sysid": "0000.0000.0004", "neighbor-sysid": "0000.0000.0004",
"hold-timer": 10, "hold-timer": 10,
"neighbor-priority": 0, "neighbor-priority": 0,
@ -28,7 +28,7 @@
"adjacencies": { "adjacencies": {
"adjacency": [ "adjacency": [
{ {
"neighbor-sys-type": "level-1-2", "neighbor-sys-type": "level-1",
"neighbor-sysid": "0000.0000.0005", "neighbor-sysid": "0000.0000.0005",
"hold-timer": 10, "hold-timer": 10,
"neighbor-priority": 0, "neighbor-priority": 0,