diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/tipc/discover.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 3cb232d1f5d..0987933155b 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -39,13 +39,9 @@ | |||
| 39 | #include "discover.h" | 39 | #include "discover.h" |
| 40 | 40 | ||
| 41 | #define TIPC_LINK_REQ_INIT 125 /* min delay during bearer start up */ | 41 | #define TIPC_LINK_REQ_INIT 125 /* min delay during bearer start up */ |
| 42 | #define TIPC_LINK_REQ_FAST 2000 /* normal delay if bearer has no links */ | 42 | #define TIPC_LINK_REQ_FAST 1000 /* max delay if bearer has no links */ |
| 43 | #define TIPC_LINK_REQ_SLOW 600000 /* normal delay if bearer has links */ | 43 | #define TIPC_LINK_REQ_SLOW 60000 /* max delay if bearer has links */ |
| 44 | 44 | #define TIPC_LINK_REQ_INACTIVE 0xffffffff /* indicates no timer in use */ | |
| 45 | /* | ||
| 46 | * TODO: Most of the inter-cluster setup stuff should be | ||
| 47 | * rewritten, and be made conformant with specification. | ||
| 48 | */ | ||
| 49 | 45 | ||
| 50 | 46 | ||
| 51 | /** | 47 | /** |
| @@ -220,22 +216,19 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) | |||
| 220 | /** | 216 | /** |
| 221 | * disc_update - update frequency of periodic link setup requests | 217 | * disc_update - update frequency of periodic link setup requests |
| 222 | * @req: ptr to link request structure | 218 | * @req: ptr to link request structure |
| 219 | * | ||
| 220 | * Reinitiates discovery process if discovery object has no associated nodes | ||
| 221 | * and is either not currently searching or is searching at a slow rate | ||
| 223 | */ | 222 | */ |
| 224 | 223 | ||
| 225 | static void disc_update(struct link_req *req) | 224 | static void disc_update(struct link_req *req) |
| 226 | { | 225 | { |
| 227 | if (req->timer_intv == TIPC_LINK_REQ_SLOW) { | 226 | if (!req->num_nodes) { |
| 228 | if (!req->bearer->nodes.count) { | 227 | if ((req->timer_intv == TIPC_LINK_REQ_INACTIVE) || |
| 229 | req->timer_intv = TIPC_LINK_REQ_FAST; | 228 | (req->timer_intv > TIPC_LINK_REQ_FAST)) { |
| 229 | req->timer_intv = TIPC_LINK_REQ_INIT; | ||
| 230 | k_start_timer(&req->timer, req->timer_intv); | 230 | k_start_timer(&req->timer, req->timer_intv); |
| 231 | } | 231 | } |
| 232 | } else if (req->timer_intv == TIPC_LINK_REQ_FAST) { | ||
| 233 | if (req->bearer->nodes.count) { | ||
| 234 | req->timer_intv = TIPC_LINK_REQ_SLOW; | ||
| 235 | k_start_timer(&req->timer, req->timer_intv); | ||
| 236 | } | ||
| 237 | } else { | ||
| 238 | /* leave timer "as is" if haven't yet reached a "normal" rate */ | ||
| 239 | } | 232 | } |
| 240 | } | 233 | } |
| 241 | 234 | ||
| @@ -247,7 +240,6 @@ static void disc_update(struct link_req *req) | |||
| 247 | void tipc_disc_add_dest(struct link_req *req) | 240 | void tipc_disc_add_dest(struct link_req *req) |
| 248 | { | 241 | { |
| 249 | req->num_nodes++; | 242 | req->num_nodes++; |
| 250 | disc_update(req); | ||
| 251 | } | 243 | } |
| 252 | 244 | ||
| 253 | /** | 245 | /** |
| @@ -281,23 +273,37 @@ static void disc_send_msg(struct link_req *req) | |||
| 281 | 273 | ||
| 282 | static void disc_timeout(struct link_req *req) | 274 | static void disc_timeout(struct link_req *req) |
| 283 | { | 275 | { |
| 276 | int max_delay; | ||
| 277 | |||
| 284 | spin_lock_bh(&req->bearer->lock); | 278 | spin_lock_bh(&req->bearer->lock); |
| 285 | 279 | ||
| 286 | disc_send_msg(req); | 280 | /* Stop searching if only desired node has been found */ |
| 287 | 281 | ||
| 288 | if ((req->timer_intv == TIPC_LINK_REQ_SLOW) || | 282 | if (tipc_node(req->domain) && req->num_nodes) { |
| 289 | (req->timer_intv == TIPC_LINK_REQ_FAST)) { | 283 | req->timer_intv = TIPC_LINK_REQ_INACTIVE; |
| 290 | /* leave timer interval "as is" if already at a "normal" rate */ | 284 | goto exit; |
| 291 | } else { | ||
| 292 | req->timer_intv *= 2; | ||
| 293 | if (req->timer_intv > TIPC_LINK_REQ_FAST) | ||
| 294 | req->timer_intv = TIPC_LINK_REQ_FAST; | ||
| 295 | if ((req->timer_intv == TIPC_LINK_REQ_FAST) && | ||
| 296 | (req->bearer->nodes.count)) | ||
| 297 | req->timer_intv = TIPC_LINK_REQ_SLOW; | ||
| 298 | } | 285 | } |
| 299 | k_start_timer(&req->timer, req->timer_intv); | ||
| 300 | 286 | ||
| 287 | /* | ||
| 288 | * Send discovery message, then update discovery timer | ||
| 289 | * | ||
| 290 | * Keep doubling time between requests until limit is reached; | ||
| 291 | * hold at fast polling rate if don't have any associated nodes, | ||
| 292 | * otherwise hold at slow polling rate | ||
| 293 | */ | ||
| 294 | |||
| 295 | disc_send_msg(req); | ||
| 296 | |||
| 297 | req->timer_intv *= 2; | ||
| 298 | if (req->num_nodes) | ||
| 299 | max_delay = TIPC_LINK_REQ_SLOW; | ||
| 300 | else | ||
| 301 | max_delay = TIPC_LINK_REQ_FAST; | ||
| 302 | if (req->timer_intv > max_delay) | ||
| 303 | req->timer_intv = max_delay; | ||
| 304 | |||
| 305 | k_start_timer(&req->timer, req->timer_intv); | ||
| 306 | exit: | ||
| 301 | spin_unlock_bh(&req->bearer->lock); | 307 | spin_unlock_bh(&req->bearer->lock); |
| 302 | } | 308 | } |
| 303 | 309 | ||
