Skip to content

Commit 1209966

Browse files
ajstephensPaul Gortmaker
authored andcommitted
tipc: Add monitoring of number of nodes discovered by bearer
Augments TIPC's discovery object to track the number of neighboring nodes having an active link to the associated bearer. This means tipc_disc_update_link_req() becomes either one of: tipc_disc_add_dest() or: tipc_disc_remove_dest() depending on the code flow direction of things. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent 691a620 commit 1209966

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

‎net/tipc/bearer.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,15 @@ struct sk_buff *tipc_bearer_get_names(void)
344344
void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest)
345345
{
346346
tipc_nmap_add(&b_ptr->nodes, dest);
347-
tipc_disc_update_link_req(b_ptr->link_req);
348347
tipc_bcbearer_sort();
348+
tipc_disc_add_dest(b_ptr->link_req);
349349
}
350350

351351
void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest)
352352
{
353353
tipc_nmap_remove(&b_ptr->nodes, dest);
354-
tipc_disc_update_link_req(b_ptr->link_req);
355354
tipc_bcbearer_sort();
355+
tipc_disc_remove_dest(b_ptr->link_req);
356356
}
357357

358358
/*

‎net/tipc/discover.c‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* @bearer: bearer issuing requests
5454
* @dest: destination address for request messages
5555
* @domain: network domain to which links can be established
56+
* @num_nodes: number of nodes currently discovered (i.e. with an active link)
5657
* @buf: request message to be (repeatedly) sent
5758
* @timer: timer governing period between requests
5859
* @timer_intv: current interval between requests (in ms)
@@ -61,6 +62,7 @@ struct link_req {
6162
struct tipc_bearer *bearer;
6263
struct tipc_media_addr dest;
6364
u32 domain;
65+
int num_nodes;
6466
struct sk_buff *buf;
6567
struct timer_list timer;
6668
unsigned int timer_intv;
@@ -216,15 +218,12 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
216218
}
217219

218220
/**
219-
* tipc_disc_update_link_req - update frequency of periodic link setup requests
221+
* disc_update - update frequency of periodic link setup requests
220222
* @req: ptr to link request structure
221223
*/
222224

223-
void tipc_disc_update_link_req(struct link_req *req)
225+
static void disc_update(struct link_req *req)
224226
{
225-
if (!req)
226-
return;
227-
228227
if (req->timer_intv == TIPC_LINK_REQ_SLOW) {
229228
if (!req->bearer->nodes.count) {
230229
req->timer_intv = TIPC_LINK_REQ_FAST;
@@ -240,6 +239,28 @@ void tipc_disc_update_link_req(struct link_req *req)
240239
}
241240
}
242241

242+
/**
243+
* tipc_disc_add_dest - increment set of discovered nodes
244+
* @req: ptr to link request structure
245+
*/
246+
247+
void tipc_disc_add_dest(struct link_req *req)
248+
{
249+
req->num_nodes++;
250+
disc_update(req);
251+
}
252+
253+
/**
254+
* tipc_disc_remove_dest - decrement set of discovered nodes
255+
* @req: ptr to link request structure
256+
*/
257+
258+
void tipc_disc_remove_dest(struct link_req *req)
259+
{
260+
req->num_nodes--;
261+
disc_update(req);
262+
}
263+
243264
/**
244265
* disc_send_msg - send link setup request message
245266
* @req: ptr to link request structure
@@ -307,6 +328,7 @@ int tipc_disc_create(struct tipc_bearer *b_ptr,
307328
memcpy(&req->dest, dest, sizeof(*dest));
308329
req->bearer = b_ptr;
309330
req->domain = dest_domain;
331+
req->num_nodes = 0;
310332
req->timer_intv = TIPC_LINK_REQ_INIT;
311333
k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req);
312334
k_start_timer(&req->timer, req->timer_intv);

‎net/tipc/discover.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ struct link_req;
4242
int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest,
4343
u32 dest_domain);
4444
void tipc_disc_delete(struct link_req *req);
45-
void tipc_disc_update_link_req(struct link_req *req);
45+
void tipc_disc_add_dest(struct link_req *req);
46+
void tipc_disc_remove_dest(struct link_req *req);
4647
void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr);
4748

4849
#endif

0 commit comments

Comments
 (0)