From 535364e90459566b603661c3dbe360c72f59ad71 Mon Sep 17 00:00:00 2001 From: Nathan Skrzypczak Date: Wed, 6 Dec 2023 17:34:57 +0100 Subject: vnet: allow format deleted swifidx This patch prevents the sw interfaces format function to fail when the interface was deleted. It also prints the swifindex alongside the 'DELETED' keyword. Printing deleted swifindex should not happen, but it is still helpful to have these safeguards for troubleshooting in the case invariants get corrupted (e.g. fib entry refcounts, ...) Type: improvement Change-Id: I66711049db2eebe0ad17e37c3a260ac81d1e5134 Signed-off-by: Nathan Skrzypczak --- src/vnet/interface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/vnet/interface.c') diff --git a/src/vnet/interface.c b/src/vnet/interface.c index b21170f9c3a..44bcc39d3cd 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -1359,7 +1359,10 @@ vnet_hw_interface_compare (vnet_main_t * vnm, int vnet_sw_interface_is_p2p (vnet_main_t * vnm, u32 sw_if_index) { - vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index); + vnet_sw_interface_t *si = vnet_get_sw_interface_or_null (vnm, sw_if_index); + if (si == NULL) + return -1; + if ((si->type == VNET_SW_INTERFACE_TYPE_P2P) || (si->type == VNET_SW_INTERFACE_TYPE_PIPE)) return 1; -- cgit 1.2.3-korg