47 static const char *link_co_err =
"Link changeover error, ";
48 static const char *link_rst_msg =
"Resetting link ";
49 static const char *link_unk_evt =
"Unknown link event ";
54 #define INVALID_SESSION 0x10000
59 #define STARTING_EVT 856384768
60 #define TRAFFIC_MSG_EVT 560815u
61 #define TIMEOUT_EVT 560817u
74 #define START_CHANGEOVER 100000u
90 static void link_handle_out_of_seq_msg(
struct tipc_link *l_ptr,
93 static int link_recv_changeover_msg(
struct tipc_link **l_ptr,
95 static void link_set_supervision_props(
struct tipc_link *l_ptr,
u32 tolerance);
96 static int link_send_sections_long(
struct tipc_port *sender,
97 struct iovec const *msg_sect,
100 static void link_check_defragm_bufs(
struct tipc_link *l_ptr);
102 static void link_reset_statistics(
struct tipc_link *l_ptr);
103 static void link_print(
struct tipc_link *l_ptr,
const char *
str);
104 static void link_start(
struct tipc_link *l_ptr);
110 static unsigned int align(
unsigned int i)
112 return (i + 3) & ~3
u;
115 static void link_init_max_pkt(
struct tipc_link *l_ptr)
119 max_pkt = (l_ptr->
b_ptr->mtu & ~3);
141 return mod(link_next_sent(l_ptr) - 1);
151 return link_working_working(l_ptr) || link_working_unknown(l_ptr);
156 return (l_ptr->
owner->active_links[0] == l_ptr) ||
157 (l_ptr->
owner->active_links[1] == l_ptr);
167 static int link_name_validate(
const char *
name,
176 u32 z_local, c_local, n_local;
177 u32 z_peer, c_peer, n_peer;
189 addr_local = name_copy;
190 if_local =
strchr(addr_local,
':');
191 if (if_local ==
NULL)
194 addr_peer =
strchr(if_local,
'-');
195 if (addr_peer ==
NULL)
198 if_local_len = addr_peer - if_local;
199 if_peer =
strchr(addr_peer,
':');
203 if_peer_len =
strlen(if_peer) + 1;
206 if ((
sscanf(addr_local,
"%u.%u.%u%c",
207 &z_local, &c_local, &n_local, &dummy) != 3) ||
208 (
sscanf(addr_peer,
"%u.%u.%u%c",
209 &z_peer, &c_peer, &n_peer, &dummy) != 3) ||
210 (z_local > 255) || (c_local > 4095) || (n_local > 4095) ||
211 (z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) ||
218 name_parts->
addr_local = tipc_addr(z_local, c_local, n_local);
220 name_parts->
addr_peer = tipc_addr(z_peer, c_peer, n_peer);
235 static void link_timeout(
struct tipc_link *l_ptr)
237 tipc_node_lock(l_ptr->
owner);
241 l_ptr->
stats.queue_sz_counts++;
249 length =
msg_size(msg_get_wrapped(msg));
253 l_ptr->
stats.msg_length_counts++;
255 l_ptr->
stats.msg_length_profile[0]++;
256 else if (length <= 256)
257 l_ptr->
stats.msg_length_profile[1]++;
258 else if (length <= 1024)
259 l_ptr->
stats.msg_length_profile[2]++;
260 else if (length <= 4096)
261 l_ptr->
stats.msg_length_profile[3]++;
262 else if (length <= 16384)
263 l_ptr->
stats.msg_length_profile[4]++;
264 else if (length <= 32768)
265 l_ptr->
stats.msg_length_profile[5]++;
267 l_ptr->
stats.msg_length_profile[6]++;
272 link_check_defragm_bufs(l_ptr);
279 tipc_node_unlock(l_ptr->
owner);
284 k_start_timer(&l_ptr->
timer, time);
302 char addr_string[16];
307 pr_err(
"Attempt to establish third link to %s\n", addr_string);
313 pr_err(
"Attempt to establish second link on <%s> to %s\n",
314 b_ptr->
name, addr_string);
320 pr_warn(
"Link creation failed, no memory\n");
326 sprintf(l_ptr->
name,
"%u.%u.%u:%s-%u.%u.%u:unknown",
327 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
330 tipc_zone(peer), tipc_cluster(peer),
tipc_node(peer));
333 l_ptr->
owner = n_ptr;
336 l_ptr->
b_ptr = b_ptr;
337 link_set_supervision_props(l_ptr, b_ptr->
tolerance);
343 msg_set_size(msg,
sizeof(l_ptr->
proto_msg));
344 msg_set_session(msg, (tipc_random & 0xffff));
345 msg_set_bearer_id(msg, b_ptr->
identity);
346 strcpy((
char *)msg_data(msg), if_name);
351 link_init_max_pkt(l_ptr);
356 link_reset_statistics(l_ptr);
360 k_init_timer(&l_ptr->
timer, (
Handler)link_timeout, (
unsigned long)l_ptr);
378 pr_err(
"Attempt to delete non-existent link\n");
382 k_cancel_timer(&l_ptr->
timer);
384 tipc_node_lock(l_ptr->
owner);
389 tipc_node_unlock(l_ptr->
owner);
390 k_term_timer(&l_ptr->
timer);
394 static void link_start(
struct tipc_link *l_ptr)
396 tipc_node_lock(l_ptr->
owner);
398 tipc_node_unlock(l_ptr->
owner);
410 static int link_schedule_port(
struct tipc_link *l_ptr,
u32 origport,
u32 sz)
414 spin_lock_bh(&tipc_port_list_lock);
415 p_ptr = tipc_port_lock(origport);
424 l_ptr->
stats.link_congs++;
426 tipc_port_unlock(p_ptr);
428 spin_unlock_bh(&tipc_port_list_lock);
444 if (link_congested(l_ptr))
451 spin_lock_bh(p_ptr->
lock);
455 spin_unlock_bh(p_ptr->
lock);
466 static void link_release_outqueue(
struct tipc_link *l_ptr)
533 msg_set_session(l_ptr->
pmsg, ((msg_session(l_ptr->
pmsg) + 1) & 0xffff));
539 link_init_max_pkt(l_ptr);
550 l_ptr->
owner->permit_changeover) {
556 link_release_outqueue(l_ptr);
581 link_reset_statistics(l_ptr);
585 static void link_activate(
struct tipc_link *l_ptr)
597 static void link_state_event(
struct tipc_link *l_ptr,
unsigned int event)
605 if (link_blocked(l_ptr)) {
607 link_set_timer(l_ptr, cont_intv);
611 switch (l_ptr->
state) {
629 link_set_timer(l_ptr, cont_intv);
636 link_set_timer(l_ptr, cont_intv / 4);
639 pr_info(
"%s<%s>, requested by peer\n", link_rst_msg,
646 link_set_timer(l_ptr, cont_intv);
649 pr_err(
"%s%u in WW state\n", link_unk_evt, event);
658 link_set_timer(l_ptr, cont_intv);
661 pr_info(
"%s<%s>, requested by peer while probing\n",
662 link_rst_msg, l_ptr->
name);
668 link_set_timer(l_ptr, cont_intv);
680 link_set_timer(l_ptr, cont_intv);
685 link_set_timer(l_ptr, cont_intv / 4);
687 pr_warn(
"%s<%s>, peer not responding\n",
688 link_rst_msg, l_ptr->
name);
695 link_set_timer(l_ptr, cont_intv);
699 pr_err(
"%s%u in WU state\n", link_unk_evt, event);
707 other = l_ptr->
owner->active_links[0];
708 if (other && link_working_unknown(other))
712 link_activate(l_ptr);
715 link_set_timer(l_ptr, cont_intv);
722 link_set_timer(l_ptr, cont_intv);
730 link_set_timer(l_ptr, cont_intv);
733 pr_err(
"%s%u in RU state\n", link_unk_evt, event);
740 other = l_ptr->
owner->active_links[0];
741 if (other && link_working_unknown(other))
745 link_activate(l_ptr);
748 link_set_timer(l_ptr, cont_intv);
755 link_set_timer(l_ptr, cont_intv);
758 pr_err(
"%s%u in RR state\n", link_unk_evt, event);
762 pr_err(
"Unknown link state %u/%u\n", l_ptr->
state, event);
770 static int link_bundle_buf(
struct tipc_link *l_ptr,
774 struct tipc_msg *bundler_msg = buf_msg(bundler);
775 struct tipc_msg *msg = buf_msg(buf);
779 u32 pad = to_pos - bundle_size;
785 if (skb_tailroom(bundler) < (pad + size))
787 if (l_ptr->
max_pkt < (to_pos + size))
791 skb_copy_to_linear_data_offset(bundler, to_pos, buf->
data, size);
792 msg_set_size(bundler_msg, to_pos + size);
793 msg_set_msgcnt(bundler_msg, msg_msgcnt(bundler_msg) + 1);
795 l_ptr->
stats.sent_bundled++;
799 static void link_add_to_outqueue(
struct tipc_link *l_ptr,
806 msg_set_word(msg, 2, ((ack << 16) | seqno));
807 msg_set_bcast_ack(msg, l_ptr->
owner->bclink.last_in);
820 static void link_add_chain_to_outqueue(
struct tipc_link *l_ptr,
831 buf_chain = buf_chain->
next;
834 msg_set_long_msgno(msg, long_msgno);
835 link_add_to_outqueue(l_ptr, buf, msg);
846 struct tipc_msg *msg = buf_msg(buf);
848 u32 dsz = msg_data_sz(msg);
855 if (
unlikely(queue_size >= queue_limit)) {
857 link_schedule_port(l_ptr, msg_origport(msg), size);
863 pr_warn(
"%s<%s>, send queue full", link_rst_msg,
871 if (size > max_packet)
872 return link_send_long_buf(l_ptr, buf);
876 !link_congested(l_ptr))) {
877 link_add_to_outqueue(l_ptr, buf, msg);
883 l_ptr->
stats.bearer_congs++;
894 link_bundle_buf(l_ptr, l_ptr->
last_out, buf)) {
900 if (size <= max_packet * 2 / 3) {
907 skb_copy_to_linear_data(bundler, &bundler_hdr,
910 link_bundle_buf(l_ptr, bundler, buf);
913 l_ptr->
stats.sent_bundles++;
919 link_add_to_outqueue(l_ptr, buf, msg);
938 tipc_node_lock(n_ptr);
944 tipc_node_unlock(n_ptr);
968 if (list_empty(message_list))
974 tipc_node_lock(n_ptr);
979 link_add_chain_to_outqueue(l_ptr,
982 INIT_LIST_HEAD(message_list);
984 tipc_node_unlock(n_ptr);
1001 static int link_send_buf_fast(
struct tipc_link *l_ptr,
struct sk_buff *buf,
1004 struct tipc_msg *msg = buf_msg(buf);
1005 int res = msg_data_sz(msg);
1007 if (
likely(!link_congested(l_ptr))) {
1009 if (
likely(list_empty(&l_ptr->
b_ptr->cong_links))) {
1010 link_add_to_outqueue(l_ptr, buf, msg);
1017 l_ptr->
stats.bearer_congs++;
1022 *used_max_pkt = l_ptr->
max_pkt;
1044 tipc_node_lock(n_ptr);
1047 res = link_send_buf_fast(l_ptr, buf, &dummy);
1048 tipc_node_unlock(n_ptr);
1052 tipc_node_unlock(n_ptr);
1055 res = msg_data_sz(buf_msg(buf));
1068 struct iovec const *msg_sect,
1091 tipc_node_lock(node);
1095 res = link_send_buf_fast(l_ptr, buf,
1098 tipc_node_unlock(node);
1108 if (link_congested(l_ptr) ||
1109 !list_empty(&l_ptr->
b_ptr->cong_links)) {
1110 res = link_schedule_port(l_ptr,
1120 tipc_node_unlock(node);
1124 if ((msg_hdr_sz(hdr) + res) <= sender->
max_pkt)
1127 return link_send_sections_long(sender, msg_sect,
1128 num_sect, total_len,
1131 tipc_node_unlock(node);
1158 static int link_send_sections_long(
struct tipc_port *sender,
1159 struct iovec const *msg_sect,
1171 u32 fragm_crs, fragm_rest, hsz, sect_rest;
1191 INT_H_SIZE, msg_destnode(hdr));
1192 msg_set_size(&fragm_hdr, max_pkt);
1193 msg_set_fragm_no(&fragm_hdr, 1);
1200 skb_copy_to_linear_data(buf, &fragm_hdr, INT_H_SIZE);
1201 hsz = msg_hdr_sz(hdr);
1202 skb_copy_to_linear_data_offset(buf, INT_H_SIZE, hdr, hsz);
1205 fragm_crs = INT_H_SIZE + hsz;
1206 fragm_rest = fragm_sz - hsz;
1212 sect_rest = msg_sect[++curr_sect].
iov_len;
1213 sect_crs = (
const unchar *)msg_sect[curr_sect].iov_base;
1216 if (sect_rest < fragm_rest)
1224 for (; buf_chain; buf_chain =
buf) {
1225 buf = buf_chain->
next;
1231 skb_copy_to_linear_data_offset(buf, fragm_crs,
1239 if (!fragm_rest && rest) {
1242 if (rest <= fragm_sz) {
1246 msg_set_type(&fragm_hdr,
FRAGMENT);
1248 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
1249 msg_set_fragm_no(&fragm_hdr, ++fragm_no);
1257 skb_copy_to_linear_data(buf, &fragm_hdr, INT_H_SIZE);
1259 fragm_rest = fragm_sz;
1269 tipc_node_lock(node);
1272 tipc_node_unlock(node);
1275 if (l_ptr->
max_pkt < max_pkt) {
1277 tipc_node_unlock(node);
1278 for (; buf_chain; buf_chain =
buf) {
1279 buf = buf_chain->
next;
1286 for (; buf_chain; buf_chain =
buf) {
1287 buf = buf_chain->
next;
1297 l_ptr->
stats.sent_fragments += fragm_no;
1298 l_ptr->
stats.sent_fragmented++;
1300 tipc_node_unlock(node);
1315 if (r_q_size && buf) {
1317 link_last_sent(l_ptr));
1320 while (buf && less(first, r_q_head)) {
1321 first =
mod(first + 1);
1329 if (r_q_size && buf) {
1331 msg_set_bcast_ack(buf_msg(buf), l_ptr->
owner->bclink.last_in);
1335 l_ptr->
stats.retransmitted++;
1338 l_ptr->
stats.bearer_congs++;
1347 msg_set_bcast_ack(buf_msg(buf), l_ptr->
owner->bclink.last_in);
1354 l_ptr->
stats.bearer_congs++;
1362 struct tipc_msg *msg = buf_msg(buf);
1363 u32 next = msg_seqno(msg);
1368 msg_set_bcast_ack(msg, l_ptr->
owner->bclink.last_in);
1375 l_ptr->
stats.bearer_congs++;
1402 static void link_reset_all(
unsigned long addr)
1405 char addr_string[16];
1415 tipc_node_lock(n_ptr);
1417 pr_warn(
"Resetting all links to %s\n",
1421 if (n_ptr->
links[i]) {
1422 link_print(n_ptr->
links[i],
"Resetting link\n");
1427 tipc_node_unlock(n_ptr);
1431 static void link_retransmit_failure(
struct tipc_link *l_ptr,
1434 struct tipc_msg *msg = buf_msg(buf);
1436 pr_warn(
"Retransmission failure on link <%s>\n", l_ptr->
name);
1440 link_print(l_ptr,
"Resetting link\n");
1446 char addr_string[16];
1448 pr_info(
"Msg seq number: %u, ", msg_seqno(msg));
1449 pr_cont(
"Outstanding acks: %lu\n",
1453 tipc_node_lock(n_ptr);
1456 pr_info(
"Broadcast link info for %s\n", addr_string);
1457 pr_info(
"Supportable: %d, Supported: %d, Acked: %u\n",
1458 n_ptr->
bclink.supportable,
1461 pr_info(
"Last in: %u, Oos state: %u, Last sent: %u\n",
1464 n_ptr->
bclink.last_sent);
1468 tipc_node_unlock(n_ptr);
1489 pr_err(
"Unexpected retransmit on link %s (qsize=%d)\n",
1497 link_retransmit_failure(l_ptr, buf);
1506 while (retransmits && (buf != l_ptr->
next_out) && buf) {
1509 msg_set_bcast_ack(msg, l_ptr->
owner->bclink.last_in);
1513 l_ptr->
stats.retransmitted++;
1516 l_ptr->
stats.bearer_congs++;
1559 static int link_recv_buf_validate(
struct sk_buff *buf)
1561 static u32 min_data_hdr_size[8] = {
1575 msg = skb_header_pointer(buf, 0,
sizeof(tipc_hdr), tipc_hdr);
1583 hdr_size = msg_hdr_sz(msg);
1584 min_hdr_size = msg_isdata(msg) ?
1587 if (
unlikely((hdr_size < min_hdr_size) ||
1588 (size < hdr_size) ||
1589 (buf->
len < size) ||
1593 return pskb_may_pull(buf, hdr_size);
1625 if (
unlikely(!link_recv_buf_validate(buf)))
1645 (msg_destnode(msg) != tipc_own_addr)))
1652 tipc_node_lock(n_ptr);
1657 tipc_node_unlock(n_ptr);
1666 !msg_redundant_link(msg))
1670 tipc_node_unlock(n_ptr);
1675 seq_no = msg_seqno(msg);
1676 ackd = msg_ack(msg);
1679 if (n_ptr->
bclink.supported)
1684 less_eq(buf_seqno(crs), ackd)) {
1702 l_ptr->
stats.sent_acks++;
1708 if (
likely(link_working_working(l_ptr))) {
1712 head = link_insert_deferred_queue(l_ptr,
1715 if (
likely(msg_isdata(msg))) {
1716 tipc_node_unlock(n_ptr);
1720 switch (msg_user(msg)) {
1723 l_ptr->
stats.recv_bundles++;
1724 l_ptr->
stats.recv_bundled +=
1726 tipc_node_unlock(n_ptr);
1730 tipc_node_unlock(n_ptr);
1734 tipc_node_unlock(n_ptr);
1738 l_ptr->
stats.recv_fragments++;
1743 l_ptr->
stats.recv_fragmented++;
1751 if (link_recv_changeover_msg(&l_ptr,
1754 seq_no = msg_seqno(msg);
1757 goto protocol_check;
1765 tipc_node_unlock(n_ptr);
1769 link_handle_out_of_seq_msg(l_ptr, buf);
1770 head = link_insert_deferred_queue(l_ptr, head);
1771 tipc_node_unlock(n_ptr);
1776 link_recv_proto_msg(l_ptr, buf);
1777 head = link_insert_deferred_queue(l_ptr, head);
1778 tipc_node_unlock(n_ptr);
1783 if (link_working_working(l_ptr)) {
1787 tipc_node_unlock(n_ptr);
1790 tipc_node_unlock(n_ptr);
1807 u32 seq_no = buf_seqno(buf);
1812 if (*head ==
NULL) {
1813 *head = *tail =
buf;
1818 if (less(buf_seqno(*tail), seq_no)) {
1819 (*tail)->next =
buf;
1828 u32 curr_seqno = buf_seqno(queue_buf);
1830 if (seq_no == curr_seqno) {
1835 if (less(seq_no, curr_seqno))
1838 prev = &queue_buf->
next;
1839 queue_buf = queue_buf->
next;
1842 buf->
next = queue_buf;
1850 static void link_handle_out_of_seq_msg(
struct tipc_link *l_ptr,
1853 u32 seq_no = buf_seqno(buf);
1856 link_recv_proto_msg(l_ptr, buf);
1868 l_ptr->
stats.duplicates++;
1876 l_ptr->
stats.deferred_recv++;
1880 l_ptr->
stats.duplicates++;
1887 int probe_msg,
u32 gap,
u32 tolerance,
1901 if (link_blocked(l_ptr))
1909 msg_set_type(msg, msg_typ);
1910 msg_set_net_plane(msg, l_ptr->
b_ptr->net_plane);
1911 msg_set_bcast_ack(msg, l_ptr->
owner->bclink.last_in);
1920 next_sent = buf_seqno(l_ptr->
next_out);
1921 msg_set_next_sent(msg, next_sent);
1926 msg_set_seq_gap(msg, gap);
1928 l_ptr->
stats.sent_nacks++;
1929 msg_set_link_tolerance(msg, tolerance);
1930 msg_set_linkprio(msg, priority);
1931 msg_set_max_pkt(msg, ack_mtu);
1933 msg_set_probe(msg, probe_msg != 0);
1937 if ((mtu < l_ptr->max_pkt_target) &&
1938 link_working_working(l_ptr) &&
1949 l_ptr->
stats.sent_probes++;
1951 l_ptr->
stats.sent_states++;
1954 msg_set_seq_gap(msg, 0);
1955 msg_set_next_sent(msg, 1);
1956 msg_set_probe(msg, 0);
1957 msg_set_link_tolerance(msg, l_ptr->
tolerance);
1958 msg_set_linkprio(msg, l_ptr->
priority);
1963 msg_set_redundant_link(msg, r_flag);
1964 msg_set_linkprio(msg, l_ptr->
priority);
1965 msg_set_size(msg, msg_size);
1973 skb_copy_to_linear_data(buf, msg,
sizeof(l_ptr->
proto_msg));
1985 l_ptr->
stats.bearer_congs++;
1999 static void link_recv_proto_msg(
struct tipc_link *l_ptr,
struct sk_buff *buf)
2005 struct tipc_msg *msg = buf_msg(buf);
2007 if (link_blocked(l_ptr))
2013 if (l_ptr->
b_ptr->net_plane != msg_net_plane(msg))
2014 if (tipc_own_addr > msg_prevnode(msg))
2015 l_ptr->
b_ptr->net_plane = msg_net_plane(msg);
2017 l_ptr->
owner->permit_changeover = msg_redundant_link(msg);
2022 if (!link_working_unknown(l_ptr) &&
2028 if (!msg_redundant_link(msg) && (link_working_working(l_ptr) ||
2029 link_working_unknown(l_ptr))) {
2044 msg_tol = msg_link_tolerance(msg);
2046 link_set_supervision_props(l_ptr, msg_tol);
2048 if (msg_linkprio(msg) > l_ptr->
priority)
2049 l_ptr->
priority = msg_linkprio(msg);
2051 max_pkt_info = msg_max_pkt(msg);
2053 if (max_pkt_info < l_ptr->max_pkt_target)
2060 l_ptr->
owner->bclink.supportable = (max_pkt_info != 0);
2064 l_ptr->
owner->bclink.last_sent =
2065 l_ptr->
owner->bclink.last_in =
2066 msg_last_bcast(msg);
2067 l_ptr->
owner->bclink.oos_state = 0;
2078 msg_tol = msg_link_tolerance(msg);
2080 link_set_supervision_props(l_ptr, msg_tol);
2082 if (msg_linkprio(msg) &&
2083 (msg_linkprio(msg) != l_ptr->
priority)) {
2084 pr_warn(
"%s<%s>, priority change %u->%u\n",
2087 l_ptr->
priority = msg_linkprio(msg);
2092 l_ptr->
stats.recv_states++;
2093 if (link_reset_unknown(l_ptr))
2097 rec_gap =
mod(msg_next_sent(msg) -
2101 max_pkt_ack = msg_max_pkt(msg);
2102 if (max_pkt_ack > l_ptr->
max_pkt) {
2108 if (msg_probe(msg)) {
2109 l_ptr->
stats.recv_probes++;
2115 if (l_ptr->
owner->bclink.supported)
2117 msg_last_bcast(msg));
2119 if (rec_gap || (msg_probe(msg))) {
2121 0, rec_gap, 0, 0, max_pkt_ack);
2123 if (msg_seq_gap(msg)) {
2124 l_ptr->
stats.recv_nacks++;
2139 static void tipc_link_tunnel(
struct tipc_link *l_ptr,
2148 tunnel = l_ptr->
owner->active_links[selector & 1];
2150 pr_warn(
"%stunnel link no longer available\n", link_co_err);
2153 msg_set_size(tunnel_hdr, length + INT_H_SIZE);
2156 pr_warn(
"%sunable to send tunnel msg\n", link_co_err);
2159 skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE);
2160 skb_copy_to_linear_data_offset(buf, INT_H_SIZE, msg, length);
2181 if (!l_ptr->
owner->permit_changeover) {
2182 pr_warn(
"%speer did not permit changeover\n", link_co_err);
2189 msg_set_msgcnt(&tunnel_hdr, msgcount);
2196 skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE);
2197 msg_set_size(&tunnel_hdr, INT_H_SIZE);
2200 pr_warn(
"%sunable to send changeover msg\n",
2206 split_bundles = (l_ptr->
owner->active_links[0] !=
2207 l_ptr->
owner->active_links[1]);
2210 struct tipc_msg *msg = buf_msg(crs);
2212 if ((msg_user(msg) ==
MSG_BUNDLER) && split_bundles) {
2213 struct tipc_msg *
m = msg_get_wrapped(msg);
2216 msgcount = msg_msgcnt(msg);
2217 while (msgcount--) {
2218 msg_set_seqno(m, msg_seqno(msg));
2219 tipc_link_tunnel(l_ptr, &tunnel_hdr, m,
2220 msg_link_selector(m));
2225 tipc_link_tunnel(l_ptr, &tunnel_hdr, msg,
2226 msg_link_selector(msg));
2244 struct tipc_msg *msg = buf_msg(iter);
2250 msg_set_bcast_ack(msg, l_ptr->
owner->bclink.last_in);
2251 msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
2253 if (outbuf ==
NULL) {
2254 pr_warn(
"%sunable to send duplicate msg\n",
2258 skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE);
2259 skb_copy_to_linear_data_offset(outbuf, INT_H_SIZE, iter->
data,
2284 skb_copy_to_linear_data(eb, msg, size);
2292 static int link_recv_changeover_msg(
struct tipc_link **l_ptr,
2298 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
2300 u32 msg_count = msg_msgcnt(tunnel_msg);
2302 dest_link = (*l_ptr)->
owner->links[msg_bearer_id(tunnel_msg)];
2305 if (dest_link == *l_ptr) {
2306 pr_err(
"Unexpected changeover message on link <%s>\n",
2311 msg = msg_get_wrapped(tunnel_msg);
2316 *buf = buf_extract(tunnel_buf, INT_H_SIZE);
2318 pr_warn(
"%sduplicate msg dropped\n", link_co_err);
2327 pr_info(
"%s<%s>, changeover initiated by peer\n", link_rst_msg,
2341 pr_warn(
"%sgot too many tunnelled messages\n", link_co_err);
2348 *buf = buf_extract(tunnel_buf, INT_H_SIZE);
2353 pr_warn(
"%soriginal msg dropped\n", link_co_err);
2367 u32 msgcount = msg_msgcnt(buf_msg(buf));
2371 while (msgcount--) {
2372 obuf = buf_extract(buf, pos);
2374 pr_warn(
"Link unable to unbundle message(s)\n");
2392 static int link_send_long_buf(
struct tipc_link *l_ptr,
struct sk_buff *buf)
2396 struct tipc_msg *inmsg = buf_msg(buf);
2399 u32 dsz = msg_data_sz(inmsg);
2407 if (msg_short(inmsg))
2408 destaddr = l_ptr->
addr;
2410 destaddr = msg_destnode(inmsg);
2414 INT_H_SIZE, destaddr);
2420 if (rest <= fragm_sz) {
2425 if (fragm ==
NULL) {
2429 buf_chain = buf_chain->
next;
2434 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
2436 msg_set_fragm_no(&fragm_hdr, fragm_no);
2437 skb_copy_to_linear_data(fragm, &fragm_hdr, INT_H_SIZE);
2438 skb_copy_to_linear_data_offset(fragm, INT_H_SIZE, crs,
2440 buf_chain_tail->
next = fragm;
2441 buf_chain_tail = fragm;
2445 msg_set_type(&fragm_hdr,
FRAGMENT);
2452 l_ptr->
stats.sent_fragments += fragm_no;
2453 l_ptr->
stats.sent_fragmented++;
2465 static void set_long_msg_seqno(
struct sk_buff *buf,
u32 seqno)
2467 msg_set_seqno(buf_msg(buf), seqno);
2470 static u32 get_fragm_size(
struct sk_buff *buf)
2472 return msg_ack(buf_msg(buf));
2475 static void set_fragm_size(
struct sk_buff *buf,
u32 sz)
2477 msg_set_ack(buf_msg(buf), sz);
2480 static u32 get_expected_frags(
struct sk_buff *buf)
2482 return msg_bcast_ack(buf_msg(buf));
2485 static void set_expected_frags(
struct sk_buff *buf,
u32 exp)
2487 msg_set_bcast_ack(buf_msg(buf), exp);
2490 static u32 get_timer_cnt(
struct sk_buff *buf)
2492 return msg_reroute_cnt(buf_msg(buf));
2495 static void incr_timer_cnt(
struct sk_buff *buf)
2497 msg_incr_reroute_cnt(buf_msg(buf));
2509 struct tipc_msg *fragm = buf_msg(fbuf);
2510 struct sk_buff *pbuf = *pending;
2511 u32 long_msg_seq_no = msg_long_msgno(fragm);
2516 while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) ||
2517 (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) {
2525 u32 fragm_sz = msg_data_sz(fragm);
2526 u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
2536 pbuf->
next = *pending;
2538 skb_copy_to_linear_data(pbuf, imsg,
2539 msg_data_sz(fragm));
2541 set_long_msg_seqno(pbuf, long_msg_seq_no);
2542 set_fragm_size(pbuf, fragm_sz);
2543 set_expected_frags(pbuf, exp_fragm_cnt - 1);
2545 pr_debug(
"Link unable to reassemble fragmented message\n");
2552 u32 dsz = msg_data_sz(fragm);
2553 u32 fsz = get_fragm_size(pbuf);
2554 u32 crs = ((msg_fragm_no(fragm) - 1) * fsz);
2555 u32 exp_frags = get_expected_frags(pbuf) - 1;
2556 skb_copy_to_linear_data_offset(pbuf, crs,
2557 msg_data(fragm), dsz);
2561 if (exp_frags == 0) {
2565 *pending = pbuf->
next;
2566 msg_reset_reroute_cnt(buf_msg(pbuf));
2571 set_expected_frags(pbuf, exp_frags);
2582 static void link_check_defragm_bufs(
struct tipc_link *l_ptr)
2590 if (!link_working_working(l_ptr))
2593 u32 cnt = get_timer_cnt(buf);
2597 incr_timer_cnt(buf);
2610 static void link_set_supervision_props(
struct tipc_link *l_ptr,
u32 tolerance)
2617 ((tolerance / 4) > 500) ? 500 : tolerance / 4;
2650 static struct tipc_link *link_find_link(
const char *name,
2657 if (!link_name_validate(name, &link_name_parts))
2668 l_ptr = (*node)->links[b_ptr->
identity];
2683 static int link_value_is_valid(
u16 cmd,
u32 new_value)
2708 static int link_cmd_set_value(
const char *name,
u32 new_value,
u16 cmd)
2715 l_ptr = link_find_link(name, &node);
2721 tipc_node_lock(node);
2724 link_set_supervision_props(l_ptr, new_value);
2737 tipc_node_unlock(node);
2751 b_ptr->
window = new_value;
2768 m_ptr->
window = new_value;
2787 if (!link_value_is_valid(cmd, new_value))
2788 return tipc_cfg_reply_error_string(
2789 "cannot change, value invalid");
2794 return tipc_cfg_reply_none();
2796 " (cannot change setting on broadcast link)");
2800 res = link_cmd_set_value(args->
name, new_value, cmd);
2803 return tipc_cfg_reply_error_string(
"cannot change link setting");
2805 return tipc_cfg_reply_none();
2812 static void link_reset_statistics(
struct tipc_link *l_ptr)
2828 link_name = (
char *)
TLV_DATA(req_tlv_area);
2831 return tipc_cfg_reply_error_string(
"link not found");
2832 return tipc_cfg_reply_none();
2836 l_ptr = link_find_link(link_name, &node);
2839 return tipc_cfg_reply_error_string(
"link not found");
2842 tipc_node_lock(node);
2843 link_reset_statistics(l_ptr);
2844 tipc_node_unlock(node);
2846 return tipc_cfg_reply_none();
2854 return (count * 100 + (total / 2)) / total;
2865 static int tipc_link_stats(
const char *name,
char *buf,
const u32 buf_size)
2871 u32 profile_total = 0;
2878 l = link_find_link(name, &node);
2883 tipc_node_lock(node);
2894 " %s MTU:%u Priority:%u Tolerance:%u ms"
2895 " Window:%u packets\n",
2900 " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
2906 " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
2916 " TX profile sample:%u packets average:%u octets\n"
2917 " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
2918 "-16384:%u%% -32768:%u%% -66000:%u%%\n",
2930 " RX states:%u probes:%u naks:%u defs:%u"
2935 " TX states:%u probes:%u naks:%u acks:%u"
2940 " Congestion bearer:%u link:%u Send queue"
2945 tipc_node_unlock(node);
2968 str_len = tipc_link_stats((
char *)
TLV_DATA(req_tlv_area),
2972 return tipc_cfg_reply_error_string(
"link not found");
2994 if (dest == tipc_own_addr)
3000 tipc_node_lock(n_ptr);
3004 tipc_node_unlock(n_ptr);
3010 static void link_print(
struct tipc_link *l_ptr,
const char *
str)
3014 if (link_working_unknown(l_ptr))
3016 else if (link_reset_reset(l_ptr))
3018 else if (link_reset_unknown(l_ptr))
3020 else if (link_working_working(l_ptr))