aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-07-16 16:54:20 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-20 23:41:14 -0400
commitd3a43b907ae688af6cb753c53cd7de05f3c1ba85 (patch)
treeb21793fdb903042e7fa094856ae477cf7928090b /net
parent9d13ec65ede775f896c3da1cfa35283afe2f796c (diff)
tipc: move link creation from neighbor discoverer to node
As a step towards turning links into node internal entities, we move the creation of links from the neighbor discovery logics to the node's link control logics. We also create an additional entry for the link's media address in the newly introduced struct tipc_link_entry, since this is where it is needed in the upcoming commits. The current copy in struct tipc_link is kept for now, but will be removed later. Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/discover.c20
-rw-r--r--net/tipc/node.c27
-rw-r--r--net/tipc/node.h6
3 files changed, 37 insertions, 16 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 933445337fb4..164d08907d6f 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "core.h" 37#include "core.h"
38#include "link.h" 38#include "node.h"
39#include "discover.h" 39#include "discover.h"
40 40
41/* min delay during bearer start up */ 41/* min delay during bearer start up */
@@ -125,7 +125,6 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
125{ 125{
126 struct tipc_net *tn = net_generic(net, tipc_net_id); 126 struct tipc_net *tn = net_generic(net, tipc_net_id);
127 struct tipc_node *node; 127 struct tipc_node *node;
128 struct tipc_link *link;
129 struct tipc_media_addr maddr; 128 struct tipc_media_addr maddr;
130 struct sk_buff *rbuf; 129 struct sk_buff *rbuf;
131 struct tipc_msg *msg = buf_msg(buf); 130 struct tipc_msg *msg = buf_msg(buf);
@@ -170,13 +169,10 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
170 return; 169 return;
171 tipc_node_lock(node); 170 tipc_node_lock(node);
172 node->capabilities = caps; 171 node->capabilities = caps;
173 link = node->links[bearer->identity].link;
174 172
175 /* Prepare to validate requesting node's signature and media address */ 173 /* Prepare to validate requesting node's signature and media address */
176 sign_match = (signature == node->signature); 174 sign_match = (signature == node->signature);
177 addr_match = link && !memcmp(&link->media_addr, &maddr, sizeof(maddr)); 175 tipc_node_check_dest(node, bearer, &link_up, &addr_match, &maddr);
178 link_up = link && tipc_link_is_up(link);
179
180 176
181 /* These three flags give us eight permutations: */ 177 /* These three flags give us eight permutations: */
182 178
@@ -239,16 +235,8 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
239 if (accept_sign) 235 if (accept_sign)
240 node->signature = signature; 236 node->signature = signature;
241 237
242 if (accept_addr) { 238 if (accept_addr && !tipc_node_update_dest(node, bearer, &maddr))
243 if (!link) 239 respond = false;
244 link = tipc_link_create(node, bearer, &maddr);
245 if (link) {
246 memcpy(&link->media_addr, &maddr, sizeof(maddr));
247 tipc_link_reset(link);
248 } else {
249 respond = false;
250 }
251 }
252 240
253 /* Send response, if necessary */ 241 /* Send response, if necessary */
254 if (respond && (mtyp == DSC_REQ_MSG)) { 242 if (respond && (mtyp == DSC_REQ_MSG)) {
diff --git a/net/tipc/node.c b/net/tipc/node.c
index db46e5d1d156..06f642abdf38 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -334,6 +334,33 @@ bool tipc_node_is_up(struct tipc_node *n)
334 return n->active_links[0]; 334 return n->active_links[0];
335} 335}
336 336
337void tipc_node_check_dest(struct tipc_node *n, struct tipc_bearer *b,
338 bool *link_up, bool *addr_match,
339 struct tipc_media_addr *maddr)
340{
341 struct tipc_link *l = n->links[b->identity].link;
342 struct tipc_media_addr *curr = &n->links[b->identity].maddr;
343
344 *link_up = l && tipc_link_is_up(l);
345 *addr_match = l && !memcmp(curr, maddr, sizeof(*maddr));
346}
347
348bool tipc_node_update_dest(struct tipc_node *n, struct tipc_bearer *b,
349 struct tipc_media_addr *maddr)
350{
351 struct tipc_link *l = n->links[b->identity].link;
352 struct tipc_media_addr *curr = &n->links[b->identity].maddr;
353
354 if (!l)
355 l = tipc_link_create(n, b, maddr);
356 if (!l)
357 return false;
358 memcpy(&l->media_addr, maddr, sizeof(*maddr));
359 memcpy(curr, maddr, sizeof(*maddr));
360 tipc_link_reset(l);
361 return true;
362}
363
337void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 364void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
338{ 365{
339 n_ptr->links[l_ptr->bearer_id].link = l_ptr; 366 n_ptr->links[l_ptr->bearer_id].link = l_ptr;
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 320cea313bdc..68579c70748b 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -92,6 +92,7 @@ struct tipc_node_bclink {
92struct tipc_link_entry { 92struct tipc_link_entry {
93 struct tipc_link *link; 93 struct tipc_link *link;
94 u32 mtu; 94 u32 mtu;
95 struct tipc_media_addr maddr;
95}; 96};
96 97
97/** 98/**
@@ -143,6 +144,11 @@ struct tipc_node *tipc_node_find(struct net *net, u32 addr);
143void tipc_node_put(struct tipc_node *node); 144void tipc_node_put(struct tipc_node *node);
144struct tipc_node *tipc_node_create(struct net *net, u32 addr); 145struct tipc_node *tipc_node_create(struct net *net, u32 addr);
145void tipc_node_stop(struct net *net); 146void tipc_node_stop(struct net *net);
147void tipc_node_check_dest(struct tipc_node *n, struct tipc_bearer *bearer,
148 bool *link_up, bool *addr_match,
149 struct tipc_media_addr *maddr);
150bool tipc_node_update_dest(struct tipc_node *n, struct tipc_bearer *bearer,
151 struct tipc_media_addr *maddr);
146void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 152void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
147void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 153void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
148void tipc_node_link_down(struct tipc_node *n_ptr, int bearer_id); 154void tipc_node_link_down(struct tipc_node *n_ptr, int bearer_id);