https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217618

--- Comment #3 from l...@donnerhacke.de ---
The patch is wrong. It does include too much fields from the record, especially
nonstatic ones (e.next) or unknown ones (e.value).

The following patch runs ins a production environment.
--- sys/netpfil/ipfw/ip_fw_table_algo.c (revision 314807)
+++ sys/netpfil/ipfw/ip_fw_table_algo.c (working copy)
@@ -44,6 +44,7 @@
 #include <sys/malloc.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
+#include <sys/libkern.h>
 #include <sys/rwlock.h>
 #include <sys/rmlock.h>
 #include <sys/socket.h>
@@ -3158,30 +3171,35 @@
        return (0);
 }

+#define UPDATE_CRC(c, x)       c = calculate_crc32c(c, (const char*)&(x),
sizeof(x))
 static __inline uint32_t
 hash_flow4(struct fhashentry4 *f, int hsize)
 {
-       uint32_t i;
+       uint32_t i = ~0u;
+
+       UPDATE_CRC(i, f->sip);
+       UPDATE_CRC(i, f->dip);
+       UPDATE_CRC(i, f->e.sport);
+       UPDATE_CRC(i, f->e.dport);
+       UPDATE_CRC(i, f->e.proto);

-       i = (f->dip.s_addr) ^ (f->sip.s_addr) ^ (f->e.dport) ^ (f->e.sport);
-
-       return (i % (hsize - 1));
+       return ((~i) % (hsize - 1));
 }

 static __inline uint32_t
 hash_flow6(struct fhashentry6 *f, int hsize)
 {
-       uint32_t i;
+       uint32_t i = ~0u;
+
+       UPDATE_CRC(i, f->sip6);
+       UPDATE_CRC(i, f->dip6);
+       UPDATE_CRC(i, f->e.sport);
+       UPDATE_CRC(i, f->e.dport);
+       UPDATE_CRC(i, f->e.proto);

-       i = (f->dip6.__u6_addr.__u6_addr32[2]) ^
-           (f->dip6.__u6_addr.__u6_addr32[3]) ^
-           (f->sip6.__u6_addr.__u6_addr32[2]) ^
-           (f->sip6.__u6_addr.__u6_addr32[3]) ^
-           (f->e.dport) ^ (f->e.sport);
-
-       return (i % (hsize - 1));
+       return ((~i) % (hsize - 1));
 }
-
+#undef UPDATE_CRC
 static uint32_t
 hash_flow_ent(struct fhashentry *ent, uint32_t size)
 {

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to