aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2010-12-09 12:17:25 -0500
committerThomas Gleixner <tglx@linutronix.de>2010-12-09 12:17:25 -0500
commitd834a9dcecae834cd6b2bc5e50e1907738d9cf6a (patch)
tree0589d753465d3fe359ba451ba6cb7798df03aaa2 /net/tipc/link.c
parenta38c5380ef9f088be9f49b6e4c5d80af8b1b5cd4 (diff)
parentf658bcfb2607bf0808966a69cf74135ce98e5c2d (diff)
Merge branch 'x86/amd-nb' into x86/apic-cleanups
Reason: apic cleanup series depends on x86/apic, x86/amd-nb x86/platform Conflicts: arch/x86/include/asm/io_apic.h Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c188
1 files changed, 52 insertions, 136 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index a3616b99529b..b31992ccd5d3 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -99,23 +99,6 @@ struct link_name {
99 char if_peer[TIPC_MAX_IF_NAME]; 99 char if_peer[TIPC_MAX_IF_NAME];
100}; 100};
101 101
102#if 0
103
104/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */
105
106/**
107 * struct link_event - link up/down event notification
108 */
109
110struct link_event {
111 u32 addr;
112 int up;
113 void (*fcn)(u32, char *, int);
114 char name[TIPC_MAX_LINK_NAME];
115};
116
117#endif
118
119static void link_handle_out_of_seq_msg(struct link *l_ptr, 102static void link_handle_out_of_seq_msg(struct link *l_ptr,
120 struct sk_buff *buf); 103 struct sk_buff *buf);
121static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf); 104static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf);
@@ -129,6 +112,9 @@ static void link_state_event(struct link *l_ptr, u32 event);
129static void link_reset_statistics(struct link *l_ptr); 112static void link_reset_statistics(struct link *l_ptr);
130static void link_print(struct link *l_ptr, struct print_buf *buf, 113static void link_print(struct link *l_ptr, struct print_buf *buf,
131 const char *str); 114 const char *str);
115static void link_start(struct link *l_ptr);
116static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf);
117
132 118
133/* 119/*
134 * Debugging code used by link routines only 120 * Debugging code used by link routines only
@@ -239,13 +225,13 @@ int tipc_link_is_up(struct link *l_ptr)
239{ 225{
240 if (!l_ptr) 226 if (!l_ptr)
241 return 0; 227 return 0;
242 return (link_working_working(l_ptr) || link_working_unknown(l_ptr)); 228 return link_working_working(l_ptr) || link_working_unknown(l_ptr);
243} 229}
244 230
245int tipc_link_is_active(struct link *l_ptr) 231int tipc_link_is_active(struct link *l_ptr)
246{ 232{
247 return ((l_ptr->owner->active_links[0] == l_ptr) || 233 return (l_ptr->owner->active_links[0] == l_ptr) ||
248 (l_ptr->owner->active_links[1] == l_ptr)); 234 (l_ptr->owner->active_links[1] == l_ptr);
249} 235}
250 236
251/** 237/**
@@ -459,7 +445,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
459 445
460 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr); 446 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr);
461 list_add_tail(&l_ptr->link_list, &b_ptr->links); 447 list_add_tail(&l_ptr->link_list, &b_ptr->links);
462 tipc_k_signal((Handler)tipc_link_start, (unsigned long)l_ptr); 448 tipc_k_signal((Handler)link_start, (unsigned long)l_ptr);
463 449
464 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", 450 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n",
465 l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit); 451 l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit);
@@ -499,9 +485,9 @@ void tipc_link_delete(struct link *l_ptr)
499 kfree(l_ptr); 485 kfree(l_ptr);
500} 486}
501 487
502void tipc_link_start(struct link *l_ptr) 488static void link_start(struct link *l_ptr)
503{ 489{
504 dbg("tipc_link_start %x\n", l_ptr); 490 dbg("link_start %x\n", l_ptr);
505 link_state_event(l_ptr, STARTING_EVT); 491 link_state_event(l_ptr, STARTING_EVT);
506} 492}
507 493
@@ -634,39 +620,9 @@ void tipc_link_stop(struct link *l_ptr)
634 l_ptr->proto_msg_queue = NULL; 620 l_ptr->proto_msg_queue = NULL;
635} 621}
636 622
637#if 0
638
639/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */ 623/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */
640
641static void link_recv_event(struct link_event *ev)
642{
643 ev->fcn(ev->addr, ev->name, ev->up);
644 kfree(ev);
645}
646
647static void link_send_event(void (*fcn)(u32 a, char *n, int up),
648 struct link *l_ptr, int up)
649{
650 struct link_event *ev;
651
652 ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
653 if (!ev) {
654 warn("Link event allocation failure\n");
655 return;
656 }
657 ev->addr = l_ptr->addr;
658 ev->up = up;
659 ev->fcn = fcn;
660 memcpy(ev->name, l_ptr->name, TIPC_MAX_LINK_NAME);
661 tipc_k_signal((Handler)link_recv_event, (unsigned long)ev);
662}
663
664#else
665
666#define link_send_event(fcn, l_ptr, up) do { } while (0) 624#define link_send_event(fcn, l_ptr, up) do { } while (0)
667 625
668#endif
669
670void tipc_link_reset(struct link *l_ptr) 626void tipc_link_reset(struct link *l_ptr)
671{ 627{
672 struct sk_buff *buf; 628 struct sk_buff *buf;
@@ -690,10 +646,7 @@ void tipc_link_reset(struct link *l_ptr)
690 646
691 tipc_node_link_down(l_ptr->owner, l_ptr); 647 tipc_node_link_down(l_ptr->owner, l_ptr);
692 tipc_bearer_remove_dest(l_ptr->b_ptr, l_ptr->addr); 648 tipc_bearer_remove_dest(l_ptr->b_ptr, l_ptr->addr);
693#if 0 649
694 tipc_printf(TIPC_CONS, "\nReset link <%s>\n", l_ptr->name);
695 dbg_link_dump();
696#endif
697 if (was_active_link && tipc_node_has_active_links(l_ptr->owner) && 650 if (was_active_link && tipc_node_has_active_links(l_ptr->owner) &&
698 l_ptr->owner->permit_changeover) { 651 l_ptr->owner->permit_changeover) {
699 l_ptr->reset_checkpoint = checkpoint; 652 l_ptr->reset_checkpoint = checkpoint;
@@ -1050,7 +1003,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1050 /* Fragmentation needed ? */ 1003 /* Fragmentation needed ? */
1051 1004
1052 if (size > max_packet) 1005 if (size > max_packet)
1053 return tipc_link_send_long_buf(l_ptr, buf); 1006 return link_send_long_buf(l_ptr, buf);
1054 1007
1055 /* Packet can be queued or sent: */ 1008 /* Packet can be queued or sent: */
1056 1009
@@ -1086,7 +1039,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1086 /* Try creating a new bundle */ 1039 /* Try creating a new bundle */
1087 1040
1088 if (size <= max_packet * 2 / 3) { 1041 if (size <= max_packet * 2 / 3) {
1089 struct sk_buff *bundler = buf_acquire(max_packet); 1042 struct sk_buff *bundler = tipc_buf_acquire(max_packet);
1090 struct tipc_msg bundler_hdr; 1043 struct tipc_msg bundler_hdr;
1091 1044
1092 if (bundler) { 1045 if (bundler) {
@@ -1362,7 +1315,7 @@ again:
1362 1315
1363 /* Prepare header of first fragment: */ 1316 /* Prepare header of first fragment: */
1364 1317
1365 buf_chain = buf = buf_acquire(max_pkt); 1318 buf_chain = buf = tipc_buf_acquire(max_pkt);
1366 if (!buf) 1319 if (!buf)
1367 return -ENOMEM; 1320 return -ENOMEM;
1368 buf->next = NULL; 1321 buf->next = NULL;
@@ -1419,7 +1372,7 @@ error:
1419 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); 1372 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
1420 msg_set_fragm_no(&fragm_hdr, ++fragm_no); 1373 msg_set_fragm_no(&fragm_hdr, ++fragm_no);
1421 prev = buf; 1374 prev = buf;
1422 buf = buf_acquire(fragm_sz + INT_H_SIZE); 1375 buf = tipc_buf_acquire(fragm_sz + INT_H_SIZE);
1423 if (!buf) 1376 if (!buf)
1424 goto error; 1377 goto error;
1425 1378
@@ -1802,6 +1755,15 @@ static int link_recv_buf_validate(struct sk_buff *buf)
1802 return pskb_may_pull(buf, hdr_size); 1755 return pskb_may_pull(buf, hdr_size);
1803} 1756}
1804 1757
1758/**
1759 * tipc_recv_msg - process TIPC messages arriving from off-node
1760 * @head: pointer to message buffer chain
1761 * @tb_ptr: pointer to bearer message arrived on
1762 *
1763 * Invoked with no locks held. Bearer pointer must point to a valid bearer
1764 * structure (i.e. cannot be NULL), but bearer can be inactive.
1765 */
1766
1805void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) 1767void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1806{ 1768{
1807 read_lock_bh(&tipc_net_lock); 1769 read_lock_bh(&tipc_net_lock);
@@ -1819,6 +1781,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1819 1781
1820 head = head->next; 1782 head = head->next;
1821 1783
1784 /* Ensure bearer is still enabled */
1785
1786 if (unlikely(!b_ptr->active))
1787 goto cont;
1788
1822 /* Ensure message is well-formed */ 1789 /* Ensure message is well-formed */
1823 1790
1824 if (unlikely(!link_recv_buf_validate(buf))) 1791 if (unlikely(!link_recv_buf_validate(buf)))
@@ -1855,13 +1822,22 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1855 goto cont; 1822 goto cont;
1856 } 1823 }
1857 1824
1858 /* Locate unicast link endpoint that should handle message */ 1825 /* Locate neighboring node that sent message */
1859 1826
1860 n_ptr = tipc_node_find(msg_prevnode(msg)); 1827 n_ptr = tipc_node_find(msg_prevnode(msg));
1861 if (unlikely(!n_ptr)) 1828 if (unlikely(!n_ptr))
1862 goto cont; 1829 goto cont;
1863 tipc_node_lock(n_ptr); 1830 tipc_node_lock(n_ptr);
1864 1831
1832 /* Don't talk to neighbor during cleanup after last session */
1833
1834 if (n_ptr->cleanup_required) {
1835 tipc_node_unlock(n_ptr);
1836 goto cont;
1837 }
1838
1839 /* Locate unicast link endpoint that should handle message */
1840
1865 l_ptr = n_ptr->links[b_ptr->identity]; 1841 l_ptr = n_ptr->links[b_ptr->identity];
1866 if (unlikely(!l_ptr)) { 1842 if (unlikely(!l_ptr)) {
1867 tipc_node_unlock(n_ptr); 1843 tipc_node_unlock(n_ptr);
@@ -2172,7 +2148,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2172 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { 2148 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
2173 if (!l_ptr->proto_msg_queue) { 2149 if (!l_ptr->proto_msg_queue) {
2174 l_ptr->proto_msg_queue = 2150 l_ptr->proto_msg_queue =
2175 buf_acquire(sizeof(l_ptr->proto_msg)); 2151 tipc_buf_acquire(sizeof(l_ptr->proto_msg));
2176 } 2152 }
2177 buf = l_ptr->proto_msg_queue; 2153 buf = l_ptr->proto_msg_queue;
2178 if (!buf) 2154 if (!buf)
@@ -2186,7 +2162,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2186 2162
2187 msg_dbg(msg, ">>"); 2163 msg_dbg(msg, ">>");
2188 2164
2189 buf = buf_acquire(msg_size); 2165 buf = tipc_buf_acquire(msg_size);
2190 if (!buf) 2166 if (!buf)
2191 return; 2167 return;
2192 2168
@@ -2345,10 +2321,10 @@ exit:
2345 * tipc_link_tunnel(): Send one message via a link belonging to 2321 * tipc_link_tunnel(): Send one message via a link belonging to
2346 * another bearer. Owner node is locked. 2322 * another bearer. Owner node is locked.
2347 */ 2323 */
2348void tipc_link_tunnel(struct link *l_ptr, 2324static void tipc_link_tunnel(struct link *l_ptr,
2349 struct tipc_msg *tunnel_hdr, 2325 struct tipc_msg *tunnel_hdr,
2350 struct tipc_msg *msg, 2326 struct tipc_msg *msg,
2351 u32 selector) 2327 u32 selector)
2352{ 2328{
2353 struct link *tunnel; 2329 struct link *tunnel;
2354 struct sk_buff *buf; 2330 struct sk_buff *buf;
@@ -2361,7 +2337,7 @@ void tipc_link_tunnel(struct link *l_ptr,
2361 return; 2337 return;
2362 } 2338 }
2363 msg_set_size(tunnel_hdr, length + INT_H_SIZE); 2339 msg_set_size(tunnel_hdr, length + INT_H_SIZE);
2364 buf = buf_acquire(length + INT_H_SIZE); 2340 buf = tipc_buf_acquire(length + INT_H_SIZE);
2365 if (!buf) { 2341 if (!buf) {
2366 warn("Link changeover error, " 2342 warn("Link changeover error, "
2367 "unable to send tunnel msg\n"); 2343 "unable to send tunnel msg\n");
@@ -2407,7 +2383,7 @@ void tipc_link_changeover(struct link *l_ptr)
2407 if (!l_ptr->first_out) { 2383 if (!l_ptr->first_out) {
2408 struct sk_buff *buf; 2384 struct sk_buff *buf;
2409 2385
2410 buf = buf_acquire(INT_H_SIZE); 2386 buf = tipc_buf_acquire(INT_H_SIZE);
2411 if (buf) { 2387 if (buf) {
2412 skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE); 2388 skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE);
2413 msg_set_size(&tunnel_hdr, INT_H_SIZE); 2389 msg_set_size(&tunnel_hdr, INT_H_SIZE);
@@ -2468,7 +2444,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2468 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */ 2444 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */
2469 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 2445 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
2470 msg_set_size(&tunnel_hdr, length + INT_H_SIZE); 2446 msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
2471 outbuf = buf_acquire(length + INT_H_SIZE); 2447 outbuf = tipc_buf_acquire(length + INT_H_SIZE);
2472 if (outbuf == NULL) { 2448 if (outbuf == NULL) {
2473 warn("Link changeover error, " 2449 warn("Link changeover error, "
2474 "unable to send duplicate msg\n"); 2450 "unable to send duplicate msg\n");
@@ -2504,7 +2480,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
2504 u32 size = msg_size(msg); 2480 u32 size = msg_size(msg);
2505 struct sk_buff *eb; 2481 struct sk_buff *eb;
2506 2482
2507 eb = buf_acquire(size); 2483 eb = tipc_buf_acquire(size);
2508 if (eb) 2484 if (eb)
2509 skb_copy_to_linear_data(eb, msg, size); 2485 skb_copy_to_linear_data(eb, msg, size);
2510 return eb; 2486 return eb;
@@ -2632,11 +2608,11 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
2632 2608
2633 2609
2634/* 2610/*
2635 * tipc_link_send_long_buf: Entry for buffers needing fragmentation. 2611 * link_send_long_buf: Entry for buffers needing fragmentation.
2636 * The buffer is complete, inclusive total message length. 2612 * The buffer is complete, inclusive total message length.
2637 * Returns user data length. 2613 * Returns user data length.
2638 */ 2614 */
2639int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) 2615static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2640{ 2616{
2641 struct tipc_msg *inmsg = buf_msg(buf); 2617 struct tipc_msg *inmsg = buf_msg(buf);
2642 struct tipc_msg fragm_hdr; 2618 struct tipc_msg fragm_hdr;
@@ -2675,7 +2651,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2675 fragm_sz = rest; 2651 fragm_sz = rest;
2676 msg_set_type(&fragm_hdr, LAST_FRAGMENT); 2652 msg_set_type(&fragm_hdr, LAST_FRAGMENT);
2677 } 2653 }
2678 fragm = buf_acquire(fragm_sz + INT_H_SIZE); 2654 fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE);
2679 if (fragm == NULL) { 2655 if (fragm == NULL) {
2680 warn("Link unable to fragment message\n"); 2656 warn("Link unable to fragment message\n");
2681 dsz = -ENOMEM; 2657 dsz = -ENOMEM;
@@ -2780,7 +2756,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2780 buf_discard(fbuf); 2756 buf_discard(fbuf);
2781 return 0; 2757 return 0;
2782 } 2758 }
2783 pbuf = buf_acquire(msg_size(imsg)); 2759 pbuf = tipc_buf_acquire(msg_size(imsg));
2784 if (pbuf != NULL) { 2760 if (pbuf != NULL) {
2785 pbuf->next = *pending; 2761 pbuf->next = *pending;
2786 *pending = pbuf; 2762 *pending = pbuf;
@@ -3174,44 +3150,6 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s
3174 return buf; 3150 return buf;
3175} 3151}
3176 3152
3177#if 0
3178int link_control(const char *name, u32 op, u32 val)
3179{
3180 int res = -EINVAL;
3181 struct link *l_ptr;
3182 u32 bearer_id;
3183 struct tipc_node * node;
3184 u32 a;
3185
3186 a = link_name2addr(name, &bearer_id);
3187 read_lock_bh(&tipc_net_lock);
3188 node = tipc_node_find(a);
3189 if (node) {
3190 tipc_node_lock(node);
3191 l_ptr = node->links[bearer_id];
3192 if (l_ptr) {
3193 if (op == TIPC_REMOVE_LINK) {
3194 struct bearer *b_ptr = l_ptr->b_ptr;
3195 spin_lock_bh(&b_ptr->publ.lock);
3196 tipc_link_delete(l_ptr);
3197 spin_unlock_bh(&b_ptr->publ.lock);
3198 }
3199 if (op == TIPC_CMD_BLOCK_LINK) {
3200 tipc_link_reset(l_ptr);
3201 l_ptr->blocked = 1;
3202 }
3203 if (op == TIPC_CMD_UNBLOCK_LINK) {
3204 l_ptr->blocked = 0;
3205 }
3206 res = 0;
3207 }
3208 tipc_node_unlock(node);
3209 }
3210 read_unlock_bh(&tipc_net_lock);
3211 return res;
3212}
3213#endif
3214
3215/** 3153/**
3216 * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination 3154 * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination
3217 * @dest: network address of destination node 3155 * @dest: network address of destination node
@@ -3242,28 +3180,6 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3242 return res; 3180 return res;
3243} 3181}
3244 3182
3245#if 0
3246static void link_dump_rec_queue(struct link *l_ptr)
3247{
3248 struct sk_buff *crs;
3249
3250 if (!l_ptr->oldest_deferred_in) {
3251 info("Reception queue empty\n");
3252 return;
3253 }
3254 info("Contents of Reception queue:\n");
3255 crs = l_ptr->oldest_deferred_in;
3256 while (crs) {
3257 if (crs->data == (void *)0x0000a3a3) {
3258 info("buffer %x invalid\n", crs);
3259 return;
3260 }
3261 msg_dbg(buf_msg(crs), "In rec queue:\n");
3262 crs = crs->next;
3263 }
3264}
3265#endif
3266
3267static void link_dump_send_queue(struct link *l_ptr) 3183static void link_dump_send_queue(struct link *l_ptr)
3268{ 3184{
3269 if (l_ptr->next_out) { 3185 if (l_ptr->next_out) {