Skip to content

Commit

Permalink
Merge "Null checks for bridge table locks"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 23, 2017
2 parents 1201a77 + 2683368 commit b28465f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions dp-core/vr_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,31 +646,32 @@ bridge_table_deinit(struct vr_rtable *rtable, struct rtable_fspec *fs,
static void
bridge_table_unlock(struct vr_interface *vif, uint8_t *mac, int cpu)
{
if (cpu < 0 || !vif->vif_bridge_table_lock)
uint8_t *bridge_table_lock = vif->vif_bridge_table_lock;

if (cpu < 0 || !bridge_table_lock)
return;

vif->vif_bridge_table_lock[cpu] = 0;
bridge_table_lock[cpu] = 0;

return;
}

static int
bridge_table_lock(struct vr_interface *vif, uint8_t *mac)
{
uint8_t lock = 1;
uint8_t lock = 1, *bridge_table_lock = vif->vif_bridge_table_lock;
uint32_t hash;
unsigned long t1s, t1ns, t2s, t2ns, diff;

if (!vif->vif_bridge_table_lock)
if (!bridge_table_lock)
return -EINVAL;

hash = vr_hash(mac, VR_ETHER_ALEN, 0);
hash %= vr_num_cpus;

vr_get_mono_time(&t1s, &t1ns);
while (lock) {
lock = __sync_lock_test_and_set(&vif->vif_bridge_table_lock[hash],
lock);
lock = __sync_lock_test_and_set(&bridge_table_lock[hash], lock);
if (lock) {
vr_get_mono_time(&t2s, &t2ns);
if (t2ns >= t1ns) {
Expand Down

0 comments on commit b28465f

Please sign in to comment.