aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2006-10-17 00:44:59 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-10-18 22:55:16 -0400
commite91ed0bcdfc4812c0342d64281ee985213df07c3 (patch)
tree17066452681e47b8ca1d28180cd28d0cd1ec9af7 /net
parenteb5959c2bd290bf6c24ddf6d1f5ebcb496c54adb (diff)
[TIPC]: Added duplicate node address detection capability
TIPC now rejects and logs link setup requests from node <Z.C.N> if the receiving node already has a functional link to that node on the associated interface, or if the requestor is using the same <Z.C.N> as the receiver. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Per Liden <per.liden@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/bearer.c8
-rw-r--r--net/tipc/discover.c32
2 files changed, 35 insertions, 5 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 75a5968c2139..39744a33bd36 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -2,7 +2,7 @@
2 * net/tipc/bearer.c: TIPC bearer code 2 * net/tipc/bearer.c: TIPC bearer code
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -191,14 +191,14 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
191 if ((i < media_count) && (m_ptr->addr2str != NULL)) { 191 if ((i < media_count) && (m_ptr->addr2str != NULL)) {
192 char addr_str[MAX_ADDR_STR]; 192 char addr_str[MAX_ADDR_STR];
193 193
194 tipc_printf(pb, "%s(%s) ", m_ptr->name, 194 tipc_printf(pb, "%s(%s)", m_ptr->name,
195 m_ptr->addr2str(a, addr_str, sizeof(addr_str))); 195 m_ptr->addr2str(a, addr_str, sizeof(addr_str)));
196 } else { 196 } else {
197 unchar *addr = (unchar *)&a->dev_addr; 197 unchar *addr = (unchar *)&a->dev_addr;
198 198
199 tipc_printf(pb, "UNKNOWN(%u):", media_type); 199 tipc_printf(pb, "UNKNOWN(%u)", media_type);
200 for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) { 200 for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) {
201 tipc_printf(pb, "%02x ", addr[i]); 201 tipc_printf(pb, "-%02x", addr[i]);
202 } 202 }
203 } 203 }
204} 204}
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ee94de92ae99..cc748d4d4742 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -132,6 +132,28 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
132} 132}
133 133
134/** 134/**
135 * disc_dupl_alert - issue node address duplication alert
136 * @b_ptr: pointer to bearer detecting duplication
137 * @node_addr: duplicated node address
138 * @media_addr: media address advertised by duplicated node
139 */
140
141static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr,
142 struct tipc_media_addr *media_addr)
143{
144 char node_addr_str[16];
145 char media_addr_str[64];
146 struct print_buf pb;
147
148 addr_string_fill(node_addr_str, node_addr);
149 tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str));
150 tipc_media_addr_printf(&pb, media_addr);
151 tipc_printbuf_validate(&pb);
152 warn("Duplicate %s using %s seen on <%s>\n",
153 node_addr_str, media_addr_str, b_ptr->publ.name);
154}
155
156/**
135 * tipc_disc_recv_msg - handle incoming link setup message (request or response) 157 * tipc_disc_recv_msg - handle incoming link setup message (request or response)
136 * @buf: buffer containing message 158 * @buf: buffer containing message
137 */ 159 */
@@ -157,8 +179,11 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
157 return; 179 return;
158 if (!tipc_addr_node_valid(orig)) 180 if (!tipc_addr_node_valid(orig))
159 return; 181 return;
160 if (orig == tipc_own_addr) 182 if (orig == tipc_own_addr) {
183 if (memcmp(&media_addr, &b_ptr->publ.addr, sizeof(media_addr)))
184 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr);
161 return; 185 return;
186 }
162 if (!in_scope(dest, tipc_own_addr)) 187 if (!in_scope(dest, tipc_own_addr))
163 return; 188 return;
164 if (is_slave(tipc_own_addr) && is_slave(orig)) 189 if (is_slave(tipc_own_addr) && is_slave(orig))
@@ -190,6 +215,11 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
190 } 215 }
191 addr = &link->media_addr; 216 addr = &link->media_addr;
192 if (memcmp(addr, &media_addr, sizeof(*addr))) { 217 if (memcmp(addr, &media_addr, sizeof(*addr))) {
218 if (tipc_link_is_up(link) || (!link->started)) {
219 disc_dupl_alert(b_ptr, orig, &media_addr);
220 spin_unlock_bh(&n_ptr->lock);
221 return;
222 }
193 warn("Resetting link <%s>, peer interface address changed\n", 223 warn("Resetting link <%s>, peer interface address changed\n",
194 link->name); 224 link->name);
195 memcpy(addr, &media_addr, sizeof(*addr)); 225 memcpy(addr, &media_addr, sizeof(*addr));