2 * net/tipc/link.c: TIPC link code
4 * Copyright (c) 1996-2007, 2012-2016, Ericsson AB
5 * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
42 #include "name_distr.h"
47 #include <linux/pkt_sched.h>
68 u32 link_congs; /* # port sends blocked by congestion */
71 u32 max_queue_sz; /* send queue size high water mark */
72 u32 accu_queue_sz; /* used for send queue size profiling */
73 u32 queue_sz_counts; /* used for send queue size profiling */
74 u32 msg_length_counts; /* used for message length profiling */
75 u32 msg_lengths_total; /* used for message length profiling */
76 u32 msg_length_profile[7]; /* used for msg. length profiling */
80 * struct tipc_link - TIPC link data structure
81 * @addr: network address of link's peer node
82 * @name: link name character string
83 * @media_addr: media address to use when sending messages over link
85 * @net: pointer to namespace struct
86 * @refcnt: reference counter for permanent references (owner node & timer)
87 * @peer_session: link session # being used by peer end of link
88 * @peer_bearer_id: bearer id used by link's peer endpoint
89 * @bearer_id: local bearer id used by link
90 * @tolerance: minimum link continuity loss needed to reset link [in ms]
91 * @abort_limit: # of unacknowledged continuity probes needed to reset link
92 * @state: current state of link FSM
93 * @peer_caps: bitmap describing capabilities of peer node
94 * @silent_intv_cnt: # of timer intervals without any reception from peer
95 * @proto_msg: template for control messages generated by link
96 * @pmsg: convenience pointer to "proto_msg" field
97 * @priority: current link priority
98 * @net_plane: current link network plane ('A' through 'H')
99 * @mon_state: cookie with information needed by link monitor
100 * @backlog_limit: backlog queue congestion thresholds (indexed by importance)
101 * @exp_msg_count: # of tunnelled messages expected during link changeover
102 * @reset_rcv_checkpt: seq # of last acknowledged message at time of link reset
103 * @mtu: current maximum packet size for this link
104 * @advertised_mtu: advertised own mtu when link is being established
105 * @transmitq: queue for sent, non-acked messages
106 * @backlogq: queue for messages waiting to be sent
107 * @snt_nxt: next sequence number to use for outbound messages
108 * @prev_from: sequence number of most previous retransmission request
109 * @stale_cnt: counter for number of identical retransmit attempts
110 * @stale_limit: time when repeated identical retransmits must force link reset
111 * @ackers: # of peers that needs to ack each packet before it can be released
112 * @acked: # last packet acked by a certain peer. Used for broadcast.
113 * @rcv_nxt: next sequence number to expect for inbound messages
114 * @deferred_queue: deferred queue saved OOS b'cast message received from node
115 * @unacked_window: # of inbound messages rx'd without ack'ing back to peer
116 * @inputq: buffer queue for messages to be delivered upwards
117 * @namedq: buffer queue for name table messages to be delivered upwards
118 * @next_out: ptr to first unsent outbound message in queue
119 * @wakeupq: linked list of wakeup msgs waiting for link congestion to abate
120 * @long_msg_seq_no: next identifier to use for outbound fragmented messages
121 * @reasm_buf: head of partially reassembled inbound message fragments
122 * @bc_rcvr: marks that this is a broadcast receiver link
123 * @stats: collects statistics regarding link activity
127 char name[TIPC_MAX_LINK_NAME];
130 /* Management and link supervision data */
144 char if_name[TIPC_MAX_IF_NAME];
147 struct tipc_mon_state mon_state;
152 struct sk_buff *failover_reasm_skb;
154 /* Max packet negotiation */
159 struct sk_buff_head transmq;
160 struct sk_buff_head backlogq;
169 unsigned long stale_limit;
174 struct sk_buff_head deferdq;
175 struct sk_buff_head *inputq;
176 struct sk_buff_head *namedq;
178 /* Congestion handling */
179 struct sk_buff_head wakeupq;
181 /* Fragmentation/reassembly */
182 struct sk_buff *reasm_buf;
187 struct tipc_link *bc_rcvlink;
188 struct tipc_link *bc_sndlink;
193 struct tipc_stats stats;
197 * Error message prefixes
199 static const char *link_co_err = "Link tunneling error, ";
200 static const char *link_rst_msg = "Resetting link ";
202 /* Send states for broadcast NACKs
205 BC_NACK_SND_CONDITIONAL,
206 BC_NACK_SND_UNCONDITIONAL,
207 BC_NACK_SND_SUPPRESS,
210 #define TIPC_BC_RETR_LIM msecs_to_jiffies(10) /* [ms] */
213 * Interval between NACKs when packets arrive out of order
215 #define TIPC_NACK_INTV (TIPC_MIN_LINK_WIN * 2)
220 LINK_ESTABLISHED = 0xe,
221 LINK_ESTABLISHING = 0xe << 4,
222 LINK_RESET = 0x1 << 8,
223 LINK_RESETTING = 0x2 << 12,
224 LINK_PEER_RESET = 0xd << 16,
225 LINK_FAILINGOVER = 0xf << 20,
226 LINK_SYNCHING = 0xc << 24
229 /* Link FSM state checking routines
231 static int link_is_up(struct tipc_link *l)
233 return l->state & (LINK_ESTABLISHED | LINK_SYNCHING);
236 static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
237 struct sk_buff_head *xmitq);
238 static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
239 bool probe_reply, u16 rcvgap,
240 int tolerance, int priority,
241 struct sk_buff_head *xmitq);
242 static void link_print(struct tipc_link *l, const char *str);
243 static int tipc_link_build_nack_msg(struct tipc_link *l,
244 struct sk_buff_head *xmitq);
245 static void tipc_link_build_bc_init_msg(struct tipc_link *l,
246 struct sk_buff_head *xmitq);
247 static bool tipc_link_release_pkts(struct tipc_link *l, u16 to);
250 * Simple non-static link routines (i.e. referenced outside this file)
252 bool tipc_link_is_up(struct tipc_link *l)
254 return link_is_up(l);
257 bool tipc_link_peer_is_down(struct tipc_link *l)
259 return l->state == LINK_PEER_RESET;
262 bool tipc_link_is_reset(struct tipc_link *l)
264 return l->state & (LINK_RESET | LINK_FAILINGOVER | LINK_ESTABLISHING);
267 bool tipc_link_is_establishing(struct tipc_link *l)
269 return l->state == LINK_ESTABLISHING;
272 bool tipc_link_is_synching(struct tipc_link *l)
274 return l->state == LINK_SYNCHING;
277 bool tipc_link_is_failingover(struct tipc_link *l)
279 return l->state == LINK_FAILINGOVER;
282 bool tipc_link_is_blocked(struct tipc_link *l)
284 return l->state & (LINK_RESETTING | LINK_PEER_RESET | LINK_FAILINGOVER);
287 static bool link_is_bc_sndlink(struct tipc_link *l)
289 return !l->bc_sndlink;
292 static bool link_is_bc_rcvlink(struct tipc_link *l)
294 return ((l->bc_rcvlink == l) && !link_is_bc_sndlink(l));
297 void tipc_link_set_active(struct tipc_link *l, bool active)
302 u32 tipc_link_id(struct tipc_link *l)
304 return l->peer_bearer_id << 16 | l->bearer_id;
307 int tipc_link_window(struct tipc_link *l)
312 int tipc_link_prio(struct tipc_link *l)
317 unsigned long tipc_link_tolerance(struct tipc_link *l)
322 struct sk_buff_head *tipc_link_inputq(struct tipc_link *l)
327 char tipc_link_plane(struct tipc_link *l)
332 void tipc_link_update_caps(struct tipc_link *l, u16 capabilities)
334 l->peer_caps = capabilities;
337 void tipc_link_add_bc_peer(struct tipc_link *snd_l,
338 struct tipc_link *uc_l,
339 struct sk_buff_head *xmitq)
341 struct tipc_link *rcv_l = uc_l->bc_rcvlink;
344 rcv_l->acked = snd_l->snd_nxt - 1;
345 snd_l->state = LINK_ESTABLISHED;
346 tipc_link_build_bc_init_msg(uc_l, xmitq);
349 void tipc_link_remove_bc_peer(struct tipc_link *snd_l,
350 struct tipc_link *rcv_l,
351 struct sk_buff_head *xmitq)
353 u16 ack = snd_l->snd_nxt - 1;
356 rcv_l->bc_peer_is_up = true;
357 rcv_l->state = LINK_ESTABLISHED;
358 tipc_link_bc_ack_rcv(rcv_l, ack, xmitq);
359 tipc_link_reset(rcv_l);
360 rcv_l->state = LINK_RESET;
361 if (!snd_l->ackers) {
362 tipc_link_reset(snd_l);
363 snd_l->state = LINK_RESET;
364 __skb_queue_purge(xmitq);
368 int tipc_link_bc_peers(struct tipc_link *l)
373 static u16 link_bc_rcv_gap(struct tipc_link *l)
375 struct sk_buff *skb = skb_peek(&l->deferdq);
378 if (more(l->snd_nxt, l->rcv_nxt))
379 gap = l->snd_nxt - l->rcv_nxt;
381 gap = buf_seqno(skb) - l->rcv_nxt;
385 void tipc_link_set_mtu(struct tipc_link *l, int mtu)
390 int tipc_link_mtu(struct tipc_link *l)
395 u16 tipc_link_rcv_nxt(struct tipc_link *l)
400 u16 tipc_link_acked(struct tipc_link *l)
405 char *tipc_link_name(struct tipc_link *l)
410 u32 tipc_link_state(struct tipc_link *l)
416 * tipc_link_create - create a new link
417 * @n: pointer to associated node
418 * @if_name: associated interface name
419 * @bearer_id: id (index) of associated bearer
420 * @tolerance: link tolerance to be used by link
421 * @net_plane: network plane (A,B,c..) this link belongs to
422 * @mtu: mtu to be advertised by link
423 * @priority: priority to be used by link
424 * @window: send window to be used by link
425 * @session: session to be used by link
426 * @ownnode: identity of own node
427 * @peer: node id of peer node
428 * @peer_caps: bitmap describing peer node capabilities
429 * @bc_sndlink: the namespace global link used for broadcast sending
430 * @bc_rcvlink: the peer specific link used for broadcast reception
431 * @inputq: queue to put messages ready for delivery
432 * @namedq: queue to put binding table update messages ready for delivery
433 * @link: return value, pointer to put the created link
435 * Returns true if link was created, otherwise false
437 bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
438 int tolerance, char net_plane, u32 mtu, int priority,
439 int window, u32 session, u32 self,
440 u32 peer, u8 *peer_id, u16 peer_caps,
441 struct tipc_link *bc_sndlink,
442 struct tipc_link *bc_rcvlink,
443 struct sk_buff_head *inputq,
444 struct sk_buff_head *namedq,
445 struct tipc_link **link)
447 char peer_str[NODE_ID_STR_LEN] = {0,};
448 char self_str[NODE_ID_STR_LEN] = {0,};
451 l = kzalloc(sizeof(*l), GFP_ATOMIC);
455 l->session = session;
457 /* Set link name for unicast links only */
459 tipc_nodeid2string(self_str, tipc_own_id(net));
460 if (strlen(self_str) > 16)
461 sprintf(self_str, "%x", self);
462 tipc_nodeid2string(peer_str, peer_id);
463 if (strlen(peer_str) > 16)
464 sprintf(peer_str, "%x", peer);
466 /* Peer i/f name will be completed by reset/activate message */
467 snprintf(l->name, sizeof(l->name), "%s:%s-%s:unknown",
468 self_str, if_name, peer_str);
470 strcpy(l->if_name, if_name);
472 l->peer_caps = peer_caps;
474 l->in_session = false;
475 l->bearer_id = bearer_id;
476 l->tolerance = tolerance;
478 bc_rcvlink->tolerance = tolerance;
479 l->net_plane = net_plane;
480 l->advertised_mtu = mtu;
482 l->priority = priority;
483 tipc_link_set_queue_limits(l, window);
485 l->bc_sndlink = bc_sndlink;
486 l->bc_rcvlink = bc_rcvlink;
489 l->state = LINK_RESETTING;
490 __skb_queue_head_init(&l->transmq);
491 __skb_queue_head_init(&l->backlogq);
492 __skb_queue_head_init(&l->deferdq);
493 skb_queue_head_init(&l->wakeupq);
494 skb_queue_head_init(l->inputq);
499 * tipc_link_bc_create - create new link to be used for broadcast
500 * @n: pointer to associated node
501 * @mtu: mtu to be used initially if no peers
502 * @window: send window to be used
503 * @inputq: queue to put messages ready for delivery
504 * @namedq: queue to put binding table update messages ready for delivery
505 * @link: return value, pointer to put the created link
507 * Returns true if link was created, otherwise false
509 bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
510 int mtu, int window, u16 peer_caps,
511 struct sk_buff_head *inputq,
512 struct sk_buff_head *namedq,
513 struct tipc_link *bc_sndlink,
514 struct tipc_link **link)
518 if (!tipc_link_create(net, "", MAX_BEARERS, 0, 'Z', mtu, 0, window,
519 0, ownnode, peer, NULL, peer_caps, bc_sndlink,
520 NULL, inputq, namedq, link))
524 strcpy(l->name, tipc_bclink_name);
526 l->state = LINK_RESET;
530 /* Broadcast send link is always up */
531 if (link_is_bc_sndlink(l))
532 l->state = LINK_ESTABLISHED;
534 /* Disable replicast if even a single peer doesn't support it */
535 if (link_is_bc_rcvlink(l) && !(peer_caps & TIPC_BCAST_RCAST))
536 tipc_bcast_disable_rcast(net);
542 * tipc_link_fsm_evt - link finite state machine
543 * @l: pointer to link
544 * @evt: state machine event to be processed
546 int tipc_link_fsm_evt(struct tipc_link *l, int evt)
553 case LINK_PEER_RESET_EVT:
554 l->state = LINK_PEER_RESET;
557 l->state = LINK_RESET;
559 case LINK_FAILURE_EVT:
560 case LINK_FAILOVER_BEGIN_EVT:
561 case LINK_ESTABLISH_EVT:
562 case LINK_FAILOVER_END_EVT:
563 case LINK_SYNCH_BEGIN_EVT:
564 case LINK_SYNCH_END_EVT:
571 case LINK_PEER_RESET_EVT:
572 l->state = LINK_ESTABLISHING;
574 case LINK_FAILOVER_BEGIN_EVT:
575 l->state = LINK_FAILINGOVER;
576 case LINK_FAILURE_EVT:
578 case LINK_ESTABLISH_EVT:
579 case LINK_FAILOVER_END_EVT:
581 case LINK_SYNCH_BEGIN_EVT:
582 case LINK_SYNCH_END_EVT:
587 case LINK_PEER_RESET:
590 l->state = LINK_ESTABLISHING;
592 case LINK_PEER_RESET_EVT:
593 case LINK_ESTABLISH_EVT:
594 case LINK_FAILURE_EVT:
596 case LINK_SYNCH_BEGIN_EVT:
597 case LINK_SYNCH_END_EVT:
598 case LINK_FAILOVER_BEGIN_EVT:
599 case LINK_FAILOVER_END_EVT:
604 case LINK_FAILINGOVER:
606 case LINK_FAILOVER_END_EVT:
607 l->state = LINK_RESET;
609 case LINK_PEER_RESET_EVT:
611 case LINK_ESTABLISH_EVT:
612 case LINK_FAILURE_EVT:
614 case LINK_FAILOVER_BEGIN_EVT:
615 case LINK_SYNCH_BEGIN_EVT:
616 case LINK_SYNCH_END_EVT:
621 case LINK_ESTABLISHING:
623 case LINK_ESTABLISH_EVT:
624 l->state = LINK_ESTABLISHED;
626 case LINK_FAILOVER_BEGIN_EVT:
627 l->state = LINK_FAILINGOVER;
630 l->state = LINK_RESET;
632 case LINK_FAILURE_EVT:
633 case LINK_PEER_RESET_EVT:
634 case LINK_SYNCH_BEGIN_EVT:
635 case LINK_FAILOVER_END_EVT:
637 case LINK_SYNCH_END_EVT:
642 case LINK_ESTABLISHED:
644 case LINK_PEER_RESET_EVT:
645 l->state = LINK_PEER_RESET;
646 rc |= TIPC_LINK_DOWN_EVT;
648 case LINK_FAILURE_EVT:
649 l->state = LINK_RESETTING;
650 rc |= TIPC_LINK_DOWN_EVT;
653 l->state = LINK_RESET;
655 case LINK_ESTABLISH_EVT:
656 case LINK_SYNCH_END_EVT:
658 case LINK_SYNCH_BEGIN_EVT:
659 l->state = LINK_SYNCHING;
661 case LINK_FAILOVER_BEGIN_EVT:
662 case LINK_FAILOVER_END_EVT:
669 case LINK_PEER_RESET_EVT:
670 l->state = LINK_PEER_RESET;
671 rc |= TIPC_LINK_DOWN_EVT;
673 case LINK_FAILURE_EVT:
674 l->state = LINK_RESETTING;
675 rc |= TIPC_LINK_DOWN_EVT;
678 l->state = LINK_RESET;
680 case LINK_ESTABLISH_EVT:
681 case LINK_SYNCH_BEGIN_EVT:
683 case LINK_SYNCH_END_EVT:
684 l->state = LINK_ESTABLISHED;
686 case LINK_FAILOVER_BEGIN_EVT:
687 case LINK_FAILOVER_END_EVT:
693 pr_err("Unknown FSM state %x in %s\n", l->state, l->name);
697 pr_err("Illegal FSM event %x in state %x on link %s\n",
698 evt, l->state, l->name);
702 /* link_profile_stats - update statistical profiling of traffic
704 static void link_profile_stats(struct tipc_link *l)
707 struct tipc_msg *msg;
710 /* Update counters used in statistical profiling of send traffic */
711 l->stats.accu_queue_sz += skb_queue_len(&l->transmq);
712 l->stats.queue_sz_counts++;
714 skb = skb_peek(&l->transmq);
718 length = msg_size(msg);
720 if (msg_user(msg) == MSG_FRAGMENTER) {
721 if (msg_type(msg) != FIRST_FRAGMENT)
723 length = msg_size(msg_get_wrapped(msg));
725 l->stats.msg_lengths_total += length;
726 l->stats.msg_length_counts++;
728 l->stats.msg_length_profile[0]++;
729 else if (length <= 256)
730 l->stats.msg_length_profile[1]++;
731 else if (length <= 1024)
732 l->stats.msg_length_profile[2]++;
733 else if (length <= 4096)
734 l->stats.msg_length_profile[3]++;
735 else if (length <= 16384)
736 l->stats.msg_length_profile[4]++;
737 else if (length <= 32768)
738 l->stats.msg_length_profile[5]++;
740 l->stats.msg_length_profile[6]++;
743 /* tipc_link_timeout - perform periodic task as instructed from node timeout
745 int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
752 u16 bc_snt = l->bc_sndlink->snd_nxt - 1;
753 u16 bc_acked = l->bc_rcvlink->acked;
754 struct tipc_mon_state *mstate = &l->mon_state;
757 case LINK_ESTABLISHED:
760 link_profile_stats(l);
761 tipc_mon_get_state(l->net, l->addr, mstate, l->bearer_id);
762 if (mstate->reset || (l->silent_intv_cnt > l->abort_limit))
763 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
764 state = bc_acked != bc_snt;
765 state |= l->bc_rcvlink->rcv_unacked;
766 state |= l->rcv_unacked;
767 state |= !skb_queue_empty(&l->transmq);
768 state |= !skb_queue_empty(&l->deferdq);
769 probe = mstate->probing;
770 probe |= l->silent_intv_cnt;
771 if (probe || mstate->monitoring)
772 l->silent_intv_cnt++;
775 setup = l->rst_cnt++ <= 4;
776 setup |= !(l->rst_cnt % 16);
779 case LINK_ESTABLISHING:
783 case LINK_PEER_RESET:
785 case LINK_FAILINGOVER:
791 if (state || probe || setup)
792 tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, 0, xmitq);
798 * link_schedule_user - schedule a message sender for wakeup after congestion
800 * @hdr: header of message that is being sent
801 * Create pseudo msg to send back to user when congestion abates
803 static int link_schedule_user(struct tipc_link *l, struct tipc_msg *hdr)
805 u32 dnode = tipc_own_addr(l->net);
806 u32 dport = msg_origport(hdr);
809 /* Create and schedule wakeup pseudo message */
810 skb = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0,
811 dnode, l->addr, dport, 0, 0);
814 msg_set_dest_droppable(buf_msg(skb), true);
815 TIPC_SKB_CB(skb)->chain_imp = msg_importance(hdr);
816 skb_queue_tail(&l->wakeupq, skb);
817 l->stats.link_congs++;
822 * link_prepare_wakeup - prepare users for wakeup after congestion
824 * Wake up a number of waiting users, as permitted by available space
827 static void link_prepare_wakeup(struct tipc_link *l)
829 struct sk_buff *skb, *tmp;
832 skb_queue_walk_safe(&l->wakeupq, skb, tmp) {
833 imp = TIPC_SKB_CB(skb)->chain_imp;
834 if (l->backlog[imp].len < l->backlog[imp].limit) {
835 skb_unlink(skb, &l->wakeupq);
836 skb_queue_tail(l->inputq, skb);
837 } else if (i++ > 10) {
843 void tipc_link_reset(struct tipc_link *l)
845 struct sk_buff_head list;
847 __skb_queue_head_init(&list);
849 l->in_session = false;
851 l->mtu = l->advertised_mtu;
853 spin_lock_bh(&l->wakeupq.lock);
854 skb_queue_splice_init(&l->wakeupq, &list);
855 spin_unlock_bh(&l->wakeupq.lock);
857 spin_lock_bh(&l->inputq->lock);
858 skb_queue_splice_init(&list, l->inputq);
859 spin_unlock_bh(&l->inputq->lock);
861 __skb_queue_purge(&l->transmq);
862 __skb_queue_purge(&l->deferdq);
863 __skb_queue_purge(&l->backlogq);
864 l->backlog[TIPC_LOW_IMPORTANCE].len = 0;
865 l->backlog[TIPC_MEDIUM_IMPORTANCE].len = 0;
866 l->backlog[TIPC_HIGH_IMPORTANCE].len = 0;
867 l->backlog[TIPC_CRITICAL_IMPORTANCE].len = 0;
868 l->backlog[TIPC_SYSTEM_IMPORTANCE].len = 0;
869 kfree_skb(l->reasm_buf);
870 kfree_skb(l->failover_reasm_skb);
872 l->failover_reasm_skb = NULL;
876 l->snd_nxt_state = 1;
877 l->rcv_nxt_state = 1;
879 l->silent_intv_cnt = 0;
882 l->bc_peer_is_up = false;
883 memset(&l->mon_state, 0, sizeof(l->mon_state));
884 tipc_link_reset_stats(l);
888 * tipc_link_xmit(): enqueue buffer list according to queue situation
890 * @list: chain of buffers containing message
891 * @xmitq: returned list of packets to be sent by caller
893 * Consumes the buffer chain.
894 * Returns 0 if success, or errno: -ELINKCONG, -EMSGSIZE or -ENOBUFS
895 * Messages at TIPC_SYSTEM_IMPORTANCE are always accepted
897 int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
898 struct sk_buff_head *xmitq)
900 struct tipc_msg *hdr = buf_msg(skb_peek(list));
901 unsigned int maxwin = l->window;
902 int imp = msg_importance(hdr);
903 unsigned int mtu = l->mtu;
904 u16 ack = l->rcv_nxt - 1;
905 u16 seqno = l->snd_nxt;
906 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
907 struct sk_buff_head *transmq = &l->transmq;
908 struct sk_buff_head *backlogq = &l->backlogq;
909 struct sk_buff *skb, *_skb, *bskb;
910 int pkt_cnt = skb_queue_len(list);
913 if (unlikely(msg_size(hdr) > mtu)) {
914 skb_queue_purge(list);
918 /* Allow oversubscription of one data msg per source at congestion */
919 if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {
920 if (imp == TIPC_SYSTEM_IMPORTANCE) {
921 pr_warn("%s<%s>, link overflow", link_rst_msg, l->name);
924 rc = link_schedule_user(l, hdr);
928 l->stats.sent_fragmented++;
929 l->stats.sent_fragments += pkt_cnt;
932 /* Prepare each packet for sending, and add to relevant queue: */
933 while (skb_queue_len(list)) {
934 skb = skb_peek(list);
936 msg_set_seqno(hdr, seqno);
937 msg_set_ack(hdr, ack);
938 msg_set_bcast_ack(hdr, bc_ack);
940 if (likely(skb_queue_len(transmq) < maxwin)) {
941 _skb = skb_clone(skb, GFP_ATOMIC);
943 skb_queue_purge(list);
947 __skb_queue_tail(transmq, skb);
948 __skb_queue_tail(xmitq, _skb);
949 TIPC_SKB_CB(skb)->ackers = l->ackers;
951 l->stats.sent_pkts++;
955 if (tipc_msg_bundle(skb_peek_tail(backlogq), hdr, mtu)) {
956 kfree_skb(__skb_dequeue(list));
957 l->stats.sent_bundled++;
960 if (tipc_msg_make_bundle(&bskb, hdr, mtu, l->addr)) {
961 kfree_skb(__skb_dequeue(list));
962 __skb_queue_tail(backlogq, bskb);
963 l->backlog[msg_importance(buf_msg(bskb))].len++;
964 l->stats.sent_bundled++;
965 l->stats.sent_bundles++;
968 l->backlog[imp].len += skb_queue_len(list);
969 skb_queue_splice_tail_init(list, backlogq);
975 static void tipc_link_advance_backlog(struct tipc_link *l,
976 struct sk_buff_head *xmitq)
978 struct sk_buff *skb, *_skb;
979 struct tipc_msg *hdr;
980 u16 seqno = l->snd_nxt;
981 u16 ack = l->rcv_nxt - 1;
982 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
984 while (skb_queue_len(&l->transmq) < l->window) {
985 skb = skb_peek(&l->backlogq);
988 _skb = skb_clone(skb, GFP_ATOMIC);
991 __skb_dequeue(&l->backlogq);
993 l->backlog[msg_importance(hdr)].len--;
994 __skb_queue_tail(&l->transmq, skb);
995 __skb_queue_tail(xmitq, _skb);
996 TIPC_SKB_CB(skb)->ackers = l->ackers;
997 msg_set_seqno(hdr, seqno);
998 msg_set_ack(hdr, ack);
999 msg_set_bcast_ack(hdr, bc_ack);
1001 l->stats.sent_pkts++;
1007 static void link_retransmit_failure(struct tipc_link *l, struct sk_buff *skb)
1009 struct tipc_msg *hdr = buf_msg(skb);
1011 pr_warn("Retransmission failure on link <%s>\n", l->name);
1012 link_print(l, "State of link ");
1013 pr_info("Failed msg: usr %u, typ %u, len %u, err %u\n",
1014 msg_user(hdr), msg_type(hdr), msg_size(hdr), msg_errcode(hdr));
1015 pr_info("sqno %u, prev: %x, src: %x\n",
1016 msg_seqno(hdr), msg_prevnode(hdr), msg_orignode(hdr));
1019 /* tipc_link_retrans() - retransmit one or more packets
1020 * @l: the link to transmit on
1021 * @r: the receiving link ordering the retransmit. Same as l if unicast
1022 * @from: retransmit from (inclusive) this sequence number
1023 * @to: retransmit to (inclusive) this sequence number
1024 * xmitq: queue for accumulating the retransmitted packets
1026 static int tipc_link_retrans(struct tipc_link *l, struct tipc_link *r,
1027 u16 from, u16 to, struct sk_buff_head *xmitq)
1029 struct sk_buff *_skb, *skb = skb_peek(&l->transmq);
1030 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
1031 u16 ack = l->rcv_nxt - 1;
1032 struct tipc_msg *hdr;
1039 /* Detect repeated retransmit failures on same packet */
1040 if (r->prev_from != from) {
1041 r->prev_from = from;
1042 r->stale_limit = jiffies + msecs_to_jiffies(r->tolerance);
1044 } else if (++r->stale_cnt > 99 && time_after(jiffies, r->stale_limit)) {
1045 link_retransmit_failure(l, skb);
1046 if (link_is_bc_sndlink(l))
1047 return TIPC_LINK_DOWN_EVT;
1048 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1051 skb_queue_walk(&l->transmq, skb) {
1053 if (less(msg_seqno(hdr), from))
1055 if (more(msg_seqno(hdr), to))
1057 if (link_is_bc_sndlink(l)) {
1058 if (time_before(jiffies, TIPC_SKB_CB(skb)->nxt_retr))
1060 TIPC_SKB_CB(skb)->nxt_retr = jiffies + TIPC_BC_RETR_LIM;
1062 _skb = __pskb_copy(skb, MIN_H_SIZE, GFP_ATOMIC);
1065 hdr = buf_msg(_skb);
1066 msg_set_ack(hdr, ack);
1067 msg_set_bcast_ack(hdr, bc_ack);
1068 _skb->priority = TC_PRIO_CONTROL;
1069 __skb_queue_tail(xmitq, _skb);
1070 l->stats.retransmitted++;
1075 /* tipc_data_input - deliver data and name distr msgs to upper layer
1077 * Consumes buffer if message is of right type
1078 * Node lock must be held
1080 static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,
1081 struct sk_buff_head *inputq)
1083 struct sk_buff_head *mc_inputq = l->bc_rcvlink->inputq;
1084 struct tipc_msg *hdr = buf_msg(skb);
1086 switch (msg_user(hdr)) {
1087 case TIPC_LOW_IMPORTANCE:
1088 case TIPC_MEDIUM_IMPORTANCE:
1089 case TIPC_HIGH_IMPORTANCE:
1090 case TIPC_CRITICAL_IMPORTANCE:
1091 if (unlikely(msg_in_group(hdr) || msg_mcast(hdr))) {
1092 skb_queue_tail(mc_inputq, skb);
1095 /* else: fall through */
1097 skb_queue_tail(inputq, skb);
1099 case GROUP_PROTOCOL:
1100 skb_queue_tail(mc_inputq, skb);
1102 case NAME_DISTRIBUTOR:
1103 l->bc_rcvlink->state = LINK_ESTABLISHED;
1104 skb_queue_tail(l->namedq, skb);
1107 case TUNNEL_PROTOCOL:
1108 case MSG_FRAGMENTER:
1109 case BCAST_PROTOCOL:
1112 pr_warn("Dropping received illegal msg type\n");
1118 /* tipc_link_input - process packet that has passed link protocol check
1122 static int tipc_link_input(struct tipc_link *l, struct sk_buff *skb,
1123 struct sk_buff_head *inputq)
1125 struct tipc_msg *hdr = buf_msg(skb);
1126 struct sk_buff **reasm_skb = &l->reasm_buf;
1127 struct sk_buff *iskb;
1128 struct sk_buff_head tmpq;
1129 int usr = msg_user(hdr);
1134 if (unlikely(usr == TUNNEL_PROTOCOL)) {
1135 if (msg_type(hdr) == SYNCH_MSG) {
1136 __skb_queue_purge(&l->deferdq);
1139 if (!tipc_msg_extract(skb, &iskb, &ipos))
1144 if (less(msg_seqno(hdr), l->drop_point))
1146 if (tipc_data_input(l, skb, inputq))
1148 usr = msg_user(hdr);
1149 reasm_skb = &l->failover_reasm_skb;
1152 if (usr == MSG_BUNDLER) {
1153 skb_queue_head_init(&tmpq);
1154 l->stats.recv_bundles++;
1155 l->stats.recv_bundled += msg_msgcnt(hdr);
1156 while (tipc_msg_extract(skb, &iskb, &pos))
1157 tipc_data_input(l, iskb, &tmpq);
1158 tipc_skb_queue_splice_tail(&tmpq, inputq);
1160 } else if (usr == MSG_FRAGMENTER) {
1161 l->stats.recv_fragments++;
1162 if (tipc_buf_append(reasm_skb, &skb)) {
1163 l->stats.recv_fragmented++;
1164 tipc_data_input(l, skb, inputq);
1165 } else if (!*reasm_skb && !link_is_bc_rcvlink(l)) {
1166 pr_warn_ratelimited("Unable to build fragment list\n");
1167 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1170 } else if (usr == BCAST_PROTOCOL) {
1171 tipc_bcast_lock(l->net);
1172 tipc_link_bc_init_rcv(l->bc_rcvlink, hdr);
1173 tipc_bcast_unlock(l->net);
1180 static bool tipc_link_release_pkts(struct tipc_link *l, u16 acked)
1182 bool released = false;
1183 struct sk_buff *skb, *tmp;
1185 skb_queue_walk_safe(&l->transmq, skb, tmp) {
1186 if (more(buf_seqno(skb), acked))
1188 __skb_unlink(skb, &l->transmq);
1195 /* tipc_link_build_state_msg: prepare link state message for transmission
1197 * Note that sending of broadcast ack is coordinated among nodes, to reduce
1198 * risk of ack storms towards the sender
1200 int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
1205 /* Broadcast ACK must be sent via a unicast link => defer to caller */
1206 if (link_is_bc_rcvlink(l)) {
1207 if (((l->rcv_nxt ^ tipc_own_addr(l->net)) & 0xf) != 0xf)
1211 /* Use snd_nxt to store peer's snd_nxt in broadcast rcv link */
1212 l->snd_nxt = l->rcv_nxt;
1213 return TIPC_LINK_SND_STATE;
1218 l->stats.sent_acks++;
1219 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, 0, xmitq);
1223 /* tipc_link_build_reset_msg: prepare link RESET or ACTIVATE message
1225 void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
1227 int mtyp = RESET_MSG;
1228 struct sk_buff *skb;
1230 if (l->state == LINK_ESTABLISHING)
1231 mtyp = ACTIVATE_MSG;
1233 tipc_link_build_proto_msg(l, mtyp, 0, 0, 0, 0, 0, xmitq);
1235 /* Inform peer that this endpoint is going down if applicable */
1236 skb = skb_peek_tail(xmitq);
1237 if (skb && (l->state == LINK_RESET))
1238 msg_set_peer_stopping(buf_msg(skb), 1);
1241 /* tipc_link_build_nack_msg: prepare link nack message for transmission
1242 * Note that sending of broadcast NACK is coordinated among nodes, to
1243 * reduce the risk of NACK storms towards the sender
1245 static int tipc_link_build_nack_msg(struct tipc_link *l,
1246 struct sk_buff_head *xmitq)
1248 u32 def_cnt = ++l->stats.deferred_recv;
1251 if (link_is_bc_rcvlink(l)) {
1252 match1 = def_cnt & 0xf;
1253 match2 = tipc_own_addr(l->net) & 0xf;
1254 if (match1 == match2)
1255 return TIPC_LINK_SND_STATE;
1259 if ((skb_queue_len(&l->deferdq) == 1) || !(def_cnt % TIPC_NACK_INTV))
1260 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, 0, xmitq);
1264 /* tipc_link_rcv - process TIPC packets/messages arriving from off-node
1265 * @l: the link that should handle the message
1267 * @xmitq: queue to place packets to be sent after this call
1269 int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
1270 struct sk_buff_head *xmitq)
1272 struct sk_buff_head *defq = &l->deferdq;
1273 struct tipc_msg *hdr;
1274 u16 seqno, rcv_nxt, win_lim;
1279 seqno = msg_seqno(hdr);
1280 rcv_nxt = l->rcv_nxt;
1281 win_lim = rcv_nxt + TIPC_MAX_LINK_WIN;
1283 /* Verify and update link state */
1284 if (unlikely(msg_user(hdr) == LINK_PROTOCOL))
1285 return tipc_link_proto_rcv(l, skb, xmitq);
1287 if (unlikely(!link_is_up(l))) {
1288 if (l->state == LINK_ESTABLISHING)
1289 rc = TIPC_LINK_UP_EVT;
1293 /* Don't send probe at next timeout expiration */
1294 l->silent_intv_cnt = 0;
1296 /* Drop if outside receive window */
1297 if (unlikely(less(seqno, rcv_nxt) || more(seqno, win_lim))) {
1298 l->stats.duplicates++;
1302 /* Forward queues and wake up waiting users */
1303 if (likely(tipc_link_release_pkts(l, msg_ack(hdr)))) {
1305 tipc_link_advance_backlog(l, xmitq);
1306 if (unlikely(!skb_queue_empty(&l->wakeupq)))
1307 link_prepare_wakeup(l);
1310 /* Defer delivery if sequence gap */
1311 if (unlikely(seqno != rcv_nxt)) {
1312 __tipc_skb_queue_sorted(defq, seqno, skb);
1313 rc |= tipc_link_build_nack_msg(l, xmitq);
1317 /* Deliver packet */
1319 l->stats.recv_pkts++;
1320 if (!tipc_data_input(l, skb, l->inputq))
1321 rc |= tipc_link_input(l, skb, l->inputq);
1322 if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN))
1323 rc |= tipc_link_build_state_msg(l, xmitq);
1324 if (unlikely(rc & ~TIPC_LINK_SND_STATE))
1326 } while ((skb = __skb_dequeue(defq)));
1334 static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1335 bool probe_reply, u16 rcvgap,
1336 int tolerance, int priority,
1337 struct sk_buff_head *xmitq)
1339 struct tipc_link *bcl = l->bc_rcvlink;
1340 struct sk_buff *skb;
1341 struct tipc_msg *hdr;
1342 struct sk_buff_head *dfq = &l->deferdq;
1343 bool node_up = link_is_up(bcl);
1344 struct tipc_mon_state *mstate = &l->mon_state;
1348 /* Don't send protocol message during reset or link failover */
1349 if (tipc_link_is_blocked(l))
1352 if (!tipc_link_is_up(l) && (mtyp == STATE_MSG))
1355 if (!skb_queue_empty(dfq))
1356 rcvgap = buf_seqno(skb_peek(dfq)) - l->rcv_nxt;
1358 skb = tipc_msg_create(LINK_PROTOCOL, mtyp, INT_H_SIZE,
1359 tipc_max_domain_size, l->addr,
1360 tipc_own_addr(l->net), 0, 0, 0);
1365 data = msg_data(hdr);
1366 msg_set_session(hdr, l->session);
1367 msg_set_bearer_id(hdr, l->bearer_id);
1368 msg_set_net_plane(hdr, l->net_plane);
1369 msg_set_next_sent(hdr, l->snd_nxt);
1370 msg_set_ack(hdr, l->rcv_nxt - 1);
1371 msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1);
1372 msg_set_bc_ack_invalid(hdr, !node_up);
1373 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
1374 msg_set_link_tolerance(hdr, tolerance);
1375 msg_set_linkprio(hdr, priority);
1376 msg_set_redundant_link(hdr, node_up);
1377 msg_set_seq_gap(hdr, 0);
1378 msg_set_seqno(hdr, l->snd_nxt + U16_MAX / 2);
1380 if (mtyp == STATE_MSG) {
1381 if (l->peer_caps & TIPC_LINK_PROTO_SEQNO)
1382 msg_set_seqno(hdr, l->snd_nxt_state++);
1383 msg_set_seq_gap(hdr, rcvgap);
1384 msg_set_bc_gap(hdr, link_bc_rcv_gap(bcl));
1385 msg_set_probe(hdr, probe);
1386 msg_set_is_keepalive(hdr, probe || probe_reply);
1387 tipc_mon_prep(l->net, data, &dlen, mstate, l->bearer_id);
1388 msg_set_size(hdr, INT_H_SIZE + dlen);
1389 skb_trim(skb, INT_H_SIZE + dlen);
1390 l->stats.sent_states++;
1393 /* RESET_MSG or ACTIVATE_MSG */
1394 msg_set_max_pkt(hdr, l->advertised_mtu);
1395 strcpy(data, l->if_name);
1396 msg_set_size(hdr, INT_H_SIZE + TIPC_MAX_IF_NAME);
1397 skb_trim(skb, INT_H_SIZE + TIPC_MAX_IF_NAME);
1400 l->stats.sent_probes++;
1402 l->stats.sent_nacks++;
1403 skb->priority = TC_PRIO_CONTROL;
1404 __skb_queue_tail(xmitq, skb);
1407 void tipc_link_create_dummy_tnl_msg(struct tipc_link *l,
1408 struct sk_buff_head *xmitq)
1410 u32 onode = tipc_own_addr(l->net);
1411 struct tipc_msg *hdr, *ihdr;
1412 struct sk_buff_head tnlq;
1413 struct sk_buff *skb;
1414 u32 dnode = l->addr;
1416 skb_queue_head_init(&tnlq);
1417 skb = tipc_msg_create(TUNNEL_PROTOCOL, FAILOVER_MSG,
1418 INT_H_SIZE, BASIC_H_SIZE,
1419 dnode, onode, 0, 0, 0);
1421 pr_warn("%sunable to create tunnel packet\n", link_co_err);
1426 msg_set_msgcnt(hdr, 1);
1427 msg_set_bearer_id(hdr, l->peer_bearer_id);
1429 ihdr = (struct tipc_msg *)msg_data(hdr);
1430 tipc_msg_init(onode, ihdr, TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG,
1431 BASIC_H_SIZE, dnode);
1432 msg_set_errcode(ihdr, TIPC_ERR_NO_PORT);
1433 __skb_queue_tail(&tnlq, skb);
1434 tipc_link_xmit(l, &tnlq, xmitq);
1437 /* tipc_link_tnl_prepare(): prepare and return a list of tunnel packets
1438 * with contents of the link's transmit and backlog queues.
1440 void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
1441 int mtyp, struct sk_buff_head *xmitq)
1443 struct sk_buff *skb, *tnlskb;
1444 struct tipc_msg *hdr, tnlhdr;
1445 struct sk_buff_head *queue = &l->transmq;
1446 struct sk_buff_head tmpxq, tnlq;
1447 u16 pktlen, pktcnt, seqno = l->snd_nxt;
1452 skb_queue_head_init(&tnlq);
1453 skb_queue_head_init(&tmpxq);
1455 /* At least one packet required for safe algorithm => add dummy */
1456 skb = tipc_msg_create(TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG,
1457 BASIC_H_SIZE, 0, l->addr, tipc_own_addr(l->net),
1458 0, 0, TIPC_ERR_NO_PORT);
1460 pr_warn("%sunable to create tunnel packet\n", link_co_err);
1463 skb_queue_tail(&tnlq, skb);
1464 tipc_link_xmit(l, &tnlq, &tmpxq);
1465 __skb_queue_purge(&tmpxq);
1467 /* Initialize reusable tunnel packet header */
1468 tipc_msg_init(tipc_own_addr(l->net), &tnlhdr, TUNNEL_PROTOCOL,
1469 mtyp, INT_H_SIZE, l->addr);
1470 pktcnt = skb_queue_len(&l->transmq) + skb_queue_len(&l->backlogq);
1471 msg_set_msgcnt(&tnlhdr, pktcnt);
1472 msg_set_bearer_id(&tnlhdr, l->peer_bearer_id);
1474 /* Wrap each packet into a tunnel packet */
1475 skb_queue_walk(queue, skb) {
1477 if (queue == &l->backlogq)
1478 msg_set_seqno(hdr, seqno++);
1479 pktlen = msg_size(hdr);
1480 msg_set_size(&tnlhdr, pktlen + INT_H_SIZE);
1481 tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE, GFP_ATOMIC);
1483 pr_warn("%sunable to send packet\n", link_co_err);
1486 skb_copy_to_linear_data(tnlskb, &tnlhdr, INT_H_SIZE);
1487 skb_copy_to_linear_data_offset(tnlskb, INT_H_SIZE, hdr, pktlen);
1488 __skb_queue_tail(&tnlq, tnlskb);
1490 if (queue != &l->backlogq) {
1491 queue = &l->backlogq;
1495 tipc_link_xmit(tnl, &tnlq, xmitq);
1497 if (mtyp == FAILOVER_MSG) {
1498 tnl->drop_point = l->rcv_nxt;
1499 tnl->failover_reasm_skb = l->reasm_buf;
1500 l->reasm_buf = NULL;
1504 /* tipc_link_validate_msg(): validate message against current link state
1505 * Returns true if message should be accepted, otherwise false
1507 bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr)
1509 u16 curr_session = l->peer_session;
1510 u16 session = msg_session(hdr);
1511 int mtyp = msg_type(hdr);
1513 if (msg_user(hdr) != LINK_PROTOCOL)
1520 /* Accept only RESET with new session number */
1521 return more(session, curr_session);
1525 /* Accept only ACTIVATE with new or current session number */
1526 return !less(session, curr_session);
1528 /* Accept only STATE with current session number */
1531 if (session != curr_session)
1533 /* Extra sanity check */
1534 if (!link_is_up(l) && msg_ack(hdr))
1536 if (!(l->peer_caps & TIPC_LINK_PROTO_SEQNO))
1538 /* Accept only STATE with new sequence number */
1539 return !less(msg_seqno(hdr), l->rcv_nxt_state);
1545 /* tipc_link_proto_rcv(): receive link level protocol message :
1546 * Note that network plane id propagates through the network, and may
1547 * change at any time. The node with lowest numerical id determines
1550 static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
1551 struct sk_buff_head *xmitq)
1553 struct tipc_msg *hdr = buf_msg(skb);
1555 u16 ack = msg_ack(hdr);
1556 u16 gap = msg_seq_gap(hdr);
1557 u16 peers_snd_nxt = msg_next_sent(hdr);
1558 u16 peers_tol = msg_link_tolerance(hdr);
1559 u16 peers_prio = msg_linkprio(hdr);
1560 u16 rcv_nxt = l->rcv_nxt;
1561 u16 dlen = msg_data_sz(hdr);
1562 int mtyp = msg_type(hdr);
1563 bool reply = msg_probe(hdr);
1568 if (tipc_link_is_blocked(l) || !xmitq)
1571 if (tipc_own_addr(l->net) > msg_prevnode(hdr))
1572 l->net_plane = msg_net_plane(hdr);
1576 data = msg_data(hdr);
1578 if (!tipc_link_validate_msg(l, hdr))
1584 /* Complete own link name with peer's interface name */
1585 if_name = strrchr(l->name, ':') + 1;
1586 if (sizeof(l->name) - (if_name - l->name) <= TIPC_MAX_IF_NAME)
1588 if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME)
1590 strncpy(if_name, data, TIPC_MAX_IF_NAME);
1592 /* Update own tolerance if peer indicates a non-zero value */
1593 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) {
1594 l->tolerance = peers_tol;
1595 l->bc_rcvlink->tolerance = peers_tol;
1597 /* Update own priority if peer's priority is higher */
1598 if (in_range(peers_prio, l->priority + 1, TIPC_MAX_LINK_PRI))
1599 l->priority = peers_prio;
1601 /* ACTIVATE_MSG serves as PEER_RESET if link is already down */
1602 if (msg_peer_stopping(hdr))
1603 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1604 else if ((mtyp == RESET_MSG) || !link_is_up(l))
1605 rc = tipc_link_fsm_evt(l, LINK_PEER_RESET_EVT);
1607 /* ACTIVATE_MSG takes up link if it was already locally reset */
1608 if ((mtyp == ACTIVATE_MSG) && (l->state == LINK_ESTABLISHING))
1609 rc = TIPC_LINK_UP_EVT;
1611 l->peer_session = msg_session(hdr);
1612 l->in_session = true;
1613 l->peer_bearer_id = msg_bearer_id(hdr);
1614 if (l->mtu > msg_max_pkt(hdr))
1615 l->mtu = msg_max_pkt(hdr);
1619 l->rcv_nxt_state = msg_seqno(hdr) + 1;
1621 /* Update own tolerance if peer indicates a non-zero value */
1622 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) {
1623 l->tolerance = peers_tol;
1624 l->bc_rcvlink->tolerance = peers_tol;
1626 /* Update own prio if peer indicates a different value */
1627 if ((peers_prio != l->priority) &&
1628 in_range(peers_prio, 1, TIPC_MAX_LINK_PRI)) {
1629 l->priority = peers_prio;
1630 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1633 l->silent_intv_cnt = 0;
1634 l->stats.recv_states++;
1636 l->stats.recv_probes++;
1638 if (!link_is_up(l)) {
1639 if (l->state == LINK_ESTABLISHING)
1640 rc = TIPC_LINK_UP_EVT;
1643 tipc_mon_rcv(l->net, data, dlen, l->addr,
1644 &l->mon_state, l->bearer_id);
1646 /* Send NACK if peer has sent pkts we haven't received yet */
1647 if (more(peers_snd_nxt, rcv_nxt) && !tipc_link_is_synching(l))
1648 rcvgap = peers_snd_nxt - l->rcv_nxt;
1649 if (rcvgap || reply)
1650 tipc_link_build_proto_msg(l, STATE_MSG, 0, reply,
1651 rcvgap, 0, 0, xmitq);
1652 tipc_link_release_pkts(l, ack);
1654 /* If NACK, retransmit will now start at right position */
1656 rc = tipc_link_retrans(l, l, ack + 1, ack + gap, xmitq);
1657 l->stats.recv_nacks++;
1660 tipc_link_advance_backlog(l, xmitq);
1661 if (unlikely(!skb_queue_empty(&l->wakeupq)))
1662 link_prepare_wakeup(l);
1669 /* tipc_link_build_bc_proto_msg() - create broadcast protocol message
1671 static bool tipc_link_build_bc_proto_msg(struct tipc_link *l, bool bcast,
1673 struct sk_buff_head *xmitq)
1675 struct sk_buff *skb;
1676 struct tipc_msg *hdr;
1677 struct sk_buff *dfrd_skb = skb_peek(&l->deferdq);
1678 u16 ack = l->rcv_nxt - 1;
1679 u16 gap_to = peers_snd_nxt - 1;
1681 skb = tipc_msg_create(BCAST_PROTOCOL, STATE_MSG, INT_H_SIZE,
1682 0, l->addr, tipc_own_addr(l->net), 0, 0, 0);
1686 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
1687 msg_set_bcast_ack(hdr, ack);
1688 msg_set_bcgap_after(hdr, ack);
1690 gap_to = buf_seqno(dfrd_skb) - 1;
1691 msg_set_bcgap_to(hdr, gap_to);
1692 msg_set_non_seq(hdr, bcast);
1693 __skb_queue_tail(xmitq, skb);
1697 /* tipc_link_build_bc_init_msg() - synchronize broadcast link endpoints.
1699 * Give a newly added peer node the sequence number where it should
1700 * start receiving and acking broadcast packets.
1702 static void tipc_link_build_bc_init_msg(struct tipc_link *l,
1703 struct sk_buff_head *xmitq)
1705 struct sk_buff_head list;
1707 __skb_queue_head_init(&list);
1708 if (!tipc_link_build_bc_proto_msg(l->bc_rcvlink, false, 0, &list))
1710 msg_set_bc_ack_invalid(buf_msg(skb_peek(&list)), true);
1711 tipc_link_xmit(l, &list, xmitq);
1714 /* tipc_link_bc_init_rcv - receive initial broadcast synch data from peer
1716 void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr)
1718 int mtyp = msg_type(hdr);
1719 u16 peers_snd_nxt = msg_bc_snd_nxt(hdr);
1724 if (msg_user(hdr) == BCAST_PROTOCOL) {
1725 l->rcv_nxt = peers_snd_nxt;
1726 l->state = LINK_ESTABLISHED;
1730 if (l->peer_caps & TIPC_BCAST_SYNCH)
1733 if (msg_peer_node_is_up(hdr))
1736 /* Compatibility: accept older, less safe initial synch data */
1737 if ((mtyp == RESET_MSG) || (mtyp == ACTIVATE_MSG))
1738 l->rcv_nxt = peers_snd_nxt;
1741 /* tipc_link_bc_sync_rcv - update rcv link according to peer's send state
1743 int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
1744 struct sk_buff_head *xmitq)
1746 struct tipc_link *snd_l = l->bc_sndlink;
1747 u16 peers_snd_nxt = msg_bc_snd_nxt(hdr);
1748 u16 from = msg_bcast_ack(hdr) + 1;
1749 u16 to = from + msg_bc_gap(hdr) - 1;
1755 if (!msg_peer_node_is_up(hdr))
1758 /* Open when peer ackowledges our bcast init msg (pkt #1) */
1760 l->bc_peer_is_up = true;
1762 if (!l->bc_peer_is_up)
1765 l->stats.recv_nacks++;
1767 /* Ignore if peers_snd_nxt goes beyond receive window */
1768 if (more(peers_snd_nxt, l->rcv_nxt + l->window))
1771 rc = tipc_link_retrans(snd_l, l, from, to, xmitq);
1773 l->snd_nxt = peers_snd_nxt;
1774 if (link_bc_rcv_gap(l))
1775 rc |= TIPC_LINK_SND_STATE;
1777 /* Return now if sender supports nack via STATE messages */
1778 if (l->peer_caps & TIPC_BCAST_STATE_NACK)
1781 /* Otherwise, be backwards compatible */
1783 if (!more(peers_snd_nxt, l->rcv_nxt)) {
1784 l->nack_state = BC_NACK_SND_CONDITIONAL;
1788 /* Don't NACK if one was recently sent or peeked */
1789 if (l->nack_state == BC_NACK_SND_SUPPRESS) {
1790 l->nack_state = BC_NACK_SND_UNCONDITIONAL;
1794 /* Conditionally delay NACK sending until next synch rcv */
1795 if (l->nack_state == BC_NACK_SND_CONDITIONAL) {
1796 l->nack_state = BC_NACK_SND_UNCONDITIONAL;
1797 if ((peers_snd_nxt - l->rcv_nxt) < TIPC_MIN_LINK_WIN)
1801 /* Send NACK now but suppress next one */
1802 tipc_link_build_bc_proto_msg(l, true, peers_snd_nxt, xmitq);
1803 l->nack_state = BC_NACK_SND_SUPPRESS;
1807 void tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked,
1808 struct sk_buff_head *xmitq)
1810 struct sk_buff *skb, *tmp;
1811 struct tipc_link *snd_l = l->bc_sndlink;
1813 if (!link_is_up(l) || !l->bc_peer_is_up)
1816 if (!more(acked, l->acked))
1819 /* Skip over packets peer has already acked */
1820 skb_queue_walk(&snd_l->transmq, skb) {
1821 if (more(buf_seqno(skb), l->acked))
1825 /* Update/release the packets peer is acking now */
1826 skb_queue_walk_from_safe(&snd_l->transmq, skb, tmp) {
1827 if (more(buf_seqno(skb), acked))
1829 if (!--TIPC_SKB_CB(skb)->ackers) {
1830 __skb_unlink(skb, &snd_l->transmq);
1835 tipc_link_advance_backlog(snd_l, xmitq);
1836 if (unlikely(!skb_queue_empty(&snd_l->wakeupq)))
1837 link_prepare_wakeup(snd_l);
1840 /* tipc_link_bc_nack_rcv(): receive broadcast nack message
1841 * This function is here for backwards compatibility, since
1842 * no BCAST_PROTOCOL/STATE messages occur from TIPC v2.5.
1844 int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb,
1845 struct sk_buff_head *xmitq)
1847 struct tipc_msg *hdr = buf_msg(skb);
1848 u32 dnode = msg_destnode(hdr);
1849 int mtyp = msg_type(hdr);
1850 u16 acked = msg_bcast_ack(hdr);
1851 u16 from = acked + 1;
1852 u16 to = msg_bcgap_to(hdr);
1853 u16 peers_snd_nxt = to + 1;
1858 if (!tipc_link_is_up(l) || !l->bc_peer_is_up)
1861 if (mtyp != STATE_MSG)
1864 if (dnode == tipc_own_addr(l->net)) {
1865 tipc_link_bc_ack_rcv(l, acked, xmitq);
1866 rc = tipc_link_retrans(l->bc_sndlink, l, from, to, xmitq);
1867 l->stats.recv_nacks++;
1871 /* Msg for other node => suppress own NACK at next sync if applicable */
1872 if (more(peers_snd_nxt, l->rcv_nxt) && !less(l->rcv_nxt, from))
1873 l->nack_state = BC_NACK_SND_SUPPRESS;
1878 void tipc_link_set_queue_limits(struct tipc_link *l, u32 win)
1880 int max_bulk = TIPC_MAX_PUBL / (l->mtu / ITEM_SIZE);
1883 l->backlog[TIPC_LOW_IMPORTANCE].limit = max_t(u16, 50, win);
1884 l->backlog[TIPC_MEDIUM_IMPORTANCE].limit = max_t(u16, 100, win * 2);
1885 l->backlog[TIPC_HIGH_IMPORTANCE].limit = max_t(u16, 150, win * 3);
1886 l->backlog[TIPC_CRITICAL_IMPORTANCE].limit = max_t(u16, 200, win * 4);
1887 l->backlog[TIPC_SYSTEM_IMPORTANCE].limit = max_bulk;
1891 * link_reset_stats - reset link statistics
1892 * @l: pointer to link
1894 void tipc_link_reset_stats(struct tipc_link *l)
1896 memset(&l->stats, 0, sizeof(l->stats));
1899 static void link_print(struct tipc_link *l, const char *str)
1901 struct sk_buff *hskb = skb_peek(&l->transmq);
1902 u16 head = hskb ? msg_seqno(buf_msg(hskb)) : l->snd_nxt - 1;
1903 u16 tail = l->snd_nxt - 1;
1905 pr_info("%s Link <%s> state %x\n", str, l->name, l->state);
1906 pr_info("XMTQ: %u [%u-%u], BKLGQ: %u, SNDNX: %u, RCVNX: %u\n",
1907 skb_queue_len(&l->transmq), head, tail,
1908 skb_queue_len(&l->backlogq), l->snd_nxt, l->rcv_nxt);
1911 /* Parse and validate nested (link) properties valid for media, bearer and link
1913 int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[])
1917 err = nla_parse_nested(props, TIPC_NLA_PROP_MAX, prop,
1918 tipc_nl_prop_policy, NULL);
1922 if (props[TIPC_NLA_PROP_PRIO]) {
1925 prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
1926 if (prio > TIPC_MAX_LINK_PRI)
1930 if (props[TIPC_NLA_PROP_TOL]) {
1933 tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
1934 if ((tol < TIPC_MIN_LINK_TOL) || (tol > TIPC_MAX_LINK_TOL))
1938 if (props[TIPC_NLA_PROP_WIN]) {
1941 win = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
1942 if ((win < TIPC_MIN_LINK_WIN) || (win > TIPC_MAX_LINK_WIN))
1949 static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)
1952 struct nlattr *stats;
1959 struct nla_map map[] = {
1960 {TIPC_NLA_STATS_RX_INFO, 0},
1961 {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments},
1962 {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented},
1963 {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles},
1964 {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled},
1965 {TIPC_NLA_STATS_TX_INFO, 0},
1966 {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments},
1967 {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented},
1968 {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles},
1969 {TIPC_NLA_STATS_TX_BUNDLED, s->sent_bundled},
1970 {TIPC_NLA_STATS_MSG_PROF_TOT, (s->msg_length_counts) ?
1971 s->msg_length_counts : 1},
1972 {TIPC_NLA_STATS_MSG_LEN_CNT, s->msg_length_counts},
1973 {TIPC_NLA_STATS_MSG_LEN_TOT, s->msg_lengths_total},
1974 {TIPC_NLA_STATS_MSG_LEN_P0, s->msg_length_profile[0]},
1975 {TIPC_NLA_STATS_MSG_LEN_P1, s->msg_length_profile[1]},
1976 {TIPC_NLA_STATS_MSG_LEN_P2, s->msg_length_profile[2]},
1977 {TIPC_NLA_STATS_MSG_LEN_P3, s->msg_length_profile[3]},
1978 {TIPC_NLA_STATS_MSG_LEN_P4, s->msg_length_profile[4]},
1979 {TIPC_NLA_STATS_MSG_LEN_P5, s->msg_length_profile[5]},
1980 {TIPC_NLA_STATS_MSG_LEN_P6, s->msg_length_profile[6]},
1981 {TIPC_NLA_STATS_RX_STATES, s->recv_states},
1982 {TIPC_NLA_STATS_RX_PROBES, s->recv_probes},
1983 {TIPC_NLA_STATS_RX_NACKS, s->recv_nacks},
1984 {TIPC_NLA_STATS_RX_DEFERRED, s->deferred_recv},
1985 {TIPC_NLA_STATS_TX_STATES, s->sent_states},
1986 {TIPC_NLA_STATS_TX_PROBES, s->sent_probes},
1987 {TIPC_NLA_STATS_TX_NACKS, s->sent_nacks},
1988 {TIPC_NLA_STATS_TX_ACKS, s->sent_acks},
1989 {TIPC_NLA_STATS_RETRANSMITTED, s->retransmitted},
1990 {TIPC_NLA_STATS_DUPLICATES, s->duplicates},
1991 {TIPC_NLA_STATS_LINK_CONGS, s->link_congs},
1992 {TIPC_NLA_STATS_MAX_QUEUE, s->max_queue_sz},
1993 {TIPC_NLA_STATS_AVG_QUEUE, s->queue_sz_counts ?
1994 (s->accu_queue_sz / s->queue_sz_counts) : 0}
1997 stats = nla_nest_start(skb, TIPC_NLA_LINK_STATS);
2001 for (i = 0; i < ARRAY_SIZE(map); i++)
2002 if (nla_put_u32(skb, map[i].key, map[i].val))
2005 nla_nest_end(skb, stats);
2009 nla_nest_cancel(skb, stats);
2014 /* Caller should hold appropriate locks to protect the link */
2015 int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
2016 struct tipc_link *link, int nlflags)
2018 u32 self = tipc_own_addr(net);
2019 struct nlattr *attrs;
2020 struct nlattr *prop;
2024 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
2025 nlflags, TIPC_NL_LINK_GET);
2029 attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK);
2033 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name))
2035 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, tipc_cluster_mask(self)))
2037 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
2039 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts))
2041 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts))
2044 if (tipc_link_is_up(link))
2045 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP))
2048 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_ACTIVE))
2051 prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
2054 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority))
2056 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_TOL, link->tolerance))
2058 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN,
2061 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority))
2063 nla_nest_end(msg->skb, prop);
2065 err = __tipc_nl_add_stats(msg->skb, &link->stats);
2069 nla_nest_end(msg->skb, attrs);
2070 genlmsg_end(msg->skb, hdr);
2075 nla_nest_cancel(msg->skb, prop);
2077 nla_nest_cancel(msg->skb, attrs);
2079 genlmsg_cancel(msg->skb, hdr);
2084 static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb,
2085 struct tipc_stats *stats)
2088 struct nlattr *nest;
2095 struct nla_map map[] = {
2096 {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts},
2097 {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments},
2098 {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented},
2099 {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles},
2100 {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled},
2101 {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts},
2102 {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments},
2103 {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented},
2104 {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles},
2105 {TIPC_NLA_STATS_TX_BUNDLED, stats->sent_bundled},
2106 {TIPC_NLA_STATS_RX_NACKS, stats->recv_nacks},
2107 {TIPC_NLA_STATS_RX_DEFERRED, stats->deferred_recv},
2108 {TIPC_NLA_STATS_TX_NACKS, stats->sent_nacks},
2109 {TIPC_NLA_STATS_TX_ACKS, stats->sent_acks},
2110 {TIPC_NLA_STATS_RETRANSMITTED, stats->retransmitted},
2111 {TIPC_NLA_STATS_DUPLICATES, stats->duplicates},
2112 {TIPC_NLA_STATS_LINK_CONGS, stats->link_congs},
2113 {TIPC_NLA_STATS_MAX_QUEUE, stats->max_queue_sz},
2114 {TIPC_NLA_STATS_AVG_QUEUE, stats->queue_sz_counts ?
2115 (stats->accu_queue_sz / stats->queue_sz_counts) : 0}
2118 nest = nla_nest_start(skb, TIPC_NLA_LINK_STATS);
2122 for (i = 0; i < ARRAY_SIZE(map); i++)
2123 if (nla_put_u32(skb, map[i].key, map[i].val))
2126 nla_nest_end(skb, nest);
2130 nla_nest_cancel(skb, nest);
2135 int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
2139 struct nlattr *attrs;
2140 struct nlattr *prop;
2141 struct tipc_net *tn = net_generic(net, tipc_net_id);
2142 struct tipc_link *bcl = tn->bcl;
2147 tipc_bcast_lock(net);
2149 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
2150 NLM_F_MULTI, TIPC_NL_LINK_GET);
2152 tipc_bcast_unlock(net);
2156 attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK);
2160 /* The broadcast link is always up */
2161 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP))
2164 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_BROADCAST))
2166 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name))
2168 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0))
2170 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0))
2173 prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
2176 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bcl->window))
2178 nla_nest_end(msg->skb, prop);
2180 err = __tipc_nl_add_bc_link_stat(msg->skb, &bcl->stats);
2184 tipc_bcast_unlock(net);
2185 nla_nest_end(msg->skb, attrs);
2186 genlmsg_end(msg->skb, hdr);
2191 nla_nest_cancel(msg->skb, prop);
2193 nla_nest_cancel(msg->skb, attrs);
2195 tipc_bcast_unlock(net);
2196 genlmsg_cancel(msg->skb, hdr);
2201 void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
2202 struct sk_buff_head *xmitq)
2206 l->bc_rcvlink->tolerance = tol;
2208 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, tol, 0, xmitq);
2211 void tipc_link_set_prio(struct tipc_link *l, u32 prio,
2212 struct sk_buff_head *xmitq)
2215 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, prio, xmitq);
2218 void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)
2220 l->abort_limit = limit;