summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDmitry Vakrhushev <dmitry@netgate.com>2021-02-12 00:42:40 +0300
committerMatthew Smith <mgsmith@netgate.com>2021-03-12 13:47:40 +0000
commit4e3f7b2869925b0812a58d04c4bf6371e6773630 (patch)
tree381bbb25035d8217c6ea9ce81724b49305cebbee /src/vnet
parent0ac8d857a553eb3fadcc2611004ed8492b3bcfa5 (diff)
interface: fix extra locking on fib/mfib table
Unlocking previeous fib/mfib table before bind it to a new. Currently if rebind interface table from one to another, previous table's lock wouldn't decrease the locks count. Type: fix Change-Id: I09340baf1c7039aed3be15ee231eded7364b213e Signed-off-by: Dmitry Vakrhushev <dmitry@netgate.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface_api.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 5b2f2fc0788..2cf6d9e4dcd 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -539,18 +539,15 @@ ip_table_bind (fib_protocol_t fproto,
fib_index,
ip6_main.fib_index_by_sw_if_index[sw_if_index]);
- if (0 == table_id)
- {
- /* reset back to default */
- if (0 != ip6_main.fib_index_by_sw_if_index[sw_if_index])
- fib_table_unlock (ip6_main.fib_index_by_sw_if_index[sw_if_index],
- FIB_PROTOCOL_IP6, src);
- if (0 != ip6_main.mfib_index_by_sw_if_index[sw_if_index])
- mfib_table_unlock (ip6_main.mfib_index_by_sw_if_index
- [sw_if_index], FIB_PROTOCOL_IP6, msrc);
-
- }
- else
+ /* unlock currently assigned tables */
+ if (0 != ip6_main.fib_index_by_sw_if_index[sw_if_index])
+ fib_table_unlock (ip6_main.fib_index_by_sw_if_index[sw_if_index],
+ FIB_PROTOCOL_IP6, src);
+ if (0 != ip6_main.mfib_index_by_sw_if_index[sw_if_index])
+ mfib_table_unlock (ip6_main.mfib_index_by_sw_if_index[sw_if_index],
+ FIB_PROTOCOL_IP6, msrc);
+
+ if (0 != table_id)
{
/* we need to lock the table now it's inuse */
fib_table_lock (fib_index, FIB_PROTOCOL_IP6, src);
@@ -590,18 +587,15 @@ ip_table_bind (fib_protocol_t fproto,
fib_index,
ip4_main.fib_index_by_sw_if_index[sw_if_index]);
- if (0 == table_id)
- {
- /* reset back to default */
- if (0 != ip4_main.fib_index_by_sw_if_index[sw_if_index])
- fib_table_unlock (ip4_main.fib_index_by_sw_if_index[sw_if_index],
- FIB_PROTOCOL_IP4, src);
- if (0 != ip4_main.mfib_index_by_sw_if_index[sw_if_index])
- mfib_table_unlock (ip4_main.mfib_index_by_sw_if_index
- [sw_if_index], FIB_PROTOCOL_IP4, msrc);
+ /* unlock currently assigned tables */
+ if (0 != ip4_main.fib_index_by_sw_if_index[sw_if_index])
+ fib_table_unlock (ip4_main.fib_index_by_sw_if_index[sw_if_index],
+ FIB_PROTOCOL_IP4, src);
+ if (0 != ip4_main.mfib_index_by_sw_if_index[sw_if_index])
+ mfib_table_unlock (ip4_main.mfib_index_by_sw_if_index[sw_if_index],
+ FIB_PROTOCOL_IP4, msrc);
- }
- else
+ if (0 != table_id)
{
/* we need to lock the table now it's inuse */
fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4,