[patch 2/9] dlm: don't add duplicate node addresses

From: David Teigland
Date: Thu Jun 02 2005 - 03:03:43 EST


If an address has already been set for a node, don't add it again.

Signed-off-by: David Teigland <teigland@xxxxxxxxxx>

Index: linux/drivers/dlm/lowcomms.c
===================================================================
--- linux.orig/drivers/dlm/lowcomms.c 2005-06-02 12:28:30.000000000 +0800
+++ linux/drivers/dlm/lowcomms.c 2005-06-02 12:52:51.391577056 +0800
@@ -272,6 +272,7 @@
int dlm_set_local(int nodeid, int weight, char *addr_buf)
{
struct sockaddr_storage *addr;
+ int i;

if (local_count > DLM_MAX_ADDR_COUNT - 1) {
log_print("too many local addresses set %d", local_count);
@@ -284,7 +285,15 @@
if (!addr)
return -ENOMEM;
memcpy(addr, addr_buf, sizeof(*addr));
+
+ for (i = 0; i < local_count; i++) {
+ if (!memcmp(local_addr[i], addr, sizeof(*addr))) {
+ kfree(addr);
+ goto out;
+ }
+ }
local_addr[local_count++] = addr;
+ out:
return 0;
}


--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/