netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/core/flow.c: compare data with memcmp
@ 2006-12-31 16:37 Daniel Marjamäki
  2006-12-31 19:49 ` [KJ] " Nishanth Aravamudan
  2006-12-31 20:37 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Marjamäki @ 2006-12-31 16:37 UTC (permalink / raw)
  To: netdev; +Cc: kernel-janitors, linux-kernel

From: Daniel Marjamäki
This has been tested by me.
Signed-off-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
--- linux-2.6.20-rc2/net/core/flow.c	2006-12-27 09:59:56.000000000 +0100
+++ linux/net/core/flow.c	2006-12-31 18:26:06.000000000 +0100
@@ -144,29 +144,16 @@ typedef u32 flow_compare_t;

 extern void flowi_is_missized(void);

-/* I hear what you're saying, use memcmp.  But memcmp cannot make
- * important assumptions that we can here, such as alignment and
- * constant size.
- */
 static int flow_key_compare(struct flowi *key1, struct flowi *key2)
 {
-	flow_compare_t *k1, *k1_lim, *k2;
-	const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
-
 	if (sizeof(struct flowi) % sizeof(flow_compare_t))
 		flowi_is_missized();

-	k1 = (flow_compare_t *) key1;
-	k1_lim = k1 + n_elem;
-
-	k2 = (flow_compare_t *) key2;
-
-	do {
-		if (*k1++ != *k2++)
-			return 1;
-	} while (k1 < k1_lim);
+	/* Number of elements to compare */
+	const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);

-	return 0;
+	/* Compare all elements in key1 and key2. */
+	return memcmp(key1, key2, n_elem * sizeof(flow_compare_t));
 }

 void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-01-02 23:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-31 16:37 [PATCH] net/core/flow.c: compare data with memcmp Daniel Marjamäki
2006-12-31 19:49 ` [KJ] " Nishanth Aravamudan
2006-12-31 20:37 ` David Miller
2007-01-01  7:47   ` Daniel Marjamäki
2007-01-01  8:49     ` David Miller
2007-01-01  9:16     ` Daniel Marjamäki
2007-01-02 23:36       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).