.. | .. |
---|
102 | 102 | pr_warn("Publication distribution failure\n"); |
---|
103 | 103 | return NULL; |
---|
104 | 104 | } |
---|
105 | | - |
---|
| 105 | + msg_set_named_seqno(buf_msg(skb), nt->snd_nxt++); |
---|
| 106 | + msg_set_non_legacy(buf_msg(skb)); |
---|
106 | 107 | item = (struct distr_item *)msg_data(buf_msg(skb)); |
---|
107 | 108 | publ_to_item(item, publ); |
---|
108 | 109 | return skb; |
---|
.. | .. |
---|
114 | 115 | struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ) |
---|
115 | 116 | { |
---|
116 | 117 | struct name_table *nt = tipc_name_table(net); |
---|
117 | | - struct sk_buff *buf; |
---|
118 | 118 | struct distr_item *item; |
---|
| 119 | + struct sk_buff *skb; |
---|
119 | 120 | |
---|
120 | 121 | write_lock_bh(&nt->cluster_scope_lock); |
---|
121 | 122 | list_del(&publ->binding_node); |
---|
.. | .. |
---|
123 | 124 | if (publ->scope == TIPC_NODE_SCOPE) |
---|
124 | 125 | return NULL; |
---|
125 | 126 | |
---|
126 | | - buf = named_prepare_buf(net, WITHDRAWAL, ITEM_SIZE, 0); |
---|
127 | | - if (!buf) { |
---|
| 127 | + skb = named_prepare_buf(net, WITHDRAWAL, ITEM_SIZE, 0); |
---|
| 128 | + if (!skb) { |
---|
128 | 129 | pr_warn("Withdrawal distribution failure\n"); |
---|
129 | 130 | return NULL; |
---|
130 | 131 | } |
---|
131 | | - |
---|
132 | | - item = (struct distr_item *)msg_data(buf_msg(buf)); |
---|
| 132 | + msg_set_named_seqno(buf_msg(skb), nt->snd_nxt++); |
---|
| 133 | + msg_set_non_legacy(buf_msg(skb)); |
---|
| 134 | + item = (struct distr_item *)msg_data(buf_msg(skb)); |
---|
133 | 135 | publ_to_item(item, publ); |
---|
134 | | - return buf; |
---|
| 136 | + return skb; |
---|
135 | 137 | } |
---|
136 | 138 | |
---|
137 | 139 | /** |
---|
.. | .. |
---|
141 | 143 | * @pls: linked list of publication items to be packed into buffer chain |
---|
142 | 144 | */ |
---|
143 | 145 | static void named_distribute(struct net *net, struct sk_buff_head *list, |
---|
144 | | - u32 dnode, struct list_head *pls) |
---|
| 146 | + u32 dnode, struct list_head *pls, u16 seqno) |
---|
145 | 147 | { |
---|
146 | 148 | struct publication *publ; |
---|
147 | 149 | struct sk_buff *skb = NULL; |
---|
148 | 150 | struct distr_item *item = NULL; |
---|
149 | | - u32 msg_dsz = ((tipc_node_get_mtu(net, dnode, 0) - INT_H_SIZE) / |
---|
| 151 | + u32 msg_dsz = ((tipc_node_get_mtu(net, dnode, 0, false) - INT_H_SIZE) / |
---|
150 | 152 | ITEM_SIZE) * ITEM_SIZE; |
---|
151 | 153 | u32 msg_rem = msg_dsz; |
---|
| 154 | + struct tipc_msg *hdr; |
---|
152 | 155 | |
---|
153 | 156 | list_for_each_entry(publ, pls, binding_node) { |
---|
154 | 157 | /* Prepare next buffer: */ |
---|
.. | .. |
---|
159 | 162 | pr_warn("Bulk publication failure\n"); |
---|
160 | 163 | return; |
---|
161 | 164 | } |
---|
162 | | - msg_set_bc_ack_invalid(buf_msg(skb), true); |
---|
163 | | - item = (struct distr_item *)msg_data(buf_msg(skb)); |
---|
| 165 | + hdr = buf_msg(skb); |
---|
| 166 | + msg_set_bc_ack_invalid(hdr, true); |
---|
| 167 | + msg_set_bulk(hdr); |
---|
| 168 | + msg_set_non_legacy(hdr); |
---|
| 169 | + item = (struct distr_item *)msg_data(hdr); |
---|
164 | 170 | } |
---|
165 | 171 | |
---|
166 | 172 | /* Pack publication into message: */ |
---|
.. | .. |
---|
176 | 182 | } |
---|
177 | 183 | } |
---|
178 | 184 | if (skb) { |
---|
179 | | - msg_set_size(buf_msg(skb), INT_H_SIZE + (msg_dsz - msg_rem)); |
---|
| 185 | + hdr = buf_msg(skb); |
---|
| 186 | + msg_set_size(hdr, INT_H_SIZE + (msg_dsz - msg_rem)); |
---|
180 | 187 | skb_trim(skb, INT_H_SIZE + (msg_dsz - msg_rem)); |
---|
181 | 188 | __skb_queue_tail(list, skb); |
---|
182 | 189 | } |
---|
| 190 | + hdr = buf_msg(skb_peek_tail(list)); |
---|
| 191 | + msg_set_last_bulk(hdr); |
---|
| 192 | + msg_set_named_seqno(hdr, seqno); |
---|
183 | 193 | } |
---|
184 | 194 | |
---|
185 | 195 | /** |
---|
186 | 196 | * tipc_named_node_up - tell specified node about all publications by this node |
---|
187 | 197 | */ |
---|
188 | | -void tipc_named_node_up(struct net *net, u32 dnode) |
---|
| 198 | +void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities) |
---|
189 | 199 | { |
---|
190 | 200 | struct name_table *nt = tipc_name_table(net); |
---|
| 201 | + struct tipc_net *tn = tipc_net(net); |
---|
191 | 202 | struct sk_buff_head head; |
---|
| 203 | + u16 seqno; |
---|
192 | 204 | |
---|
193 | 205 | __skb_queue_head_init(&head); |
---|
| 206 | + spin_lock_bh(&tn->nametbl_lock); |
---|
| 207 | + if (!(capabilities & TIPC_NAMED_BCAST)) |
---|
| 208 | + nt->rc_dests++; |
---|
| 209 | + seqno = nt->snd_nxt; |
---|
| 210 | + spin_unlock_bh(&tn->nametbl_lock); |
---|
194 | 211 | |
---|
195 | 212 | read_lock_bh(&nt->cluster_scope_lock); |
---|
196 | | - named_distribute(net, &head, dnode, &nt->cluster_scope); |
---|
| 213 | + named_distribute(net, &head, dnode, &nt->cluster_scope, seqno); |
---|
197 | 214 | tipc_node_xmit(net, &head, dnode, 0); |
---|
198 | 215 | read_unlock_bh(&nt->cluster_scope_lock); |
---|
199 | 216 | } |
---|
.. | .. |
---|
245 | 262 | spin_unlock_bh(&tn->nametbl_lock); |
---|
246 | 263 | } |
---|
247 | 264 | |
---|
248 | | -void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr) |
---|
| 265 | +void tipc_publ_notify(struct net *net, struct list_head *nsub_list, |
---|
| 266 | + u32 addr, u16 capabilities) |
---|
249 | 267 | { |
---|
| 268 | + struct name_table *nt = tipc_name_table(net); |
---|
| 269 | + struct tipc_net *tn = tipc_net(net); |
---|
| 270 | + |
---|
250 | 271 | struct publication *publ, *tmp; |
---|
251 | 272 | |
---|
252 | 273 | list_for_each_entry_safe(publ, tmp, nsub_list, binding_node) |
---|
253 | 274 | tipc_publ_purge(net, publ, addr); |
---|
254 | 275 | tipc_dist_queue_purge(net, addr); |
---|
| 276 | + spin_lock_bh(&tn->nametbl_lock); |
---|
| 277 | + if (!(capabilities & TIPC_NAMED_BCAST)) |
---|
| 278 | + nt->rc_dests--; |
---|
| 279 | + spin_unlock_bh(&tn->nametbl_lock); |
---|
255 | 280 | } |
---|
256 | 281 | |
---|
257 | 282 | /** |
---|
.. | .. |
---|
295 | 320 | return false; |
---|
296 | 321 | } |
---|
297 | 322 | |
---|
| 323 | +static struct sk_buff *tipc_named_dequeue(struct sk_buff_head *namedq, |
---|
| 324 | + u16 *rcv_nxt, bool *open) |
---|
| 325 | +{ |
---|
| 326 | + struct sk_buff *skb, *tmp; |
---|
| 327 | + struct tipc_msg *hdr; |
---|
| 328 | + u16 seqno; |
---|
| 329 | + |
---|
| 330 | + spin_lock_bh(&namedq->lock); |
---|
| 331 | + skb_queue_walk_safe(namedq, skb, tmp) { |
---|
| 332 | + if (unlikely(skb_linearize(skb))) { |
---|
| 333 | + __skb_unlink(skb, namedq); |
---|
| 334 | + kfree_skb(skb); |
---|
| 335 | + continue; |
---|
| 336 | + } |
---|
| 337 | + hdr = buf_msg(skb); |
---|
| 338 | + seqno = msg_named_seqno(hdr); |
---|
| 339 | + if (msg_is_last_bulk(hdr)) { |
---|
| 340 | + *rcv_nxt = seqno; |
---|
| 341 | + *open = true; |
---|
| 342 | + } |
---|
| 343 | + |
---|
| 344 | + if (msg_is_bulk(hdr) || msg_is_legacy(hdr)) { |
---|
| 345 | + __skb_unlink(skb, namedq); |
---|
| 346 | + spin_unlock_bh(&namedq->lock); |
---|
| 347 | + return skb; |
---|
| 348 | + } |
---|
| 349 | + |
---|
| 350 | + if (*open && (*rcv_nxt == seqno)) { |
---|
| 351 | + (*rcv_nxt)++; |
---|
| 352 | + __skb_unlink(skb, namedq); |
---|
| 353 | + spin_unlock_bh(&namedq->lock); |
---|
| 354 | + return skb; |
---|
| 355 | + } |
---|
| 356 | + |
---|
| 357 | + if (less(seqno, *rcv_nxt)) { |
---|
| 358 | + __skb_unlink(skb, namedq); |
---|
| 359 | + kfree_skb(skb); |
---|
| 360 | + continue; |
---|
| 361 | + } |
---|
| 362 | + } |
---|
| 363 | + spin_unlock_bh(&namedq->lock); |
---|
| 364 | + return NULL; |
---|
| 365 | +} |
---|
| 366 | + |
---|
298 | 367 | /** |
---|
299 | 368 | * tipc_named_rcv - process name table update messages sent by another node |
---|
300 | 369 | */ |
---|
301 | | -void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq) |
---|
| 370 | +void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq, |
---|
| 371 | + u16 *rcv_nxt, bool *open) |
---|
302 | 372 | { |
---|
303 | | - struct tipc_net *tn = net_generic(net, tipc_net_id); |
---|
304 | | - struct tipc_msg *msg; |
---|
| 373 | + struct tipc_net *tn = tipc_net(net); |
---|
305 | 374 | struct distr_item *item; |
---|
306 | | - uint count; |
---|
307 | | - u32 node; |
---|
| 375 | + struct tipc_msg *hdr; |
---|
308 | 376 | struct sk_buff *skb; |
---|
309 | | - int mtype; |
---|
| 377 | + u32 count, node; |
---|
310 | 378 | |
---|
311 | 379 | spin_lock_bh(&tn->nametbl_lock); |
---|
312 | | - for (skb = skb_dequeue(inputq); skb; skb = skb_dequeue(inputq)) { |
---|
313 | | - skb_linearize(skb); |
---|
314 | | - msg = buf_msg(skb); |
---|
315 | | - mtype = msg_type(msg); |
---|
316 | | - item = (struct distr_item *)msg_data(msg); |
---|
317 | | - count = msg_data_sz(msg) / ITEM_SIZE; |
---|
318 | | - node = msg_orignode(msg); |
---|
| 380 | + while ((skb = tipc_named_dequeue(namedq, rcv_nxt, open))) { |
---|
| 381 | + hdr = buf_msg(skb); |
---|
| 382 | + node = msg_orignode(hdr); |
---|
| 383 | + item = (struct distr_item *)msg_data(hdr); |
---|
| 384 | + count = msg_data_sz(hdr) / ITEM_SIZE; |
---|
319 | 385 | while (count--) { |
---|
320 | | - tipc_update_nametbl(net, item, node, mtype); |
---|
| 386 | + tipc_update_nametbl(net, item, node, msg_type(hdr)); |
---|
321 | 387 | item++; |
---|
322 | 388 | } |
---|
323 | 389 | kfree_skb(skb); |
---|
.. | .. |
---|
345 | 411 | publ->node = self; |
---|
346 | 412 | list_for_each_entry_rcu(publ, &nt->cluster_scope, binding_node) |
---|
347 | 413 | publ->node = self; |
---|
348 | | - |
---|
| 414 | + nt->rc_dests = 0; |
---|
349 | 415 | spin_unlock_bh(&tn->nametbl_lock); |
---|
350 | 416 | } |
---|