aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-05-26 18:21:27 +0000
committerMark Johnston <markj@FreeBSD.org>2026-05-26 18:26:43 +0000
commitc564074c9aaa8a3f9273de3cb802edcb3e2e2a40 (patch)
treeead62200f2aeebb9d955bce967fd8e4adac2d124
parent00b96a777845d9b558b2303cbef03ba5197b593a (diff)
divert: Avoid using atomic_(load|store)_(acq|rel)_16
It's not implemented on some arches. Use a plain int to count the number of sockets in a divert lbgroup. Reported by: Jenkins Fixes: 895a0ae67fe2 ("divert: Define semantics for SO_REUSEPORT_LB on divert sockets")
-rw-r--r--sys/netinet/ip_divert.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 839048908f9f..390fdd9368b6 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -50,12 +50,14 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
-#include <net/vnet.h>
+
+#include <machine/atomic.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_private.h>
#include <net/netisr.h>
+#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
@@ -152,7 +154,7 @@ struct divcblbgroup {
CK_SLIST_ENTRY(divcblbgroup) dl_next;
struct epoch_context dl_epochctx;
uint16_t dl_port;
- uint16_t dl_count;
+ int dl_count;
#define DIVCBLBGROUP_SIZE 32
struct divcb *dl_dcb[DIVCBLBGROUP_SIZE];
};
@@ -297,7 +299,7 @@ divert_packet(struct mbuf *m, uint64_t id, bool incoming)
CK_SLIST_FOREACH(dlb, &V_divlbhash[DIVHASH(nport)], dl_next) {
uint16_t count;
- count = atomic_load_acq_16(&dlb->dl_count);
+ count = atomic_load_acq_int(&dlb->dl_count);
if (dlb->dl_port == nport && count > 0) {
uint32_t hash;
@@ -666,7 +668,7 @@ div_lbgroup_detach(struct divcb *dcb)
count = dlb->dl_count;
if (i != count - 1)
dlb->dl_dcb[i] = dlb->dl_dcb[count - 1];
- atomic_store_rel_16(&dlb->dl_count, count - 1);
+ atomic_store_rel_int(&dlb->dl_count, count - 1);
if (count == 1) {
CK_SLIST_REMOVE(&V_divlbhash[DCBHASH(dcb)], dlb,
divcblbgroup, dl_next);
@@ -743,7 +745,7 @@ div_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
("div_bind: lbgroup %p has count 0", tmp));
tmp->dl_dcb[tmp->dl_count] = dcb;
- atomic_store_rel_16(&tmp->dl_count, tmp->dl_count + 1);
+ atomic_store_rel_int(&tmp->dl_count, tmp->dl_count + 1);
free(dlb, M_PCB);
} else {
error = ENOSPC;