aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/addr.c32
-rw-r--r--net/tipc/addr.h37
-rw-r--r--net/tipc/bcast.c114
-rw-r--r--net/tipc/bcast.h117
-rw-r--r--net/tipc/bearer.c16
-rw-r--r--net/tipc/bearer.h16
-rw-r--r--net/tipc/cluster.c2
-rw-r--r--net/tipc/config.c68
-rw-r--r--net/tipc/core.c26
-rw-r--r--net/tipc/core.h27
-rw-r--r--net/tipc/discover.c8
-rw-r--r--net/tipc/link.c83
-rw-r--r--net/tipc/link.h35
-rw-r--r--net/tipc/msg.c94
-rw-r--r--net/tipc/msg.h99
-rw-r--r--net/tipc/name_distr.c2
-rw-r--r--net/tipc/name_table.c2
-rw-r--r--net/tipc/net.c4
-rw-r--r--net/tipc/node.c12
-rw-r--r--net/tipc/port.c27
-rw-r--r--net/tipc/port.h2
21 files changed, 436 insertions, 387 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c
index e5207a11edf6..c048543ffbeb 100644
--- a/net/tipc/addr.c
+++ b/net/tipc/addr.c
@@ -92,3 +92,35 @@ int tipc_addr_node_valid(u32 addr)
92 return (tipc_addr_domain_valid(addr) && tipc_node(addr)); 92 return (tipc_addr_domain_valid(addr) && tipc_node(addr));
93} 93}
94 94
95int tipc_in_scope(u32 domain, u32 addr)
96{
97 if (!domain || (domain == addr))
98 return 1;
99 if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */
100 return 1;
101 if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */
102 return 1;
103 return 0;
104}
105
106/**
107 * tipc_addr_scope - convert message lookup domain to a 2-bit scope value
108 */
109
110int tipc_addr_scope(u32 domain)
111{
112 if (likely(!domain))
113 return TIPC_ZONE_SCOPE;
114 if (tipc_node(domain))
115 return TIPC_NODE_SCOPE;
116 if (tipc_cluster(domain))
117 return TIPC_CLUSTER_SCOPE;
118 return TIPC_ZONE_SCOPE;
119}
120
121char *tipc_addr_string_fill(char *string, u32 addr)
122{
123 snprintf(string, 16, "<%u.%u.%u>",
124 tipc_zone(addr), tipc_cluster(addr), tipc_node(addr));
125 return string;
126}
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index 3ba67e6ce03e..c1cc5724d8cc 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -67,32 +67,6 @@ static inline int may_route(u32 addr)
67 return(addr ^ tipc_own_addr) >> 11; 67 return(addr ^ tipc_own_addr) >> 11;
68} 68}
69 69
70static inline int in_scope(u32 domain, u32 addr)
71{
72 if (!domain || (domain == addr))
73 return 1;
74 if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */
75 return 1;
76 if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */
77 return 1;
78 return 0;
79}
80
81/**
82 * addr_scope - convert message lookup domain to equivalent 2-bit scope value
83 */
84
85static inline int addr_scope(u32 domain)
86{
87 if (likely(!domain))
88 return TIPC_ZONE_SCOPE;
89 if (tipc_node(domain))
90 return TIPC_NODE_SCOPE;
91 if (tipc_cluster(domain))
92 return TIPC_CLUSTER_SCOPE;
93 return TIPC_ZONE_SCOPE;
94}
95
96/** 70/**
97 * addr_domain - convert 2-bit scope value to equivalent message lookup domain 71 * addr_domain - convert 2-bit scope value to equivalent message lookup domain
98 * 72 *
@@ -110,14 +84,9 @@ static inline int addr_domain(int sc)
110 return tipc_addr(tipc_zone(tipc_own_addr), 0, 0); 84 return tipc_addr(tipc_zone(tipc_own_addr), 0, 0);
111} 85}
112 86
113static inline char *addr_string_fill(char *string, u32 addr)
114{
115 snprintf(string, 16, "<%u.%u.%u>",
116 tipc_zone(addr), tipc_cluster(addr), tipc_node(addr));
117 return string;
118}
119
120int tipc_addr_domain_valid(u32); 87int tipc_addr_domain_valid(u32);
121int tipc_addr_node_valid(u32 addr); 88int tipc_addr_node_valid(u32 addr);
122 89int tipc_in_scope(u32 domain, u32 addr);
90int tipc_addr_scope(u32 domain);
91char *tipc_addr_string_fill(char *string, u32 addr);
123#endif 92#endif
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 90a051912c03..a008c6689305 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -119,7 +119,7 @@ static struct bclink *bclink = NULL;
119static struct link *bcl = NULL; 119static struct link *bcl = NULL;
120static DEFINE_SPINLOCK(bc_lock); 120static DEFINE_SPINLOCK(bc_lock);
121 121
122const char tipc_bclink_name[] = "multicast-link"; 122const char tipc_bclink_name[] = "broadcast-link";
123 123
124 124
125static u32 buf_seqno(struct sk_buff *buf) 125static u32 buf_seqno(struct sk_buff *buf)
@@ -275,7 +275,7 @@ static void bclink_send_nack(struct tipc_node *n_ptr)
275 buf = buf_acquire(INT_H_SIZE); 275 buf = buf_acquire(INT_H_SIZE);
276 if (buf) { 276 if (buf) {
277 msg = buf_msg(buf); 277 msg = buf_msg(buf);
278 msg_init(msg, BCAST_PROTOCOL, STATE_MSG, 278 tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
279 INT_H_SIZE, n_ptr->addr); 279 INT_H_SIZE, n_ptr->addr);
280 msg_set_mc_netid(msg, tipc_net_id); 280 msg_set_mc_netid(msg, tipc_net_id);
281 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); 281 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in));
@@ -822,3 +822,113 @@ void tipc_bclink_stop(void)
822 spin_unlock_bh(&bc_lock); 822 spin_unlock_bh(&bc_lock);
823} 823}
824 824
825
826/**
827 * tipc_nmap_add - add a node to a node map
828 */
829
830void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node)
831{
832 int n = tipc_node(node);
833 int w = n / WSIZE;
834 u32 mask = (1 << (n % WSIZE));
835
836 if ((nm_ptr->map[w] & mask) == 0) {
837 nm_ptr->count++;
838 nm_ptr->map[w] |= mask;
839 }
840}
841
842/**
843 * tipc_nmap_remove - remove a node from a node map
844 */
845
846void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node)
847{
848 int n = tipc_node(node);
849 int w = n / WSIZE;
850 u32 mask = (1 << (n % WSIZE));
851
852 if ((nm_ptr->map[w] & mask) != 0) {
853 nm_ptr->map[w] &= ~mask;
854 nm_ptr->count--;
855 }
856}
857
858/**
859 * tipc_nmap_diff - find differences between node maps
860 * @nm_a: input node map A
861 * @nm_b: input node map B
862 * @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
863 */
864
865void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b,
866 struct tipc_node_map *nm_diff)
867{
868 int stop = ARRAY_SIZE(nm_a->map);
869 int w;
870 int b;
871 u32 map;
872
873 memset(nm_diff, 0, sizeof(*nm_diff));
874 for (w = 0; w < stop; w++) {
875 map = nm_a->map[w] ^ (nm_a->map[w] & nm_b->map[w]);
876 nm_diff->map[w] = map;
877 if (map != 0) {
878 for (b = 0 ; b < WSIZE; b++) {
879 if (map & (1 << b))
880 nm_diff->count++;
881 }
882 }
883 }
884}
885
886/**
887 * tipc_port_list_add - add a port to a port list, ensuring no duplicates
888 */
889
890void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
891{
892 struct port_list *item = pl_ptr;
893 int i;
894 int item_sz = PLSIZE;
895 int cnt = pl_ptr->count;
896
897 for (; ; cnt -= item_sz, item = item->next) {
898 if (cnt < PLSIZE)
899 item_sz = cnt;
900 for (i = 0; i < item_sz; i++)
901 if (item->ports[i] == port)
902 return;
903 if (i < PLSIZE) {
904 item->ports[i] = port;
905 pl_ptr->count++;
906 return;
907 }
908 if (!item->next) {
909 item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
910 if (!item->next) {
911 warn("Incomplete multicast delivery, no memory\n");
912 return;
913 }
914 item->next->next = NULL;
915 }
916 }
917}
918
919/**
920 * tipc_port_list_free - free dynamically created entries in port_list chain
921 *
922 */
923
924void tipc_port_list_free(struct port_list *pl_ptr)
925{
926 struct port_list *item;
927 struct port_list *next;
928
929 for (item = pl_ptr->next; item; item = next) {
930 next = item->next;
931 kfree(item);
932 }
933}
934
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index 4c1771e95c99..e8c2b81658c7 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -72,41 +72,11 @@ struct tipc_node;
72 72
73extern const char tipc_bclink_name[]; 73extern const char tipc_bclink_name[];
74 74
75void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node);
76void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node);
75 77
76/** 78/**
77 * nmap_add - add a node to a node map 79 * tipc_nmap_equal - test for equality of node maps
78 */
79
80static inline void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node)
81{
82 int n = tipc_node(node);
83 int w = n / WSIZE;
84 u32 mask = (1 << (n % WSIZE));
85
86 if ((nm_ptr->map[w] & mask) == 0) {
87 nm_ptr->count++;
88 nm_ptr->map[w] |= mask;
89 }
90}
91
92/**
93 * nmap_remove - remove a node from a node map
94 */
95
96static inline void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node)
97{
98 int n = tipc_node(node);
99 int w = n / WSIZE;
100 u32 mask = (1 << (n % WSIZE));
101
102 if ((nm_ptr->map[w] & mask) != 0) {
103 nm_ptr->map[w] &= ~mask;
104 nm_ptr->count--;
105 }
106}
107
108/**
109 * nmap_equal - test for equality of node maps
110 */ 80 */
111 81
112static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) 82static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b)
@@ -114,84 +84,11 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m
114 return !memcmp(nm_a, nm_b, sizeof(*nm_a)); 84 return !memcmp(nm_a, nm_b, sizeof(*nm_a));
115} 85}
116 86
117/** 87void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b,
118 * nmap_diff - find differences between node maps 88 struct tipc_node_map *nm_diff);
119 * @nm_a: input node map A
120 * @nm_b: input node map B
121 * @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
122 */
123
124static inline void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b,
125 struct tipc_node_map *nm_diff)
126{
127 int stop = ARRAY_SIZE(nm_a->map);
128 int w;
129 int b;
130 u32 map;
131
132 memset(nm_diff, 0, sizeof(*nm_diff));
133 for (w = 0; w < stop; w++) {
134 map = nm_a->map[w] ^ (nm_a->map[w] & nm_b->map[w]);
135 nm_diff->map[w] = map;
136 if (map != 0) {
137 for (b = 0 ; b < WSIZE; b++) {
138 if (map & (1 << b))
139 nm_diff->count++;
140 }
141 }
142 }
143}
144
145/**
146 * port_list_add - add a port to a port list, ensuring no duplicates
147 */
148
149static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
150{
151 struct port_list *item = pl_ptr;
152 int i;
153 int item_sz = PLSIZE;
154 int cnt = pl_ptr->count;
155
156 for (; ; cnt -= item_sz, item = item->next) {
157 if (cnt < PLSIZE)
158 item_sz = cnt;
159 for (i = 0; i < item_sz; i++)
160 if (item->ports[i] == port)
161 return;
162 if (i < PLSIZE) {
163 item->ports[i] = port;
164 pl_ptr->count++;
165 return;
166 }
167 if (!item->next) {
168 item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
169 if (!item->next) {
170 warn("Incomplete multicast delivery, no memory\n");
171 return;
172 }
173 item->next->next = NULL;
174 }
175 }
176}
177
178/**
179 * port_list_free - free dynamically created entries in port_list chain
180 *
181 * Note: First item is on stack, so it doesn't need to be released
182 */
183
184static inline void tipc_port_list_free(struct port_list *pl_ptr)
185{
186 struct port_list *item;
187 struct port_list *next;
188
189 for (item = pl_ptr->next; item; item = next) {
190 next = item->next;
191 kfree(item);
192 }
193}
194 89
90void tipc_port_list_add(struct port_list *pl_ptr, u32 port);
91void tipc_port_list_free(struct port_list *pl_ptr);
195 92
196int tipc_bclink_init(void); 93int tipc_bclink_init(void);
197void tipc_bclink_stop(void); 94void tipc_bclink_stop(void);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 78091375ca12..52ae17b2583e 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -467,6 +467,18 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
467 return res; 467 return res;
468} 468}
469 469
470/**
471 * tipc_bearer_congested - determines if bearer is currently congested
472 */
473
474int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr)
475{
476 if (unlikely(b_ptr->publ.blocked))
477 return 1;
478 if (likely(list_empty(&b_ptr->cong_links)))
479 return 0;
480 return !tipc_bearer_resolve_congestion(b_ptr, l_ptr);
481}
470 482
471/** 483/**
472 * tipc_enable_bearer - enable bearer with the given name 484 * tipc_enable_bearer - enable bearer with the given name
@@ -493,7 +505,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
493 return -EINVAL; 505 return -EINVAL;
494 } 506 }
495 if (!tipc_addr_domain_valid(bcast_scope) || 507 if (!tipc_addr_domain_valid(bcast_scope) ||
496 !in_scope(bcast_scope, tipc_own_addr)) { 508 !tipc_in_scope(bcast_scope, tipc_own_addr)) {
497 warn("Bearer <%s> rejected, illegal broadcast scope\n", name); 509 warn("Bearer <%s> rejected, illegal broadcast scope\n", name);
498 return -EINVAL; 510 return -EINVAL;
499 } 511 }
@@ -571,7 +583,7 @@ restart:
571 spin_lock_init(&b_ptr->publ.lock); 583 spin_lock_init(&b_ptr->publ.lock);
572 write_unlock_bh(&tipc_net_lock); 584 write_unlock_bh(&tipc_net_lock);
573 info("Enabled bearer <%s>, discovery domain %s, priority %u\n", 585 info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
574 name, addr_string_fill(addr_string, bcast_scope), priority); 586 name, tipc_addr_string_fill(addr_string, bcast_scope), priority);
575 return 0; 587 return 0;
576failed: 588failed:
577 write_unlock_bh(&tipc_net_lock); 589 write_unlock_bh(&tipc_net_lock);
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 000228e93f9e..a850b389663e 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -125,6 +125,7 @@ void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest);
125void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr); 125void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr);
126struct bearer *tipc_bearer_find_interface(const char *if_name); 126struct bearer *tipc_bearer_find_interface(const char *if_name);
127int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr); 127int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr);
128int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr);
128int tipc_bearer_init(void); 129int tipc_bearer_init(void);
129void tipc_bearer_stop(void); 130void tipc_bearer_stop(void);
130void tipc_bearer_lock_push(struct bearer *b_ptr); 131void tipc_bearer_lock_push(struct bearer *b_ptr);
@@ -154,17 +155,4 @@ static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf,
154 return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest); 155 return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest);
155} 156}
156 157
157/** 158#endif /* _TIPC_BEARER_H */
158 * tipc_bearer_congested - determines if bearer is currently congested
159 */
160
161static inline int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr)
162{
163 if (unlikely(b_ptr->publ.blocked))
164 return 1;
165 if (likely(list_empty(&b_ptr->cong_links)))
166 return 0;
167 return !tipc_bearer_resolve_congestion(b_ptr, l_ptr);
168}
169
170#endif
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c
index a7eac00cd363..e68f705381bc 100644
--- a/net/tipc/cluster.c
+++ b/net/tipc/cluster.c
@@ -238,7 +238,7 @@ static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest)
238 if (buf) { 238 if (buf) {
239 msg = buf_msg(buf); 239 msg = buf_msg(buf);
240 memset((char *)msg, 0, size); 240 memset((char *)msg, 0, size);
241 msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest); 241 tipc_msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest);
242 } 242 }
243 return buf; 243 return buf;
244} 244}
diff --git a/net/tipc/config.c b/net/tipc/config.c
index ca3544d030c7..961d1b097146 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -56,9 +56,6 @@ struct subscr_data {
56struct manager { 56struct manager {
57 u32 user_ref; 57 u32 user_ref;
58 u32 port_ref; 58 u32 port_ref;
59 u32 subscr_ref;
60 u32 link_subscriptions;
61 struct list_head link_subscribers;
62}; 59};
63 60
64static struct manager mng = { 0}; 61static struct manager mng = { 0};
@@ -70,12 +67,6 @@ static int req_tlv_space; /* request message TLV area size */
70static int rep_headroom; /* reply message headroom to use */ 67static int rep_headroom; /* reply message headroom to use */
71 68
72 69
73void tipc_cfg_link_event(u32 addr, char *name, int up)
74{
75 /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */
76}
77
78
79struct sk_buff *tipc_cfg_reply_alloc(int payload_size) 70struct sk_buff *tipc_cfg_reply_alloc(int payload_size)
80{ 71{
81 struct sk_buff *buf; 72 struct sk_buff *buf;
@@ -130,12 +121,24 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
130} 121}
131 122
132 123
133
134
135#if 0 124#if 0
136 125
137/* Now obsolete code for handling commands not yet implemented the new way */ 126/* Now obsolete code for handling commands not yet implemented the new way */
138 127
128/*
129 * Some of this code assumed that the manager structure contains two added
130 * fields:
131 * u32 link_subscriptions;
132 * struct list_head link_subscribers;
133 * which are currently not present. These fields may need to be re-introduced
134 * if and when support for link subscriptions is added.
135 */
136
137void tipc_cfg_link_event(u32 addr, char *name, int up)
138{
139 /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */
140}
141
139int tipc_cfg_cmd(const struct tipc_cmd_msg * msg, 142int tipc_cfg_cmd(const struct tipc_cmd_msg * msg,
140 char *data, 143 char *data,
141 u32 sz, 144 u32 sz,
@@ -243,13 +246,48 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
243 default: 246 default:
244 rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig); 247 rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig);
245 } 248 }
246 exit: 249exit:
247 rmsg.result_len = htonl(msg_sect[1].iov_len); 250 rmsg.result_len = htonl(msg_sect[1].iov_len);
248 rmsg.retval = htonl(rv); 251 rmsg.retval = htonl(rv);
249 tipc_cfg_respond(msg_sect, 2u, orig); 252 tipc_cfg_respond(msg_sect, 2u, orig);
250} 253}
251#endif 254#endif
252 255
256#define MAX_STATS_INFO 2000
257
258static struct sk_buff *tipc_show_stats(void)
259{
260 struct sk_buff *buf;
261 struct tlv_desc *rep_tlv;
262 struct print_buf pb;
263 int str_len;
264 u32 value;
265
266 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
267 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
268
269 value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
270 if (value != 0)
271 return tipc_cfg_reply_error_string("unsupported argument");
272
273 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO));
274 if (buf == NULL)
275 return NULL;
276
277 rep_tlv = (struct tlv_desc *)buf->data;
278 tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO);
279
280 tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n");
281
282 /* Use additional tipc_printf()'s to return more info ... */
283
284 str_len = tipc_printbuf_validate(&pb);
285 skb_put(buf, TLV_SPACE(str_len));
286 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
287
288 return buf;
289}
290
253static struct sk_buff *cfg_enable_bearer(void) 291static struct sk_buff *cfg_enable_bearer(void)
254{ 292{
255 struct tipc_bearer_config *args; 293 struct tipc_bearer_config *args;
@@ -533,6 +571,9 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
533 case TIPC_CMD_DUMP_LOG: 571 case TIPC_CMD_DUMP_LOG:
534 rep_tlv_buf = tipc_log_dump(); 572 rep_tlv_buf = tipc_log_dump();
535 break; 573 break;
574 case TIPC_CMD_SHOW_STATS:
575 rep_tlv_buf = tipc_show_stats();
576 break;
536 case TIPC_CMD_SET_LINK_TOL: 577 case TIPC_CMD_SET_LINK_TOL:
537 case TIPC_CMD_SET_LINK_PRI: 578 case TIPC_CMD_SET_LINK_PRI:
538 case TIPC_CMD_SET_LINK_WINDOW: 579 case TIPC_CMD_SET_LINK_WINDOW:
@@ -667,9 +708,6 @@ int tipc_cfg_init(void)
667 struct tipc_name_seq seq; 708 struct tipc_name_seq seq;
668 int res; 709 int res;
669 710
670 memset(&mng, 0, sizeof(mng));
671 INIT_LIST_HEAD(&mng.link_subscribers);
672
673 res = tipc_attach(&mng.user_ref, NULL, NULL); 711 res = tipc_attach(&mng.user_ref, NULL, NULL);
674 if (res) 712 if (res)
675 goto failed; 713 goto failed;
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 4e84c8431f32..696468117985 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -49,8 +49,6 @@
49#include "config.h" 49#include "config.h"
50 50
51 51
52#define TIPC_MOD_VER "2.0.0"
53
54#ifndef CONFIG_TIPC_ZONES 52#ifndef CONFIG_TIPC_ZONES
55#define CONFIG_TIPC_ZONES 3 53#define CONFIG_TIPC_ZONES 3
56#endif 54#endif
@@ -104,6 +102,30 @@ int tipc_get_mode(void)
104} 102}
105 103
106/** 104/**
105 * buf_acquire - creates a TIPC message buffer
106 * @size: message size (including TIPC header)
107 *
108 * Returns a new buffer with data pointers set to the specified size.
109 *
110 * NOTE: Headroom is reserved to allow prepending of a data link header.
111 * There may also be unrequested tailroom present at the buffer's end.
112 */
113
114struct sk_buff *buf_acquire(u32 size)
115{
116 struct sk_buff *skb;
117 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
118
119 skb = alloc_skb_fclone(buf_size, GFP_ATOMIC);
120 if (skb) {
121 skb_reserve(skb, BUF_HEADROOM);
122 skb_put(skb, size);
123 skb->next = NULL;
124 }
125 return skb;
126}
127
128/**
107 * tipc_core_stop_net - shut down TIPC networking sub-systems 129 * tipc_core_stop_net - shut down TIPC networking sub-systems
108 */ 130 */
109 131
diff --git a/net/tipc/core.h b/net/tipc/core.h
index c58a1d16563a..188799017abd 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -59,6 +59,9 @@
59#include <linux/slab.h> 59#include <linux/slab.h>
60#include <linux/vmalloc.h> 60#include <linux/vmalloc.h>
61 61
62
63#define TIPC_MOD_VER "2.0.0"
64
62/* 65/*
63 * TIPC sanity test macros 66 * TIPC sanity test macros
64 */ 67 */
@@ -325,29 +328,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
325 return (struct tipc_msg *)skb->data; 328 return (struct tipc_msg *)skb->data;
326} 329}
327 330
328/** 331extern struct sk_buff *buf_acquire(u32 size);
329 * buf_acquire - creates a TIPC message buffer
330 * @size: message size (including TIPC header)
331 *
332 * Returns a new buffer with data pointers set to the specified size.
333 *
334 * NOTE: Headroom is reserved to allow prepending of a data link header.
335 * There may also be unrequested tailroom present at the buffer's end.
336 */
337
338static inline struct sk_buff *buf_acquire(u32 size)
339{
340 struct sk_buff *skb;
341 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
342
343 skb = alloc_skb_fclone(buf_size, GFP_ATOMIC);
344 if (skb) {
345 skb_reserve(skb, BUF_HEADROOM);
346 skb_put(skb, size);
347 skb->next = NULL;
348 }
349 return skb;
350}
351 332
352/** 333/**
353 * buf_discard - frees a TIPC message buffer 334 * buf_discard - frees a TIPC message buffer
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 74b7d1e28aec..fc1fcf5e6b53 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -120,7 +120,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
120 120
121 if (buf) { 121 if (buf) {
122 msg = buf_msg(buf); 122 msg = buf_msg(buf);
123 msg_init(msg, LINK_CONFIG, type, DSC_H_SIZE, dest_domain); 123 tipc_msg_init(msg, LINK_CONFIG, type, DSC_H_SIZE, dest_domain);
124 msg_set_non_seq(msg, 1); 124 msg_set_non_seq(msg, 1);
125 msg_set_req_links(msg, req_links); 125 msg_set_req_links(msg, req_links);
126 msg_set_dest_domain(msg, dest_domain); 126 msg_set_dest_domain(msg, dest_domain);
@@ -144,7 +144,7 @@ static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr,
144 char media_addr_str[64]; 144 char media_addr_str[64];
145 struct print_buf pb; 145 struct print_buf pb;
146 146
147 addr_string_fill(node_addr_str, node_addr); 147 tipc_addr_string_fill(node_addr_str, node_addr);
148 tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str)); 148 tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str));
149 tipc_media_addr_printf(&pb, media_addr); 149 tipc_media_addr_printf(&pb, media_addr);
150 tipc_printbuf_validate(&pb); 150 tipc_printbuf_validate(&pb);
@@ -183,7 +183,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr)
183 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr); 183 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr);
184 return; 184 return;
185 } 185 }
186 if (!in_scope(dest, tipc_own_addr)) 186 if (!tipc_in_scope(dest, tipc_own_addr))
187 return; 187 return;
188 if (is_slave(tipc_own_addr) && is_slave(orig)) 188 if (is_slave(tipc_own_addr) && is_slave(orig))
189 return; 189 return;
@@ -224,7 +224,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr)
224 memcpy(addr, &media_addr, sizeof(*addr)); 224 memcpy(addr, &media_addr, sizeof(*addr));
225 tipc_link_reset(link); 225 tipc_link_reset(link);
226 } 226 }
227 link_fully_up = (link->state == WORKING_WORKING); 227 link_fully_up = link_working_working(link);
228 spin_unlock_bh(&n_ptr->lock); 228 spin_unlock_bh(&n_ptr->lock);
229 if ((type == DSC_RESP_MSG) || link_fully_up) 229 if ((type == DSC_RESP_MSG) || link_fully_up)
230 return; 230 return;
diff --git a/net/tipc/link.c b/net/tipc/link.c
index c76e82e5f982..a3616b99529b 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -202,41 +202,6 @@ static unsigned int align(unsigned int i)
202 return (i + 3) & ~3u; 202 return (i + 3) & ~3u;
203} 203}
204 204
205static int link_working_working(struct link *l_ptr)
206{
207 return (l_ptr->state == WORKING_WORKING);
208}
209
210static int link_working_unknown(struct link *l_ptr)
211{
212 return (l_ptr->state == WORKING_UNKNOWN);
213}
214
215static int link_reset_unknown(struct link *l_ptr)
216{
217 return (l_ptr->state == RESET_UNKNOWN);
218}
219
220static int link_reset_reset(struct link *l_ptr)
221{
222 return (l_ptr->state == RESET_RESET);
223}
224
225static int link_blocked(struct link *l_ptr)
226{
227 return (l_ptr->exp_msg_count || l_ptr->blocked);
228}
229
230static int link_congested(struct link *l_ptr)
231{
232 return (l_ptr->out_queue_size >= l_ptr->queue_limit[0]);
233}
234
235static u32 link_max_pkt(struct link *l_ptr)
236{
237 return l_ptr->max_pkt;
238}
239
240static void link_init_max_pkt(struct link *l_ptr) 205static void link_init_max_pkt(struct link *l_ptr)
241{ 206{
242 u32 max_pkt; 207 u32 max_pkt;
@@ -468,7 +433,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
468 433
469 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; 434 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg;
470 msg = l_ptr->pmsg; 435 msg = l_ptr->pmsg;
471 msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); 436 tipc_msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr);
472 msg_set_size(msg, sizeof(l_ptr->proto_msg)); 437 msg_set_size(msg, sizeof(l_ptr->proto_msg));
473 msg_set_session(msg, (tipc_random & 0xffff)); 438 msg_set_session(msg, (tipc_random & 0xffff));
474 msg_set_bearer_id(msg, b_ptr->identity); 439 msg_set_bearer_id(msg, b_ptr->identity);
@@ -561,9 +526,8 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
561 goto exit; 526 goto exit;
562 if (!list_empty(&p_ptr->wait_list)) 527 if (!list_empty(&p_ptr->wait_list))
563 goto exit; 528 goto exit;
564 p_ptr->congested_link = l_ptr;
565 p_ptr->publ.congested = 1; 529 p_ptr->publ.congested = 1;
566 p_ptr->waiting_pkts = 1 + ((sz - 1) / link_max_pkt(l_ptr)); 530 p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt);
567 list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports); 531 list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports);
568 l_ptr->stats.link_congs++; 532 l_ptr->stats.link_congs++;
569exit: 533exit:
@@ -592,7 +556,6 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
592 if (win <= 0) 556 if (win <= 0)
593 break; 557 break;
594 list_del_init(&p_ptr->wait_list); 558 list_del_init(&p_ptr->wait_list);
595 p_ptr->congested_link = NULL;
596 spin_lock_bh(p_ptr->publ.lock); 559 spin_lock_bh(p_ptr->publ.lock);
597 p_ptr->publ.congested = 0; 560 p_ptr->publ.congested = 0;
598 p_ptr->wakeup(&p_ptr->publ); 561 p_ptr->wakeup(&p_ptr->publ);
@@ -1017,7 +980,7 @@ static int link_bundle_buf(struct link *l_ptr,
1017 return 0; 980 return 0;
1018 if (skb_tailroom(bundler) < (pad + size)) 981 if (skb_tailroom(bundler) < (pad + size))
1019 return 0; 982 return 0;
1020 if (link_max_pkt(l_ptr) < (to_pos + size)) 983 if (l_ptr->max_pkt < (to_pos + size))
1021 return 0; 984 return 0;
1022 985
1023 skb_put(bundler, pad + size); 986 skb_put(bundler, pad + size);
@@ -1062,9 +1025,9 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1062 u32 size = msg_size(msg); 1025 u32 size = msg_size(msg);
1063 u32 dsz = msg_data_sz(msg); 1026 u32 dsz = msg_data_sz(msg);
1064 u32 queue_size = l_ptr->out_queue_size; 1027 u32 queue_size = l_ptr->out_queue_size;
1065 u32 imp = msg_tot_importance(msg); 1028 u32 imp = tipc_msg_tot_importance(msg);
1066 u32 queue_limit = l_ptr->queue_limit[imp]; 1029 u32 queue_limit = l_ptr->queue_limit[imp];
1067 u32 max_packet = link_max_pkt(l_ptr); 1030 u32 max_packet = l_ptr->max_pkt;
1068 1031
1069 msg_set_prevnode(msg, tipc_own_addr); /* If routed message */ 1032 msg_set_prevnode(msg, tipc_own_addr); /* If routed message */
1070 1033
@@ -1127,7 +1090,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1127 struct tipc_msg bundler_hdr; 1090 struct tipc_msg bundler_hdr;
1128 1091
1129 if (bundler) { 1092 if (bundler) {
1130 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, 1093 tipc_msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
1131 INT_H_SIZE, l_ptr->addr); 1094 INT_H_SIZE, l_ptr->addr);
1132 skb_copy_to_linear_data(bundler, &bundler_hdr, 1095 skb_copy_to_linear_data(bundler, &bundler_hdr,
1133 INT_H_SIZE); 1096 INT_H_SIZE);
@@ -1195,7 +1158,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
1195 int res = msg_data_sz(msg); 1158 int res = msg_data_sz(msg);
1196 1159
1197 if (likely(!link_congested(l_ptr))) { 1160 if (likely(!link_congested(l_ptr))) {
1198 if (likely(msg_size(msg) <= link_max_pkt(l_ptr))) { 1161 if (likely(msg_size(msg) <= l_ptr->max_pkt)) {
1199 if (likely(list_empty(&l_ptr->b_ptr->cong_links))) { 1162 if (likely(list_empty(&l_ptr->b_ptr->cong_links))) {
1200 link_add_to_outqueue(l_ptr, buf, msg); 1163 link_add_to_outqueue(l_ptr, buf, msg);
1201 if (likely(tipc_bearer_send(l_ptr->b_ptr, buf, 1164 if (likely(tipc_bearer_send(l_ptr->b_ptr, buf,
@@ -1212,7 +1175,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
1212 } 1175 }
1213 } 1176 }
1214 else 1177 else
1215 *used_max_pkt = link_max_pkt(l_ptr); 1178 *used_max_pkt = l_ptr->max_pkt;
1216 } 1179 }
1217 return tipc_link_send_buf(l_ptr, buf); /* All other cases */ 1180 return tipc_link_send_buf(l_ptr, buf); /* All other cases */
1218} 1181}
@@ -1280,7 +1243,7 @@ again:
1280 * (Must not hold any locks while building message.) 1243 * (Must not hold any locks while building message.)
1281 */ 1244 */
1282 1245
1283 res = msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, 1246 res = tipc_msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt,
1284 !sender->user_port, &buf); 1247 !sender->user_port, &buf);
1285 1248
1286 read_lock_bh(&tipc_net_lock); 1249 read_lock_bh(&tipc_net_lock);
@@ -1319,7 +1282,7 @@ exit:
1319 * then re-try fast path or fragment the message 1282 * then re-try fast path or fragment the message
1320 */ 1283 */
1321 1284
1322 sender->publ.max_pkt = link_max_pkt(l_ptr); 1285 sender->publ.max_pkt = l_ptr->max_pkt;
1323 tipc_node_unlock(node); 1286 tipc_node_unlock(node);
1324 read_unlock_bh(&tipc_net_lock); 1287 read_unlock_bh(&tipc_net_lock);
1325 1288
@@ -1391,7 +1354,7 @@ again:
1391 /* Prepare reusable fragment header: */ 1354 /* Prepare reusable fragment header: */
1392 1355
1393 msg_dbg(hdr, ">FRAGMENTING>"); 1356 msg_dbg(hdr, ">FRAGMENTING>");
1394 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, 1357 tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
1395 INT_H_SIZE, msg_destnode(hdr)); 1358 INT_H_SIZE, msg_destnode(hdr));
1396 msg_set_link_selector(&fragm_hdr, sender->publ.ref); 1359 msg_set_link_selector(&fragm_hdr, sender->publ.ref);
1397 msg_set_size(&fragm_hdr, max_pkt); 1360 msg_set_size(&fragm_hdr, max_pkt);
@@ -1482,8 +1445,8 @@ error:
1482 tipc_node_unlock(node); 1445 tipc_node_unlock(node);
1483 goto reject; 1446 goto reject;
1484 } 1447 }
1485 if (link_max_pkt(l_ptr) < max_pkt) { 1448 if (l_ptr->max_pkt < max_pkt) {
1486 sender->publ.max_pkt = link_max_pkt(l_ptr); 1449 sender->publ.max_pkt = l_ptr->max_pkt;
1487 tipc_node_unlock(node); 1450 tipc_node_unlock(node);
1488 for (; buf_chain; buf_chain = buf) { 1451 for (; buf_chain; buf_chain = buf) {
1489 buf = buf_chain->next; 1452 buf = buf_chain->next;
@@ -1650,7 +1613,7 @@ static void link_reset_all(unsigned long addr)
1650 tipc_node_lock(n_ptr); 1613 tipc_node_lock(n_ptr);
1651 1614
1652 warn("Resetting all links to %s\n", 1615 warn("Resetting all links to %s\n",
1653 addr_string_fill(addr_string, n_ptr->addr)); 1616 tipc_addr_string_fill(addr_string, n_ptr->addr));
1654 1617
1655 for (i = 0; i < MAX_BEARERS; i++) { 1618 for (i = 0; i < MAX_BEARERS; i++) {
1656 if (n_ptr->links[i]) { 1619 if (n_ptr->links[i]) {
@@ -1692,7 +1655,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
1692 n_ptr = l_ptr->owner->next; 1655 n_ptr = l_ptr->owner->next;
1693 tipc_node_lock(n_ptr); 1656 tipc_node_lock(n_ptr);
1694 1657
1695 addr_string_fill(addr_string, n_ptr->addr); 1658 tipc_addr_string_fill(addr_string, n_ptr->addr);
1696 tipc_printf(TIPC_OUTPUT, "Multicast link info for %s\n", addr_string); 1659 tipc_printf(TIPC_OUTPUT, "Multicast link info for %s\n", addr_string);
1697 tipc_printf(TIPC_OUTPUT, "Supported: %d, ", n_ptr->bclink.supported); 1660 tipc_printf(TIPC_OUTPUT, "Supported: %d, ", n_ptr->bclink.supported);
1698 tipc_printf(TIPC_OUTPUT, "Acked: %u\n", n_ptr->bclink.acked); 1661 tipc_printf(TIPC_OUTPUT, "Acked: %u\n", n_ptr->bclink.acked);
@@ -2435,7 +2398,7 @@ void tipc_link_changeover(struct link *l_ptr)
2435 return; 2398 return;
2436 } 2399 }
2437 2400
2438 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, 2401 tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL,
2439 ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); 2402 ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr);
2440 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 2403 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
2441 msg_set_msgcnt(&tunnel_hdr, msgcount); 2404 msg_set_msgcnt(&tunnel_hdr, msgcount);
@@ -2490,7 +2453,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2490 struct sk_buff *iter; 2453 struct sk_buff *iter;
2491 struct tipc_msg tunnel_hdr; 2454 struct tipc_msg tunnel_hdr;
2492 2455
2493 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, 2456 tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL,
2494 DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); 2457 DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr);
2495 msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size); 2458 msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size);
2496 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 2459 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
@@ -2681,7 +2644,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2681 u32 dsz = msg_data_sz(inmsg); 2644 u32 dsz = msg_data_sz(inmsg);
2682 unchar *crs = buf->data; 2645 unchar *crs = buf->data;
2683 u32 rest = insize; 2646 u32 rest = insize;
2684 u32 pack_sz = link_max_pkt(l_ptr); 2647 u32 pack_sz = l_ptr->max_pkt;
2685 u32 fragm_sz = pack_sz - INT_H_SIZE; 2648 u32 fragm_sz = pack_sz - INT_H_SIZE;
2686 u32 fragm_no = 1; 2649 u32 fragm_no = 1;
2687 u32 destaddr; 2650 u32 destaddr;
@@ -2696,7 +2659,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2696 2659
2697 /* Prepare reusable fragment header: */ 2660 /* Prepare reusable fragment header: */
2698 2661
2699 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, 2662 tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
2700 INT_H_SIZE, destaddr); 2663 INT_H_SIZE, destaddr);
2701 msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg)); 2664 msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg));
2702 msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++)); 2665 msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++));
@@ -3127,7 +3090,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
3127 tipc_printf(&pb, "Link <%s>\n" 3090 tipc_printf(&pb, "Link <%s>\n"
3128 " %s MTU:%u Priority:%u Tolerance:%u ms" 3091 " %s MTU:%u Priority:%u Tolerance:%u ms"
3129 " Window:%u packets\n", 3092 " Window:%u packets\n",
3130 l_ptr->name, status, link_max_pkt(l_ptr), 3093 l_ptr->name, status, l_ptr->max_pkt,
3131 l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); 3094 l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]);
3132 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", 3095 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
3133 l_ptr->next_in_no - l_ptr->stats.recv_info, 3096 l_ptr->next_in_no - l_ptr->stats.recv_info,
@@ -3272,7 +3235,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3272 tipc_node_lock(n_ptr); 3235 tipc_node_lock(n_ptr);
3273 l_ptr = n_ptr->active_links[selector & 1]; 3236 l_ptr = n_ptr->active_links[selector & 1];
3274 if (l_ptr) 3237 if (l_ptr)
3275 res = link_max_pkt(l_ptr); 3238 res = l_ptr->max_pkt;
3276 tipc_node_unlock(n_ptr); 3239 tipc_node_unlock(n_ptr);
3277 } 3240 }
3278 read_unlock_bh(&tipc_net_lock); 3241 read_unlock_bh(&tipc_net_lock);
@@ -3330,9 +3293,7 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
3330 if (l_ptr->next_out) 3293 if (l_ptr->next_out)
3331 tipc_printf(buf, "%u..", 3294 tipc_printf(buf, "%u..",
3332 msg_seqno(buf_msg(l_ptr->next_out))); 3295 msg_seqno(buf_msg(l_ptr->next_out)));
3333 tipc_printf(buf, "%u]", 3296 tipc_printf(buf, "%u]", msg_seqno(buf_msg(l_ptr->last_out)));
3334 msg_seqno(buf_msg
3335 (l_ptr->last_out)), l_ptr->out_queue_size);
3336 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - 3297 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
3337 msg_seqno(buf_msg(l_ptr->first_out))) 3298 msg_seqno(buf_msg(l_ptr->first_out)))
3338 != (l_ptr->out_queue_size - 1)) || 3299 != (l_ptr->out_queue_size - 1)) ||
diff --git a/net/tipc/link.h b/net/tipc/link.h
index 6a51e38ad25c..2e5385c47d30 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -292,4 +292,39 @@ static inline u32 lesser(u32 left, u32 right)
292 return less_eq(left, right) ? left : right; 292 return less_eq(left, right) ? left : right;
293} 293}
294 294
295
296/*
297 * Link status checking routines
298 */
299
300static inline int link_working_working(struct link *l_ptr)
301{
302 return (l_ptr->state == WORKING_WORKING);
303}
304
305static inline int link_working_unknown(struct link *l_ptr)
306{
307 return (l_ptr->state == WORKING_UNKNOWN);
308}
309
310static inline int link_reset_unknown(struct link *l_ptr)
311{
312 return (l_ptr->state == RESET_UNKNOWN);
313}
314
315static inline int link_reset_reset(struct link *l_ptr)
316{
317 return (l_ptr->state == RESET_RESET);
318}
319
320static inline int link_blocked(struct link *l_ptr)
321{
322 return (l_ptr->exp_msg_count || l_ptr->blocked);
323}
324
325static inline int link_congested(struct link *l_ptr)
326{
327 return (l_ptr->out_queue_size >= l_ptr->queue_limit[0]);
328}
329
295#endif 330#endif
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 73dcd00d674e..381063817b41 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -40,6 +40,100 @@
40#include "msg.h" 40#include "msg.h"
41#include "bearer.h" 41#include "bearer.h"
42 42
43u32 tipc_msg_tot_importance(struct tipc_msg *m)
44{
45 if (likely(msg_isdata(m))) {
46 if (likely(msg_orignode(m) == tipc_own_addr))
47 return msg_importance(m);
48 return msg_importance(m) + 4;
49 }
50 if ((msg_user(m) == MSG_FRAGMENTER) &&
51 (msg_type(m) == FIRST_FRAGMENT))
52 return msg_importance(msg_get_wrapped(m));
53 return msg_importance(m);
54}
55
56
57void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
58 u32 hsize, u32 destnode)
59{
60 memset(m, 0, hsize);
61 msg_set_version(m);
62 msg_set_user(m, user);
63 msg_set_hdr_sz(m, hsize);
64 msg_set_size(m, hsize);
65 msg_set_prevnode(m, tipc_own_addr);
66 msg_set_type(m, type);
67 if (!msg_short(m)) {
68 msg_set_orignode(m, tipc_own_addr);
69 msg_set_destnode(m, destnode);
70 }
71}
72
73/**
74 * tipc_msg_calc_data_size - determine total data size for message
75 */
76
77int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect)
78{
79 int dsz = 0;
80 int i;
81
82 for (i = 0; i < num_sect; i++)
83 dsz += msg_sect[i].iov_len;
84 return dsz;
85}
86
87/**
88 * tipc_msg_build - create message using specified header and data
89 *
90 * Note: Caller must not hold any locks in case copy_from_user() is interrupted!
91 *
92 * Returns message data size or errno
93 */
94
95int tipc_msg_build(struct tipc_msg *hdr,
96 struct iovec const *msg_sect, u32 num_sect,
97 int max_size, int usrmem, struct sk_buff** buf)
98{
99 int dsz, sz, hsz, pos, res, cnt;
100
101 dsz = tipc_msg_calc_data_size(msg_sect, num_sect);
102 if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) {
103 *buf = NULL;
104 return -EINVAL;
105 }
106
107 pos = hsz = msg_hdr_sz(hdr);
108 sz = hsz + dsz;
109 msg_set_size(hdr, sz);
110 if (unlikely(sz > max_size)) {
111 *buf = NULL;
112 return dsz;
113 }
114
115 *buf = buf_acquire(sz);
116 if (!(*buf))
117 return -ENOMEM;
118 skb_copy_to_linear_data(*buf, hdr, hsz);
119 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
120 if (likely(usrmem))
121 res = !copy_from_user((*buf)->data + pos,
122 msg_sect[cnt].iov_base,
123 msg_sect[cnt].iov_len);
124 else
125 skb_copy_to_linear_data_offset(*buf, pos,
126 msg_sect[cnt].iov_base,
127 msg_sect[cnt].iov_len);
128 pos += msg_sect[cnt].iov_len;
129 }
130 if (likely(res))
131 return dsz;
132
133 buf_discard(*buf);
134 *buf = NULL;
135 return -EFAULT;
136}
43 137
44#ifdef CONFIG_TIPC_DEBUG 138#ifdef CONFIG_TIPC_DEBUG
45 139
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 7ee6ae238147..995d2da35b01 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -708,100 +708,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
708#define DSC_REQ_MSG 0 708#define DSC_REQ_MSG 0
709#define DSC_RESP_MSG 1 709#define DSC_RESP_MSG 1
710 710
711static inline u32 msg_tot_importance(struct tipc_msg *m) 711u32 tipc_msg_tot_importance(struct tipc_msg *m);
712{ 712void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
713 if (likely(msg_isdata(m))) { 713 u32 hsize, u32 destnode);
714 if (likely(msg_orignode(m) == tipc_own_addr)) 714int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect);
715 return msg_importance(m); 715int tipc_msg_build(struct tipc_msg *hdr,
716 return msg_importance(m) + 4;
717 }
718 if ((msg_user(m) == MSG_FRAGMENTER) &&
719 (msg_type(m) == FIRST_FRAGMENT))
720 return msg_importance(msg_get_wrapped(m));
721 return msg_importance(m);
722}
723
724
725static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
726 u32 hsize, u32 destnode)
727{
728 memset(m, 0, hsize);
729 msg_set_version(m);
730 msg_set_user(m, user);
731 msg_set_hdr_sz(m, hsize);
732 msg_set_size(m, hsize);
733 msg_set_prevnode(m, tipc_own_addr);
734 msg_set_type(m, type);
735 if (!msg_short(m)) {
736 msg_set_orignode(m, tipc_own_addr);
737 msg_set_destnode(m, destnode);
738 }
739}
740
741/**
742 * msg_calc_data_size - determine total data size for message
743 */
744
745static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect)
746{
747 int dsz = 0;
748 int i;
749
750 for (i = 0; i < num_sect; i++)
751 dsz += msg_sect[i].iov_len;
752 return dsz;
753}
754
755/**
756 * msg_build - create message using specified header and data
757 *
758 * Note: Caller must not hold any locks in case copy_from_user() is interrupted!
759 *
760 * Returns message data size or errno
761 */
762
763static inline int msg_build(struct tipc_msg *hdr,
764 struct iovec const *msg_sect, u32 num_sect, 716 struct iovec const *msg_sect, u32 num_sect,
765 int max_size, int usrmem, struct sk_buff** buf) 717 int max_size, int usrmem, struct sk_buff** buf);
766{
767 int dsz, sz, hsz, pos, res, cnt;
768
769 dsz = msg_calc_data_size(msg_sect, num_sect);
770 if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) {
771 *buf = NULL;
772 return -EINVAL;
773 }
774
775 pos = hsz = msg_hdr_sz(hdr);
776 sz = hsz + dsz;
777 msg_set_size(hdr, sz);
778 if (unlikely(sz > max_size)) {
779 *buf = NULL;
780 return dsz;
781 }
782
783 *buf = buf_acquire(sz);
784 if (!(*buf))
785 return -ENOMEM;
786 skb_copy_to_linear_data(*buf, hdr, hsz);
787 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
788 if (likely(usrmem))
789 res = !copy_from_user((*buf)->data + pos,
790 msg_sect[cnt].iov_base,
791 msg_sect[cnt].iov_len);
792 else
793 skb_copy_to_linear_data_offset(*buf, pos,
794 msg_sect[cnt].iov_base,
795 msg_sect[cnt].iov_len);
796 pos += msg_sect[cnt].iov_len;
797 }
798 if (likely(res))
799 return dsz;
800
801 buf_discard(*buf);
802 *buf = NULL;
803 return -EFAULT;
804}
805 718
806static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) 719static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
807{ 720{
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 10a69894e2fd..6ac3c543250b 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -103,7 +103,7 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
103 103
104 if (buf != NULL) { 104 if (buf != NULL) {
105 msg = buf_msg(buf); 105 msg = buf_msg(buf);
106 msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest); 106 tipc_msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest);
107 msg_set_size(msg, LONG_H_SIZE + size); 107 msg_set_size(msg, LONG_H_SIZE + size);
108 } 108 }
109 return buf; 109 return buf;
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index acab41a48d67..8ba79620db3f 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -627,7 +627,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
627 struct name_seq *seq; 627 struct name_seq *seq;
628 u32 ref; 628 u32 ref;
629 629
630 if (!in_scope(*destnode, tipc_own_addr)) 630 if (!tipc_in_scope(*destnode, tipc_own_addr))
631 return 0; 631 return 0;
632 632
633 read_lock_bh(&tipc_nametbl_lock); 633 read_lock_bh(&tipc_nametbl_lock);
diff --git a/net/tipc/net.c b/net/tipc/net.c
index d7cd1e064a80..f61b7694138b 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -219,7 +219,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
219 219
220 /* Handle message for this node */ 220 /* Handle message for this node */
221 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); 221 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
222 if (in_scope(dnode, tipc_own_addr)) { 222 if (tipc_in_scope(dnode, tipc_own_addr)) {
223 if (msg_isdata(msg)) { 223 if (msg_isdata(msg)) {
224 if (msg_mcast(msg)) 224 if (msg_mcast(msg))
225 tipc_port_recv_mcast(buf, NULL); 225 tipc_port_recv_mcast(buf, NULL);
@@ -277,7 +277,7 @@ int tipc_net_start(u32 addr)
277 277
278 info("Started in network mode\n"); 278 info("Started in network mode\n");
279 info("Own node address %s, network identity %u\n", 279 info("Own node address %s, network identity %u\n",
280 addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); 280 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
281 return 0; 281 return 0;
282} 282}
283 283
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 17cc394f424f..b634942caba5 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -268,7 +268,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
268 268
269 if (n_ptr->link_cnt >= 2) { 269 if (n_ptr->link_cnt >= 2) {
270 err("Attempt to create third link to %s\n", 270 err("Attempt to create third link to %s\n",
271 addr_string_fill(addr_string, n_ptr->addr)); 271 tipc_addr_string_fill(addr_string, n_ptr->addr));
272 return NULL; 272 return NULL;
273 } 273 }
274 274
@@ -280,7 +280,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
280 } 280 }
281 err("Attempt to establish second link on <%s> to %s\n", 281 err("Attempt to establish second link on <%s> to %s\n",
282 l_ptr->b_ptr->publ.name, 282 l_ptr->b_ptr->publ.name,
283 addr_string_fill(addr_string, l_ptr->addr)); 283 tipc_addr_string_fill(addr_string, l_ptr->addr));
284 } 284 }
285 return NULL; 285 return NULL;
286} 286}
@@ -439,7 +439,7 @@ static void node_lost_contact(struct tipc_node *n_ptr)
439 return; 439 return;
440 440
441 info("Lost contact with %s\n", 441 info("Lost contact with %s\n",
442 addr_string_fill(addr_string, n_ptr->addr)); 442 tipc_addr_string_fill(addr_string, n_ptr->addr));
443 443
444 /* Abort link changeover */ 444 /* Abort link changeover */
445 for (i = 0; i < MAX_BEARERS; i++) { 445 for (i = 0; i < MAX_BEARERS; i++) {
@@ -602,7 +602,7 @@ u32 tipc_available_nodes(const u32 domain)
602 602
603 read_lock_bh(&tipc_net_lock); 603 read_lock_bh(&tipc_net_lock);
604 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { 604 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
605 if (!in_scope(domain, n_ptr->addr)) 605 if (!tipc_in_scope(domain, n_ptr->addr))
606 continue; 606 continue;
607 if (tipc_node_is_up(n_ptr)) 607 if (tipc_node_is_up(n_ptr))
608 cnt++; 608 cnt++;
@@ -651,7 +651,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
651 /* Add TLVs for all nodes in scope */ 651 /* Add TLVs for all nodes in scope */
652 652
653 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { 653 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
654 if (!in_scope(domain, n_ptr->addr)) 654 if (!tipc_in_scope(domain, n_ptr->addr))
655 continue; 655 continue;
656 node_info.addr = htonl(n_ptr->addr); 656 node_info.addr = htonl(n_ptr->addr);
657 node_info.up = htonl(tipc_node_is_up(n_ptr)); 657 node_info.up = htonl(tipc_node_is_up(n_ptr));
@@ -711,7 +711,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
711 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { 711 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
712 u32 i; 712 u32 i;
713 713
714 if (!in_scope(domain, n_ptr->addr)) 714 if (!tipc_in_scope(domain, n_ptr->addr))
715 continue; 715 continue;
716 tipc_node_lock(n_ptr); 716 tipc_node_lock(n_ptr);
717 for (i = 0; i < MAX_BEARERS; i++) { 717 for (i = 0; i < MAX_BEARERS; i++) {
diff --git a/net/tipc/port.c b/net/tipc/port.c
index e70d27ea6578..0737680e9266 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -116,7 +116,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
116 msg_set_namelower(hdr, seq->lower); 116 msg_set_namelower(hdr, seq->lower);
117 msg_set_nameupper(hdr, seq->upper); 117 msg_set_nameupper(hdr, seq->upper);
118 msg_set_hdr_sz(hdr, MCAST_H_SIZE); 118 msg_set_hdr_sz(hdr, MCAST_H_SIZE);
119 res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, 119 res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE,
120 !oport->user_port, &buf); 120 !oport->user_port, &buf);
121 if (unlikely(!buf)) 121 if (unlikely(!buf))
122 return res; 122 return res;
@@ -241,13 +241,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
241 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 241 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT;
242 p_ptr->publ.ref = ref; 242 p_ptr->publ.ref = ref;
243 msg = &p_ptr->publ.phdr; 243 msg = &p_ptr->publ.phdr;
244 msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); 244 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0);
245 msg_set_origport(msg, ref); 245 msg_set_origport(msg, ref);
246 p_ptr->last_in_seqno = 41; 246 p_ptr->last_in_seqno = 41;
247 p_ptr->sent = 1; 247 p_ptr->sent = 1;
248 INIT_LIST_HEAD(&p_ptr->wait_list); 248 INIT_LIST_HEAD(&p_ptr->wait_list);
249 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); 249 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
250 p_ptr->congested_link = NULL;
251 p_ptr->dispatcher = dispatcher; 250 p_ptr->dispatcher = dispatcher;
252 p_ptr->wakeup = wakeup; 251 p_ptr->wakeup = wakeup;
253 p_ptr->user_port = NULL; 252 p_ptr->user_port = NULL;
@@ -396,7 +395,7 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
396 buf = buf_acquire(LONG_H_SIZE); 395 buf = buf_acquire(LONG_H_SIZE);
397 if (buf) { 396 if (buf) {
398 msg = buf_msg(buf); 397 msg = buf_msg(buf);
399 msg_init(msg, usr, type, LONG_H_SIZE, destnode); 398 tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode);
400 msg_set_errcode(msg, err); 399 msg_set_errcode(msg, err);
401 msg_set_destport(msg, destport); 400 msg_set_destport(msg, destport);
402 msg_set_origport(msg, origport); 401 msg_set_origport(msg, origport);
@@ -440,7 +439,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
440 return data_sz; 439 return data_sz;
441 } 440 }
442 rmsg = buf_msg(rbuf); 441 rmsg = buf_msg(rbuf);
443 msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg)); 442 tipc_msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg));
444 msg_set_errcode(rmsg, err); 443 msg_set_errcode(rmsg, err);
445 msg_set_destport(rmsg, msg_origport(msg)); 444 msg_set_destport(rmsg, msg_origport(msg));
446 msg_set_origport(rmsg, msg_destport(msg)); 445 msg_set_origport(rmsg, msg_destport(msg));
@@ -481,7 +480,7 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
481 struct sk_buff *buf; 480 struct sk_buff *buf;
482 int res; 481 int res;
483 482
484 res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, 483 res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE,
485 !p_ptr->user_port, &buf); 484 !p_ptr->user_port, &buf);
486 if (!buf) 485 if (!buf)
487 return res; 486 return res;
@@ -1344,7 +1343,7 @@ int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
1344 struct sk_buff *buf; 1343 struct sk_buff *buf;
1345 int res; 1344 int res;
1346 1345
1347 res = msg_build(&sender->publ.phdr, msg_sect, num_sect, 1346 res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect,
1348 MAX_MSG_SIZE, !sender->user_port, &buf); 1347 MAX_MSG_SIZE, !sender->user_port, &buf);
1349 if (likely(buf)) 1348 if (likely(buf))
1350 tipc_port_recv_msg(buf); 1349 tipc_port_recv_msg(buf);
@@ -1384,7 +1383,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1384 if (port_unreliable(p_ptr)) { 1383 if (port_unreliable(p_ptr)) {
1385 p_ptr->publ.congested = 0; 1384 p_ptr->publ.congested = 0;
1386 /* Just calculate msg length and return */ 1385 /* Just calculate msg length and return */
1387 return msg_calc_data_size(msg_sect, num_sect); 1386 return tipc_msg_calc_data_size(msg_sect, num_sect);
1388 } 1387 }
1389 return -ELINKCONG; 1388 return -ELINKCONG;
1390} 1389}
@@ -1453,7 +1452,7 @@ int tipc_forward2name(u32 ref,
1453 struct port *p_ptr; 1452 struct port *p_ptr;
1454 struct tipc_msg *msg; 1453 struct tipc_msg *msg;
1455 u32 destnode = domain; 1454 u32 destnode = domain;
1456 u32 destport = 0; 1455 u32 destport;
1457 int res; 1456 int res;
1458 1457
1459 p_ptr = tipc_port_deref(ref); 1458 p_ptr = tipc_port_deref(ref);
@@ -1467,7 +1466,7 @@ int tipc_forward2name(u32 ref,
1467 msg_set_hdr_sz(msg, LONG_H_SIZE); 1466 msg_set_hdr_sz(msg, LONG_H_SIZE);
1468 msg_set_nametype(msg, name->type); 1467 msg_set_nametype(msg, name->type);
1469 msg_set_nameinst(msg, name->instance); 1468 msg_set_nameinst(msg, name->instance);
1470 msg_set_lookup_scope(msg, addr_scope(domain)); 1469 msg_set_lookup_scope(msg, tipc_addr_scope(domain));
1471 if (importance <= TIPC_CRITICAL_IMPORTANCE) 1470 if (importance <= TIPC_CRITICAL_IMPORTANCE)
1472 msg_set_importance(msg,importance); 1471 msg_set_importance(msg,importance);
1473 destport = tipc_nametbl_translate(name->type, name->instance, &destnode); 1472 destport = tipc_nametbl_translate(name->type, name->instance, &destnode);
@@ -1484,7 +1483,7 @@ int tipc_forward2name(u32 ref,
1484 return res; 1483 return res;
1485 if (port_unreliable(p_ptr)) { 1484 if (port_unreliable(p_ptr)) {
1486 /* Just calculate msg length and return */ 1485 /* Just calculate msg length and return */
1487 return msg_calc_data_size(msg_sect, num_sect); 1486 return tipc_msg_calc_data_size(msg_sect, num_sect);
1488 } 1487 }
1489 return -ELINKCONG; 1488 return -ELINKCONG;
1490 } 1489 }
@@ -1525,7 +1524,7 @@ int tipc_forward_buf2name(u32 ref,
1525 struct port *p_ptr; 1524 struct port *p_ptr;
1526 struct tipc_msg *msg; 1525 struct tipc_msg *msg;
1527 u32 destnode = domain; 1526 u32 destnode = domain;
1528 u32 destport = 0; 1527 u32 destport;
1529 int res; 1528 int res;
1530 1529
1531 p_ptr = (struct port *)tipc_ref_deref(ref); 1530 p_ptr = (struct port *)tipc_ref_deref(ref);
@@ -1540,7 +1539,7 @@ int tipc_forward_buf2name(u32 ref,
1540 msg_set_origport(msg, orig->ref); 1539 msg_set_origport(msg, orig->ref);
1541 msg_set_nametype(msg, name->type); 1540 msg_set_nametype(msg, name->type);
1542 msg_set_nameinst(msg, name->instance); 1541 msg_set_nameinst(msg, name->instance);
1543 msg_set_lookup_scope(msg, addr_scope(domain)); 1542 msg_set_lookup_scope(msg, tipc_addr_scope(domain));
1544 msg_set_hdr_sz(msg, LONG_H_SIZE); 1543 msg_set_hdr_sz(msg, LONG_H_SIZE);
1545 msg_set_size(msg, LONG_H_SIZE + dsz); 1544 msg_set_size(msg, LONG_H_SIZE + dsz);
1546 destport = tipc_nametbl_translate(name->type, name->instance, &destnode); 1545 destport = tipc_nametbl_translate(name->type, name->instance, &destnode);
@@ -1620,7 +1619,7 @@ int tipc_forward2port(u32 ref,
1620 return res; 1619 return res;
1621 if (port_unreliable(p_ptr)) { 1620 if (port_unreliable(p_ptr)) {
1622 /* Just calculate msg length and return */ 1621 /* Just calculate msg length and return */
1623 return msg_calc_data_size(msg_sect, num_sect); 1622 return tipc_msg_calc_data_size(msg_sect, num_sect);
1624 } 1623 }
1625 return -ELINKCONG; 1624 return -ELINKCONG;
1626} 1625}
diff --git a/net/tipc/port.h b/net/tipc/port.h
index ff31ee4a1dc3..8d1652aab298 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -75,7 +75,6 @@ struct user_port {
75 * @wakeup: ptr to routine to call when port is no longer congested 75 * @wakeup: ptr to routine to call when port is no longer congested
76 * @user_port: ptr to user port associated with port (if any) 76 * @user_port: ptr to user port associated with port (if any)
77 * @wait_list: adjacent ports in list of ports waiting on link congestion 77 * @wait_list: adjacent ports in list of ports waiting on link congestion
78 * @congested_link: ptr to congested link port is waiting on
79 * @waiting_pkts: 78 * @waiting_pkts:
80 * @sent: 79 * @sent:
81 * @acked: 80 * @acked:
@@ -95,7 +94,6 @@ struct port {
95 void (*wakeup)(struct tipc_port *); 94 void (*wakeup)(struct tipc_port *);
96 struct user_port *user_port; 95 struct user_port *user_port;
97 struct list_head wait_list; 96 struct list_head wait_list;
98 struct link *congested_link;
99 u32 waiting_pkts; 97 u32 waiting_pkts;
100 u32 sent; 98 u32 sent;
101 u32 acked; 99 u32 acked;