From: Steven Luong Date: Tue, 29 Sep 2020 23:23:25 +0000 (-0700) Subject: avf: check duplicate pci address upon create interface X-Git-Tag: v21.06-rc0~438 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=5aa34d54de1e3dcdab1b74207ef8a24cc67a0f5d;p=vpp.git avf: check duplicate pci address upon create interface Entering duplicate pci address when creating an avf interface causes crash in register_node (gdb) f 4 145 error_exit (1); (gdb) up 354 clib_error ("more than one node named `%v'", n->name); (gdb) p n $1 = (vlib_node_t *) 0x7fffbbe55de4 (gdb) p n->name $2 = (u8 *) 0x7fffbc410b10 "avf-0/4/a/0-tx" (gdb) The fix is to loop through the pci addresses in the avf interface pool and to reject the duplicate. Type: improvement Signed-off-by: Steven Luong Change-Id: I4ed6fb630fb11982d85c5bb325d9f0d6beeaf023 --- diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index d7115044c05..32df1dfcb79 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -1469,6 +1469,19 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) if (avf_validate_queue_size (args) != 0) return; + /* *INDENT-OFF* */ + pool_foreach (adp, am->devices, ({ + if ((*adp)->pci_addr.as_u32 == args->addr.as_u32) + { + args->rv = VNET_API_ERROR_ADDRESS_IN_USE; + args->error = + clib_error_return (error, "%U: %s", format_vlib_pci_addr, + &args->addr, "pci address in use"); + return; + } + })); + /* *INDENT-ON* */ + pool_get (am->devices, adp); adp[0] = ad = clib_mem_alloc_aligned (sizeof (avf_device_t), CLIB_CACHE_LINE_BYTES);