aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-19 20:02:01 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-19 20:02:01 -0400
commit10ce3cc919f50c2043b41ca968b43c26a3672600 (patch)
treeea409366a5208aced495bc0516a08b81fd43222e /net/tipc
parent24e3e5ae1e4c2a3a32f5b1f96b4e3fd721806acd (diff)
parent5c6a7a62c130afef3d61c1dee153012231ff5cd9 (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/bcast.c161
-rw-r--r--net/tipc/bcast.h16
-rw-r--r--net/tipc/bearer.c190
-rw-r--r--net/tipc/bearer.h77
-rw-r--r--net/tipc/config.c13
-rw-r--r--net/tipc/core.c2
-rw-r--r--net/tipc/discover.c27
-rw-r--r--net/tipc/discover.h8
-rw-r--r--net/tipc/eth_media.c159
-rw-r--r--net/tipc/link.c346
-rw-r--r--net/tipc/link.h63
-rw-r--r--net/tipc/msg.c9
-rw-r--r--net/tipc/msg.h16
-rw-r--r--net/tipc/name_distr.c14
-rw-r--r--net/tipc/name_table.c15
-rw-r--r--net/tipc/name_table.h10
-rw-r--r--net/tipc/net.c7
-rw-r--r--net/tipc/node.c25
-rw-r--r--net/tipc/node.h12
-rw-r--r--net/tipc/port.c8
-rw-r--r--net/tipc/port.h4
-rw-r--r--net/tipc/ref.c3
-rw-r--r--net/tipc/socket.c3
-rw-r--r--net/tipc/subscr.c46
-rw-r--r--net/tipc/subscr.h10
25 files changed, 699 insertions, 545 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 28908f54459e..8eb87b11d100 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -46,7 +46,7 @@
46#define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */ 46#define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */
47 47
48/** 48/**
49 * struct bcbearer_pair - a pair of bearers used by broadcast link 49 * struct tipc_bcbearer_pair - a pair of bearers used by broadcast link
50 * @primary: pointer to primary bearer 50 * @primary: pointer to primary bearer
51 * @secondary: pointer to secondary bearer 51 * @secondary: pointer to secondary bearer
52 * 52 *
@@ -54,13 +54,13 @@
54 * to be paired. 54 * to be paired.
55 */ 55 */
56 56
57struct bcbearer_pair { 57struct tipc_bcbearer_pair {
58 struct tipc_bearer *primary; 58 struct tipc_bearer *primary;
59 struct tipc_bearer *secondary; 59 struct tipc_bearer *secondary;
60}; 60};
61 61
62/** 62/**
63 * struct bcbearer - bearer used by broadcast link 63 * struct tipc_bcbearer - bearer used by broadcast link
64 * @bearer: (non-standard) broadcast bearer structure 64 * @bearer: (non-standard) broadcast bearer structure
65 * @media: (non-standard) broadcast media structure 65 * @media: (non-standard) broadcast media structure
66 * @bpairs: array of bearer pairs 66 * @bpairs: array of bearer pairs
@@ -74,38 +74,40 @@ struct bcbearer_pair {
74 * prevented through use of the spinlock "bc_lock". 74 * prevented through use of the spinlock "bc_lock".
75 */ 75 */
76 76
77struct bcbearer { 77struct tipc_bcbearer {
78 struct tipc_bearer bearer; 78 struct tipc_bearer bearer;
79 struct media media; 79 struct tipc_media media;
80 struct bcbearer_pair bpairs[MAX_BEARERS]; 80 struct tipc_bcbearer_pair bpairs[MAX_BEARERS];
81 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; 81 struct tipc_bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1];
82 struct tipc_node_map remains; 82 struct tipc_node_map remains;
83 struct tipc_node_map remains_new; 83 struct tipc_node_map remains_new;
84}; 84};
85 85
86/** 86/**
87 * struct bclink - link used for broadcast messages 87 * struct tipc_bclink - link used for broadcast messages
88 * @link: (non-standard) broadcast link structure 88 * @link: (non-standard) broadcast link structure
89 * @node: (non-standard) node structure representing b'cast link's peer node 89 * @node: (non-standard) node structure representing b'cast link's peer node
90 * @bcast_nodes: map of broadcast-capable nodes
90 * @retransmit_to: node that most recently requested a retransmit 91 * @retransmit_to: node that most recently requested a retransmit
91 * 92 *
92 * Handles sequence numbering, fragmentation, bundling, etc. 93 * Handles sequence numbering, fragmentation, bundling, etc.
93 */ 94 */
94 95
95struct bclink { 96struct tipc_bclink {
96 struct link link; 97 struct tipc_link link;
97 struct tipc_node node; 98 struct tipc_node node;
99 struct tipc_node_map bcast_nodes;
98 struct tipc_node *retransmit_to; 100 struct tipc_node *retransmit_to;
99}; 101};
100 102
103static struct tipc_bcbearer bcast_bearer;
104static struct tipc_bclink bcast_link;
101 105
102static struct bcbearer *bcbearer; 106static struct tipc_bcbearer *bcbearer = &bcast_bearer;
103static struct bclink *bclink; 107static struct tipc_bclink *bclink = &bcast_link;
104static struct link *bcl; 108static struct tipc_link *bcl = &bcast_link.link;
105static DEFINE_SPINLOCK(bc_lock);
106 109
107/* broadcast-capable node map */ 110static DEFINE_SPINLOCK(bc_lock);
108struct tipc_node_map tipc_bcast_nmap;
109 111
110const char tipc_bclink_name[] = "broadcast-link"; 112const char tipc_bclink_name[] = "broadcast-link";
111 113
@@ -113,11 +115,6 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
113 struct tipc_node_map *nm_b, 115 struct tipc_node_map *nm_b,
114 struct tipc_node_map *nm_diff); 116 struct tipc_node_map *nm_diff);
115 117
116static u32 buf_seqno(struct sk_buff *buf)
117{
118 return msg_seqno(buf_msg(buf));
119}
120
121static u32 bcbuf_acks(struct sk_buff *buf) 118static u32 bcbuf_acks(struct sk_buff *buf)
122{ 119{
123 return (u32)(unsigned long)TIPC_SKB_CB(buf)->handle; 120 return (u32)(unsigned long)TIPC_SKB_CB(buf)->handle;
@@ -133,6 +130,19 @@ static void bcbuf_decr_acks(struct sk_buff *buf)
133 bcbuf_set_acks(buf, bcbuf_acks(buf) - 1); 130 bcbuf_set_acks(buf, bcbuf_acks(buf) - 1);
134} 131}
135 132
133void tipc_bclink_add_node(u32 addr)
134{
135 spin_lock_bh(&bc_lock);
136 tipc_nmap_add(&bclink->bcast_nodes, addr);
137 spin_unlock_bh(&bc_lock);
138}
139
140void tipc_bclink_remove_node(u32 addr)
141{
142 spin_lock_bh(&bc_lock);
143 tipc_nmap_remove(&bclink->bcast_nodes, addr);
144 spin_unlock_bh(&bc_lock);
145}
136 146
137static void bclink_set_last_sent(void) 147static void bclink_set_last_sent(void)
138{ 148{
@@ -222,14 +232,36 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
222 struct sk_buff *next; 232 struct sk_buff *next;
223 unsigned int released = 0; 233 unsigned int released = 0;
224 234
225 if (less_eq(acked, n_ptr->bclink.acked))
226 return;
227
228 spin_lock_bh(&bc_lock); 235 spin_lock_bh(&bc_lock);
229 236
230 /* Skip over packets that node has previously acknowledged */ 237 /* Bail out if tx queue is empty (no clean up is required) */
231
232 crs = bcl->first_out; 238 crs = bcl->first_out;
239 if (!crs)
240 goto exit;
241
242 /* Determine which messages need to be acknowledged */
243 if (acked == INVALID_LINK_SEQ) {
244 /*
245 * Contact with specified node has been lost, so need to
246 * acknowledge sent messages only (if other nodes still exist)
247 * or both sent and unsent messages (otherwise)
248 */
249 if (bclink->bcast_nodes.count)
250 acked = bcl->fsm_msg_cnt;
251 else
252 acked = bcl->next_out_no;
253 } else {
254 /*
255 * Bail out if specified sequence number does not correspond
256 * to a message that has been sent and not yet acknowledged
257 */
258 if (less(acked, buf_seqno(crs)) ||
259 less(bcl->fsm_msg_cnt, acked) ||
260 less_eq(acked, n_ptr->bclink.acked))
261 goto exit;
262 }
263
264 /* Skip over packets that node has previously acknowledged */
233 while (crs && less_eq(buf_seqno(crs), n_ptr->bclink.acked)) 265 while (crs && less_eq(buf_seqno(crs), n_ptr->bclink.acked))
234 crs = crs->next; 266 crs = crs->next;
235 267
@@ -237,7 +269,15 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
237 269
238 while (crs && less_eq(buf_seqno(crs), acked)) { 270 while (crs && less_eq(buf_seqno(crs), acked)) {
239 next = crs->next; 271 next = crs->next;
240 bcbuf_decr_acks(crs); 272
273 if (crs != bcl->next_out)
274 bcbuf_decr_acks(crs);
275 else {
276 bcbuf_set_acks(crs, 0);
277 bcl->next_out = next;
278 bclink_set_last_sent();
279 }
280
241 if (bcbuf_acks(crs) == 0) { 281 if (bcbuf_acks(crs) == 0) {
242 bcl->first_out = next; 282 bcl->first_out = next;
243 bcl->out_queue_size--; 283 bcl->out_queue_size--;
@@ -256,6 +296,7 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
256 } 296 }
257 if (unlikely(released && !list_empty(&bcl->waiting_ports))) 297 if (unlikely(released && !list_empty(&bcl->waiting_ports)))
258 tipc_link_wakeup_ports(bcl, 0); 298 tipc_link_wakeup_ports(bcl, 0);
299exit:
259 spin_unlock_bh(&bc_lock); 300 spin_unlock_bh(&bc_lock);
260} 301}
261 302
@@ -267,7 +308,7 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
267 308
268static void bclink_send_ack(struct tipc_node *n_ptr) 309static void bclink_send_ack(struct tipc_node *n_ptr)
269{ 310{
270 struct link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; 311 struct tipc_link *l_ptr = n_ptr->active_links[n_ptr->addr & 1];
271 312
272 if (l_ptr != NULL) 313 if (l_ptr != NULL)
273 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); 314 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
@@ -402,13 +443,19 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
402 443
403 spin_lock_bh(&bc_lock); 444 spin_lock_bh(&bc_lock);
404 445
446 if (!bclink->bcast_nodes.count) {
447 res = msg_data_sz(buf_msg(buf));
448 buf_discard(buf);
449 goto exit;
450 }
451
405 res = tipc_link_send_buf(bcl, buf); 452 res = tipc_link_send_buf(bcl, buf);
406 if (likely(res > 0)) 453 if (likely(res >= 0)) {
407 bclink_set_last_sent(); 454 bclink_set_last_sent();
408 455 bcl->stats.queue_sz_counts++;
409 bcl->stats.queue_sz_counts++; 456 bcl->stats.accu_queue_sz += bcl->out_queue_size;
410 bcl->stats.accu_queue_sz += bcl->out_queue_size; 457 }
411 458exit:
412 spin_unlock_bh(&bc_lock); 459 spin_unlock_bh(&bc_lock);
413 return res; 460 return res;
414} 461}
@@ -572,13 +619,13 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
572 if (likely(!msg_non_seq(buf_msg(buf)))) { 619 if (likely(!msg_non_seq(buf_msg(buf)))) {
573 struct tipc_msg *msg; 620 struct tipc_msg *msg;
574 621
575 bcbuf_set_acks(buf, tipc_bcast_nmap.count); 622 bcbuf_set_acks(buf, bclink->bcast_nodes.count);
576 msg = buf_msg(buf); 623 msg = buf_msg(buf);
577 msg_set_non_seq(msg, 1); 624 msg_set_non_seq(msg, 1);
578 msg_set_mc_netid(msg, tipc_net_id); 625 msg_set_mc_netid(msg, tipc_net_id);
579 bcl->stats.sent_info++; 626 bcl->stats.sent_info++;
580 627
581 if (WARN_ON(!tipc_bcast_nmap.count)) { 628 if (WARN_ON(!bclink->bcast_nodes.count)) {
582 dump_stack(); 629 dump_stack();
583 return 0; 630 return 0;
584 } 631 }
@@ -586,7 +633,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
586 633
587 /* Send buffer over bearers until all targets reached */ 634 /* Send buffer over bearers until all targets reached */
588 635
589 bcbearer->remains = tipc_bcast_nmap; 636 bcbearer->remains = bclink->bcast_nodes;
590 637
591 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { 638 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
592 struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary; 639 struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
@@ -630,8 +677,8 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
630 677
631void tipc_bcbearer_sort(void) 678void tipc_bcbearer_sort(void)
632{ 679{
633 struct bcbearer_pair *bp_temp = bcbearer->bpairs_temp; 680 struct tipc_bcbearer_pair *bp_temp = bcbearer->bpairs_temp;
634 struct bcbearer_pair *bp_curr; 681 struct tipc_bcbearer_pair *bp_curr;
635 int b_index; 682 int b_index;
636 int pri; 683 int pri;
637 684
@@ -752,25 +799,13 @@ int tipc_bclink_set_queue_limits(u32 limit)
752 return 0; 799 return 0;
753} 800}
754 801
755int tipc_bclink_init(void) 802void tipc_bclink_init(void)
756{ 803{
757 bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC);
758 bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
759 if (!bcbearer || !bclink) {
760 warn("Broadcast link creation failed, no memory\n");
761 kfree(bcbearer);
762 bcbearer = NULL;
763 kfree(bclink);
764 bclink = NULL;
765 return -ENOMEM;
766 }
767
768 INIT_LIST_HEAD(&bcbearer->bearer.cong_links); 804 INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
769 bcbearer->bearer.media = &bcbearer->media; 805 bcbearer->bearer.media = &bcbearer->media;
770 bcbearer->media.send_msg = tipc_bcbearer_send; 806 bcbearer->media.send_msg = tipc_bcbearer_send;
771 sprintf(bcbearer->media.name, "tipc-broadcast"); 807 sprintf(bcbearer->media.name, "tipc-broadcast");
772 808
773 bcl = &bclink->link;
774 INIT_LIST_HEAD(&bcl->waiting_ports); 809 INIT_LIST_HEAD(&bcl->waiting_ports);
775 bcl->next_out_no = 1; 810 bcl->next_out_no = 1;
776 spin_lock_init(&bclink->node.lock); 811 spin_lock_init(&bclink->node.lock);
@@ -780,22 +815,16 @@ int tipc_bclink_init(void)
780 bcl->b_ptr = &bcbearer->bearer; 815 bcl->b_ptr = &bcbearer->bearer;
781 bcl->state = WORKING_WORKING; 816 bcl->state = WORKING_WORKING;
782 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); 817 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
783
784 return 0;
785} 818}
786 819
787void tipc_bclink_stop(void) 820void tipc_bclink_stop(void)
788{ 821{
789 spin_lock_bh(&bc_lock); 822 spin_lock_bh(&bc_lock);
790 if (bcbearer) { 823 tipc_link_stop(bcl);
791 tipc_link_stop(bcl);
792 bcl = NULL;
793 kfree(bclink);
794 bclink = NULL;
795 kfree(bcbearer);
796 bcbearer = NULL;
797 }
798 spin_unlock_bh(&bc_lock); 824 spin_unlock_bh(&bc_lock);
825
826 memset(bclink, 0, sizeof(*bclink));
827 memset(bcbearer, 0, sizeof(*bcbearer));
799} 828}
800 829
801 830
@@ -864,9 +893,9 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
864 * tipc_port_list_add - add a port to a port list, ensuring no duplicates 893 * tipc_port_list_add - add a port to a port list, ensuring no duplicates
865 */ 894 */
866 895
867void tipc_port_list_add(struct port_list *pl_ptr, u32 port) 896void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
868{ 897{
869 struct port_list *item = pl_ptr; 898 struct tipc_port_list *item = pl_ptr;
870 int i; 899 int i;
871 int item_sz = PLSIZE; 900 int item_sz = PLSIZE;
872 int cnt = pl_ptr->count; 901 int cnt = pl_ptr->count;
@@ -898,10 +927,10 @@ void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
898 * 927 *
899 */ 928 */
900 929
901void tipc_port_list_free(struct port_list *pl_ptr) 930void tipc_port_list_free(struct tipc_port_list *pl_ptr)
902{ 931{
903 struct port_list *item; 932 struct tipc_port_list *item;
904 struct port_list *next; 933 struct tipc_port_list *next;
905 934
906 for (item = pl_ptr->next; item; item = next) { 935 for (item = pl_ptr->next; item; item = next) {
907 next = item->next; 936 next = item->next;
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index 06740da5ae61..b009666c60b0 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -51,20 +51,18 @@ struct tipc_node_map {
51 u32 map[MAX_NODES / WSIZE]; 51 u32 map[MAX_NODES / WSIZE];
52}; 52};
53 53
54extern struct tipc_node_map tipc_bcast_nmap;
55
56#define PLSIZE 32 54#define PLSIZE 32
57 55
58/** 56/**
59 * struct port_list - set of node local destination ports 57 * struct tipc_port_list - set of node local destination ports
60 * @count: # of ports in set (only valid for first entry in list) 58 * @count: # of ports in set (only valid for first entry in list)
61 * @next: pointer to next entry in list 59 * @next: pointer to next entry in list
62 * @ports: array of port references 60 * @ports: array of port references
63 */ 61 */
64 62
65struct port_list { 63struct tipc_port_list {
66 int count; 64 int count;
67 struct port_list *next; 65 struct tipc_port_list *next;
68 u32 ports[PLSIZE]; 66 u32 ports[PLSIZE];
69}; 67};
70 68
@@ -85,11 +83,13 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m
85 return !memcmp(nm_a, nm_b, sizeof(*nm_a)); 83 return !memcmp(nm_a, nm_b, sizeof(*nm_a));
86} 84}
87 85
88void tipc_port_list_add(struct port_list *pl_ptr, u32 port); 86void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port);
89void tipc_port_list_free(struct port_list *pl_ptr); 87void tipc_port_list_free(struct tipc_port_list *pl_ptr);
90 88
91int tipc_bclink_init(void); 89void tipc_bclink_init(void);
92void tipc_bclink_stop(void); 90void tipc_bclink_stop(void);
91void tipc_bclink_add_node(u32 addr);
92void tipc_bclink_remove_node(u32 addr);
93struct tipc_node *tipc_bclink_retransmit_to(void); 93struct tipc_node *tipc_bclink_retransmit_to(void);
94void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked); 94void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked);
95int tipc_bclink_send_msg(struct sk_buff *buf); 95int tipc_bclink_send_msg(struct sk_buff *buf);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index e2202de3d93e..329fb659fae4 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -41,7 +41,7 @@
41 41
42#define MAX_ADDR_STR 32 42#define MAX_ADDR_STR 32
43 43
44static struct media media_list[MAX_MEDIA]; 44static struct tipc_media *media_list[MAX_MEDIA];
45static u32 media_count; 45static u32 media_count;
46 46
47struct tipc_bearer tipc_bearers[MAX_BEARERS]; 47struct tipc_bearer tipc_bearers[MAX_BEARERS];
@@ -65,17 +65,31 @@ static int media_name_valid(const char *name)
65} 65}
66 66
67/** 67/**
68 * media_find - locates specified media object by name 68 * tipc_media_find - locates specified media object by name
69 */ 69 */
70 70
71static struct media *media_find(const char *name) 71struct tipc_media *tipc_media_find(const char *name)
72{ 72{
73 struct media *m_ptr;
74 u32 i; 73 u32 i;
75 74
76 for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) { 75 for (i = 0; i < media_count; i++) {
77 if (!strcmp(m_ptr->name, name)) 76 if (!strcmp(media_list[i]->name, name))
78 return m_ptr; 77 return media_list[i];
78 }
79 return NULL;
80}
81
82/**
83 * media_find_id - locates specified media object by type identifier
84 */
85
86static struct tipc_media *media_find_id(u8 type)
87{
88 u32 i;
89
90 for (i = 0; i < media_count; i++) {
91 if (media_list[i]->type_id == type)
92 return media_list[i];
79 } 93 }
80 return NULL; 94 return NULL;
81} 95}
@@ -86,87 +100,34 @@ static struct media *media_find(const char *name)
86 * Bearers for this media type must be activated separately at a later stage. 100 * Bearers for this media type must be activated separately at a later stage.
87 */ 101 */
88 102
89int tipc_register_media(u32 media_type, 103int tipc_register_media(struct tipc_media *m_ptr)
90 char *name,
91 int (*enable)(struct tipc_bearer *),
92 void (*disable)(struct tipc_bearer *),
93 int (*send_msg)(struct sk_buff *,
94 struct tipc_bearer *,
95 struct tipc_media_addr *),
96 char *(*addr2str)(struct tipc_media_addr *a,
97 char *str_buf, int str_size),
98 struct tipc_media_addr *bcast_addr,
99 const u32 bearer_priority,
100 const u32 link_tolerance, /* [ms] */
101 const u32 send_window_limit)
102{ 104{
103 struct media *m_ptr;
104 u32 media_id;
105 u32 i;
106 int res = -EINVAL; 105 int res = -EINVAL;
107 106
108 write_lock_bh(&tipc_net_lock); 107 write_lock_bh(&tipc_net_lock);
109 108
110 if (tipc_mode != TIPC_NET_MODE) { 109 if (!media_name_valid(m_ptr->name))
111 warn("Media <%s> rejected, not in networked mode yet\n", name);
112 goto exit; 110 goto exit;
113 } 111 if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
114 if (!media_name_valid(name)) { 112 !m_ptr->bcast_addr.broadcast)
115 warn("Media <%s> rejected, illegal name\n", name);
116 goto exit; 113 goto exit;
117 } 114 if (m_ptr->priority > TIPC_MAX_LINK_PRI)
118 if (!bcast_addr) {
119 warn("Media <%s> rejected, no broadcast address\n", name);
120 goto exit; 115 goto exit;
121 } 116 if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
122 if ((bearer_priority < TIPC_MIN_LINK_PRI) || 117 (m_ptr->tolerance > TIPC_MAX_LINK_TOL))
123 (bearer_priority > TIPC_MAX_LINK_PRI)) {
124 warn("Media <%s> rejected, illegal priority (%u)\n", name,
125 bearer_priority);
126 goto exit; 118 goto exit;
127 } 119 if (media_count >= MAX_MEDIA)
128 if ((link_tolerance < TIPC_MIN_LINK_TOL) ||
129 (link_tolerance > TIPC_MAX_LINK_TOL)) {
130 warn("Media <%s> rejected, illegal tolerance (%u)\n", name,
131 link_tolerance);
132 goto exit; 120 goto exit;
133 } 121 if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
134
135 media_id = media_count++;
136 if (media_id >= MAX_MEDIA) {
137 warn("Media <%s> rejected, media limit reached (%u)\n", name,
138 MAX_MEDIA);
139 media_count--;
140 goto exit; 122 goto exit;
141 }
142 for (i = 0; i < media_id; i++) {
143 if (media_list[i].type_id == media_type) {
144 warn("Media <%s> rejected, duplicate type (%u)\n", name,
145 media_type);
146 media_count--;
147 goto exit;
148 }
149 if (!strcmp(name, media_list[i].name)) {
150 warn("Media <%s> rejected, duplicate name\n", name);
151 media_count--;
152 goto exit;
153 }
154 }
155 123
156 m_ptr = &media_list[media_id]; 124 media_list[media_count] = m_ptr;
157 m_ptr->type_id = media_type; 125 media_count++;
158 m_ptr->send_msg = send_msg;
159 m_ptr->enable_bearer = enable;
160 m_ptr->disable_bearer = disable;
161 m_ptr->addr2str = addr2str;
162 memcpy(&m_ptr->bcast_addr, bcast_addr, sizeof(*bcast_addr));
163 strcpy(m_ptr->name, name);
164 m_ptr->priority = bearer_priority;
165 m_ptr->tolerance = link_tolerance;
166 m_ptr->window = send_window_limit;
167 res = 0; 126 res = 0;
168exit: 127exit:
169 write_unlock_bh(&tipc_net_lock); 128 write_unlock_bh(&tipc_net_lock);
129 if (res)
130 warn("Media <%s> registration error\n", m_ptr->name);
170 return res; 131 return res;
171} 132}
172 133
@@ -176,27 +137,19 @@ exit:
176 137
177void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) 138void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
178{ 139{
179 struct media *m_ptr; 140 char addr_str[MAX_ADDR_STR];
180 u32 media_type; 141 struct tipc_media *m_ptr;
181 u32 i;
182 142
183 media_type = ntohl(a->type); 143 m_ptr = media_find_id(a->media_id);
184 for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
185 if (m_ptr->type_id == media_type)
186 break;
187 }
188
189 if ((i < media_count) && (m_ptr->addr2str != NULL)) {
190 char addr_str[MAX_ADDR_STR];
191 144
192 tipc_printf(pb, "%s(%s)", m_ptr->name, 145 if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
193 m_ptr->addr2str(a, addr_str, sizeof(addr_str))); 146 tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str);
194 } else { 147 else {
195 unchar *addr = (unchar *)&a->dev_addr; 148 u32 i;
196 149
197 tipc_printf(pb, "UNKNOWN(%u)", media_type); 150 tipc_printf(pb, "UNKNOWN(%u)", a->media_id);
198 for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) 151 for (i = 0; i < sizeof(a->value); i++)
199 tipc_printf(pb, "-%02x", addr[i]); 152 tipc_printf(pb, "-%02x", a->value[i]);
200 } 153 }
201} 154}
202 155
@@ -207,7 +160,6 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
207struct sk_buff *tipc_media_get_names(void) 160struct sk_buff *tipc_media_get_names(void)
208{ 161{
209 struct sk_buff *buf; 162 struct sk_buff *buf;
210 struct media *m_ptr;
211 int i; 163 int i;
212 164
213 buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME)); 165 buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME));
@@ -215,9 +167,10 @@ struct sk_buff *tipc_media_get_names(void)
215 return NULL; 167 return NULL;
216 168
217 read_lock_bh(&tipc_net_lock); 169 read_lock_bh(&tipc_net_lock);
218 for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) { 170 for (i = 0; i < media_count; i++) {
219 tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name, 171 tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
220 strlen(m_ptr->name) + 1); 172 media_list[i]->name,
173 strlen(media_list[i]->name) + 1);
221 } 174 }
222 read_unlock_bh(&tipc_net_lock); 175 read_unlock_bh(&tipc_net_lock);
223 return buf; 176 return buf;
@@ -232,7 +185,7 @@ struct sk_buff *tipc_media_get_names(void)
232 */ 185 */
233 186
234static int bearer_name_validate(const char *name, 187static int bearer_name_validate(const char *name,
235 struct bearer_name *name_parts) 188 struct tipc_bearer_names *name_parts)
236{ 189{
237 char name_copy[TIPC_MAX_BEARER_NAME]; 190 char name_copy[TIPC_MAX_BEARER_NAME];
238 char *media_name; 191 char *media_name;
@@ -276,10 +229,10 @@ static int bearer_name_validate(const char *name,
276} 229}
277 230
278/** 231/**
279 * bearer_find - locates bearer object with matching bearer name 232 * tipc_bearer_find - locates bearer object with matching bearer name
280 */ 233 */
281 234
282static struct tipc_bearer *bearer_find(const char *name) 235struct tipc_bearer *tipc_bearer_find(const char *name)
283{ 236{
284 struct tipc_bearer *b_ptr; 237 struct tipc_bearer *b_ptr;
285 u32 i; 238 u32 i;
@@ -318,7 +271,6 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
318struct sk_buff *tipc_bearer_get_names(void) 271struct sk_buff *tipc_bearer_get_names(void)
319{ 272{
320 struct sk_buff *buf; 273 struct sk_buff *buf;
321 struct media *m_ptr;
322 struct tipc_bearer *b_ptr; 274 struct tipc_bearer *b_ptr;
323 int i, j; 275 int i, j;
324 276
@@ -327,10 +279,10 @@ struct sk_buff *tipc_bearer_get_names(void)
327 return NULL; 279 return NULL;
328 280
329 read_lock_bh(&tipc_net_lock); 281 read_lock_bh(&tipc_net_lock);
330 for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) { 282 for (i = 0; i < media_count; i++) {
331 for (j = 0; j < MAX_BEARERS; j++) { 283 for (j = 0; j < MAX_BEARERS; j++) {
332 b_ptr = &tipc_bearers[j]; 284 b_ptr = &tipc_bearers[j];
333 if (b_ptr->active && (b_ptr->media == m_ptr)) { 285 if (b_ptr->active && (b_ptr->media == media_list[i])) {
334 tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, 286 tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
335 b_ptr->name, 287 b_ptr->name,
336 strlen(b_ptr->name) + 1); 288 strlen(b_ptr->name) + 1);
@@ -366,7 +318,7 @@ void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest)
366static int bearer_push(struct tipc_bearer *b_ptr) 318static int bearer_push(struct tipc_bearer *b_ptr)
367{ 319{
368 u32 res = 0; 320 u32 res = 0;
369 struct link *ln, *tln; 321 struct tipc_link *ln, *tln;
370 322
371 if (b_ptr->blocked) 323 if (b_ptr->blocked)
372 return 0; 324 return 0;
@@ -412,7 +364,8 @@ void tipc_continue(struct tipc_bearer *b_ptr)
412 * bearer.lock is busy 364 * bearer.lock is busy
413 */ 365 */
414 366
415static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, struct link *l_ptr) 367static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr,
368 struct tipc_link *l_ptr)
416{ 369{
417 list_move_tail(&l_ptr->link_list, &b_ptr->cong_links); 370 list_move_tail(&l_ptr->link_list, &b_ptr->cong_links);
418} 371}
@@ -425,7 +378,7 @@ static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, struct link
425 * bearer.lock is free 378 * bearer.lock is free
426 */ 379 */
427 380
428void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr) 381void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
429{ 382{
430 spin_lock_bh(&b_ptr->lock); 383 spin_lock_bh(&b_ptr->lock);
431 tipc_bearer_schedule_unlocked(b_ptr, l_ptr); 384 tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
@@ -438,7 +391,8 @@ void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr)
438 * and if there is, try to resolve it before returning. 391 * and if there is, try to resolve it before returning.
439 * 'tipc_net_lock' is read_locked when this function is called 392 * 'tipc_net_lock' is read_locked when this function is called
440 */ 393 */
441int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr) 394int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr,
395 struct tipc_link *l_ptr)
442{ 396{
443 int res = 1; 397 int res = 1;
444 398
@@ -457,7 +411,7 @@ int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr
457 * tipc_bearer_congested - determines if bearer is currently congested 411 * tipc_bearer_congested - determines if bearer is currently congested
458 */ 412 */
459 413
460int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr) 414int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
461{ 415{
462 if (unlikely(b_ptr->blocked)) 416 if (unlikely(b_ptr->blocked))
463 return 1; 417 return 1;
@@ -473,8 +427,8 @@ int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr)
473int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) 427int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
474{ 428{
475 struct tipc_bearer *b_ptr; 429 struct tipc_bearer *b_ptr;
476 struct media *m_ptr; 430 struct tipc_media *m_ptr;
477 struct bearer_name b_name; 431 struct tipc_bearer_names b_names;
478 char addr_string[16]; 432 char addr_string[16];
479 u32 bearer_id; 433 u32 bearer_id;
480 u32 with_this_prio; 434 u32 with_this_prio;
@@ -486,7 +440,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
486 name); 440 name);
487 return -ENOPROTOOPT; 441 return -ENOPROTOOPT;
488 } 442 }
489 if (!bearer_name_validate(name, &b_name)) { 443 if (!bearer_name_validate(name, &b_names)) {
490 warn("Bearer <%s> rejected, illegal name\n", name); 444 warn("Bearer <%s> rejected, illegal name\n", name);
491 return -EINVAL; 445 return -EINVAL;
492 } 446 }
@@ -511,10 +465,10 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
511 465
512 write_lock_bh(&tipc_net_lock); 466 write_lock_bh(&tipc_net_lock);
513 467
514 m_ptr = media_find(b_name.media_name); 468 m_ptr = tipc_media_find(b_names.media_name);
515 if (!m_ptr) { 469 if (!m_ptr) {
516 warn("Bearer <%s> rejected, media <%s> not registered\n", name, 470 warn("Bearer <%s> rejected, media <%s> not registered\n", name,
517 b_name.media_name); 471 b_names.media_name);
518 goto exit; 472 goto exit;
519 } 473 }
520 474
@@ -561,6 +515,8 @@ restart:
561 515
562 b_ptr->identity = bearer_id; 516 b_ptr->identity = bearer_id;
563 b_ptr->media = m_ptr; 517 b_ptr->media = m_ptr;
518 b_ptr->tolerance = m_ptr->tolerance;
519 b_ptr->window = m_ptr->window;
564 b_ptr->net_plane = bearer_id + 'A'; 520 b_ptr->net_plane = bearer_id + 'A';
565 b_ptr->active = 1; 521 b_ptr->active = 1;
566 b_ptr->priority = priority; 522 b_ptr->priority = priority;
@@ -590,11 +546,11 @@ exit:
590int tipc_block_bearer(const char *name) 546int tipc_block_bearer(const char *name)
591{ 547{
592 struct tipc_bearer *b_ptr = NULL; 548 struct tipc_bearer *b_ptr = NULL;
593 struct link *l_ptr; 549 struct tipc_link *l_ptr;
594 struct link *temp_l_ptr; 550 struct tipc_link *temp_l_ptr;
595 551
596 read_lock_bh(&tipc_net_lock); 552 read_lock_bh(&tipc_net_lock);
597 b_ptr = bearer_find(name); 553 b_ptr = tipc_bearer_find(name);
598 if (!b_ptr) { 554 if (!b_ptr) {
599 warn("Attempt to block unknown bearer <%s>\n", name); 555 warn("Attempt to block unknown bearer <%s>\n", name);
600 read_unlock_bh(&tipc_net_lock); 556 read_unlock_bh(&tipc_net_lock);
@@ -625,8 +581,8 @@ int tipc_block_bearer(const char *name)
625 581
626static void bearer_disable(struct tipc_bearer *b_ptr) 582static void bearer_disable(struct tipc_bearer *b_ptr)
627{ 583{
628 struct link *l_ptr; 584 struct tipc_link *l_ptr;
629 struct link *temp_l_ptr; 585 struct tipc_link *temp_l_ptr;
630 586
631 info("Disabling bearer <%s>\n", b_ptr->name); 587 info("Disabling bearer <%s>\n", b_ptr->name);
632 spin_lock_bh(&b_ptr->lock); 588 spin_lock_bh(&b_ptr->lock);
@@ -648,7 +604,7 @@ int tipc_disable_bearer(const char *name)
648 int res; 604 int res;
649 605
650 write_lock_bh(&tipc_net_lock); 606 write_lock_bh(&tipc_net_lock);
651 b_ptr = bearer_find(name); 607 b_ptr = tipc_bearer_find(name);
652 if (b_ptr == NULL) { 608 if (b_ptr == NULL) {
653 warn("Attempt to disable unknown bearer <%s>\n", name); 609 warn("Attempt to disable unknown bearer <%s>\n", name);
654 res = -EINVAL; 610 res = -EINVAL;
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index d696f9e414e3..d3eac56b8c21 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -43,32 +43,45 @@
43#define MAX_MEDIA 2 43#define MAX_MEDIA 2
44 44
45/* 45/*
46 * Identifiers associated with TIPC message header media address info
47 *
48 * - address info field is 20 bytes long
49 * - media type identifier located at offset 3
50 * - remaining bytes vary according to media type
51 */
52
53#define TIPC_MEDIA_ADDR_SIZE 20
54#define TIPC_MEDIA_TYPE_OFFSET 3
55
56/*
46 * Identifiers of supported TIPC media types 57 * Identifiers of supported TIPC media types
47 */ 58 */
48#define TIPC_MEDIA_TYPE_ETH 1 59#define TIPC_MEDIA_TYPE_ETH 1
49 60
50/* 61/*
51 * Destination address structure used by TIPC bearers when sending messages 62 * struct tipc_media_addr - destination address used by TIPC bearers
52 * 63 * @value: address info (format defined by media)
53 * IMPORTANT: The fields of this structure MUST be stored using the specified 64 * @media_id: TIPC media type identifier
54 * byte order indicated below, as the structure is exchanged between nodes 65 * @broadcast: non-zero if address is a broadcast address
55 * as part of a link setup process.
56 */ 66 */
67
57struct tipc_media_addr { 68struct tipc_media_addr {
58 __be32 type; /* bearer type (network byte order) */ 69 u8 value[TIPC_MEDIA_ADDR_SIZE];
59 union { 70 u8 media_id;
60 __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */ 71 u8 broadcast;
61 } dev_addr;
62}; 72};
63 73
64struct tipc_bearer; 74struct tipc_bearer;
65 75
66/** 76/**
67 * struct media - TIPC media information available to internal users 77 * struct tipc_media - TIPC media information available to internal users
68 * @send_msg: routine which handles buffer transmission 78 * @send_msg: routine which handles buffer transmission
69 * @enable_bearer: routine which enables a bearer 79 * @enable_bearer: routine which enables a bearer
70 * @disable_bearer: routine which disables a bearer 80 * @disable_bearer: routine which disables a bearer
71 * @addr2str: routine which converts bearer's address to string form 81 * @addr2str: routine which converts media address to string
82 * @str2addr: routine which converts media address from string
83 * @addr2msg: routine which converts media address to protocol message area
84 * @msg2addr: routine which converts media address from protocol message area
72 * @bcast_addr: media address used in broadcasting 85 * @bcast_addr: media address used in broadcasting
73 * @priority: default link (and bearer) priority 86 * @priority: default link (and bearer) priority
74 * @tolerance: default time (in ms) before declaring link failure 87 * @tolerance: default time (in ms) before declaring link failure
@@ -77,14 +90,16 @@ struct tipc_bearer;
77 * @name: media name 90 * @name: media name
78 */ 91 */
79 92
80struct media { 93struct tipc_media {
81 int (*send_msg)(struct sk_buff *buf, 94 int (*send_msg)(struct sk_buff *buf,
82 struct tipc_bearer *b_ptr, 95 struct tipc_bearer *b_ptr,
83 struct tipc_media_addr *dest); 96 struct tipc_media_addr *dest);
84 int (*enable_bearer)(struct tipc_bearer *b_ptr); 97 int (*enable_bearer)(struct tipc_bearer *b_ptr);
85 void (*disable_bearer)(struct tipc_bearer *b_ptr); 98 void (*disable_bearer)(struct tipc_bearer *b_ptr);
86 char *(*addr2str)(struct tipc_media_addr *a, 99 int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
87 char *str_buf, int str_size); 100 int (*str2addr)(struct tipc_media_addr *a, char *str_buf);
101 int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
102 int (*msg2addr)(struct tipc_media_addr *a, char *msg_area);
88 struct tipc_media_addr bcast_addr; 103 struct tipc_media_addr bcast_addr;
89 u32 priority; 104 u32 priority;
90 u32 tolerance; 105 u32 tolerance;
@@ -103,6 +118,8 @@ struct media {
103 * @name: bearer name (format = media:interface) 118 * @name: bearer name (format = media:interface)
104 * @media: ptr to media structure associated with bearer 119 * @media: ptr to media structure associated with bearer
105 * @priority: default link priority for bearer 120 * @priority: default link priority for bearer
121 * @window: default window size for bearer
122 * @tolerance: default link tolerance for bearer
106 * @identity: array index of this bearer within TIPC bearer array 123 * @identity: array index of this bearer within TIPC bearer array
107 * @link_req: ptr to (optional) structure making periodic link setup requests 124 * @link_req: ptr to (optional) structure making periodic link setup requests
108 * @links: list of non-congested links associated with bearer 125 * @links: list of non-congested links associated with bearer
@@ -122,10 +139,12 @@ struct tipc_bearer {
122 struct tipc_media_addr addr; /* initalized by media */ 139 struct tipc_media_addr addr; /* initalized by media */
123 char name[TIPC_MAX_BEARER_NAME]; 140 char name[TIPC_MAX_BEARER_NAME];
124 spinlock_t lock; 141 spinlock_t lock;
125 struct media *media; 142 struct tipc_media *media;
126 u32 priority; 143 u32 priority;
144 u32 window;
145 u32 tolerance;
127 u32 identity; 146 u32 identity;
128 struct link_req *link_req; 147 struct tipc_link_req *link_req;
129 struct list_head links; 148 struct list_head links;
130 struct list_head cong_links; 149 struct list_head cong_links;
131 int active; 150 int active;
@@ -133,28 +152,19 @@ struct tipc_bearer {
133 struct tipc_node_map nodes; 152 struct tipc_node_map nodes;
134}; 153};
135 154
136struct bearer_name { 155struct tipc_bearer_names {
137 char media_name[TIPC_MAX_MEDIA_NAME]; 156 char media_name[TIPC_MAX_MEDIA_NAME];
138 char if_name[TIPC_MAX_IF_NAME]; 157 char if_name[TIPC_MAX_IF_NAME];
139}; 158};
140 159
141struct link; 160struct tipc_link;
142 161
143extern struct tipc_bearer tipc_bearers[]; 162extern struct tipc_bearer tipc_bearers[];
144 163
145/* 164/*
146 * TIPC routines available to supported media types 165 * TIPC routines available to supported media types
147 */ 166 */
148int tipc_register_media(u32 media_type, 167int tipc_register_media(struct tipc_media *m_ptr);
149 char *media_name, int (*enable)(struct tipc_bearer *),
150 void (*disable)(struct tipc_bearer *),
151 int (*send_msg)(struct sk_buff *,
152 struct tipc_bearer *, struct tipc_media_addr *),
153 char *(*addr2str)(struct tipc_media_addr *a,
154 char *str_buf, int str_size),
155 struct tipc_media_addr *bcast_addr, const u32 bearer_priority,
156 const u32 link_tolerance, /* [ms] */
157 const u32 send_window_limit);
158 168
159void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); 169void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
160 170
@@ -170,16 +180,21 @@ int tipc_disable_bearer(const char *name);
170int tipc_eth_media_start(void); 180int tipc_eth_media_start(void);
171void tipc_eth_media_stop(void); 181void tipc_eth_media_stop(void);
172 182
183int tipc_media_set_priority(const char *name, u32 new_value);
184int tipc_media_set_window(const char *name, u32 new_value);
173void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); 185void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
174struct sk_buff *tipc_media_get_names(void); 186struct sk_buff *tipc_media_get_names(void);
175 187
176struct sk_buff *tipc_bearer_get_names(void); 188struct sk_buff *tipc_bearer_get_names(void);
177void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); 189void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest);
178void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest); 190void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest);
179void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr); 191void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr);
192struct tipc_bearer *tipc_bearer_find(const char *name);
180struct tipc_bearer *tipc_bearer_find_interface(const char *if_name); 193struct tipc_bearer *tipc_bearer_find_interface(const char *if_name);
181int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr); 194struct tipc_media *tipc_media_find(const char *name);
182int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr); 195int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr,
196 struct tipc_link *l_ptr);
197int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr);
183void tipc_bearer_stop(void); 198void tipc_bearer_stop(void);
184void tipc_bearer_lock_push(struct tipc_bearer *b_ptr); 199void tipc_bearer_lock_push(struct tipc_bearer *b_ptr);
185 200
diff --git a/net/tipc/config.c b/net/tipc/config.c
index b25a396b7e1e..4785bf26cdf4 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -184,13 +184,12 @@ static struct sk_buff *cfg_set_own_addr(void)
184 " (cannot change node address once assigned)"); 184 " (cannot change node address once assigned)");
185 185
186 /* 186 /*
187 * Must release all spinlocks before calling start_net() because 187 * Must temporarily release configuration spinlock while switching into
188 * Linux version of TIPC calls eth_media_start() which calls 188 * networking mode as it calls tipc_eth_media_start(), which may sleep.
189 * register_netdevice_notifier() which may block! 189 * Releasing the lock is harmless as other locally-issued configuration
190 * 190 * commands won't occur until this one completes, and remotely-issued
191 * Temporarily releasing the lock should be harmless for non-Linux TIPC, 191 * configuration commands can't be received until a local configuration
192 * but Linux version of eth_media_start() should really be reworked 192 * command to enable the first bearer is received and processed.
193 * so that it can be called with spinlocks held.
194 */ 193 */
195 194
196 spin_unlock_bh(&config_lock); 195 spin_unlock_bh(&config_lock);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index c21331d58fdb..2691cd57b8a8 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -99,8 +99,8 @@ struct sk_buff *tipc_buf_acquire(u32 size)
99 99
100static void tipc_core_stop_net(void) 100static void tipc_core_stop_net(void)
101{ 101{
102 tipc_eth_media_stop();
103 tipc_net_stop(); 102 tipc_net_stop();
103 tipc_eth_media_stop();
104} 104}
105 105
106/** 106/**
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index f2fb96e86ee8..a00e5f811569 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -45,7 +45,7 @@
45 45
46 46
47/** 47/**
48 * struct link_req - information about an ongoing link setup request 48 * struct tipc_link_req - information about an ongoing link setup request
49 * @bearer: bearer issuing requests 49 * @bearer: bearer issuing requests
50 * @dest: destination address for request messages 50 * @dest: destination address for request messages
51 * @domain: network domain to which links can be established 51 * @domain: network domain to which links can be established
@@ -54,7 +54,7 @@
54 * @timer: timer governing period between requests 54 * @timer: timer governing period between requests
55 * @timer_intv: current interval between requests (in ms) 55 * @timer_intv: current interval between requests (in ms)
56 */ 56 */
57struct link_req { 57struct tipc_link_req {
58 struct tipc_bearer *bearer; 58 struct tipc_bearer *bearer;
59 struct tipc_media_addr dest; 59 struct tipc_media_addr dest;
60 u32 domain; 60 u32 domain;
@@ -84,7 +84,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
84 msg_set_non_seq(msg, 1); 84 msg_set_non_seq(msg, 1);
85 msg_set_dest_domain(msg, dest_domain); 85 msg_set_dest_domain(msg, dest_domain);
86 msg_set_bc_netid(msg, tipc_net_id); 86 msg_set_bc_netid(msg, tipc_net_id);
87 msg_set_media_addr(msg, &b_ptr->addr); 87 b_ptr->media->addr2msg(&b_ptr->addr, msg_media_addr(msg));
88 } 88 }
89 return buf; 89 return buf;
90} 90}
@@ -120,7 +120,7 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
120void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) 120void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
121{ 121{
122 struct tipc_node *n_ptr; 122 struct tipc_node *n_ptr;
123 struct link *link; 123 struct tipc_link *link;
124 struct tipc_media_addr media_addr, *addr; 124 struct tipc_media_addr media_addr, *addr;
125 struct sk_buff *rbuf; 125 struct sk_buff *rbuf;
126 struct tipc_msg *msg = buf_msg(buf); 126 struct tipc_msg *msg = buf_msg(buf);
@@ -130,12 +130,15 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
130 u32 type = msg_type(msg); 130 u32 type = msg_type(msg);
131 int link_fully_up; 131 int link_fully_up;
132 132
133 msg_get_media_addr(msg, &media_addr); 133 media_addr.broadcast = 1;
134 b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg));
134 buf_discard(buf); 135 buf_discard(buf);
135 136
136 /* Validate discovery message from requesting node */ 137 /* Validate discovery message from requesting node */
137 if (net_id != tipc_net_id) 138 if (net_id != tipc_net_id)
138 return; 139 return;
140 if (media_addr.broadcast)
141 return;
139 if (!tipc_addr_domain_valid(dest)) 142 if (!tipc_addr_domain_valid(dest))
140 return; 143 return;
141 if (!tipc_addr_node_valid(orig)) 144 if (!tipc_addr_node_valid(orig))
@@ -215,7 +218,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
215 * and is either not currently searching or is searching at a slow rate 218 * and is either not currently searching or is searching at a slow rate
216 */ 219 */
217 220
218static void disc_update(struct link_req *req) 221static void disc_update(struct tipc_link_req *req)
219{ 222{
220 if (!req->num_nodes) { 223 if (!req->num_nodes) {
221 if ((req->timer_intv == TIPC_LINK_REQ_INACTIVE) || 224 if ((req->timer_intv == TIPC_LINK_REQ_INACTIVE) ||
@@ -231,7 +234,7 @@ static void disc_update(struct link_req *req)
231 * @req: ptr to link request structure 234 * @req: ptr to link request structure
232 */ 235 */
233 236
234void tipc_disc_add_dest(struct link_req *req) 237void tipc_disc_add_dest(struct tipc_link_req *req)
235{ 238{
236 req->num_nodes++; 239 req->num_nodes++;
237} 240}
@@ -241,7 +244,7 @@ void tipc_disc_add_dest(struct link_req *req)
241 * @req: ptr to link request structure 244 * @req: ptr to link request structure
242 */ 245 */
243 246
244void tipc_disc_remove_dest(struct link_req *req) 247void tipc_disc_remove_dest(struct tipc_link_req *req)
245{ 248{
246 req->num_nodes--; 249 req->num_nodes--;
247 disc_update(req); 250 disc_update(req);
@@ -252,7 +255,7 @@ void tipc_disc_remove_dest(struct link_req *req)
252 * @req: ptr to link request structure 255 * @req: ptr to link request structure
253 */ 256 */
254 257
255static void disc_send_msg(struct link_req *req) 258static void disc_send_msg(struct tipc_link_req *req)
256{ 259{
257 if (!req->bearer->blocked) 260 if (!req->bearer->blocked)
258 tipc_bearer_send(req->bearer, req->buf, &req->dest); 261 tipc_bearer_send(req->bearer, req->buf, &req->dest);
@@ -265,7 +268,7 @@ static void disc_send_msg(struct link_req *req)
265 * Called whenever a link setup request timer associated with a bearer expires. 268 * Called whenever a link setup request timer associated with a bearer expires.
266 */ 269 */
267 270
268static void disc_timeout(struct link_req *req) 271static void disc_timeout(struct tipc_link_req *req)
269{ 272{
270 int max_delay; 273 int max_delay;
271 274
@@ -313,7 +316,7 @@ exit:
313int tipc_disc_create(struct tipc_bearer *b_ptr, 316int tipc_disc_create(struct tipc_bearer *b_ptr,
314 struct tipc_media_addr *dest, u32 dest_domain) 317 struct tipc_media_addr *dest, u32 dest_domain)
315{ 318{
316 struct link_req *req; 319 struct tipc_link_req *req;
317 320
318 req = kmalloc(sizeof(*req), GFP_ATOMIC); 321 req = kmalloc(sizeof(*req), GFP_ATOMIC);
319 if (!req) 322 if (!req)
@@ -342,7 +345,7 @@ int tipc_disc_create(struct tipc_bearer *b_ptr,
342 * @req: ptr to link request structure 345 * @req: ptr to link request structure
343 */ 346 */
344 347
345void tipc_disc_delete(struct link_req *req) 348void tipc_disc_delete(struct tipc_link_req *req)
346{ 349{
347 k_cancel_timer(&req->timer); 350 k_cancel_timer(&req->timer);
348 k_term_timer(&req->timer); 351 k_term_timer(&req->timer);
diff --git a/net/tipc/discover.h b/net/tipc/discover.h
index a3af595b86cb..75b67c403aa3 100644
--- a/net/tipc/discover.h
+++ b/net/tipc/discover.h
@@ -37,13 +37,13 @@
37#ifndef _TIPC_DISCOVER_H 37#ifndef _TIPC_DISCOVER_H
38#define _TIPC_DISCOVER_H 38#define _TIPC_DISCOVER_H
39 39
40struct link_req; 40struct tipc_link_req;
41 41
42int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest, 42int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest,
43 u32 dest_domain); 43 u32 dest_domain);
44void tipc_disc_delete(struct link_req *req); 44void tipc_disc_delete(struct tipc_link_req *req);
45void tipc_disc_add_dest(struct link_req *req); 45void tipc_disc_add_dest(struct tipc_link_req *req);
46void tipc_disc_remove_dest(struct link_req *req); 46void tipc_disc_remove_dest(struct tipc_link_req *req);
47void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr); 47void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr);
48 48
49#endif 49#endif
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index e728d4ce2a1b..527e3f0e165d 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -38,28 +38,45 @@
38#include "bearer.h" 38#include "bearer.h"
39 39
40#define MAX_ETH_BEARERS MAX_BEARERS 40#define MAX_ETH_BEARERS MAX_BEARERS
41#define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI 41
42#define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL 42#define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */
43#define ETH_LINK_WINDOW TIPC_DEF_LINK_WIN
44 43
45/** 44/**
46 * struct eth_bearer - Ethernet bearer data structure 45 * struct eth_bearer - Ethernet bearer data structure
47 * @bearer: ptr to associated "generic" bearer structure 46 * @bearer: ptr to associated "generic" bearer structure
48 * @dev: ptr to associated Ethernet network device 47 * @dev: ptr to associated Ethernet network device
49 * @tipc_packet_type: used in binding TIPC to Ethernet driver 48 * @tipc_packet_type: used in binding TIPC to Ethernet driver
49 * @cleanup: work item used when disabling bearer
50 */ 50 */
51 51
52struct eth_bearer { 52struct eth_bearer {
53 struct tipc_bearer *bearer; 53 struct tipc_bearer *bearer;
54 struct net_device *dev; 54 struct net_device *dev;
55 struct packet_type tipc_packet_type; 55 struct packet_type tipc_packet_type;
56 struct work_struct cleanup;
56}; 57};
57 58
59static struct tipc_media eth_media_info;
58static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; 60static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
59static int eth_started; 61static int eth_started;
60static struct notifier_block notifier; 62static struct notifier_block notifier;
61 63
62/** 64/**
65 * eth_media_addr_set - initialize Ethernet media address structure
66 *
67 * Media-dependent "value" field stores MAC address in first 6 bytes
68 * and zeroes out the remaining bytes.
69 */
70
71static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
72{
73 memcpy(a->value, mac, ETH_ALEN);
74 memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
75 a->media_id = TIPC_MEDIA_TYPE_ETH;
76 a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN);
77}
78
79/**
63 * send_msg - send a TIPC message out over an Ethernet interface 80 * send_msg - send a TIPC message out over an Ethernet interface
64 */ 81 */
65 82
@@ -85,7 +102,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
85 102
86 skb_reset_network_header(clone); 103 skb_reset_network_header(clone);
87 clone->dev = dev; 104 clone->dev = dev;
88 dev_hard_header(clone, dev, ETH_P_TIPC, &dest->dev_addr.eth_addr, 105 dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
89 dev->dev_addr, clone->len); 106 dev->dev_addr, clone->len);
90 dev_queue_xmit(clone); 107 dev_queue_xmit(clone);
91 return 0; 108 return 0;
@@ -172,22 +189,41 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
172 tb_ptr->usr_handle = (void *)eb_ptr; 189 tb_ptr->usr_handle = (void *)eb_ptr;
173 tb_ptr->mtu = dev->mtu; 190 tb_ptr->mtu = dev->mtu;
174 tb_ptr->blocked = 0; 191 tb_ptr->blocked = 0;
175 tb_ptr->addr.type = htonl(TIPC_MEDIA_TYPE_ETH); 192 eth_media_addr_set(&tb_ptr->addr, (char *)dev->dev_addr);
176 memcpy(&tb_ptr->addr.dev_addr, dev->dev_addr, ETH_ALEN);
177 return 0; 193 return 0;
178} 194}
179 195
180/** 196/**
197 * cleanup_bearer - break association between Ethernet bearer and interface
198 *
199 * This routine must be invoked from a work queue because it can sleep.
200 */
201
202static void cleanup_bearer(struct work_struct *work)
203{
204 struct eth_bearer *eb_ptr =
205 container_of(work, struct eth_bearer, cleanup);
206
207 dev_remove_pack(&eb_ptr->tipc_packet_type);
208 dev_put(eb_ptr->dev);
209 eb_ptr->dev = NULL;
210}
211
212/**
181 * disable_bearer - detach TIPC bearer from an Ethernet interface 213 * disable_bearer - detach TIPC bearer from an Ethernet interface
182 * 214 *
183 * We really should do dev_remove_pack() here, but this function can not be 215 * Mark Ethernet bearer as inactive so that incoming buffers are thrown away,
184 * called at tasklet level. => Use eth_bearer->bearer as a flag to throw away 216 * then get worker thread to complete bearer cleanup. (Can't do cleanup
185 * incoming buffers, & postpone dev_remove_pack() to eth_media_stop() on exit. 217 * here because cleanup code needs to sleep and caller holds spinlocks.)
186 */ 218 */
187 219
188static void disable_bearer(struct tipc_bearer *tb_ptr) 220static void disable_bearer(struct tipc_bearer *tb_ptr)
189{ 221{
190 ((struct eth_bearer *)tb_ptr->usr_handle)->bearer = NULL; 222 struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle;
223
224 eb_ptr->bearer = NULL;
225 INIT_WORK(&eb_ptr->cleanup, cleanup_bearer);
226 schedule_work(&eb_ptr->cleanup);
191} 227}
192 228
193/** 229/**
@@ -246,17 +282,81 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
246 * eth_addr2str - convert Ethernet address to string 282 * eth_addr2str - convert Ethernet address to string
247 */ 283 */
248 284
249static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) 285static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
286{
287 if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
288 return 1;
289
290 sprintf(str_buf, "%pM", a->value);
291 return 0;
292}
293
294/**
295 * eth_str2addr - convert string to Ethernet address
296 */
297
298static int eth_str2addr(struct tipc_media_addr *a, char *str_buf)
299{
300 char mac[ETH_ALEN];
301 int r;
302
303 r = sscanf(str_buf, "%02x:%02x:%02x:%02x:%02x:%02x",
304 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2],
305 (u32 *)&mac[3], (u32 *)&mac[4], (u32 *)&mac[5]);
306
307 if (r != ETH_ALEN)
308 return 1;
309
310 eth_media_addr_set(a, mac);
311 return 0;
312}
313
314/**
315 * eth_str2addr - convert Ethernet address format to message header format
316 */
317
318static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
250{ 319{
251 unchar *addr = (unchar *)&a->dev_addr; 320 memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE);
321 msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
322 memcpy(msg_area + ETH_ADDR_OFFSET, a->value, ETH_ALEN);
323 return 0;
324}
252 325
253 if (str_size < 18) 326/**
254 *str_buf = '\0'; 327 * eth_str2addr - convert message header address format to Ethernet format
255 else 328 */
256 sprintf(str_buf, "%pM", addr); 329
257 return str_buf; 330static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area)
331{
332 if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH)
333 return 1;
334
335 eth_media_addr_set(a, msg_area + ETH_ADDR_OFFSET);
336 return 0;
258} 337}
259 338
339/*
340 * Ethernet media registration info
341 */
342
343static struct tipc_media eth_media_info = {
344 .send_msg = send_msg,
345 .enable_bearer = enable_bearer,
346 .disable_bearer = disable_bearer,
347 .addr2str = eth_addr2str,
348 .str2addr = eth_str2addr,
349 .addr2msg = eth_addr2msg,
350 .msg2addr = eth_msg2addr,
351 .bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
352 TIPC_MEDIA_TYPE_ETH, 1 },
353 .priority = TIPC_DEF_LINK_PRI,
354 .tolerance = TIPC_DEF_LINK_TOL,
355 .window = TIPC_DEF_LINK_WIN,
356 .type_id = TIPC_MEDIA_TYPE_ETH,
357 .name = "eth"
358};
359
260/** 360/**
261 * tipc_eth_media_start - activate Ethernet bearer support 361 * tipc_eth_media_start - activate Ethernet bearer support
262 * 362 *
@@ -266,21 +366,12 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
266 366
267int tipc_eth_media_start(void) 367int tipc_eth_media_start(void)
268{ 368{
269 struct tipc_media_addr bcast_addr;
270 int res; 369 int res;
271 370
272 if (eth_started) 371 if (eth_started)
273 return -EINVAL; 372 return -EINVAL;
274 373
275 bcast_addr.type = htonl(TIPC_MEDIA_TYPE_ETH); 374 res = tipc_register_media(&eth_media_info);
276 memset(&bcast_addr.dev_addr, 0xff, ETH_ALEN);
277
278 memset(eth_bearers, 0, sizeof(eth_bearers));
279
280 res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
281 enable_bearer, disable_bearer, send_msg,
282 eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY,
283 ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
284 if (res) 375 if (res)
285 return res; 376 return res;
286 377
@@ -298,22 +389,10 @@ int tipc_eth_media_start(void)
298 389
299void tipc_eth_media_stop(void) 390void tipc_eth_media_stop(void)
300{ 391{
301 int i;
302
303 if (!eth_started) 392 if (!eth_started)
304 return; 393 return;
305 394
395 flush_scheduled_work();
306 unregister_netdevice_notifier(&notifier); 396 unregister_netdevice_notifier(&notifier);
307 for (i = 0; i < MAX_ETH_BEARERS ; i++) {
308 if (eth_bearers[i].bearer) {
309 eth_bearers[i].bearer->blocked = 1;
310 eth_bearers[i].bearer = NULL;
311 }
312 if (eth_bearers[i].dev) {
313 dev_remove_pack(&eth_bearers[i].tipc_packet_type);
314 dev_put(eth_bearers[i].dev);
315 }
316 }
317 memset(&eth_bearers, 0, sizeof(eth_bearers));
318 eth_started = 0; 397 eth_started = 0;
319} 398}
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ae98a72da11a..ac1832a66f8a 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -71,35 +71,36 @@
71#define START_CHANGEOVER 100000u 71#define START_CHANGEOVER 100000u
72 72
73/** 73/**
74 * struct link_name - deconstructed link name 74 * struct tipc_link_name - deconstructed link name
75 * @addr_local: network address of node at this end 75 * @addr_local: network address of node at this end
76 * @if_local: name of interface at this end 76 * @if_local: name of interface at this end
77 * @addr_peer: network address of node at far end 77 * @addr_peer: network address of node at far end
78 * @if_peer: name of interface at far end 78 * @if_peer: name of interface at far end
79 */ 79 */
80 80
81struct link_name { 81struct tipc_link_name {
82 u32 addr_local; 82 u32 addr_local;
83 char if_local[TIPC_MAX_IF_NAME]; 83 char if_local[TIPC_MAX_IF_NAME];
84 u32 addr_peer; 84 u32 addr_peer;
85 char if_peer[TIPC_MAX_IF_NAME]; 85 char if_peer[TIPC_MAX_IF_NAME];
86}; 86};
87 87
88static void link_handle_out_of_seq_msg(struct link *l_ptr, 88static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
89 struct sk_buff *buf); 89 struct sk_buff *buf);
90static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf); 90static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf);
91static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf); 91static int link_recv_changeover_msg(struct tipc_link **l_ptr,
92static void link_set_supervision_props(struct link *l_ptr, u32 tolerance); 92 struct sk_buff **buf);
93static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance);
93static int link_send_sections_long(struct tipc_port *sender, 94static int link_send_sections_long(struct tipc_port *sender,
94 struct iovec const *msg_sect, 95 struct iovec const *msg_sect,
95 u32 num_sect, unsigned int total_len, 96 u32 num_sect, unsigned int total_len,
96 u32 destnode); 97 u32 destnode);
97static void link_check_defragm_bufs(struct link *l_ptr); 98static void link_check_defragm_bufs(struct tipc_link *l_ptr);
98static void link_state_event(struct link *l_ptr, u32 event); 99static void link_state_event(struct tipc_link *l_ptr, u32 event);
99static void link_reset_statistics(struct link *l_ptr); 100static void link_reset_statistics(struct tipc_link *l_ptr);
100static void link_print(struct link *l_ptr, const char *str); 101static void link_print(struct tipc_link *l_ptr, const char *str);
101static void link_start(struct link *l_ptr); 102static void link_start(struct tipc_link *l_ptr);
102static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf); 103static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf);
103 104
104/* 105/*
105 * Simple link routines 106 * Simple link routines
@@ -110,7 +111,7 @@ static unsigned int align(unsigned int i)
110 return (i + 3) & ~3u; 111 return (i + 3) & ~3u;
111} 112}
112 113
113static void link_init_max_pkt(struct link *l_ptr) 114static void link_init_max_pkt(struct tipc_link *l_ptr)
114{ 115{
115 u32 max_pkt; 116 u32 max_pkt;
116 117
@@ -127,14 +128,14 @@ static void link_init_max_pkt(struct link *l_ptr)
127 l_ptr->max_pkt_probes = 0; 128 l_ptr->max_pkt_probes = 0;
128} 129}
129 130
130static u32 link_next_sent(struct link *l_ptr) 131static u32 link_next_sent(struct tipc_link *l_ptr)
131{ 132{
132 if (l_ptr->next_out) 133 if (l_ptr->next_out)
133 return msg_seqno(buf_msg(l_ptr->next_out)); 134 return buf_seqno(l_ptr->next_out);
134 return mod(l_ptr->next_out_no); 135 return mod(l_ptr->next_out_no);
135} 136}
136 137
137static u32 link_last_sent(struct link *l_ptr) 138static u32 link_last_sent(struct tipc_link *l_ptr)
138{ 139{
139 return mod(link_next_sent(l_ptr) - 1); 140 return mod(link_next_sent(l_ptr) - 1);
140} 141}
@@ -143,28 +144,29 @@ static u32 link_last_sent(struct link *l_ptr)
143 * Simple non-static link routines (i.e. referenced outside this file) 144 * Simple non-static link routines (i.e. referenced outside this file)
144 */ 145 */
145 146
146int tipc_link_is_up(struct link *l_ptr) 147int tipc_link_is_up(struct tipc_link *l_ptr)
147{ 148{
148 if (!l_ptr) 149 if (!l_ptr)
149 return 0; 150 return 0;
150 return link_working_working(l_ptr) || link_working_unknown(l_ptr); 151 return link_working_working(l_ptr) || link_working_unknown(l_ptr);
151} 152}
152 153
153int tipc_link_is_active(struct link *l_ptr) 154int tipc_link_is_active(struct tipc_link *l_ptr)
154{ 155{
155 return (l_ptr->owner->active_links[0] == l_ptr) || 156 return (l_ptr->owner->active_links[0] == l_ptr) ||
156 (l_ptr->owner->active_links[1] == l_ptr); 157 (l_ptr->owner->active_links[1] == l_ptr);
157} 158}
158 159
159/** 160/**
160 * link_name_validate - validate & (optionally) deconstruct link name 161 * link_name_validate - validate & (optionally) deconstruct tipc_link name
161 * @name - ptr to link name string 162 * @name - ptr to link name string
162 * @name_parts - ptr to area for link name components (or NULL if not needed) 163 * @name_parts - ptr to area for link name components (or NULL if not needed)
163 * 164 *
164 * Returns 1 if link name is valid, otherwise 0. 165 * Returns 1 if link name is valid, otherwise 0.
165 */ 166 */
166 167
167static int link_name_validate(const char *name, struct link_name *name_parts) 168static int link_name_validate(const char *name,
169 struct tipc_link_name *name_parts)
168{ 170{
169 char name_copy[TIPC_MAX_LINK_NAME]; 171 char name_copy[TIPC_MAX_LINK_NAME];
170 char *addr_local; 172 char *addr_local;
@@ -238,7 +240,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
238 * tipc_node_delete() is called.) 240 * tipc_node_delete() is called.)
239 */ 241 */
240 242
241static void link_timeout(struct link *l_ptr) 243static void link_timeout(struct tipc_link *l_ptr)
242{ 244{
243 tipc_node_lock(l_ptr->owner); 245 tipc_node_lock(l_ptr->owner);
244 246
@@ -287,7 +289,7 @@ static void link_timeout(struct link *l_ptr)
287 tipc_node_unlock(l_ptr->owner); 289 tipc_node_unlock(l_ptr->owner);
288} 290}
289 291
290static void link_set_timer(struct link *l_ptr, u32 time) 292static void link_set_timer(struct tipc_link *l_ptr, u32 time)
291{ 293{
292 k_start_timer(&l_ptr->timer, time); 294 k_start_timer(&l_ptr->timer, time);
293} 295}
@@ -301,11 +303,11 @@ static void link_set_timer(struct link *l_ptr, u32 time)
301 * Returns pointer to link. 303 * Returns pointer to link.
302 */ 304 */
303 305
304struct link *tipc_link_create(struct tipc_node *n_ptr, 306struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
305 struct tipc_bearer *b_ptr, 307 struct tipc_bearer *b_ptr,
306 const struct tipc_media_addr *media_addr) 308 const struct tipc_media_addr *media_addr)
307{ 309{
308 struct link *l_ptr; 310 struct tipc_link *l_ptr;
309 struct tipc_msg *msg; 311 struct tipc_msg *msg;
310 char *if_name; 312 char *if_name;
311 char addr_string[16]; 313 char addr_string[16];
@@ -343,7 +345,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr,
343 l_ptr->checkpoint = 1; 345 l_ptr->checkpoint = 1;
344 l_ptr->peer_session = INVALID_SESSION; 346 l_ptr->peer_session = INVALID_SESSION;
345 l_ptr->b_ptr = b_ptr; 347 l_ptr->b_ptr = b_ptr;
346 link_set_supervision_props(l_ptr, b_ptr->media->tolerance); 348 link_set_supervision_props(l_ptr, b_ptr->tolerance);
347 l_ptr->state = RESET_UNKNOWN; 349 l_ptr->state = RESET_UNKNOWN;
348 350
349 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; 351 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg;
@@ -355,7 +357,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr,
355 strcpy((char *)msg_data(msg), if_name); 357 strcpy((char *)msg_data(msg), if_name);
356 358
357 l_ptr->priority = b_ptr->priority; 359 l_ptr->priority = b_ptr->priority;
358 tipc_link_set_queue_limits(l_ptr, b_ptr->media->window); 360 tipc_link_set_queue_limits(l_ptr, b_ptr->window);
359 361
360 link_init_max_pkt(l_ptr); 362 link_init_max_pkt(l_ptr);
361 363
@@ -382,7 +384,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr,
382 * to avoid a potential deadlock situation. 384 * to avoid a potential deadlock situation.
383 */ 385 */
384 386
385void tipc_link_delete(struct link *l_ptr) 387void tipc_link_delete(struct tipc_link *l_ptr)
386{ 388{
387 if (!l_ptr) { 389 if (!l_ptr) {
388 err("Attempt to delete non-existent link\n"); 390 err("Attempt to delete non-existent link\n");
@@ -401,7 +403,7 @@ void tipc_link_delete(struct link *l_ptr)
401 kfree(l_ptr); 403 kfree(l_ptr);
402} 404}
403 405
404static void link_start(struct link *l_ptr) 406static void link_start(struct tipc_link *l_ptr)
405{ 407{
406 tipc_node_lock(l_ptr->owner); 408 tipc_node_lock(l_ptr->owner);
407 link_state_event(l_ptr, STARTING_EVT); 409 link_state_event(l_ptr, STARTING_EVT);
@@ -418,7 +420,7 @@ static void link_start(struct link *l_ptr)
418 * has abated. 420 * has abated.
419 */ 421 */
420 422
421static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) 423static int link_schedule_port(struct tipc_link *l_ptr, u32 origport, u32 sz)
422{ 424{
423 struct tipc_port *p_ptr; 425 struct tipc_port *p_ptr;
424 426
@@ -440,7 +442,7 @@ exit:
440 return -ELINKCONG; 442 return -ELINKCONG;
441} 443}
442 444
443void tipc_link_wakeup_ports(struct link *l_ptr, int all) 445void tipc_link_wakeup_ports(struct tipc_link *l_ptr, int all)
444{ 446{
445 struct tipc_port *p_ptr; 447 struct tipc_port *p_ptr;
446 struct tipc_port *temp_p_ptr; 448 struct tipc_port *temp_p_ptr;
@@ -475,7 +477,7 @@ exit:
475 * @l_ptr: pointer to link 477 * @l_ptr: pointer to link
476 */ 478 */
477 479
478static void link_release_outqueue(struct link *l_ptr) 480static void link_release_outqueue(struct tipc_link *l_ptr)
479{ 481{
480 struct sk_buff *buf = l_ptr->first_out; 482 struct sk_buff *buf = l_ptr->first_out;
481 struct sk_buff *next; 483 struct sk_buff *next;
@@ -494,7 +496,7 @@ static void link_release_outqueue(struct link *l_ptr)
494 * @l_ptr: pointer to link 496 * @l_ptr: pointer to link
495 */ 497 */
496 498
497void tipc_link_reset_fragments(struct link *l_ptr) 499void tipc_link_reset_fragments(struct tipc_link *l_ptr)
498{ 500{
499 struct sk_buff *buf = l_ptr->defragm_buf; 501 struct sk_buff *buf = l_ptr->defragm_buf;
500 struct sk_buff *next; 502 struct sk_buff *next;
@@ -512,7 +514,7 @@ void tipc_link_reset_fragments(struct link *l_ptr)
512 * @l_ptr: pointer to link 514 * @l_ptr: pointer to link
513 */ 515 */
514 516
515void tipc_link_stop(struct link *l_ptr) 517void tipc_link_stop(struct tipc_link *l_ptr)
516{ 518{
517 struct sk_buff *buf; 519 struct sk_buff *buf;
518 struct sk_buff *next; 520 struct sk_buff *next;
@@ -537,7 +539,7 @@ void tipc_link_stop(struct link *l_ptr)
537 l_ptr->proto_msg_queue = NULL; 539 l_ptr->proto_msg_queue = NULL;
538} 540}
539 541
540void tipc_link_reset(struct link *l_ptr) 542void tipc_link_reset(struct tipc_link *l_ptr)
541{ 543{
542 struct sk_buff *buf; 544 struct sk_buff *buf;
543 u32 prev_state = l_ptr->state; 545 u32 prev_state = l_ptr->state;
@@ -597,7 +599,7 @@ void tipc_link_reset(struct link *l_ptr)
597} 599}
598 600
599 601
600static void link_activate(struct link *l_ptr) 602static void link_activate(struct tipc_link *l_ptr)
601{ 603{
602 l_ptr->next_in_no = l_ptr->stats.recv_info = 1; 604 l_ptr->next_in_no = l_ptr->stats.recv_info = 1;
603 tipc_node_link_up(l_ptr->owner, l_ptr); 605 tipc_node_link_up(l_ptr->owner, l_ptr);
@@ -610,9 +612,9 @@ static void link_activate(struct link *l_ptr)
610 * @event: state machine event to process 612 * @event: state machine event to process
611 */ 613 */
612 614
613static void link_state_event(struct link *l_ptr, unsigned event) 615static void link_state_event(struct tipc_link *l_ptr, unsigned event)
614{ 616{
615 struct link *other; 617 struct tipc_link *other;
616 u32 cont_intv = l_ptr->continuity_interval; 618 u32 cont_intv = l_ptr->continuity_interval;
617 619
618 if (!l_ptr->started && (event != STARTING_EVT)) 620 if (!l_ptr->started && (event != STARTING_EVT))
@@ -784,7 +786,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
784 * the tail of an existing one. 786 * the tail of an existing one.
785 */ 787 */
786 788
787static int link_bundle_buf(struct link *l_ptr, 789static int link_bundle_buf(struct tipc_link *l_ptr,
788 struct sk_buff *bundler, 790 struct sk_buff *bundler,
789 struct sk_buff *buf) 791 struct sk_buff *buf)
790{ 792{
@@ -813,7 +815,7 @@ static int link_bundle_buf(struct link *l_ptr,
813 return 1; 815 return 1;
814} 816}
815 817
816static void link_add_to_outqueue(struct link *l_ptr, 818static void link_add_to_outqueue(struct tipc_link *l_ptr,
817 struct sk_buff *buf, 819 struct sk_buff *buf,
818 struct tipc_msg *msg) 820 struct tipc_msg *msg)
819{ 821{
@@ -834,7 +836,7 @@ static void link_add_to_outqueue(struct link *l_ptr,
834 l_ptr->stats.max_queue_sz = l_ptr->out_queue_size; 836 l_ptr->stats.max_queue_sz = l_ptr->out_queue_size;
835} 837}
836 838
837static void link_add_chain_to_outqueue(struct link *l_ptr, 839static void link_add_chain_to_outqueue(struct tipc_link *l_ptr,
838 struct sk_buff *buf_chain, 840 struct sk_buff *buf_chain,
839 u32 long_msgno) 841 u32 long_msgno)
840{ 842{
@@ -859,7 +861,7 @@ static void link_add_chain_to_outqueue(struct link *l_ptr,
859 * has failed, and from link_send() 861 * has failed, and from link_send()
860 */ 862 */
861 863
862int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) 864int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf)
863{ 865{
864 struct tipc_msg *msg = buf_msg(buf); 866 struct tipc_msg *msg = buf_msg(buf);
865 u32 size = msg_size(msg); 867 u32 size = msg_size(msg);
@@ -954,7 +956,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
954 956
955int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) 957int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
956{ 958{
957 struct link *l_ptr; 959 struct tipc_link *l_ptr;
958 struct tipc_node *n_ptr; 960 struct tipc_node *n_ptr;
959 int res = -ELINKCONG; 961 int res = -ELINKCONG;
960 962
@@ -988,7 +990,7 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
988void tipc_link_send_names(struct list_head *message_list, u32 dest) 990void tipc_link_send_names(struct list_head *message_list, u32 dest)
989{ 991{
990 struct tipc_node *n_ptr; 992 struct tipc_node *n_ptr;
991 struct link *l_ptr; 993 struct tipc_link *l_ptr;
992 struct sk_buff *buf; 994 struct sk_buff *buf;
993 struct sk_buff *temp_buf; 995 struct sk_buff *temp_buf;
994 996
@@ -1027,7 +1029,7 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest)
1027 * Link is locked. Returns user data length. 1029 * Link is locked. Returns user data length.
1028 */ 1030 */
1029 1031
1030static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, 1032static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf,
1031 u32 *used_max_pkt) 1033 u32 *used_max_pkt)
1032{ 1034{
1033 struct tipc_msg *msg = buf_msg(buf); 1035 struct tipc_msg *msg = buf_msg(buf);
@@ -1061,7 +1063,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
1061 */ 1063 */
1062int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) 1064int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
1063{ 1065{
1064 struct link *l_ptr; 1066 struct tipc_link *l_ptr;
1065 struct tipc_node *n_ptr; 1067 struct tipc_node *n_ptr;
1066 int res; 1068 int res;
1067 u32 selector = msg_origport(buf_msg(buf)) & 1; 1069 u32 selector = msg_origport(buf_msg(buf)) & 1;
@@ -1100,7 +1102,7 @@ int tipc_link_send_sections_fast(struct tipc_port *sender,
1100 u32 destaddr) 1102 u32 destaddr)
1101{ 1103{
1102 struct tipc_msg *hdr = &sender->phdr; 1104 struct tipc_msg *hdr = &sender->phdr;
1103 struct link *l_ptr; 1105 struct tipc_link *l_ptr;
1104 struct sk_buff *buf; 1106 struct sk_buff *buf;
1105 struct tipc_node *node; 1107 struct tipc_node *node;
1106 int res; 1108 int res;
@@ -1195,7 +1197,7 @@ static int link_send_sections_long(struct tipc_port *sender,
1195 unsigned int total_len, 1197 unsigned int total_len,
1196 u32 destaddr) 1198 u32 destaddr)
1197{ 1199{
1198 struct link *l_ptr; 1200 struct tipc_link *l_ptr;
1199 struct tipc_node *node; 1201 struct tipc_node *node;
1200 struct tipc_msg *hdr = &sender->phdr; 1202 struct tipc_msg *hdr = &sender->phdr;
1201 u32 dsz = total_len; 1203 u32 dsz = total_len;
@@ -1342,7 +1344,7 @@ reject:
1342/* 1344/*
1343 * tipc_link_push_packet: Push one unsent packet to the media 1345 * tipc_link_push_packet: Push one unsent packet to the media
1344 */ 1346 */
1345u32 tipc_link_push_packet(struct link *l_ptr) 1347u32 tipc_link_push_packet(struct tipc_link *l_ptr)
1346{ 1348{
1347 struct sk_buff *buf = l_ptr->first_out; 1349 struct sk_buff *buf = l_ptr->first_out;
1348 u32 r_q_size = l_ptr->retransm_queue_size; 1350 u32 r_q_size = l_ptr->retransm_queue_size;
@@ -1354,7 +1356,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1354 if (r_q_size && buf) { 1356 if (r_q_size && buf) {
1355 u32 last = lesser(mod(r_q_head + r_q_size), 1357 u32 last = lesser(mod(r_q_head + r_q_size),
1356 link_last_sent(l_ptr)); 1358 link_last_sent(l_ptr));
1357 u32 first = msg_seqno(buf_msg(buf)); 1359 u32 first = buf_seqno(buf);
1358 1360
1359 while (buf && less(first, r_q_head)) { 1361 while (buf && less(first, r_q_head)) {
1360 first = mod(first + 1); 1362 first = mod(first + 1);
@@ -1403,7 +1405,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1403 if (buf) { 1405 if (buf) {
1404 struct tipc_msg *msg = buf_msg(buf); 1406 struct tipc_msg *msg = buf_msg(buf);
1405 u32 next = msg_seqno(msg); 1407 u32 next = msg_seqno(msg);
1406 u32 first = msg_seqno(buf_msg(l_ptr->first_out)); 1408 u32 first = buf_seqno(l_ptr->first_out);
1407 1409
1408 if (mod(next - first) < l_ptr->queue_limit[0]) { 1410 if (mod(next - first) < l_ptr->queue_limit[0]) {
1409 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); 1411 msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
@@ -1426,7 +1428,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1426 * push_queue(): push out the unsent messages of a link where 1428 * push_queue(): push out the unsent messages of a link where
1427 * congestion has abated. Node is locked 1429 * congestion has abated. Node is locked
1428 */ 1430 */
1429void tipc_link_push_queue(struct link *l_ptr) 1431void tipc_link_push_queue(struct tipc_link *l_ptr)
1430{ 1432{
1431 u32 res; 1433 u32 res;
1432 1434
@@ -1470,7 +1472,8 @@ static void link_reset_all(unsigned long addr)
1470 read_unlock_bh(&tipc_net_lock); 1472 read_unlock_bh(&tipc_net_lock);
1471} 1473}
1472 1474
1473static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) 1475static void link_retransmit_failure(struct tipc_link *l_ptr,
1476 struct sk_buff *buf)
1474{ 1477{
1475 struct tipc_msg *msg = buf_msg(buf); 1478 struct tipc_msg *msg = buf_msg(buf);
1476 1479
@@ -1514,7 +1517,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
1514 } 1517 }
1515} 1518}
1516 1519
1517void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, 1520void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf,
1518 u32 retransmits) 1521 u32 retransmits)
1519{ 1522{
1520 struct tipc_msg *msg; 1523 struct tipc_msg *msg;
@@ -1558,7 +1561,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1558 } else { 1561 } else {
1559 tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); 1562 tipc_bearer_schedule(l_ptr->b_ptr, l_ptr);
1560 l_ptr->stats.bearer_congs++; 1563 l_ptr->stats.bearer_congs++;
1561 l_ptr->retransm_queue_head = msg_seqno(buf_msg(buf)); 1564 l_ptr->retransm_queue_head = buf_seqno(buf);
1562 l_ptr->retransm_queue_size = retransmits; 1565 l_ptr->retransm_queue_size = retransmits;
1563 return; 1566 return;
1564 } 1567 }
@@ -1571,7 +1574,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1571 * link_insert_deferred_queue - insert deferred messages back into receive chain 1574 * link_insert_deferred_queue - insert deferred messages back into receive chain
1572 */ 1575 */
1573 1576
1574static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, 1577static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr,
1575 struct sk_buff *buf) 1578 struct sk_buff *buf)
1576{ 1579{
1577 u32 seq_no; 1580 u32 seq_no;
@@ -1579,7 +1582,7 @@ static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr,
1579 if (l_ptr->oldest_deferred_in == NULL) 1582 if (l_ptr->oldest_deferred_in == NULL)
1580 return buf; 1583 return buf;
1581 1584
1582 seq_no = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); 1585 seq_no = buf_seqno(l_ptr->oldest_deferred_in);
1583 if (seq_no == mod(l_ptr->next_in_no)) { 1586 if (seq_no == mod(l_ptr->next_in_no)) {
1584 l_ptr->newest_deferred_in->next = buf; 1587 l_ptr->newest_deferred_in->next = buf;
1585 buf = l_ptr->oldest_deferred_in; 1588 buf = l_ptr->oldest_deferred_in;
@@ -1653,7 +1656,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1653 read_lock_bh(&tipc_net_lock); 1656 read_lock_bh(&tipc_net_lock);
1654 while (head) { 1657 while (head) {
1655 struct tipc_node *n_ptr; 1658 struct tipc_node *n_ptr;
1656 struct link *l_ptr; 1659 struct tipc_link *l_ptr;
1657 struct sk_buff *crs; 1660 struct sk_buff *crs;
1658 struct sk_buff *buf = head; 1661 struct sk_buff *buf = head;
1659 struct tipc_msg *msg; 1662 struct tipc_msg *msg;
@@ -1733,14 +1736,12 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1733 1736
1734 /* Release acked messages */ 1737 /* Release acked messages */
1735 1738
1736 if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) { 1739 if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
1737 if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) 1740 tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg));
1738 tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg));
1739 }
1740 1741
1741 crs = l_ptr->first_out; 1742 crs = l_ptr->first_out;
1742 while ((crs != l_ptr->next_out) && 1743 while ((crs != l_ptr->next_out) &&
1743 less_eq(msg_seqno(buf_msg(crs)), ackd)) { 1744 less_eq(buf_seqno(crs), ackd)) {
1744 struct sk_buff *next = crs->next; 1745 struct sk_buff *next = crs->next;
1745 1746
1746 buf_discard(crs); 1747 buf_discard(crs);
@@ -1863,7 +1864,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1863{ 1864{
1864 struct sk_buff *prev = NULL; 1865 struct sk_buff *prev = NULL;
1865 struct sk_buff *crs = *head; 1866 struct sk_buff *crs = *head;
1866 u32 seq_no = msg_seqno(buf_msg(buf)); 1867 u32 seq_no = buf_seqno(buf);
1867 1868
1868 buf->next = NULL; 1869 buf->next = NULL;
1869 1870
@@ -1874,7 +1875,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1874 } 1875 }
1875 1876
1876 /* Last ? */ 1877 /* Last ? */
1877 if (less(msg_seqno(buf_msg(*tail)), seq_no)) { 1878 if (less(buf_seqno(*tail), seq_no)) {
1878 (*tail)->next = buf; 1879 (*tail)->next = buf;
1879 *tail = buf; 1880 *tail = buf;
1880 return 1; 1881 return 1;
@@ -1908,10 +1909,10 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1908 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet 1909 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
1909 */ 1910 */
1910 1911
1911static void link_handle_out_of_seq_msg(struct link *l_ptr, 1912static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
1912 struct sk_buff *buf) 1913 struct sk_buff *buf)
1913{ 1914{
1914 u32 seq_no = msg_seqno(buf_msg(buf)); 1915 u32 seq_no = buf_seqno(buf);
1915 1916
1916 if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { 1917 if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) {
1917 link_recv_proto_msg(l_ptr, buf); 1918 link_recv_proto_msg(l_ptr, buf);
@@ -1946,8 +1947,9 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
1946/* 1947/*
1947 * Send protocol message to the other endpoint. 1948 * Send protocol message to the other endpoint.
1948 */ 1949 */
1949void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, 1950void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
1950 u32 gap, u32 tolerance, u32 priority, u32 ack_mtu) 1951 int probe_msg, u32 gap, u32 tolerance,
1952 u32 priority, u32 ack_mtu)
1951{ 1953{
1952 struct sk_buff *buf = NULL; 1954 struct sk_buff *buf = NULL;
1953 struct tipc_msg *msg = l_ptr->pmsg; 1955 struct tipc_msg *msg = l_ptr->pmsg;
@@ -1973,10 +1975,10 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
1973 if (!tipc_link_is_up(l_ptr)) 1975 if (!tipc_link_is_up(l_ptr))
1974 return; 1976 return;
1975 if (l_ptr->next_out) 1977 if (l_ptr->next_out)
1976 next_sent = msg_seqno(buf_msg(l_ptr->next_out)); 1978 next_sent = buf_seqno(l_ptr->next_out);
1977 msg_set_next_sent(msg, next_sent); 1979 msg_set_next_sent(msg, next_sent);
1978 if (l_ptr->oldest_deferred_in) { 1980 if (l_ptr->oldest_deferred_in) {
1979 u32 rec = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); 1981 u32 rec = buf_seqno(l_ptr->oldest_deferred_in);
1980 gap = mod(rec - mod(l_ptr->next_in_no)); 1982 gap = mod(rec - mod(l_ptr->next_in_no));
1981 } 1983 }
1982 msg_set_seq_gap(msg, gap); 1984 msg_set_seq_gap(msg, gap);
@@ -2064,7 +2066,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2064 * change at any time. The node with lowest address rules 2066 * change at any time. The node with lowest address rules
2065 */ 2067 */
2066 2068
2067static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) 2069static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
2068{ 2070{
2069 u32 rec_gap = 0; 2071 u32 rec_gap = 0;
2070 u32 max_pkt_info; 2072 u32 max_pkt_info;
@@ -2197,12 +2199,12 @@ exit:
2197 * tipc_link_tunnel(): Send one message via a link belonging to 2199 * tipc_link_tunnel(): Send one message via a link belonging to
2198 * another bearer. Owner node is locked. 2200 * another bearer. Owner node is locked.
2199 */ 2201 */
2200static void tipc_link_tunnel(struct link *l_ptr, 2202static void tipc_link_tunnel(struct tipc_link *l_ptr,
2201 struct tipc_msg *tunnel_hdr, 2203 struct tipc_msg *tunnel_hdr,
2202 struct tipc_msg *msg, 2204 struct tipc_msg *msg,
2203 u32 selector) 2205 u32 selector)
2204{ 2206{
2205 struct link *tunnel; 2207 struct tipc_link *tunnel;
2206 struct sk_buff *buf; 2208 struct sk_buff *buf;
2207 u32 length = msg_size(msg); 2209 u32 length = msg_size(msg);
2208 2210
@@ -2231,11 +2233,11 @@ static void tipc_link_tunnel(struct link *l_ptr,
2231 * Owner node is locked. 2233 * Owner node is locked.
2232 */ 2234 */
2233 2235
2234void tipc_link_changeover(struct link *l_ptr) 2236void tipc_link_changeover(struct tipc_link *l_ptr)
2235{ 2237{
2236 u32 msgcount = l_ptr->out_queue_size; 2238 u32 msgcount = l_ptr->out_queue_size;
2237 struct sk_buff *crs = l_ptr->first_out; 2239 struct sk_buff *crs = l_ptr->first_out;
2238 struct link *tunnel = l_ptr->owner->active_links[0]; 2240 struct tipc_link *tunnel = l_ptr->owner->active_links[0];
2239 struct tipc_msg tunnel_hdr; 2241 struct tipc_msg tunnel_hdr;
2240 int split_bundles; 2242 int split_bundles;
2241 2243
@@ -2294,7 +2296,7 @@ void tipc_link_changeover(struct link *l_ptr)
2294 } 2296 }
2295} 2297}
2296 2298
2297void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) 2299void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *tunnel)
2298{ 2300{
2299 struct sk_buff *iter; 2301 struct sk_buff *iter;
2300 struct tipc_msg tunnel_hdr; 2302 struct tipc_msg tunnel_hdr;
@@ -2358,11 +2360,11 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
2358 * via other link. Node is locked. Return extracted buffer. 2360 * via other link. Node is locked. Return extracted buffer.
2359 */ 2361 */
2360 2362
2361static int link_recv_changeover_msg(struct link **l_ptr, 2363static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2362 struct sk_buff **buf) 2364 struct sk_buff **buf)
2363{ 2365{
2364 struct sk_buff *tunnel_buf = *buf; 2366 struct sk_buff *tunnel_buf = *buf;
2365 struct link *dest_link; 2367 struct tipc_link *dest_link;
2366 struct tipc_msg *msg; 2368 struct tipc_msg *msg;
2367 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf); 2369 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
2368 u32 msg_typ = msg_type(tunnel_msg); 2370 u32 msg_typ = msg_type(tunnel_msg);
@@ -2462,7 +2464,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
2462 * The buffer is complete, inclusive total message length. 2464 * The buffer is complete, inclusive total message length.
2463 * Returns user data length. 2465 * Returns user data length.
2464 */ 2466 */
2465static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) 2467static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf)
2466{ 2468{
2467 struct sk_buff *buf_chain = NULL; 2469 struct sk_buff *buf_chain = NULL;
2468 struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain; 2470 struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain;
@@ -2591,7 +2593,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2591 2593
2592 /* Is there an incomplete message waiting for this fragment? */ 2594 /* Is there an incomplete message waiting for this fragment? */
2593 2595
2594 while (pbuf && ((msg_seqno(buf_msg(pbuf)) != long_msg_seq_no) || 2596 while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) ||
2595 (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { 2597 (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) {
2596 prev = pbuf; 2598 prev = pbuf;
2597 pbuf = pbuf->next; 2599 pbuf = pbuf->next;
@@ -2658,7 +2660,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2658 * @l_ptr: pointer to link 2660 * @l_ptr: pointer to link
2659 */ 2661 */
2660 2662
2661static void link_check_defragm_bufs(struct link *l_ptr) 2663static void link_check_defragm_bufs(struct tipc_link *l_ptr)
2662{ 2664{
2663 struct sk_buff *prev = NULL; 2665 struct sk_buff *prev = NULL;
2664 struct sk_buff *next = NULL; 2666 struct sk_buff *next = NULL;
@@ -2688,7 +2690,7 @@ static void link_check_defragm_bufs(struct link *l_ptr)
2688 2690
2689 2691
2690 2692
2691static void link_set_supervision_props(struct link *l_ptr, u32 tolerance) 2693static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance)
2692{ 2694{
2693 if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) 2695 if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL))
2694 return; 2696 return;
@@ -2700,7 +2702,7 @@ static void link_set_supervision_props(struct link *l_ptr, u32 tolerance)
2700} 2702}
2701 2703
2702 2704
2703void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) 2705void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window)
2704{ 2706{
2705 /* Data messages from this node, inclusive FIRST_FRAGM */ 2707 /* Data messages from this node, inclusive FIRST_FRAGM */
2706 l_ptr->queue_limit[TIPC_LOW_IMPORTANCE] = window; 2708 l_ptr->queue_limit[TIPC_LOW_IMPORTANCE] = window;
@@ -2730,11 +2732,12 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window)
2730 * Returns pointer to link (or 0 if invalid link name). 2732 * Returns pointer to link (or 0 if invalid link name).
2731 */ 2733 */
2732 2734
2733static struct link *link_find_link(const char *name, struct tipc_node **node) 2735static struct tipc_link *link_find_link(const char *name,
2736 struct tipc_node **node)
2734{ 2737{
2735 struct link_name link_name_parts; 2738 struct tipc_link_name link_name_parts;
2736 struct tipc_bearer *b_ptr; 2739 struct tipc_bearer *b_ptr;
2737 struct link *l_ptr; 2740 struct tipc_link *l_ptr;
2738 2741
2739 if (!link_name_validate(name, &link_name_parts)) 2742 if (!link_name_validate(name, &link_name_parts))
2740 return NULL; 2743 return NULL;
@@ -2754,13 +2757,113 @@ static struct link *link_find_link(const char *name, struct tipc_node **node)
2754 return l_ptr; 2757 return l_ptr;
2755} 2758}
2756 2759
2760/**
2761 * link_value_is_valid -- validate proposed link tolerance/priority/window
2762 *
2763 * @cmd - value type (TIPC_CMD_SET_LINK_*)
2764 * @new_value - the new value
2765 *
2766 * Returns 1 if value is within range, 0 if not.
2767 */
2768
2769static int link_value_is_valid(u16 cmd, u32 new_value)
2770{
2771 switch (cmd) {
2772 case TIPC_CMD_SET_LINK_TOL:
2773 return (new_value >= TIPC_MIN_LINK_TOL) &&
2774 (new_value <= TIPC_MAX_LINK_TOL);
2775 case TIPC_CMD_SET_LINK_PRI:
2776 return (new_value <= TIPC_MAX_LINK_PRI);
2777 case TIPC_CMD_SET_LINK_WINDOW:
2778 return (new_value >= TIPC_MIN_LINK_WIN) &&
2779 (new_value <= TIPC_MAX_LINK_WIN);
2780 }
2781 return 0;
2782}
2783
2784
2785/**
2786 * link_cmd_set_value - change priority/tolerance/window for link/bearer/media
2787 * @name - ptr to link, bearer, or media name
2788 * @new_value - new value of link, bearer, or media setting
2789 * @cmd - which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*)
2790 *
2791 * Caller must hold 'tipc_net_lock' to ensure link/bearer/media is not deleted.
2792 *
2793 * Returns 0 if value updated and negative value on error.
2794 */
2795
2796static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd)
2797{
2798 struct tipc_node *node;
2799 struct tipc_link *l_ptr;
2800 struct tipc_bearer *b_ptr;
2801 struct tipc_media *m_ptr;
2802
2803 l_ptr = link_find_link(name, &node);
2804 if (l_ptr) {
2805 /*
2806 * acquire node lock for tipc_link_send_proto_msg().
2807 * see "TIPC locking policy" in net.c.
2808 */
2809 tipc_node_lock(node);
2810 switch (cmd) {
2811 case TIPC_CMD_SET_LINK_TOL:
2812 link_set_supervision_props(l_ptr, new_value);
2813 tipc_link_send_proto_msg(l_ptr,
2814 STATE_MSG, 0, 0, new_value, 0, 0);
2815 break;
2816 case TIPC_CMD_SET_LINK_PRI:
2817 l_ptr->priority = new_value;
2818 tipc_link_send_proto_msg(l_ptr,
2819 STATE_MSG, 0, 0, 0, new_value, 0);
2820 break;
2821 case TIPC_CMD_SET_LINK_WINDOW:
2822 tipc_link_set_queue_limits(l_ptr, new_value);
2823 break;
2824 }
2825 tipc_node_unlock(node);
2826 return 0;
2827 }
2828
2829 b_ptr = tipc_bearer_find(name);
2830 if (b_ptr) {
2831 switch (cmd) {
2832 case TIPC_CMD_SET_LINK_TOL:
2833 b_ptr->tolerance = new_value;
2834 return 0;
2835 case TIPC_CMD_SET_LINK_PRI:
2836 b_ptr->priority = new_value;
2837 return 0;
2838 case TIPC_CMD_SET_LINK_WINDOW:
2839 b_ptr->window = new_value;
2840 return 0;
2841 }
2842 return -EINVAL;
2843 }
2844
2845 m_ptr = tipc_media_find(name);
2846 if (!m_ptr)
2847 return -ENODEV;
2848 switch (cmd) {
2849 case TIPC_CMD_SET_LINK_TOL:
2850 m_ptr->tolerance = new_value;
2851 return 0;
2852 case TIPC_CMD_SET_LINK_PRI:
2853 m_ptr->priority = new_value;
2854 return 0;
2855 case TIPC_CMD_SET_LINK_WINDOW:
2856 m_ptr->window = new_value;
2857 return 0;
2858 }
2859 return -EINVAL;
2860}
2861
2757struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, 2862struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space,
2758 u16 cmd) 2863 u16 cmd)
2759{ 2864{
2760 struct tipc_link_config *args; 2865 struct tipc_link_config *args;
2761 u32 new_value; 2866 u32 new_value;
2762 struct link *l_ptr;
2763 struct tipc_node *node;
2764 int res; 2867 int res;
2765 2868
2766 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) 2869 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG))
@@ -2769,6 +2872,10 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
2769 args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); 2872 args = (struct tipc_link_config *)TLV_DATA(req_tlv_area);
2770 new_value = ntohl(args->value); 2873 new_value = ntohl(args->value);
2771 2874
2875 if (!link_value_is_valid(cmd, new_value))
2876 return tipc_cfg_reply_error_string(
2877 "cannot change, value invalid");
2878
2772 if (!strcmp(args->name, tipc_bclink_name)) { 2879 if (!strcmp(args->name, tipc_bclink_name)) {
2773 if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && 2880 if ((cmd == TIPC_CMD_SET_LINK_WINDOW) &&
2774 (tipc_bclink_set_queue_limits(new_value) == 0)) 2881 (tipc_bclink_set_queue_limits(new_value) == 0))
@@ -2778,43 +2885,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
2778 } 2885 }
2779 2886
2780 read_lock_bh(&tipc_net_lock); 2887 read_lock_bh(&tipc_net_lock);
2781 l_ptr = link_find_link(args->name, &node); 2888 res = link_cmd_set_value(args->name, new_value, cmd);
2782 if (!l_ptr) {
2783 read_unlock_bh(&tipc_net_lock);
2784 return tipc_cfg_reply_error_string("link not found");
2785 }
2786
2787 tipc_node_lock(node);
2788 res = -EINVAL;
2789 switch (cmd) {
2790 case TIPC_CMD_SET_LINK_TOL:
2791 if ((new_value >= TIPC_MIN_LINK_TOL) &&
2792 (new_value <= TIPC_MAX_LINK_TOL)) {
2793 link_set_supervision_props(l_ptr, new_value);
2794 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
2795 0, 0, new_value, 0, 0);
2796 res = 0;
2797 }
2798 break;
2799 case TIPC_CMD_SET_LINK_PRI:
2800 if ((new_value >= TIPC_MIN_LINK_PRI) &&
2801 (new_value <= TIPC_MAX_LINK_PRI)) {
2802 l_ptr->priority = new_value;
2803 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
2804 0, 0, 0, new_value, 0);
2805 res = 0;
2806 }
2807 break;
2808 case TIPC_CMD_SET_LINK_WINDOW:
2809 if ((new_value >= TIPC_MIN_LINK_WIN) &&
2810 (new_value <= TIPC_MAX_LINK_WIN)) {
2811 tipc_link_set_queue_limits(l_ptr, new_value);
2812 res = 0;
2813 }
2814 break;
2815 }
2816 tipc_node_unlock(node);
2817
2818 read_unlock_bh(&tipc_net_lock); 2889 read_unlock_bh(&tipc_net_lock);
2819 if (res) 2890 if (res)
2820 return tipc_cfg_reply_error_string("cannot change link setting"); 2891 return tipc_cfg_reply_error_string("cannot change link setting");
@@ -2827,7 +2898,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
2827 * @l_ptr: pointer to link 2898 * @l_ptr: pointer to link
2828 */ 2899 */
2829 2900
2830static void link_reset_statistics(struct link *l_ptr) 2901static void link_reset_statistics(struct tipc_link *l_ptr)
2831{ 2902{
2832 memset(&l_ptr->stats, 0, sizeof(l_ptr->stats)); 2903 memset(&l_ptr->stats, 0, sizeof(l_ptr->stats));
2833 l_ptr->stats.sent_info = l_ptr->next_out_no; 2904 l_ptr->stats.sent_info = l_ptr->next_out_no;
@@ -2837,7 +2908,7 @@ static void link_reset_statistics(struct link *l_ptr)
2837struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) 2908struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space)
2838{ 2909{
2839 char *link_name; 2910 char *link_name;
2840 struct link *l_ptr; 2911 struct tipc_link *l_ptr;
2841 struct tipc_node *node; 2912 struct tipc_node *node;
2842 2913
2843 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) 2914 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME))
@@ -2885,7 +2956,7 @@ static u32 percent(u32 count, u32 total)
2885static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) 2956static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
2886{ 2957{
2887 struct print_buf pb; 2958 struct print_buf pb;
2888 struct link *l_ptr; 2959 struct tipc_link *l_ptr;
2889 struct tipc_node *node; 2960 struct tipc_node *node;
2890 char *status; 2961 char *status;
2891 u32 profile_total = 0; 2962 u32 profile_total = 0;
@@ -3007,7 +3078,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s
3007u32 tipc_link_get_max_pkt(u32 dest, u32 selector) 3078u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3008{ 3079{
3009 struct tipc_node *n_ptr; 3080 struct tipc_node *n_ptr;
3010 struct link *l_ptr; 3081 struct tipc_link *l_ptr;
3011 u32 res = MAX_PKT_DEFAULT; 3082 u32 res = MAX_PKT_DEFAULT;
3012 3083
3013 if (dest == tipc_own_addr) 3084 if (dest == tipc_own_addr)
@@ -3026,7 +3097,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3026 return res; 3097 return res;
3027} 3098}
3028 3099
3029static void link_print(struct link *l_ptr, const char *str) 3100static void link_print(struct tipc_link *l_ptr, const char *str)
3030{ 3101{
3031 char print_area[256]; 3102 char print_area[256];
3032 struct print_buf pb; 3103 struct print_buf pb;
@@ -3046,13 +3117,12 @@ static void link_print(struct link *l_ptr, const char *str)
3046 tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no)); 3117 tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no));
3047 tipc_printf(buf, "SQUE"); 3118 tipc_printf(buf, "SQUE");
3048 if (l_ptr->first_out) { 3119 if (l_ptr->first_out) {
3049 tipc_printf(buf, "[%u..", msg_seqno(buf_msg(l_ptr->first_out))); 3120 tipc_printf(buf, "[%u..", buf_seqno(l_ptr->first_out));
3050 if (l_ptr->next_out) 3121 if (l_ptr->next_out)
3051 tipc_printf(buf, "%u..", 3122 tipc_printf(buf, "%u..", buf_seqno(l_ptr->next_out));
3052 msg_seqno(buf_msg(l_ptr->next_out))); 3123 tipc_printf(buf, "%u]", buf_seqno(l_ptr->last_out));
3053 tipc_printf(buf, "%u]", msg_seqno(buf_msg(l_ptr->last_out))); 3124 if ((mod(buf_seqno(l_ptr->last_out) -
3054 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - 3125 buf_seqno(l_ptr->first_out))
3055 msg_seqno(buf_msg(l_ptr->first_out)))
3056 != (l_ptr->out_queue_size - 1)) || 3126 != (l_ptr->out_queue_size - 1)) ||
3057 (l_ptr->last_out->next != NULL)) { 3127 (l_ptr->last_out->next != NULL)) {
3058 tipc_printf(buf, "\nSend queue inconsistency\n"); 3128 tipc_printf(buf, "\nSend queue inconsistency\n");
@@ -3064,8 +3134,8 @@ static void link_print(struct link *l_ptr, const char *str)
3064 tipc_printf(buf, "[]"); 3134 tipc_printf(buf, "[]");
3065 tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size); 3135 tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size);
3066 if (l_ptr->oldest_deferred_in) { 3136 if (l_ptr->oldest_deferred_in) {
3067 u32 o = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); 3137 u32 o = buf_seqno(l_ptr->oldest_deferred_in);
3068 u32 n = msg_seqno(buf_msg(l_ptr->newest_deferred_in)); 3138 u32 n = buf_seqno(l_ptr->newest_deferred_in);
3069 tipc_printf(buf, ":RQUE[%u..%u]", o, n); 3139 tipc_printf(buf, ":RQUE[%u..%u]", o, n);
3070 if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) { 3140 if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) {
3071 tipc_printf(buf, ":RQSIZ(%u)", 3141 tipc_printf(buf, ":RQSIZ(%u)",
diff --git a/net/tipc/link.h b/net/tipc/link.h
index e56cb532913e..73c18c140e1d 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -45,6 +45,12 @@
45#define PUSH_FINISHED 2 45#define PUSH_FINISHED 2
46 46
47/* 47/*
48 * Out-of-range value for link sequence numbers
49 */
50
51#define INVALID_LINK_SEQ 0x10000
52
53/*
48 * Link states 54 * Link states
49 */ 55 */
50 56
@@ -61,7 +67,7 @@
61#define MAX_PKT_DEFAULT 1500 67#define MAX_PKT_DEFAULT 1500
62 68
63/** 69/**
64 * struct link - TIPC link data structure 70 * struct tipc_link - TIPC link data structure
65 * @addr: network address of link's peer node 71 * @addr: network address of link's peer node
66 * @name: link name character string 72 * @name: link name character string
67 * @media_addr: media address to use when sending messages over link 73 * @media_addr: media address to use when sending messages over link
@@ -109,7 +115,7 @@
109 * @stats: collects statistics regarding link activity 115 * @stats: collects statistics regarding link activity
110 */ 116 */
111 117
112struct link { 118struct tipc_link {
113 u32 addr; 119 u32 addr;
114 char name[TIPC_MAX_LINK_NAME]; 120 char name[TIPC_MAX_LINK_NAME];
115 struct tipc_media_addr media_addr; 121 struct tipc_media_addr media_addr;
@@ -207,24 +213,24 @@ struct link {
207 213
208struct tipc_port; 214struct tipc_port;
209 215
210struct link *tipc_link_create(struct tipc_node *n_ptr, 216struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
211 struct tipc_bearer *b_ptr, 217 struct tipc_bearer *b_ptr,
212 const struct tipc_media_addr *media_addr); 218 const struct tipc_media_addr *media_addr);
213void tipc_link_delete(struct link *l_ptr); 219void tipc_link_delete(struct tipc_link *l_ptr);
214void tipc_link_changeover(struct link *l_ptr); 220void tipc_link_changeover(struct tipc_link *l_ptr);
215void tipc_link_send_duplicate(struct link *l_ptr, struct link *dest); 221void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *dest);
216void tipc_link_reset_fragments(struct link *l_ptr); 222void tipc_link_reset_fragments(struct tipc_link *l_ptr);
217int tipc_link_is_up(struct link *l_ptr); 223int tipc_link_is_up(struct tipc_link *l_ptr);
218int tipc_link_is_active(struct link *l_ptr); 224int tipc_link_is_active(struct tipc_link *l_ptr);
219u32 tipc_link_push_packet(struct link *l_ptr); 225u32 tipc_link_push_packet(struct tipc_link *l_ptr);
220void tipc_link_stop(struct link *l_ptr); 226void tipc_link_stop(struct tipc_link *l_ptr);
221struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, u16 cmd); 227struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, u16 cmd);
222struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space); 228struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space);
223struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space); 229struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space);
224void tipc_link_reset(struct link *l_ptr); 230void tipc_link_reset(struct tipc_link *l_ptr);
225int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector); 231int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
226void tipc_link_send_names(struct list_head *message_list, u32 dest); 232void tipc_link_send_names(struct list_head *message_list, u32 dest);
227int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf); 233int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf);
228u32 tipc_link_get_max_pkt(u32 dest, u32 selector); 234u32 tipc_link_get_max_pkt(u32 dest, u32 selector);
229int tipc_link_send_sections_fast(struct tipc_port *sender, 235int tipc_link_send_sections_fast(struct tipc_port *sender,
230 struct iovec const *msg_sect, 236 struct iovec const *msg_sect,
@@ -235,19 +241,26 @@ void tipc_link_recv_bundle(struct sk_buff *buf);
235int tipc_link_recv_fragment(struct sk_buff **pending, 241int tipc_link_recv_fragment(struct sk_buff **pending,
236 struct sk_buff **fb, 242 struct sk_buff **fb,
237 struct tipc_msg **msg); 243 struct tipc_msg **msg);
238void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int prob, u32 gap, 244void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, int prob,
239 u32 tolerance, u32 priority, u32 acked_mtu); 245 u32 gap, u32 tolerance, u32 priority,
240void tipc_link_push_queue(struct link *l_ptr); 246 u32 acked_mtu);
247void tipc_link_push_queue(struct tipc_link *l_ptr);
241u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, 248u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
242 struct sk_buff *buf); 249 struct sk_buff *buf);
243void tipc_link_wakeup_ports(struct link *l_ptr, int all); 250void tipc_link_wakeup_ports(struct tipc_link *l_ptr, int all);
244void tipc_link_set_queue_limits(struct link *l_ptr, u32 window); 251void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window);
245void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *start, u32 retransmits); 252void tipc_link_retransmit(struct tipc_link *l_ptr,
253 struct sk_buff *start, u32 retransmits);
246 254
247/* 255/*
248 * Link sequence number manipulation routines (uses modulo 2**16 arithmetic) 256 * Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
249 */ 257 */
250 258
259static inline u32 buf_seqno(struct sk_buff *buf)
260{
261 return msg_seqno(buf_msg(buf));
262}
263
251static inline u32 mod(u32 x) 264static inline u32 mod(u32 x)
252{ 265{
253 return x & 0xffffu; 266 return x & 0xffffu;
@@ -282,32 +295,32 @@ static inline u32 lesser(u32 left, u32 right)
282 * Link status checking routines 295 * Link status checking routines
283 */ 296 */
284 297
285static inline int link_working_working(struct link *l_ptr) 298static inline int link_working_working(struct tipc_link *l_ptr)
286{ 299{
287 return l_ptr->state == WORKING_WORKING; 300 return l_ptr->state == WORKING_WORKING;
288} 301}
289 302
290static inline int link_working_unknown(struct link *l_ptr) 303static inline int link_working_unknown(struct tipc_link *l_ptr)
291{ 304{
292 return l_ptr->state == WORKING_UNKNOWN; 305 return l_ptr->state == WORKING_UNKNOWN;
293} 306}
294 307
295static inline int link_reset_unknown(struct link *l_ptr) 308static inline int link_reset_unknown(struct tipc_link *l_ptr)
296{ 309{
297 return l_ptr->state == RESET_UNKNOWN; 310 return l_ptr->state == RESET_UNKNOWN;
298} 311}
299 312
300static inline int link_reset_reset(struct link *l_ptr) 313static inline int link_reset_reset(struct tipc_link *l_ptr)
301{ 314{
302 return l_ptr->state == RESET_RESET; 315 return l_ptr->state == RESET_RESET;
303} 316}
304 317
305static inline int link_blocked(struct link *l_ptr) 318static inline int link_blocked(struct tipc_link *l_ptr)
306{ 319{
307 return l_ptr->exp_msg_count || l_ptr->blocked; 320 return l_ptr->exp_msg_count || l_ptr->blocked;
308} 321}
309 322
310static inline int link_congested(struct link *l_ptr) 323static inline int link_congested(struct tipc_link *l_ptr)
311{ 324{
312 return l_ptr->out_queue_size >= l_ptr->queue_limit[0]; 325 return l_ptr->out_queue_size >= l_ptr->queue_limit[0];
313} 326}
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 83d50967910c..3e4d3e29be61 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -333,11 +333,14 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
333 } 333 }
334 334
335 if (msg_user(msg) == LINK_CONFIG) { 335 if (msg_user(msg) == LINK_CONFIG) {
336 u32 *raw = (u32 *)msg; 336 struct tipc_media_addr orig;
337 struct tipc_media_addr *orig = (struct tipc_media_addr *)&raw[5]; 337
338 tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg)); 338 tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg));
339 tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg)); 339 tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg));
340 tipc_media_addr_printf(buf, orig); 340 memcpy(orig.value, msg_media_addr(msg), sizeof(orig.value));
341 orig.media_id = 0;
342 orig.broadcast = 0;
343 tipc_media_addr_printf(buf, &orig);
341 } 344 }
342 if (msg_user(msg) == BCAST_PROTOCOL) { 345 if (msg_user(msg) == BCAST_PROTOCOL) {
343 tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg)); 346 tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg));
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index d93178f2e852..7b0cda167107 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -78,6 +78,8 @@
78 78
79#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) 79#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
80 80
81#define TIPC_MEDIA_ADDR_OFFSET 5
82
81 83
82struct tipc_msg { 84struct tipc_msg {
83 __be32 hdr[15]; 85 __be32 hdr[15];
@@ -682,6 +684,10 @@ static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r)
682 msg_set_bits(m, 5, 12, 0x1, r); 684 msg_set_bits(m, 5, 12, 0x1, r);
683} 685}
684 686
687static inline char *msg_media_addr(struct tipc_msg *m)
688{
689 return (char *)&m->hdr[TIPC_MEDIA_ADDR_OFFSET];
690}
685 691
686/* 692/*
687 * Word 9 693 * Word 9
@@ -734,14 +740,4 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
734 u32 num_sect, unsigned int total_len, 740 u32 num_sect, unsigned int total_len,
735 int max_size, int usrmem, struct sk_buff **buf); 741 int max_size, int usrmem, struct sk_buff **buf);
736 742
737static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
738{
739 memcpy(&((int *)m)[5], a, sizeof(*a));
740}
741
742static inline void msg_get_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
743{
744 memcpy(a, &((int *)m)[5], sizeof(*a));
745}
746
747#endif 743#endif
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index b7ca1bd7b151..98ebb37f1808 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -176,7 +176,7 @@ void tipc_named_withdraw(struct publication *publ)
176void tipc_named_node_up(unsigned long nodearg) 176void tipc_named_node_up(unsigned long nodearg)
177{ 177{
178 struct tipc_node *n_ptr; 178 struct tipc_node *n_ptr;
179 struct link *l_ptr; 179 struct tipc_link *l_ptr;
180 struct publication *publ; 180 struct publication *publ;
181 struct distr_item *item = NULL; 181 struct distr_item *item = NULL;
182 struct sk_buff *buf = NULL; 182 struct sk_buff *buf = NULL;
@@ -322,10 +322,9 @@ void tipc_named_recv(struct sk_buff *buf)
322/** 322/**
323 * tipc_named_reinit - re-initialize local publication list 323 * tipc_named_reinit - re-initialize local publication list
324 * 324 *
325 * This routine is called whenever TIPC networking is (re)enabled. 325 * This routine is called whenever TIPC networking is enabled.
326 * All existing publications by this node that have "cluster" or "zone" scope 326 * All existing publications by this node that have "cluster" or "zone" scope
327 * are updated to reflect the node's current network address. 327 * are updated to reflect the node's new network address.
328 * (If the node's address is unchanged, the update loop terminates immediately.)
329 */ 328 */
330 329
331void tipc_named_reinit(void) 330void tipc_named_reinit(void)
@@ -333,10 +332,9 @@ void tipc_named_reinit(void)
333 struct publication *publ; 332 struct publication *publ;
334 333
335 write_lock_bh(&tipc_nametbl_lock); 334 write_lock_bh(&tipc_nametbl_lock);
336 list_for_each_entry(publ, &publ_root, local_list) { 335
337 if (publ->node == tipc_own_addr) 336 list_for_each_entry(publ, &publ_root, local_list)
338 break;
339 publ->node = tipc_own_addr; 337 publ->node = tipc_own_addr;
340 } 338
341 write_unlock_bh(&tipc_nametbl_lock); 339 write_unlock_bh(&tipc_nametbl_lock);
342} 340}
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 46e6b6c2ecc9..89eb5621ebba 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -251,8 +251,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
251 u32 type, u32 lower, u32 upper, 251 u32 type, u32 lower, u32 upper,
252 u32 scope, u32 node, u32 port, u32 key) 252 u32 scope, u32 node, u32 port, u32 key)
253{ 253{
254 struct subscription *s; 254 struct tipc_subscription *s;
255 struct subscription *st; 255 struct tipc_subscription *st;
256 struct publication *publ; 256 struct publication *publ;
257 struct sub_seq *sseq; 257 struct sub_seq *sseq;
258 struct name_info *info; 258 struct name_info *info;
@@ -381,7 +381,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
381 struct sub_seq *sseq = nameseq_find_subseq(nseq, inst); 381 struct sub_seq *sseq = nameseq_find_subseq(nseq, inst);
382 struct name_info *info; 382 struct name_info *info;
383 struct sub_seq *free; 383 struct sub_seq *free;
384 struct subscription *s, *st; 384 struct tipc_subscription *s, *st;
385 int removed_subseq = 0; 385 int removed_subseq = 0;
386 386
387 if (!sseq) 387 if (!sseq)
@@ -448,7 +448,8 @@ found:
448 * sequence overlapping with the requested sequence 448 * sequence overlapping with the requested sequence
449 */ 449 */
450 450
451static void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s) 451static void tipc_nameseq_subscribe(struct name_seq *nseq,
452 struct tipc_subscription *s)
452{ 453{
453 struct sub_seq *sseq = nseq->sseqs; 454 struct sub_seq *sseq = nseq->sseqs;
454 455
@@ -625,7 +626,7 @@ not_found:
625 */ 626 */
626 627
627int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, 628int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
628 struct port_list *dports) 629 struct tipc_port_list *dports)
629{ 630{
630 struct name_seq *seq; 631 struct name_seq *seq;
631 struct sub_seq *sseq; 632 struct sub_seq *sseq;
@@ -739,7 +740,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
739 * tipc_nametbl_subscribe - add a subscription object to the name table 740 * tipc_nametbl_subscribe - add a subscription object to the name table
740 */ 741 */
741 742
742void tipc_nametbl_subscribe(struct subscription *s) 743void tipc_nametbl_subscribe(struct tipc_subscription *s)
743{ 744{
744 u32 type = s->seq.type; 745 u32 type = s->seq.type;
745 struct name_seq *seq; 746 struct name_seq *seq;
@@ -763,7 +764,7 @@ void tipc_nametbl_subscribe(struct subscription *s)
763 * tipc_nametbl_unsubscribe - remove a subscription object from name table 764 * tipc_nametbl_unsubscribe - remove a subscription object from name table
764 */ 765 */
765 766
766void tipc_nametbl_unsubscribe(struct subscription *s) 767void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
767{ 768{
768 struct name_seq *seq; 769 struct name_seq *seq;
769 770
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index 62d77e5e902e..8086b42f92ad 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -39,8 +39,8 @@
39 39
40#include "node_subscr.h" 40#include "node_subscr.h"
41 41
42struct subscription; 42struct tipc_subscription;
43struct port_list; 43struct tipc_port_list;
44 44
45/* 45/*
46 * TIPC name types reserved for internal TIPC use (both current and planned) 46 * TIPC name types reserved for internal TIPC use (both current and planned)
@@ -90,7 +90,7 @@ extern rwlock_t tipc_nametbl_lock;
90struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); 90struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space);
91u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); 91u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node);
92int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, 92int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
93 struct port_list *dports); 93 struct tipc_port_list *dports);
94int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, 94int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
95 struct tipc_name_seq const *seq); 95 struct tipc_name_seq const *seq);
96struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, 96struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
@@ -100,8 +100,8 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
100 u32 scope, u32 node, u32 ref, u32 key); 100 u32 scope, u32 node, u32 ref, u32 key);
101struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, 101struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
102 u32 node, u32 ref, u32 key); 102 u32 node, u32 ref, u32 key);
103void tipc_nametbl_subscribe(struct subscription *s); 103void tipc_nametbl_subscribe(struct tipc_subscription *s);
104void tipc_nametbl_unsubscribe(struct subscription *s); 104void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
105int tipc_nametbl_init(void); 105int tipc_nametbl_init(void);
106void tipc_nametbl_stop(void); 106void tipc_nametbl_stop(void);
107 107
diff --git a/net/tipc/net.c b/net/tipc/net.c
index fafef6c3c0f6..61afee7e8291 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -174,7 +174,6 @@ void tipc_net_route_msg(struct sk_buff *buf)
174int tipc_net_start(u32 addr) 174int tipc_net_start(u32 addr)
175{ 175{
176 char addr_string[16]; 176 char addr_string[16];
177 int res;
178 177
179 if (tipc_mode != TIPC_NODE_MODE) 178 if (tipc_mode != TIPC_NODE_MODE)
180 return -ENOPROTOOPT; 179 return -ENOPROTOOPT;
@@ -187,9 +186,7 @@ int tipc_net_start(u32 addr)
187 tipc_named_reinit(); 186 tipc_named_reinit();
188 tipc_port_reinit(); 187 tipc_port_reinit();
189 188
190 res = tipc_bclink_init(); 189 tipc_bclink_init();
191 if (res)
192 return res;
193 190
194 tipc_k_signal((Handler)tipc_subscr_start, 0); 191 tipc_k_signal((Handler)tipc_subscr_start, 0);
195 tipc_k_signal((Handler)tipc_cfg_init, 0); 192 tipc_k_signal((Handler)tipc_cfg_init, 0);
@@ -207,8 +204,8 @@ void tipc_net_stop(void)
207 if (tipc_mode != TIPC_NET_MODE) 204 if (tipc_mode != TIPC_NET_MODE)
208 return; 205 return;
209 write_lock_bh(&tipc_net_lock); 206 write_lock_bh(&tipc_net_lock);
210 tipc_bearer_stop();
211 tipc_mode = TIPC_NODE_MODE; 207 tipc_mode = TIPC_NODE_MODE;
208 tipc_bearer_stop();
212 tipc_bclink_stop(); 209 tipc_bclink_stop();
213 list_for_each_entry_safe(node, t_node, &tipc_node_list, list) 210 list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
214 tipc_node_delete(node); 211 tipc_node_delete(node);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 27b4bb0cca6c..6b226faad89f 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -136,9 +136,9 @@ void tipc_node_delete(struct tipc_node *n_ptr)
136 * Link becomes active (alone or shared) or standby, depending on its priority. 136 * Link becomes active (alone or shared) or standby, depending on its priority.
137 */ 137 */
138 138
139void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr) 139void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
140{ 140{
141 struct link **active = &n_ptr->active_links[0]; 141 struct tipc_link **active = &n_ptr->active_links[0];
142 142
143 n_ptr->working_links++; 143 n_ptr->working_links++;
144 144
@@ -171,14 +171,14 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr)
171 171
172static void node_select_active_links(struct tipc_node *n_ptr) 172static void node_select_active_links(struct tipc_node *n_ptr)
173{ 173{
174 struct link **active = &n_ptr->active_links[0]; 174 struct tipc_link **active = &n_ptr->active_links[0];
175 u32 i; 175 u32 i;
176 u32 highest_prio = 0; 176 u32 highest_prio = 0;
177 177
178 active[0] = active[1] = NULL; 178 active[0] = active[1] = NULL;
179 179
180 for (i = 0; i < MAX_BEARERS; i++) { 180 for (i = 0; i < MAX_BEARERS; i++) {
181 struct link *l_ptr = n_ptr->links[i]; 181 struct tipc_link *l_ptr = n_ptr->links[i];
182 182
183 if (!l_ptr || !tipc_link_is_up(l_ptr) || 183 if (!l_ptr || !tipc_link_is_up(l_ptr) ||
184 (l_ptr->priority < highest_prio)) 184 (l_ptr->priority < highest_prio))
@@ -197,9 +197,9 @@ static void node_select_active_links(struct tipc_node *n_ptr)
197 * tipc_node_link_down - handle loss of link 197 * tipc_node_link_down - handle loss of link
198 */ 198 */
199 199
200void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr) 200void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
201{ 201{
202 struct link **active; 202 struct tipc_link **active;
203 203
204 n_ptr->working_links--; 204 n_ptr->working_links--;
205 205
@@ -239,14 +239,14 @@ int tipc_node_is_up(struct tipc_node *n_ptr)
239 return tipc_node_active_links(n_ptr); 239 return tipc_node_active_links(n_ptr);
240} 240}
241 241
242void tipc_node_attach_link(struct tipc_node *n_ptr, struct link *l_ptr) 242void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
243{ 243{
244 n_ptr->links[l_ptr->b_ptr->identity] = l_ptr; 244 n_ptr->links[l_ptr->b_ptr->identity] = l_ptr;
245 atomic_inc(&tipc_num_links); 245 atomic_inc(&tipc_num_links);
246 n_ptr->link_cnt++; 246 n_ptr->link_cnt++;
247} 247}
248 248
249void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) 249void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
250{ 250{
251 n_ptr->links[l_ptr->b_ptr->identity] = NULL; 251 n_ptr->links[l_ptr->b_ptr->identity] = NULL;
252 atomic_dec(&tipc_num_links); 252 atomic_dec(&tipc_num_links);
@@ -307,7 +307,7 @@ static void node_established_contact(struct tipc_node *n_ptr)
307 n_ptr->bclink.acked = tipc_bclink_get_last_sent(); 307 n_ptr->bclink.acked = tipc_bclink_get_last_sent();
308 308
309 if (n_ptr->bclink.supported) { 309 if (n_ptr->bclink.supported) {
310 tipc_nmap_add(&tipc_bcast_nmap, n_ptr->addr); 310 tipc_bclink_add_node(n_ptr->addr);
311 if (n_ptr->addr < tipc_own_addr) 311 if (n_ptr->addr < tipc_own_addr)
312 tipc_own_tag++; 312 tipc_own_tag++;
313 } 313 }
@@ -350,9 +350,8 @@ static void node_lost_contact(struct tipc_node *n_ptr)
350 n_ptr->bclink.defragm = NULL; 350 n_ptr->bclink.defragm = NULL;
351 } 351 }
352 352
353 tipc_nmap_remove(&tipc_bcast_nmap, n_ptr->addr); 353 tipc_bclink_remove_node(n_ptr->addr);
354 tipc_bclink_acknowledge(n_ptr, 354 tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ);
355 mod(n_ptr->bclink.acked + 10000));
356 if (n_ptr->addr < tipc_own_addr) 355 if (n_ptr->addr < tipc_own_addr)
357 tipc_own_tag--; 356 tipc_own_tag--;
358 357
@@ -361,7 +360,7 @@ static void node_lost_contact(struct tipc_node *n_ptr)
361 360
362 /* Abort link changeover */ 361 /* Abort link changeover */
363 for (i = 0; i < MAX_BEARERS; i++) { 362 for (i = 0; i < MAX_BEARERS; i++) {
364 struct link *l_ptr = n_ptr->links[i]; 363 struct tipc_link *l_ptr = n_ptr->links[i];
365 if (!l_ptr) 364 if (!l_ptr)
366 continue; 365 continue;
367 l_ptr->reset_checkpoint = l_ptr->next_in_no; 366 l_ptr->reset_checkpoint = l_ptr->next_in_no;
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 4f15cb40aaa4..0b1c5f8b6996 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -79,8 +79,8 @@ struct tipc_node {
79 struct hlist_node hash; 79 struct hlist_node hash;
80 struct list_head list; 80 struct list_head list;
81 struct list_head nsub; 81 struct list_head nsub;
82 struct link *active_links[2]; 82 struct tipc_link *active_links[2];
83 struct link *links[MAX_BEARERS]; 83 struct tipc_link *links[MAX_BEARERS];
84 int link_cnt; 84 int link_cnt;
85 int working_links; 85 int working_links;
86 int block_setup; 86 int block_setup;
@@ -117,10 +117,10 @@ extern u32 tipc_own_tag;
117struct tipc_node *tipc_node_find(u32 addr); 117struct tipc_node *tipc_node_find(u32 addr);
118struct tipc_node *tipc_node_create(u32 addr); 118struct tipc_node *tipc_node_create(u32 addr);
119void tipc_node_delete(struct tipc_node *n_ptr); 119void tipc_node_delete(struct tipc_node *n_ptr);
120void tipc_node_attach_link(struct tipc_node *n_ptr, struct link *l_ptr); 120void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
121void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr); 121void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
122void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr); 122void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
123void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr); 123void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
124int tipc_node_active_links(struct tipc_node *n_ptr); 124int tipc_node_active_links(struct tipc_node *n_ptr);
125int tipc_node_redundant_links(struct tipc_node *n_ptr); 125int tipc_node_redundant_links(struct tipc_node *n_ptr);
126int tipc_node_is_up(struct tipc_node *n_ptr); 126int tipc_node_is_up(struct tipc_node *n_ptr);
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 54d812a5a4d9..d91efc69e6f9 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -80,7 +80,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
80 struct tipc_msg *hdr; 80 struct tipc_msg *hdr;
81 struct sk_buff *buf; 81 struct sk_buff *buf;
82 struct sk_buff *ibuf = NULL; 82 struct sk_buff *ibuf = NULL;
83 struct port_list dports = {0, NULL, }; 83 struct tipc_port_list dports = {0, NULL, };
84 struct tipc_port *oport = tipc_port_deref(ref); 84 struct tipc_port *oport = tipc_port_deref(ref);
85 int ext_targets; 85 int ext_targets;
86 int res; 86 int res;
@@ -142,11 +142,11 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
142 * If there is no port list, perform a lookup to create one 142 * If there is no port list, perform a lookup to create one
143 */ 143 */
144 144
145void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) 145void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
146{ 146{
147 struct tipc_msg *msg; 147 struct tipc_msg *msg;
148 struct port_list dports = {0, NULL, }; 148 struct tipc_port_list dports = {0, NULL, };
149 struct port_list *item = dp; 149 struct tipc_port_list *item = dp;
150 int cnt = 0; 150 int cnt = 0;
151 151
152 msg = buf_msg(buf); 152 msg = buf_msg(buf);
diff --git a/net/tipc/port.h b/net/tipc/port.h
index b9aa34195aec..f751807e2a91 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -151,7 +151,7 @@ struct tipc_port {
151}; 151};
152 152
153extern spinlock_t tipc_port_list_lock; 153extern spinlock_t tipc_port_list_lock;
154struct port_list; 154struct tipc_port_list;
155 155
156/* 156/*
157 * TIPC port manipulation routines 157 * TIPC port manipulation routines
@@ -228,7 +228,7 @@ int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
228 unsigned int total_len, int err); 228 unsigned int total_len, int err);
229struct sk_buff *tipc_port_get_ports(void); 229struct sk_buff *tipc_port_get_ports(void);
230void tipc_port_recv_proto_msg(struct sk_buff *buf); 230void tipc_port_recv_proto_msg(struct sk_buff *buf);
231void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp); 231void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp);
232void tipc_port_reinit(void); 232void tipc_port_reinit(void);
233 233
234/** 234/**
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index 83116892528b..9e37b7812c3c 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -110,8 +110,7 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
110 110
111 /* allocate table & mark all entries as uninitialized */ 111 /* allocate table & mark all entries as uninitialized */
112 112
113 table = __vmalloc(actual_size * sizeof(struct reference), 113 table = vzalloc(actual_size * sizeof(struct reference));
114 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
115 if (table == NULL) 114 if (table == NULL)
116 return -ENOMEM; 115 return -ENOMEM;
117 116
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 42b8324ff2ee..e2f7c5d370ba 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -185,9 +185,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
185 185
186 /* Validate arguments */ 186 /* Validate arguments */
187 187
188 if (!net_eq(net, &init_net))
189 return -EAFNOSUPPORT;
190
191 if (unlikely(protocol != 0)) 188 if (unlikely(protocol != 0))
192 return -EPROTONOSUPPORT; 189 return -EPROTONOSUPPORT;
193 190
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 198371723b41..8c49566da8f3 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -40,14 +40,14 @@
40#include "subscr.h" 40#include "subscr.h"
41 41
42/** 42/**
43 * struct subscriber - TIPC network topology subscriber 43 * struct tipc_subscriber - TIPC network topology subscriber
44 * @port_ref: object reference to server port connecting to subscriber 44 * @port_ref: object reference to server port connecting to subscriber
45 * @lock: pointer to spinlock controlling access to subscriber's server port 45 * @lock: pointer to spinlock controlling access to subscriber's server port
46 * @subscriber_list: adjacent subscribers in top. server's list of subscribers 46 * @subscriber_list: adjacent subscribers in top. server's list of subscribers
47 * @subscription_list: list of subscription objects for this subscriber 47 * @subscription_list: list of subscription objects for this subscriber
48 */ 48 */
49 49
50struct subscriber { 50struct tipc_subscriber {
51 u32 port_ref; 51 u32 port_ref;
52 spinlock_t *lock; 52 spinlock_t *lock;
53 struct list_head subscriber_list; 53 struct list_head subscriber_list;
@@ -92,7 +92,7 @@ static u32 htohl(u32 in, int swap)
92 * try to take the lock if the message is rejected and returned! 92 * try to take the lock if the message is rejected and returned!
93 */ 93 */
94 94
95static void subscr_send_event(struct subscription *sub, 95static void subscr_send_event(struct tipc_subscription *sub,
96 u32 found_lower, 96 u32 found_lower,
97 u32 found_upper, 97 u32 found_upper,
98 u32 event, 98 u32 event,
@@ -118,7 +118,7 @@ static void subscr_send_event(struct subscription *sub,
118 * Returns 1 if there is overlap, otherwise 0. 118 * Returns 1 if there is overlap, otherwise 0.
119 */ 119 */
120 120
121int tipc_subscr_overlap(struct subscription *sub, 121int tipc_subscr_overlap(struct tipc_subscription *sub,
122 u32 found_lower, 122 u32 found_lower,
123 u32 found_upper) 123 u32 found_upper)
124 124
@@ -138,7 +138,7 @@ int tipc_subscr_overlap(struct subscription *sub,
138 * Protected by nameseq.lock in name_table.c 138 * Protected by nameseq.lock in name_table.c
139 */ 139 */
140 140
141void tipc_subscr_report_overlap(struct subscription *sub, 141void tipc_subscr_report_overlap(struct tipc_subscription *sub,
142 u32 found_lower, 142 u32 found_lower,
143 u32 found_upper, 143 u32 found_upper,
144 u32 event, 144 u32 event,
@@ -158,7 +158,7 @@ void tipc_subscr_report_overlap(struct subscription *sub,
158 * subscr_timeout - subscription timeout has occurred 158 * subscr_timeout - subscription timeout has occurred
159 */ 159 */
160 160
161static void subscr_timeout(struct subscription *sub) 161static void subscr_timeout(struct tipc_subscription *sub)
162{ 162{
163 struct tipc_port *server_port; 163 struct tipc_port *server_port;
164 164
@@ -205,7 +205,7 @@ static void subscr_timeout(struct subscription *sub)
205 * Called with subscriber port locked. 205 * Called with subscriber port locked.
206 */ 206 */
207 207
208static void subscr_del(struct subscription *sub) 208static void subscr_del(struct tipc_subscription *sub)
209{ 209{
210 tipc_nametbl_unsubscribe(sub); 210 tipc_nametbl_unsubscribe(sub);
211 list_del(&sub->subscription_list); 211 list_del(&sub->subscription_list);
@@ -224,11 +224,11 @@ static void subscr_del(struct subscription *sub)
224 * simply wait for it to be released, then claim it.) 224 * simply wait for it to be released, then claim it.)
225 */ 225 */
226 226
227static void subscr_terminate(struct subscriber *subscriber) 227static void subscr_terminate(struct tipc_subscriber *subscriber)
228{ 228{
229 u32 port_ref; 229 u32 port_ref;
230 struct subscription *sub; 230 struct tipc_subscription *sub;
231 struct subscription *sub_temp; 231 struct tipc_subscription *sub_temp;
232 232
233 /* Invalidate subscriber reference */ 233 /* Invalidate subscriber reference */
234 234
@@ -278,10 +278,10 @@ static void subscr_terminate(struct subscriber *subscriber)
278 */ 278 */
279 279
280static void subscr_cancel(struct tipc_subscr *s, 280static void subscr_cancel(struct tipc_subscr *s,
281 struct subscriber *subscriber) 281 struct tipc_subscriber *subscriber)
282{ 282{
283 struct subscription *sub; 283 struct tipc_subscription *sub;
284 struct subscription *sub_temp; 284 struct tipc_subscription *sub_temp;
285 int found = 0; 285 int found = 0;
286 286
287 /* Find first matching subscription, exit if not found */ 287 /* Find first matching subscription, exit if not found */
@@ -314,10 +314,10 @@ static void subscr_cancel(struct tipc_subscr *s,
314 * Called with subscriber port locked. 314 * Called with subscriber port locked.
315 */ 315 */
316 316
317static struct subscription *subscr_subscribe(struct tipc_subscr *s, 317static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
318 struct subscriber *subscriber) 318 struct tipc_subscriber *subscriber)
319{ 319{
320 struct subscription *sub; 320 struct tipc_subscription *sub;
321 int swap; 321 int swap;
322 322
323 /* Determine subscriber's endianness */ 323 /* Determine subscriber's endianness */
@@ -393,7 +393,7 @@ static void subscr_conn_shutdown_event(void *usr_handle,
393 unsigned int size, 393 unsigned int size,
394 int reason) 394 int reason)
395{ 395{
396 struct subscriber *subscriber = usr_handle; 396 struct tipc_subscriber *subscriber = usr_handle;
397 spinlock_t *subscriber_lock; 397 spinlock_t *subscriber_lock;
398 398
399 if (tipc_port_lock(port_ref) == NULL) 399 if (tipc_port_lock(port_ref) == NULL)
@@ -416,9 +416,9 @@ static void subscr_conn_msg_event(void *usr_handle,
416 const unchar *data, 416 const unchar *data,
417 u32 size) 417 u32 size)
418{ 418{
419 struct subscriber *subscriber = usr_handle; 419 struct tipc_subscriber *subscriber = usr_handle;
420 spinlock_t *subscriber_lock; 420 spinlock_t *subscriber_lock;
421 struct subscription *sub; 421 struct tipc_subscription *sub;
422 422
423 /* 423 /*
424 * Lock subscriber's server port (& make a local copy of lock pointer, 424 * Lock subscriber's server port (& make a local copy of lock pointer,
@@ -471,12 +471,12 @@ static void subscr_named_msg_event(void *usr_handle,
471 struct tipc_portid const *orig, 471 struct tipc_portid const *orig,
472 struct tipc_name_seq const *dest) 472 struct tipc_name_seq const *dest)
473{ 473{
474 struct subscriber *subscriber; 474 struct tipc_subscriber *subscriber;
475 u32 server_port_ref; 475 u32 server_port_ref;
476 476
477 /* Create subscriber object */ 477 /* Create subscriber object */
478 478
479 subscriber = kzalloc(sizeof(struct subscriber), GFP_ATOMIC); 479 subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC);
480 if (subscriber == NULL) { 480 if (subscriber == NULL) {
481 warn("Subscriber rejected, no memory\n"); 481 warn("Subscriber rejected, no memory\n");
482 return; 482 return;
@@ -568,8 +568,8 @@ failed:
568 568
569void tipc_subscr_stop(void) 569void tipc_subscr_stop(void)
570{ 570{
571 struct subscriber *subscriber; 571 struct tipc_subscriber *subscriber;
572 struct subscriber *subscriber_temp; 572 struct tipc_subscriber *subscriber_temp;
573 spinlock_t *subscriber_lock; 573 spinlock_t *subscriber_lock;
574 574
575 if (topsrv.setup_port) { 575 if (topsrv.setup_port) {
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index 4b06ef6f8401..ef6529c8456f 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -37,10 +37,10 @@
37#ifndef _TIPC_SUBSCR_H 37#ifndef _TIPC_SUBSCR_H
38#define _TIPC_SUBSCR_H 38#define _TIPC_SUBSCR_H
39 39
40struct subscription; 40struct tipc_subscription;
41 41
42/** 42/**
43 * struct subscription - TIPC network topology subscription object 43 * struct tipc_subscription - TIPC network topology subscription object
44 * @seq: name sequence associated with subscription 44 * @seq: name sequence associated with subscription
45 * @timeout: duration of subscription (in ms) 45 * @timeout: duration of subscription (in ms)
46 * @filter: event filtering to be done for subscription 46 * @filter: event filtering to be done for subscription
@@ -52,7 +52,7 @@ struct subscription;
52 * @evt: template for events generated by subscription 52 * @evt: template for events generated by subscription
53 */ 53 */
54 54
55struct subscription { 55struct tipc_subscription {
56 struct tipc_name_seq seq; 56 struct tipc_name_seq seq;
57 u32 timeout; 57 u32 timeout;
58 u32 filter; 58 u32 filter;
@@ -64,11 +64,11 @@ struct subscription {
64 struct tipc_event evt; 64 struct tipc_event evt;
65}; 65};
66 66
67int tipc_subscr_overlap(struct subscription *sub, 67int tipc_subscr_overlap(struct tipc_subscription *sub,
68 u32 found_lower, 68 u32 found_lower,
69 u32 found_upper); 69 u32 found_upper);
70 70
71void tipc_subscr_report_overlap(struct subscription *sub, 71void tipc_subscr_report_overlap(struct tipc_subscription *sub,
72 u32 found_lower, 72 u32 found_lower,
73 u32 found_upper, 73 u32 found_upper,
74 u32 event, 74 u32 event,