nat64: reinstate atomic operations

Turns out the atomics just needed to operate on a 64-bit variable, we
didn't actually need a newer compiler.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This commit is contained in:
Toke Høiland-Jørgensen
2021-09-30 23:11:15 +02:00
parent b6a3775b6a
commit 3b200d0153
2 changed files with 4 additions and 7 deletions

View File

@@ -6,9 +6,9 @@
struct nat64_config {
struct in6_addr v6_prefix;
__u64 timeout_ns;
__u64 next_addr;
__u32 v4_prefix;
__u32 v4_mask;
__u32 next_addr;
};
struct v6_addr_state {

View File

@@ -157,8 +157,7 @@ static struct v6_addr_state *alloc_new_state(struct in6_addr *src_v6)
for (i = 0; i < 10; i++) {
__u32 next_v4, next_addr;
// next_addr = __sync_fetch_and_add(&config.next_addr, 0);
next_addr = config.next_addr;
next_addr = __sync_fetch_and_add(&config.next_addr, 0);
next_v4 = config.v4_prefix + next_addr;
if (next_v4 >= max_v4) {
@@ -166,14 +165,12 @@ static struct v6_addr_state *alloc_new_state(struct in6_addr *src_v6)
break;
}
/* if (__sync_val_compare_and_swap(&config.next_addr,
if (__sync_val_compare_and_swap(&config.next_addr,
next_addr,
next_addr + 1) == next_addr) {
src_v4 = next_v4;
break;
}*/
config.next_addr = next_addr + 1;
src_v4 = next_v4;
}
}
/* If src_v4 is 0 here, we failed to find an available addr */