@@ -120,29 +120,24 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
120
120
* @buf: buffer containing message
121
121
* @bearer: bearer that message arrived on
122
122
*/
123
- void tipc_disc_rcv (struct net * net , struct sk_buff * buf ,
123
+ void tipc_disc_rcv (struct net * net , struct sk_buff * skb ,
124
124
struct tipc_bearer * bearer )
125
125
{
126
126
struct tipc_net * tn = net_generic (net , tipc_net_id );
127
- struct tipc_node * node ;
128
127
struct tipc_media_addr maddr ;
129
- struct sk_buff * rbuf ;
130
- struct tipc_msg * msg = buf_msg (buf );
131
- u32 ddom = msg_dest_domain (msg );
132
- u32 onode = msg_prevnode (msg );
133
- u32 net_id = msg_bc_netid (msg );
134
- u32 mtyp = msg_type (msg );
135
- u32 signature = msg_node_sig (msg );
136
- u16 caps = msg_node_capabilities (msg );
137
- bool addr_match = false;
138
- bool sign_match = false;
139
- bool link_up = false;
140
- bool accept_addr = false;
141
- bool accept_sign = false;
128
+ struct sk_buff * rskb ;
129
+ struct tipc_msg * hdr = buf_msg (skb );
130
+ u32 ddom = msg_dest_domain (hdr );
131
+ u32 onode = msg_prevnode (hdr );
132
+ u32 net_id = msg_bc_netid (hdr );
133
+ u32 mtyp = msg_type (hdr );
134
+ u32 signature = msg_node_sig (hdr );
135
+ u16 caps = msg_node_capabilities (hdr );
142
136
bool respond = false;
137
+ bool dupl_addr = false;
143
138
144
- bearer -> media -> msg2addr (bearer , & maddr , msg_media_addr (msg ));
145
- kfree_skb (buf );
139
+ bearer -> media -> msg2addr (bearer , & maddr , msg_media_addr (hdr ));
140
+ kfree_skb (skb );
146
141
147
142
/* Ensure message from node is valid and communication is permitted */
148
143
if (net_id != tn -> net_id )
@@ -164,91 +159,20 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
164
159
if (!tipc_in_scope (bearer -> domain , onode ))
165
160
return ;
166
161
167
- node = tipc_node_create (net , onode );
168
- if (!node )
169
- return ;
170
- tipc_node_lock (node );
171
- node -> capabilities = caps ;
172
-
173
- /* Prepare to validate requesting node's signature and media address */
174
- sign_match = (signature == node -> signature );
175
- tipc_node_check_dest (node , bearer , & link_up , & addr_match , & maddr );
176
-
177
- /* These three flags give us eight permutations: */
178
-
179
- if (sign_match && addr_match && link_up ) {
180
- /* All is fine. Do nothing. */
181
- } else if (sign_match && addr_match && !link_up ) {
182
- /* Respond. The link will come up in due time */
183
- respond = true;
184
- } else if (sign_match && !addr_match && link_up ) {
185
- /* Peer has changed i/f address without rebooting.
186
- * If so, the link will reset soon, and the next
187
- * discovery will be accepted. So we can ignore it.
188
- * It may also be an cloned or malicious peer having
189
- * chosen the same node address and signature as an
190
- * existing one.
191
- * Ignore requests until the link goes down, if ever.
192
- */
162
+ tipc_node_check_dest (net , onode , bearer , caps , signature ,
163
+ & maddr , & respond , & dupl_addr );
164
+ if (dupl_addr )
193
165
disc_dupl_alert (bearer , onode , & maddr );
194
- } else if (sign_match && !addr_match && !link_up ) {
195
- /* Peer link has changed i/f address without rebooting.
196
- * It may also be a cloned or malicious peer; we can't
197
- * distinguish between the two.
198
- * The signature is correct, so we must accept.
199
- */
200
- accept_addr = true;
201
- respond = true;
202
- } else if (!sign_match && addr_match && link_up ) {
203
- /* Peer node rebooted. Two possibilities:
204
- * - Delayed re-discovery; this link endpoint has already
205
- * reset and re-established contact with the peer, before
206
- * receiving a discovery message from that node.
207
- * (The peer happened to receive one from this node first).
208
- * - The peer came back so fast that our side has not
209
- * discovered it yet. Probing from this side will soon
210
- * reset the link, since there can be no working link
211
- * endpoint at the peer end, and the link will re-establish.
212
- * Accept the signature, since it comes from a known peer.
213
- */
214
- accept_sign = true;
215
- } else if (!sign_match && addr_match && !link_up ) {
216
- /* The peer node has rebooted.
217
- * Accept signature, since it is a known peer.
218
- */
219
- accept_sign = true;
220
- respond = true;
221
- } else if (!sign_match && !addr_match && link_up ) {
222
- /* Peer rebooted with new address, or a new/duplicate peer.
223
- * Ignore until the link goes down, if ever.
224
- */
225
- disc_dupl_alert (bearer , onode , & maddr );
226
- } else if (!sign_match && !addr_match && !link_up ) {
227
- /* Peer rebooted with new address, or it is a new peer.
228
- * Accept signature and address.
229
- */
230
- accept_sign = true;
231
- accept_addr = true;
232
- respond = true;
233
- }
234
-
235
- if (accept_sign )
236
- node -> signature = signature ;
237
-
238
- if (accept_addr && !tipc_node_update_dest (node , bearer , & maddr ))
239
- respond = false;
240
166
241
167
/* Send response, if necessary */
242
168
if (respond && (mtyp == DSC_REQ_MSG )) {
243
- rbuf = tipc_buf_acquire (MAX_H_SIZE );
244
- if (rbuf ) {
245
- tipc_disc_init_msg (net , rbuf , DSC_RESP_MSG , bearer );
246
- tipc_bearer_send (net , bearer -> identity , rbuf , & maddr );
247
- kfree_skb (rbuf );
169
+ rskb = tipc_buf_acquire (MAX_H_SIZE );
170
+ if (rskb ) {
171
+ tipc_disc_init_msg (net , rskb , DSC_RESP_MSG , bearer );
172
+ tipc_bearer_send (net , bearer -> identity , rskb , & maddr );
173
+ kfree_skb (rskb );
248
174
}
249
175
}
250
- tipc_node_unlock (node );
251
- tipc_node_put (node );
252
176
}
253
177
254
178
/**
0 commit comments