mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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:
@@ -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 {
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user