Merge pull request #8539 from donaldsharp/isis_circuit_warning

Isis circuit warning
This commit is contained in:
Igor Ryzhov 2021-04-23 22:44:49 +03:00 committed by GitHub
commit 646c4a38dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 31 deletions

View File

@ -31,6 +31,7 @@
#include "isis_constants.h"
#include "isis_common.h"
#include "isis_csm.h"
DECLARE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp));
@ -77,7 +78,7 @@ struct isis_circuit_arg {
};
struct isis_circuit {
int state;
enum isis_circuit_state state;
uint8_t circuit_id; /* l1/l2 bcast CircuitID */
time_t last_uptime;
struct isis *isis;

View File

@ -60,12 +60,14 @@ static const char *const csm_eventstr[] = {
#define EVENT2STR(E) csm_eventstr[E]
struct isis_circuit *
isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
struct isis_circuit *isis_csm_state_change(enum isis_circuit_event event,
struct isis_circuit *circuit,
void *arg)
{
int old_state;
enum isis_circuit_state old_state;
struct isis *isis = NULL;
struct isis_area *area = NULL;
struct interface *ifp;
old_state = circuit ? circuit->state : C_STATE_NA;
if (IS_DEBUG_EVENTS)
@ -85,23 +87,29 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
circuit->state = C_STATE_CONF;
break;
case IF_UP_FROM_Z:
isis = isis_lookup_by_vrfid(((struct interface *)arg)->vrf_id);
ifp = arg;
isis = isis_lookup_by_vrfid(ifp->vrf_id);
if (isis == NULL) {
zlog_warn(
" %s : ISIS routing instance not found",
__func__);
if (IS_DEBUG_EVENTS)
zlog_debug(
" %s : ISIS routing instance not found when attempting to apply against interface %s",
__func__, ifp->name);
break;
}
circuit = isis_circuit_new(isis);
isis_circuit_if_add(circuit, (struct interface *)arg);
isis_circuit_if_add(circuit, ifp);
listnode_add(isis->init_circ_list, circuit);
circuit->state = C_STATE_INIT;
break;
case ISIS_DISABLE:
zlog_warn("circuit already disabled");
if (IS_DEBUG_EVENTS)
zlog_debug(
"circuit disable event passed for a non existent circuit");
break;
case IF_DOWN_FROM_Z:
zlog_warn("circuit already disconnected");
if (IS_DEBUG_EVENTS)
zlog_debug(
"circuit disconnect event passed for a non existent circuit");
break;
}
break;
@ -123,11 +131,14 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
circuit);
break;
case IF_UP_FROM_Z:
assert(circuit);
zlog_warn("circuit already connected");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %s already connected",
circuit->interface->name);
break;
case ISIS_DISABLE:
zlog_warn("circuit already disabled");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %s already disabled",
circuit->interface->name);
break;
case IF_DOWN_FROM_Z:
isis_circuit_if_del(circuit, (struct interface *)arg);
@ -142,7 +153,9 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
assert(circuit);
switch (event) {
case ISIS_ENABLE:
zlog_warn("circuit already enabled");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %p is already enabled",
circuit);
break;
case IF_UP_FROM_Z:
isis_circuit_if_add(circuit, (struct interface *)arg);
@ -165,7 +178,9 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
circuit = NULL;
break;
case IF_DOWN_FROM_Z:
zlog_warn("circuit already disconnected");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %p already disconnected",
circuit);
break;
}
break;
@ -173,10 +188,14 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
assert(circuit);
switch (event) {
case ISIS_ENABLE:
zlog_warn("circuit already configured");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %s already configured",
circuit->interface->name);
break;
case IF_UP_FROM_Z:
zlog_warn("circuit already connected");
if (IS_DEBUG_EVENTS)
zlog_debug("circuit %s already connected",
circuit->interface->name);
break;
case ISIS_DISABLE:
isis = circuit->isis;
@ -197,9 +216,6 @@ isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg)
break;
}
break;
default:
zlog_warn("Invalid circuit state %d", old_state);
}
if (IS_DEBUG_EVENTS)

View File

@ -27,20 +27,25 @@
/*
* Circuit states
*/
#define C_STATE_NA 0
#define C_STATE_INIT 1 /* Connected to interface */
#define C_STATE_CONF 2 /* Configured for ISIS */
#define C_STATE_UP 3 /* CONN | CONF */
enum isis_circuit_state {
C_STATE_NA,
C_STATE_INIT, /* Connected to interface */
C_STATE_CONF, /* Configured for ISIS */
C_STATE_UP, /* CONN | CONF */
};
/*
* Circuit events
*/
#define ISIS_ENABLE 1
#define IF_UP_FROM_Z 2
#define ISIS_DISABLE 3
#define IF_DOWN_FROM_Z 4
enum isis_circuit_event {
ISIS_ENABLE = 1,
IF_UP_FROM_Z,
ISIS_DISABLE,
IF_DOWN_FROM_Z,
};
struct isis_circuit *
isis_csm_state_change(int event, struct isis_circuit *circuit, void *arg);
struct isis_circuit *isis_csm_state_change(enum isis_circuit_event event,
struct isis_circuit *circuit,
void *arg);
#endif /* _ZEBRA_ISIS_CSM_H */