I think the problem is indeed ATOMIC_INCL.
It seems to be defined as:
for FreeBSD version > 500043
However:
cpp /usr/include/machine/atomic.h produces:
void atomic_add_long(volatile u_long *p, u_long v);
So a pointer is required. It also seems to be that way on FreeBSD 4.
FreeBSD_version 500043 introduced a third argument for mtx_init.
There are some more bugs in the section defining these macro's fro FreeBSD.
I also had to change the ATOMIC_INCL to ATOMIC_INC64 for fr->fr_hits,
fr_authstats.fas_hist and fas_miss, to get rid of other atomic_add_long
warnings. However this is probably not completely correct as it
depends on how U_QUAD_T is defined. The other U_QUAD_T values seem
to just use the '+' operator (probably with some locking).
The following patch fixes my problems...
-Guido
--- ip_compat.h.orig Wed Aug 25 13:40:19 2004
+++ ip_compat.h Wed Aug 25 13:45:38 2004
@@ -856,14 +856,14 @@
mtx_unlock(&ipf_rw.ipf_lk); }
# define ATOMIC_DEC(x) { mtx_lock(&ipf_rw.ipf_lk); (x)--; \
mtx_unlock(&ipf_rw.ipf_lk); }
-# define ATOMIC_INCL(x) atomic_add_long(x, 1)
+# define ATOMIC_INCL(x) atomic_add_long(&x, 1)
# define ATOMIC_INC64(x) ATOMIC_INC(x)
-# define ATOMIC_INC32(x) atomic_add_32(x, 1)
-# define ATOMIC_INC16(x) atomic_add_16(x, 1)
-# define ATOMIC_DECL(x) ATOMIC_DEC(x)
-# define ATOMIC_DEC64(x) atomic_subtract_(x, -1)
-# define ATOMIC_DEC32(x) atomic_subtract_32(x, -1)
-# define ATOMIC_DEC16(x) atomic_subtract_16(x, -1)
+# define ATOMIC_INC32(x) atomic_add_32(&x, 1)
+# define ATOMIC_INC16(x) atomic_add_16(&x, 1)
+# define ATOMIC_DECL(x) atomic_add_long(&x, -11)
+# define ATOMIC_DEC64(x) ATOMIC_DEC(x)
+# define ATOMIC_DEC32(x) atomic_add_32(&x, -1)
+# define ATOMIC_DEC16(x) atomic_add_16(&x, -1)
# define SPL_X(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
--- fil.c.orig Wed Jun 30 13:26:08 2004
+++ fil.c Wed Aug 25 13:51:29 2004
@@ -1766,7 +1766,7 @@
* it, except for increasing the hit counter.
*/
if ((passt & FR_CALLNOW) != 0) {
- ATOMIC_INCL(fr->fr_hits);
+ ATOMIC_INC64(fr->fr_hits);
if ((fr->fr_func != NULL) &&
(fr->fr_func != (ipfunc_t)-1)) {
frentry_t *frs;
@@ -1809,7 +1809,7 @@
if (passt & (FR_RETICMP|FR_FAKEICMP))
fin->fin_icode = fr->fr_icode;
FR_DEBUG(("pass %#x\n", pass));
- ATOMIC_INCL(fr->fr_hits);
+ ATOMIC_INC64(fr->fr_hits);
fin->fin_rule = rulen;
(void) strncpy(fin->fin_group, fr->fr_group, FR_GROUPLEN);
if (fr->fr_grp != NULL) {
@@ -1918,7 +1918,7 @@
bcopy((char *)fc, (char *)fin, FI_COPYSIZE);
ATOMIC_INCL(frstats[out].fr_chit);
if ((fr = fin->fin_fr) != NULL) {
- ATOMIC_INCL(fr->fr_hits);
+ ATOMIC_INC64(fr->fr_hits);
pass = fr->fr_flags;
}
} else {
--- ip_auth.c.orig Wed Aug 25 13:58:11 2004
+++ ip_auth.c Wed Aug 25 13:57:48 2004
@@ -260,7 +260,7 @@
RWLOCK_EXIT(&ipf_auth);
if (passp != NULL)
*passp = pass;
- ATOMIC_INCL(fr_authstats.fas_hits);
+ ATOMIC_INC64(fr_authstats.fas_hits);
return fr;
}
i++;
@@ -269,7 +269,7 @@
}
fr_authstats.fas_miss++;
RWLOCK_EXIT(&ipf_auth);
- ATOMIC_INCL(fr_authstats.fas_miss);
+ ATOMIC_INC64(fr_authstats.fas_miss);
return NULL;
}