Blame view
net/tipc/discover.c
12.6 KB
b97bf3fd8 [TIPC] Initial merge |
1 2 |
/* * net/tipc/discover.c |
c43072852 [NET] TIPC: Fix w... |
3 |
* |
25b0b9c4e tipc: handle coll... |
4 |
* Copyright (c) 2003-2006, 2014-2018, Ericsson AB |
2d627b92f tipc: Combine bea... |
5 |
* Copyright (c) 2005-2006, 2010-2011, Wind River Systems |
b97bf3fd8 [TIPC] Initial merge |
6 7 |
* All rights reserved. * |
9ea1fd3c1 [TIPC] License he... |
8 |
* Redistribution and use in source and binary forms, with or without |
b97bf3fd8 [TIPC] Initial merge |
9 10 |
* modification, are permitted provided that the following conditions are met: * |
9ea1fd3c1 [TIPC] License he... |
11 12 13 14 15 16 17 18 |
* 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. |
b97bf3fd8 [TIPC] Initial merge |
19 |
* |
9ea1fd3c1 [TIPC] License he... |
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
* Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
b97bf3fd8 [TIPC] Initial merge |
34 35 36 37 |
* POSSIBILITY OF SUCH DAMAGE. */ #include "core.h" |
d3a43b907 tipc: move link c... |
38 |
#include "node.h" |
b97bf3fd8 [TIPC] Initial merge |
39 |
#include "discover.h" |
b97bf3fd8 [TIPC] Initial merge |
40 |
|
2f55c4378 tipc: remove unne... |
41 |
/* min delay during bearer start up */ |
b39e465e5 tipc: some cleanu... |
42 |
#define TIPC_DISC_INIT msecs_to_jiffies(125) |
2f55c4378 tipc: remove unne... |
43 |
/* max delay if bearer has no links */ |
b39e465e5 tipc: some cleanu... |
44 |
#define TIPC_DISC_FAST msecs_to_jiffies(1000) |
2f55c4378 tipc: remove unne... |
45 |
/* max delay if bearer has links */ |
b39e465e5 tipc: some cleanu... |
46 |
#define TIPC_DISC_SLOW msecs_to_jiffies(60000) |
2f55c4378 tipc: remove unne... |
47 |
/* indicates no timer in use */ |
b39e465e5 tipc: some cleanu... |
48 |
#define TIPC_DISC_INACTIVE 0xffffffff |
b97bf3fd8 [TIPC] Initial merge |
49 |
|
b97bf3fd8 [TIPC] Initial merge |
50 |
/** |
b39e465e5 tipc: some cleanu... |
51 |
* struct tipc_discoverer - information about an ongoing link setup request |
7a2f7d18e tipc: decouple th... |
52 |
* @bearer_id: identity of bearer issuing requests |
7f9f95d9d tipc: make bearer... |
53 |
* @net: network namespace instance |
b97bf3fd8 [TIPC] Initial merge |
54 |
* @dest: destination address for request messages |
7a2f7d18e tipc: decouple th... |
55 |
* @domain: network domain to which links can be established |
1209966cd tipc: Add monitor... |
56 |
* @num_nodes: number of nodes currently discovered (i.e. with an active link) |
f9a2c80b8 tipc: introduce n... |
57 |
* @lock: spinlock for controlling access to requests |
b39e465e5 tipc: some cleanu... |
58 |
* @skb: request message to be (repeatedly) sent |
b97bf3fd8 [TIPC] Initial merge |
59 60 61 |
* @timer: timer governing period between requests * @timer_intv: current interval between requests (in ms) */ |
b39e465e5 tipc: some cleanu... |
62 |
struct tipc_discoverer { |
7a2f7d18e tipc: decouple th... |
63 |
u32 bearer_id; |
b97bf3fd8 [TIPC] Initial merge |
64 |
struct tipc_media_addr dest; |
7f9f95d9d tipc: make bearer... |
65 |
struct net *net; |
7a2f7d18e tipc: decouple th... |
66 |
u32 domain; |
1209966cd tipc: Add monitor... |
67 |
int num_nodes; |
f9a2c80b8 tipc: introduce n... |
68 |
spinlock_t lock; |
b39e465e5 tipc: some cleanu... |
69 |
struct sk_buff *skb; |
b97bf3fd8 [TIPC] Initial merge |
70 |
struct timer_list timer; |
2f55c4378 tipc: remove unne... |
71 |
unsigned long timer_intv; |
b97bf3fd8 [TIPC] Initial merge |
72 |
}; |
c43072852 [NET] TIPC: Fix w... |
73 |
/** |
4323add67 [TIPC] Avoid poll... |
74 |
* tipc_disc_init_msg - initialize a link setup message |
c93d3baa2 tipc: involve nam... |
75 |
* @net: the applicable net namespace |
d8141208b net: tipc: kernel... |
76 |
* @mtyp: message type (request or response) |
1a90632da tipc: eliminate r... |
77 |
* @b: ptr to bearer issuing message |
b97bf3fd8 [TIPC] Initial merge |
78 |
*/ |
b39e465e5 tipc: some cleanu... |
79 |
static void tipc_disc_init_msg(struct net *net, struct sk_buff *skb, |
25b0b9c4e tipc: handle coll... |
80 |
u32 mtyp, struct tipc_bearer *b) |
b97bf3fd8 [TIPC] Initial merge |
81 |
{ |
b39e465e5 tipc: some cleanu... |
82 |
struct tipc_net *tn = tipc_net(net); |
1a90632da tipc: eliminate r... |
83 |
u32 dest_domain = b->domain; |
b39e465e5 tipc: some cleanu... |
84 |
struct tipc_msg *hdr; |
b97bf3fd8 [TIPC] Initial merge |
85 |
|
b39e465e5 tipc: some cleanu... |
86 |
hdr = buf_msg(skb); |
25b0b9c4e tipc: handle coll... |
87 |
tipc_msg_init(tn->trial_addr, hdr, LINK_CONFIG, mtyp, |
948fa2d11 tipc: increase si... |
88 |
MAX_H_SIZE, dest_domain); |
25b0b9c4e tipc: handle coll... |
89 |
msg_set_size(hdr, MAX_H_SIZE + NODE_ID_LEN); |
b39e465e5 tipc: some cleanu... |
90 91 92 93 94 95 |
msg_set_non_seq(hdr, 1); msg_set_node_sig(hdr, tn->random); msg_set_node_capabilities(hdr, TIPC_NODE_CAPABILITIES); msg_set_dest_domain(hdr, dest_domain); msg_set_bc_netid(hdr, tn->net_id); b->media->addr2msg(msg_media_addr(hdr), &b->addr); |
f73b12812 tipc: improve thr... |
96 |
msg_set_peer_net_hash(hdr, tipc_net_hash_mixes(net, tn->random)); |
25b0b9c4e tipc: handle coll... |
97 |
msg_set_node_id(hdr, tipc_own_id(net)); |
b39e465e5 tipc: some cleanu... |
98 |
} |
25b0b9c4e tipc: handle coll... |
99 100 |
static void tipc_disc_msg_xmit(struct net *net, u32 mtyp, u32 dst, u32 src, u32 sugg_addr, |
b39e465e5 tipc: some cleanu... |
101 102 103 |
struct tipc_media_addr *maddr, struct tipc_bearer *b) { |
25b0b9c4e tipc: handle coll... |
104 |
struct tipc_msg *hdr; |
b39e465e5 tipc: some cleanu... |
105 |
struct sk_buff *skb; |
25b0b9c4e tipc: handle coll... |
106 |
skb = tipc_buf_acquire(MAX_H_SIZE + NODE_ID_LEN, GFP_ATOMIC); |
b39e465e5 tipc: some cleanu... |
107 108 |
if (!skb) return; |
25b0b9c4e tipc: handle coll... |
109 |
hdr = buf_msg(skb); |
b39e465e5 tipc: some cleanu... |
110 |
tipc_disc_init_msg(net, skb, mtyp, b); |
25b0b9c4e tipc: handle coll... |
111 112 |
msg_set_sugg_node_addr(hdr, sugg_addr); msg_set_dest_domain(hdr, dst); |
b39e465e5 tipc: some cleanu... |
113 |
tipc_bearer_xmit_skb(net, b->identity, skb, maddr); |
b97bf3fd8 [TIPC] Initial merge |
114 115 116 |
} /** |
e91ed0bcd [TIPC]: Added dup... |
117 |
* disc_dupl_alert - issue node address duplication alert |
1a90632da tipc: eliminate r... |
118 |
* @b: pointer to bearer detecting duplication |
e91ed0bcd [TIPC]: Added dup... |
119 120 121 |
* @node_addr: duplicated node address * @media_addr: media address advertised by duplicated node */ |
1a90632da tipc: eliminate r... |
122 |
static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr, |
e91ed0bcd [TIPC]: Added dup... |
123 124 |
struct tipc_media_addr *media_addr) { |
e91ed0bcd [TIPC]: Added dup... |
125 |
char media_addr_str[64]; |
e91ed0bcd [TIPC]: Added dup... |
126 |
|
dc1aed37d tipc: phase out m... |
127 128 |
tipc_media_addr_printf(media_addr_str, sizeof(media_addr_str), media_addr); |
d50ccc2d3 tipc: add 128-bit... |
129 130 |
pr_warn("Duplicate %x using %s seen on <%s> ", node_addr, |
1a90632da tipc: eliminate r... |
131 |
media_addr_str, b->name); |
e91ed0bcd [TIPC]: Added dup... |
132 |
} |
25b0b9c4e tipc: handle coll... |
133 |
/* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer |
e415577f5 tipc: correct dis... |
134 135 |
* Returns true if message should be dropped by caller, i.e., if it is a * trial message or we are inside trial period. Otherwise false. |
25b0b9c4e tipc: handle coll... |
136 |
*/ |
da18ab32d tipc: tipc_disc_a... |
137 138 139 140 141 142 143 |
static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, struct tipc_media_addr *maddr, struct tipc_bearer *b, u32 dst, u32 src, u32 sugg_addr, u8 *peer_id, int mtyp) |
25b0b9c4e tipc: handle coll... |
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
{ struct net *net = d->net; struct tipc_net *tn = tipc_net(net); bool trial = time_before(jiffies, tn->addr_trial_end); u32 self = tipc_own_addr(net); if (mtyp == DSC_TRIAL_FAIL_MSG) { if (!trial) return true; /* Ignore if somebody else already gave new suggestion */ if (dst != tn->trial_addr) return true; /* Otherwise update trial address and restart trial period */ tn->trial_addr = sugg_addr; msg_set_prevnode(buf_msg(d->skb), sugg_addr); tn->addr_trial_end = jiffies + msecs_to_jiffies(1000); return true; } /* Apply trial address if we just left trial period */ if (!trial && !self) { |
adba75be0 tipc: fix lockdep... |
167 168 |
tipc_sched_net_finalize(net, tn->trial_addr); msg_set_prevnode(buf_msg(d->skb), tn->trial_addr); |
25b0b9c4e tipc: handle coll... |
169 170 |
msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); } |
e415577f5 tipc: correct dis... |
171 |
/* Accept regular link requests/responses only after trial period */ |
25b0b9c4e tipc: handle coll... |
172 |
if (mtyp != DSC_TRIAL_MSG) |
e415577f5 tipc: correct dis... |
173 |
return trial; |
25b0b9c4e tipc: handle coll... |
174 175 176 177 178 179 180 |
sugg_addr = tipc_node_try_addr(net, peer_id, src); if (sugg_addr) tipc_disc_msg_xmit(net, DSC_TRIAL_FAIL_MSG, src, self, sugg_addr, maddr, b); return true; } |
e91ed0bcd [TIPC]: Added dup... |
181 |
/** |
c82910e2a tipc: clean up ne... |
182 |
* tipc_disc_rcv - handle incoming discovery message (request or response) |
b39e465e5 tipc: some cleanu... |
183 184 185 |
* @net: applicable net namespace * @skb: buffer containing message * @b: bearer that message arrived on |
b97bf3fd8 [TIPC] Initial merge |
186 |
*/ |
cf148816a tipc: move receiv... |
187 |
void tipc_disc_rcv(struct net *net, struct sk_buff *skb, |
b39e465e5 tipc: some cleanu... |
188 |
struct tipc_bearer *b) |
b97bf3fd8 [TIPC] Initial merge |
189 |
{ |
b39e465e5 tipc: some cleanu... |
190 |
struct tipc_net *tn = tipc_net(net); |
cf148816a tipc: move receiv... |
191 |
struct tipc_msg *hdr = buf_msg(skb); |
31e4ccc99 tipc: fix use-aft... |
192 |
u32 pnet_hash = msg_peer_net_hash(hdr); |
b39e465e5 tipc: some cleanu... |
193 |
u16 caps = msg_node_capabilities(hdr); |
b89afb116 tipc: allow close... |
194 |
bool legacy = tn->legacy_addr_format; |
25b0b9c4e tipc: handle coll... |
195 |
u32 sugg = msg_sugg_node_addr(hdr); |
b39e465e5 tipc: some cleanu... |
196 |
u32 signature = msg_node_sig(hdr); |
25b0b9c4e tipc: handle coll... |
197 |
u8 peer_id[NODE_ID_LEN] = {0,}; |
b39e465e5 tipc: some cleanu... |
198 |
u32 dst = msg_dest_domain(hdr); |
cf148816a tipc: move receiv... |
199 |
u32 net_id = msg_bc_netid(hdr); |
b39e465e5 tipc: some cleanu... |
200 201 |
struct tipc_media_addr maddr; u32 src = msg_prevnode(hdr); |
cf148816a tipc: move receiv... |
202 |
u32 mtyp = msg_type(hdr); |
cf148816a tipc: move receiv... |
203 |
bool dupl_addr = false; |
b39e465e5 tipc: some cleanu... |
204 |
bool respond = false; |
25b0b9c4e tipc: handle coll... |
205 |
u32 self; |
e99429232 tipc: honor msg2a... |
206 |
int err; |
b97bf3fd8 [TIPC] Initial merge |
207 |
|
25b0b9c4e tipc: handle coll... |
208 209 210 211 212 213 214 |
skb_linearize(skb); hdr = buf_msg(skb); if (caps & TIPC_NODE_ID128) memcpy(peer_id, msg_node_id(hdr), NODE_ID_LEN); else sprintf(peer_id, "%x", src); |
b39e465e5 tipc: some cleanu... |
215 |
err = b->media->msg2addr(b, &maddr, msg_media_addr(hdr)); |
cf148816a tipc: move receiv... |
216 |
kfree_skb(skb); |
b39e465e5 tipc: some cleanu... |
217 218 219 |
if (err || maddr.broadcast) { pr_warn_ratelimited("Rcv corrupt discovery message "); |
e99429232 tipc: honor msg2a... |
220 |
return; |
b39e465e5 tipc: some cleanu... |
221 222 223 |
} /* Ignore discovery messages from own node */ if (!memcmp(&maddr, &b->addr, sizeof(maddr))) |
b97bf3fd8 [TIPC] Initial merge |
224 |
return; |
b39e465e5 tipc: some cleanu... |
225 |
if (net_id != tn->net_id) |
d6d4577ae tipc: Ignore neig... |
226 |
return; |
25b0b9c4e tipc: handle coll... |
227 228 229 230 231 232 |
if (tipc_disc_addr_trial_msg(b->disc, &maddr, b, dst, src, sugg, peer_id, mtyp)) return; self = tipc_own_addr(net); /* Message from somebody using this node's address */ |
b39e465e5 tipc: some cleanu... |
233 234 |
if (in_own_node(net, src)) { disc_dupl_alert(b, self, &maddr); |
b97bf3fd8 [TIPC] Initial merge |
235 |
return; |
e91ed0bcd [TIPC]: Added dup... |
236 |
} |
b89afb116 tipc: allow close... |
237 238 239 240 |
if (!tipc_in_scope(legacy, dst, self)) return; if (!tipc_in_scope(legacy, b->domain, src)) return; |
31e4ccc99 tipc: fix use-aft... |
241 242 |
tipc_node_check_dest(net, src, peer_id, b, caps, signature, pnet_hash, &maddr, &respond, &dupl_addr); |
cf148816a tipc: move receiv... |
243 |
if (dupl_addr) |
b39e465e5 tipc: some cleanu... |
244 245 246 247 248 |
disc_dupl_alert(b, src, &maddr); if (!respond) return; if (mtyp != DSC_REQ_MSG) return; |
25b0b9c4e tipc: handle coll... |
249 |
tipc_disc_msg_xmit(net, DSC_RESP_MSG, src, self, 0, &maddr, b); |
b97bf3fd8 [TIPC] Initial merge |
250 |
} |
b39e465e5 tipc: some cleanu... |
251 |
/* tipc_disc_add_dest - increment set of discovered nodes |
b97bf3fd8 [TIPC] Initial merge |
252 |
*/ |
b39e465e5 tipc: some cleanu... |
253 |
void tipc_disc_add_dest(struct tipc_discoverer *d) |
b97bf3fd8 [TIPC] Initial merge |
254 |
{ |
b39e465e5 tipc: some cleanu... |
255 256 257 |
spin_lock_bh(&d->lock); d->num_nodes++; spin_unlock_bh(&d->lock); |
c43072852 [NET] TIPC: Fix w... |
258 |
} |
b97bf3fd8 [TIPC] Initial merge |
259 |
|
b39e465e5 tipc: some cleanu... |
260 |
/* tipc_disc_remove_dest - decrement set of discovered nodes |
1209966cd tipc: Add monitor... |
261 |
*/ |
b39e465e5 tipc: some cleanu... |
262 |
void tipc_disc_remove_dest(struct tipc_discoverer *d) |
1209966cd tipc: Add monitor... |
263 |
{ |
b39e465e5 tipc: some cleanu... |
264 |
int intv, num; |
1209966cd tipc: Add monitor... |
265 |
|
b39e465e5 tipc: some cleanu... |
266 267 268 269 270 271 272 273 274 |
spin_lock_bh(&d->lock); d->num_nodes--; num = d->num_nodes; intv = d->timer_intv; if (!num && (intv == TIPC_DISC_INACTIVE || intv > TIPC_DISC_FAST)) { d->timer_intv = TIPC_DISC_INIT; mod_timer(&d->timer, jiffies + d->timer_intv); } spin_unlock_bh(&d->lock); |
1209966cd tipc: Add monitor... |
275 |
} |
b39e465e5 tipc: some cleanu... |
276 |
/* tipc_disc_timeout - send a periodic link setup request |
b97bf3fd8 [TIPC] Initial merge |
277 |
* Called whenever a link setup request timer associated with a bearer expires. |
b39e465e5 tipc: some cleanu... |
278 279 280 |
* - Keep doubling time between sent request until limit is reached; * - Hold at fast polling rate if we don't have any associated nodes * - Otherwise hold at slow polling rate |
b97bf3fd8 [TIPC] Initial merge |
281 |
*/ |
b39e465e5 tipc: some cleanu... |
282 |
static void tipc_disc_timeout(struct timer_list *t) |
b97bf3fd8 [TIPC] Initial merge |
283 |
{ |
b39e465e5 tipc: some cleanu... |
284 |
struct tipc_discoverer *d = from_timer(d, t, timer); |
25b0b9c4e tipc: handle coll... |
285 |
struct tipc_net *tn = tipc_net(d->net); |
b39e465e5 tipc: some cleanu... |
286 287 |
struct tipc_media_addr maddr; struct sk_buff *skb = NULL; |
25b0b9c4e tipc: handle coll... |
288 |
struct net *net = d->net; |
b39e465e5 tipc: some cleanu... |
289 |
u32 bearer_id; |
972a77fbf tipc: Revise timi... |
290 |
|
b39e465e5 tipc: some cleanu... |
291 |
spin_lock_bh(&d->lock); |
b97bf3fd8 [TIPC] Initial merge |
292 |
|
972a77fbf tipc: Revise timi... |
293 |
/* Stop searching if only desired node has been found */ |
b39e465e5 tipc: some cleanu... |
294 295 |
if (tipc_node(d->domain) && d->num_nodes) { d->timer_intv = TIPC_DISC_INACTIVE; |
972a77fbf tipc: Revise timi... |
296 |
goto exit; |
b97bf3fd8 [TIPC] Initial merge |
297 |
} |
25b0b9c4e tipc: handle coll... |
298 |
|
adba75be0 tipc: fix lockdep... |
299 300 301 302 303 304 |
/* Did we just leave trial period ? */ if (!time_before(jiffies, tn->addr_trial_end) && !tipc_own_addr(net)) { mod_timer(&d->timer, jiffies + TIPC_DISC_INIT); spin_unlock_bh(&d->lock); tipc_sched_net_finalize(net, tn->trial_addr); return; |
25b0b9c4e tipc: handle coll... |
305 |
} |
b39e465e5 tipc: some cleanu... |
306 |
/* Adjust timeout interval according to discovery phase */ |
25b0b9c4e tipc: handle coll... |
307 308 309 310 311 312 313 314 |
if (time_before(jiffies, tn->addr_trial_end)) { d->timer_intv = TIPC_DISC_INIT; } else { d->timer_intv *= 2; if (d->num_nodes && d->timer_intv > TIPC_DISC_SLOW) d->timer_intv = TIPC_DISC_SLOW; else if (!d->num_nodes && d->timer_intv > TIPC_DISC_FAST) d->timer_intv = TIPC_DISC_FAST; |
adba75be0 tipc: fix lockdep... |
315 316 |
msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); msg_set_prevnode(buf_msg(d->skb), tn->trial_addr); |
25b0b9c4e tipc: handle coll... |
317 |
} |
b39e465e5 tipc: some cleanu... |
318 319 320 |
mod_timer(&d->timer, jiffies + d->timer_intv); memcpy(&maddr, &d->dest, sizeof(maddr)); skb = skb_clone(d->skb, GFP_ATOMIC); |
b39e465e5 tipc: some cleanu... |
321 |
bearer_id = d->bearer_id; |
972a77fbf tipc: Revise timi... |
322 |
exit: |
b39e465e5 tipc: some cleanu... |
323 324 325 |
spin_unlock_bh(&d->lock); if (skb) tipc_bearer_xmit_skb(net, bearer_id, skb, &maddr); |
b97bf3fd8 [TIPC] Initial merge |
326 327 328 |
} /** |
3a777ff8b tipc: Enhance han... |
329 |
* tipc_disc_create - create object to send periodic link setup requests |
c93d3baa2 tipc: involve nam... |
330 |
* @net: the applicable net namespace |
1a90632da tipc: eliminate r... |
331 |
* @b: ptr to bearer issuing requests |
b97bf3fd8 [TIPC] Initial merge |
332 |
* @dest: destination address for request messages |
d8141208b net: tipc: kernel... |
333 |
* @skb: pointer to created frame |
c43072852 [NET] TIPC: Fix w... |
334 |
* |
3a777ff8b tipc: Enhance han... |
335 |
* Returns 0 if successful, otherwise -errno. |
b97bf3fd8 [TIPC] Initial merge |
336 |
*/ |
1a90632da tipc: eliminate r... |
337 |
int tipc_disc_create(struct net *net, struct tipc_bearer *b, |
4e801fa14 tipc: eliminate b... |
338 |
struct tipc_media_addr *dest, struct sk_buff **skb) |
b97bf3fd8 [TIPC] Initial merge |
339 |
{ |
25b0b9c4e tipc: handle coll... |
340 |
struct tipc_net *tn = tipc_net(net); |
b39e465e5 tipc: some cleanu... |
341 |
struct tipc_discoverer *d; |
b97bf3fd8 [TIPC] Initial merge |
342 |
|
b39e465e5 tipc: some cleanu... |
343 344 |
d = kmalloc(sizeof(*d), GFP_ATOMIC); if (!d) |
3a777ff8b tipc: Enhance han... |
345 |
return -ENOMEM; |
25b0b9c4e tipc: handle coll... |
346 |
d->skb = tipc_buf_acquire(MAX_H_SIZE + NODE_ID_LEN, GFP_ATOMIC); |
b39e465e5 tipc: some cleanu... |
347 348 |
if (!d->skb) { kfree(d); |
a8b9b96e9 tipc: fix race in... |
349 |
return -ENOMEM; |
22e7987ae tipc: fix a possi... |
350 |
} |
b39e465e5 tipc: some cleanu... |
351 |
tipc_disc_init_msg(net, d->skb, DSC_REQ_MSG, b); |
25b0b9c4e tipc: handle coll... |
352 353 354 355 356 357 |
/* Do we need an address trial period first ? */ if (!tipc_own_addr(net)) { tn->addr_trial_end = jiffies + msecs_to_jiffies(1000); msg_set_type(buf_msg(d->skb), DSC_TRIAL_MSG); } |
b39e465e5 tipc: some cleanu... |
358 359 360 361 362 363 364 365 366 367 368 |
memcpy(&d->dest, dest, sizeof(*dest)); d->net = net; d->bearer_id = b->identity; d->domain = b->domain; d->num_nodes = 0; d->timer_intv = TIPC_DISC_INIT; spin_lock_init(&d->lock); timer_setup(&d->timer, tipc_disc_timeout, 0); mod_timer(&d->timer, jiffies + d->timer_intv); b->disc = d; *skb = skb_clone(d->skb, GFP_ATOMIC); |
3a777ff8b tipc: Enhance han... |
369 370 371 372 373 |
return 0; } /** * tipc_disc_delete - destroy object sending periodic link setup requests |
b39e465e5 tipc: some cleanu... |
374 |
* @d: ptr to link duest structure |
3a777ff8b tipc: Enhance han... |
375 |
*/ |
b39e465e5 tipc: some cleanu... |
376 |
void tipc_disc_delete(struct tipc_discoverer *d) |
3a777ff8b tipc: Enhance han... |
377 |
{ |
b39e465e5 tipc: some cleanu... |
378 379 380 |
del_timer_sync(&d->timer); kfree_skb(d->skb); kfree(d); |
c43072852 [NET] TIPC: Fix w... |
381 |
} |
a8b9b96e9 tipc: fix race in... |
382 383 384 |
/** * tipc_disc_reset - reset object to send periodic link setup requests |
c93d3baa2 tipc: involve nam... |
385 |
* @net: the applicable net namespace |
1a90632da tipc: eliminate r... |
386 |
* @b: ptr to bearer issuing requests |
a8b9b96e9 tipc: fix race in... |
387 |
*/ |
1a90632da tipc: eliminate r... |
388 |
void tipc_disc_reset(struct net *net, struct tipc_bearer *b) |
a8b9b96e9 tipc: fix race in... |
389 |
{ |
b39e465e5 tipc: some cleanu... |
390 391 |
struct tipc_discoverer *d = b->disc; struct tipc_media_addr maddr; |
60852d679 tipc: let neighbo... |
392 |
struct sk_buff *skb; |
a8b9b96e9 tipc: fix race in... |
393 |
|
b39e465e5 tipc: some cleanu... |
394 395 396 397 398 399 400 401 402 403 404 |
spin_lock_bh(&d->lock); tipc_disc_init_msg(net, d->skb, DSC_REQ_MSG, b); d->net = net; d->bearer_id = b->identity; d->domain = b->domain; d->num_nodes = 0; d->timer_intv = TIPC_DISC_INIT; memcpy(&maddr, &d->dest, sizeof(maddr)); mod_timer(&d->timer, jiffies + d->timer_intv); skb = skb_clone(d->skb, GFP_ATOMIC); spin_unlock_bh(&d->lock); |
60852d679 tipc: let neighbo... |
405 |
if (skb) |
b39e465e5 tipc: some cleanu... |
406 |
tipc_bearer_xmit_skb(net, b->identity, skb, &maddr); |
a8b9b96e9 tipc: fix race in... |
407 |
} |