Page MenuHomeFreeBSD

D33131.id99077.diff
No OneTemporary

D33131.id99077.diff

Index: sys/netpfil/pf/pf.c
===================================================================
--- sys/netpfil/pf/pf.c
+++ sys/netpfil/pf/pf.c
@@ -419,6 +419,40 @@
VNET_DEFINE(uint32_t, pf_hashseed);
#define V_pf_hashseed VNET(pf_hashseed)
+#ifdef __LP64__
+static int
+pf_bcmp_state_key(struct pf_state_key *k1_orig, struct pf_state_key_cmp *k2_orig)
+{
+ unsigned long *k1 = (unsigned long *)k1_orig;
+ unsigned long *k2 = (unsigned long *)k2_orig;
+
+ if (k1[0] != k2[0])
+ return (1);
+
+ if (k1[1] != k2[1])
+ return (1);
+
+ if (k1[2] != k2[2])
+ return (1);
+
+ if (k1[3] != k2[3])
+ return (1);
+
+ if (k1[4] != k2[4])
+ return (1);
+
+ return (0);
+}
+_Static_assert(sizeof(struct pf_state_key_cmp) == 40, "bad size of pf_state_key_cmp");
+#else
+static inline int
+pf_bcmp_state_key(struct pf_state_key *k1_orig, struct pf_state_key_cmp *k2_orig)
+{
+
+ return (bcmp(k1_orig, k2_orig, sizeof(struct pf_state_key_cmp)));
+}
+#endif
+
int
pf_addr_cmp(struct pf_addr *a, struct pf_addr *b, sa_family_t af)
{
@@ -1174,7 +1208,7 @@
keyattach:
LIST_FOREACH(cur, &kh->keys, entry)
- if (bcmp(cur, sk, sizeof(struct pf_state_key_cmp)) == 0)
+ if (pf_bcmp_state_key(cur, (struct pf_state_key_cmp *)sk) == 0)
break;
if (cur != NULL) {
@@ -1480,7 +1514,7 @@
PF_HASHROW_LOCK(kh);
LIST_FOREACH(sk, &kh->keys, entry)
- if (bcmp(sk, key, sizeof(struct pf_state_key_cmp)) == 0)
+ if (pf_bcmp_state_key(sk, key) == 0)
break;
if (sk == NULL) {
PF_HASHROW_UNLOCK(kh);
@@ -1527,7 +1561,7 @@
PF_HASHROW_LOCK(kh);
LIST_FOREACH(sk, &kh->keys, entry)
- if (bcmp(sk, key, sizeof(struct pf_state_key_cmp)) == 0)
+ if (pf_bcmp_state_key(sk, key) == 0)
break;
if (sk == NULL) {
PF_HASHROW_UNLOCK(kh);

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 10:26 PM (14 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773349
Default Alt Text
D33131.id99077.diff (1 KB)

Event Timeline