Skip to content

Commit 0d6f539

Browse files
matperinigsilya
authored andcommitted
ovs-router: Fix locking in ovs_router_rule_add().
ovs_router_rule_add() is annotated with OVS_REQUIRES(mutex) but its external caller rule_handle_msg() in route-table.c does not hold the mutex. This could lead to data races on the rules pvector. Fix this by changing the annotation to OVS_EXCLUDED(mutex) and acquiring the mutex inside ovs_router_rule_add() around the call to the internal ovs_router_rule_add__() function. Fixes: dc14e92 ("route-table: Introduce multi-table route lookup.") Signed-off-by: Matteo Perin <matteo.perin@canonical.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
1 parent 7c94662 commit 0d6f539

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ovs-router.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,11 +1339,13 @@ void
13391339
ovs_router_rule_add(uint32_t prio, bool invert, bool user, uint8_t src_len,
13401340
const struct in6_addr *from, uint32_t lookup_table,
13411341
bool ipv4)
1342-
OVS_REQUIRES(mutex)
1342+
OVS_EXCLUDED(mutex)
13431343
{
13441344
if (use_system_routing_table) {
1345+
ovs_mutex_lock(&mutex);
13451346
ovs_router_rule_add__(prio, invert, user, src_len, from,
13461347
lookup_table, ipv4);
1348+
ovs_mutex_unlock(&mutex);
13471349
}
13481350
}
13491351

0 commit comments

Comments
 (0)