diff options
author | David S. Miller <davem@davemloft.net> | 2013-10-18 13:22:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-18 13:22:19 -0400 |
commit | ace0d5d8bf8a69866e4394ca2e4c5d1296ef7db2 (patch) | |
tree | d12bae2180f77b4dc48580bf5a85b995f1f4909c | |
parent | 7cc7c5e54b7128195a1403747a63971c3c3f8e25 (diff) | |
parent | bbfbe47cc99ce093708aaf28b7f2c08d28045c67 (diff) |
Merge branch 'tipc'
Jon Maloy says:
====================
Some small and relatively straightforward patches. With exception of
the two first ones they are all unrelated and address minor issues.
v2: update of v1 (http://patchwork.ozlabs.org/patch/277404/)
-added commit to use memcpy_fromiovec on user data as per v1 feedback
-updated sparse fix commit to drop chunks covered by above commit
-added new commit that greatly simplifies the link lookup routine
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/bearer.c | 18 | ||||
-rw-r--r-- | net/tipc/bearer.h | 10 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 68 | ||||
-rw-r--r-- | net/tipc/ib_media.c | 58 | ||||
-rw-r--r-- | net/tipc/link.c | 167 | ||||
-rw-r--r-- | net/tipc/link.h | 4 | ||||
-rw-r--r-- | net/tipc/msg.c | 27 | ||||
-rw-r--r-- | net/tipc/msg.h | 3 | ||||
-rw-r--r-- | net/tipc/port.c | 66 | ||||
-rw-r--r-- | net/tipc/port.h | 16 | ||||
-rw-r--r-- | net/tipc/socket.c | 12 |
11 files changed, 167 insertions, 282 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 609c30c80816..3f9707a16d06 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -387,7 +387,7 @@ restart: | |||
387 | 387 | ||
388 | b_ptr = &tipc_bearers[bearer_id]; | 388 | b_ptr = &tipc_bearers[bearer_id]; |
389 | strcpy(b_ptr->name, name); | 389 | strcpy(b_ptr->name, name); |
390 | res = m_ptr->enable_bearer(b_ptr); | 390 | res = m_ptr->enable_media(b_ptr); |
391 | if (res) { | 391 | if (res) { |
392 | pr_warn("Bearer <%s> rejected, enable failure (%d)\n", | 392 | pr_warn("Bearer <%s> rejected, enable failure (%d)\n", |
393 | name, -res); | 393 | name, -res); |
@@ -420,23 +420,15 @@ exit: | |||
420 | } | 420 | } |
421 | 421 | ||
422 | /** | 422 | /** |
423 | * tipc_block_bearer - Block the bearer with the given name, and reset all its links | 423 | * tipc_block_bearer - Block the bearer, and reset all its links |
424 | */ | 424 | */ |
425 | int tipc_block_bearer(const char *name) | 425 | int tipc_block_bearer(struct tipc_bearer *b_ptr) |
426 | { | 426 | { |
427 | struct tipc_bearer *b_ptr = NULL; | ||
428 | struct tipc_link *l_ptr; | 427 | struct tipc_link *l_ptr; |
429 | struct tipc_link *temp_l_ptr; | 428 | struct tipc_link *temp_l_ptr; |
430 | 429 | ||
431 | read_lock_bh(&tipc_net_lock); | 430 | read_lock_bh(&tipc_net_lock); |
432 | b_ptr = tipc_bearer_find(name); | 431 | pr_info("Blocking bearer <%s>\n", b_ptr->name); |
433 | if (!b_ptr) { | ||
434 | pr_warn("Attempt to block unknown bearer <%s>\n", name); | ||
435 | read_unlock_bh(&tipc_net_lock); | ||
436 | return -EINVAL; | ||
437 | } | ||
438 | |||
439 | pr_info("Blocking bearer <%s>\n", name); | ||
440 | spin_lock_bh(&b_ptr->lock); | 432 | spin_lock_bh(&b_ptr->lock); |
441 | b_ptr->blocked = 1; | 433 | b_ptr->blocked = 1; |
442 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 434 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
@@ -465,7 +457,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr) | |||
465 | pr_info("Disabling bearer <%s>\n", b_ptr->name); | 457 | pr_info("Disabling bearer <%s>\n", b_ptr->name); |
466 | spin_lock_bh(&b_ptr->lock); | 458 | spin_lock_bh(&b_ptr->lock); |
467 | b_ptr->blocked = 1; | 459 | b_ptr->blocked = 1; |
468 | b_ptr->media->disable_bearer(b_ptr); | 460 | b_ptr->media->disable_media(b_ptr); |
469 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 461 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
470 | tipc_link_delete(l_ptr); | 462 | tipc_link_delete(l_ptr); |
471 | } | 463 | } |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 09c869adcfcf..e5e04be6fffa 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -75,8 +75,8 @@ struct tipc_bearer; | |||
75 | /** | 75 | /** |
76 | * struct tipc_media - TIPC media information available to internal users | 76 | * struct tipc_media - TIPC media information available to internal users |
77 | * @send_msg: routine which handles buffer transmission | 77 | * @send_msg: routine which handles buffer transmission |
78 | * @enable_bearer: routine which enables a bearer | 78 | * @enable_media: routine which enables a media |
79 | * @disable_bearer: routine which disables a bearer | 79 | * @disable_media: routine which disables a media |
80 | * @addr2str: routine which converts media address to string | 80 | * @addr2str: routine which converts media address to string |
81 | * @addr2msg: routine which converts media address to protocol message area | 81 | * @addr2msg: routine which converts media address to protocol message area |
82 | * @msg2addr: routine which converts media address from protocol message area | 82 | * @msg2addr: routine which converts media address from protocol message area |
@@ -91,8 +91,8 @@ struct tipc_media { | |||
91 | int (*send_msg)(struct sk_buff *buf, | 91 | int (*send_msg)(struct sk_buff *buf, |
92 | struct tipc_bearer *b_ptr, | 92 | struct tipc_bearer *b_ptr, |
93 | struct tipc_media_addr *dest); | 93 | struct tipc_media_addr *dest); |
94 | int (*enable_bearer)(struct tipc_bearer *b_ptr); | 94 | int (*enable_media)(struct tipc_bearer *b_ptr); |
95 | void (*disable_bearer)(struct tipc_bearer *b_ptr); | 95 | void (*disable_media)(struct tipc_bearer *b_ptr); |
96 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); | 96 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); |
97 | int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); | 97 | int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); |
98 | int (*msg2addr)(const struct tipc_bearer *b_ptr, | 98 | int (*msg2addr)(const struct tipc_bearer *b_ptr, |
@@ -163,7 +163,7 @@ int tipc_register_media(struct tipc_media *m_ptr); | |||
163 | 163 | ||
164 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); | 164 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); |
165 | 165 | ||
166 | int tipc_block_bearer(const char *name); | 166 | int tipc_block_bearer(struct tipc_bearer *b_ptr); |
167 | void tipc_continue(struct tipc_bearer *tb_ptr); | 167 | void tipc_continue(struct tipc_bearer *tb_ptr); |
168 | 168 | ||
169 | int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority); | 169 | int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority); |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 40ea40cf6204..f80d59f5a161 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC | 2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2007, Ericsson AB | 4 | * Copyright (c) 2001-2007, Ericsson AB |
5 | * Copyright (c) 2005-2008, 2011, Wind River Systems | 5 | * Copyright (c) 2005-2008, 2011-2013, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -37,19 +37,19 @@ | |||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "bearer.h" | 38 | #include "bearer.h" |
39 | 39 | ||
40 | #define MAX_ETH_BEARERS MAX_BEARERS | 40 | #define MAX_ETH_MEDIA MAX_BEARERS |
41 | 41 | ||
42 | #define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */ | 42 | #define ETH_ADDR_OFFSET 4 /* message header offset of MAC address */ |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * struct eth_bearer - Ethernet bearer data structure | 45 | * struct eth_media - Ethernet bearer data structure |
46 | * @bearer: ptr to associated "generic" bearer structure | 46 | * @bearer: ptr to associated "generic" bearer structure |
47 | * @dev: ptr to associated Ethernet network device | 47 | * @dev: ptr to associated Ethernet network device |
48 | * @tipc_packet_type: used in binding TIPC to Ethernet driver | 48 | * @tipc_packet_type: used in binding TIPC to Ethernet driver |
49 | * @setup: work item used when enabling bearer | 49 | * @setup: work item used when enabling bearer |
50 | * @cleanup: work item used when disabling bearer | 50 | * @cleanup: work item used when disabling bearer |
51 | */ | 51 | */ |
52 | struct eth_bearer { | 52 | struct eth_media { |
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; |
@@ -58,7 +58,7 @@ struct eth_bearer { | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | static struct tipc_media eth_media_info; | 60 | static struct tipc_media eth_media_info; |
61 | static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; | 61 | static struct eth_media eth_media_array[MAX_ETH_MEDIA]; |
62 | static int eth_started; | 62 | static int eth_started; |
63 | 63 | ||
64 | static int recv_notification(struct notifier_block *nb, unsigned long evt, | 64 | static int recv_notification(struct notifier_block *nb, unsigned long evt, |
@@ -100,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
100 | if (!clone) | 100 | if (!clone) |
101 | return 0; | 101 | return 0; |
102 | 102 | ||
103 | dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; | 103 | dev = ((struct eth_media *)(tb_ptr->usr_handle))->dev; |
104 | delta = dev->hard_header_len - skb_headroom(buf); | 104 | delta = dev->hard_header_len - skb_headroom(buf); |
105 | 105 | ||
106 | if ((delta > 0) && | 106 | if ((delta > 0) && |
@@ -128,43 +128,43 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
128 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | 128 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, |
129 | struct packet_type *pt, struct net_device *orig_dev) | 129 | struct packet_type *pt, struct net_device *orig_dev) |
130 | { | 130 | { |
131 | struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; | 131 | struct eth_media *eb_ptr = (struct eth_media *)pt->af_packet_priv; |
132 | 132 | ||
133 | if (!net_eq(dev_net(dev), &init_net)) { | 133 | if (!net_eq(dev_net(dev), &init_net)) { |
134 | kfree_skb(buf); | 134 | kfree_skb(buf); |
135 | return 0; | 135 | return NET_RX_DROP; |
136 | } | 136 | } |
137 | 137 | ||
138 | if (likely(eb_ptr->bearer)) { | 138 | if (likely(eb_ptr->bearer)) { |
139 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | 139 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { |
140 | buf->next = NULL; | 140 | buf->next = NULL; |
141 | tipc_recv_msg(buf, eb_ptr->bearer); | 141 | tipc_recv_msg(buf, eb_ptr->bearer); |
142 | return 0; | 142 | return NET_RX_SUCCESS; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | kfree_skb(buf); | 145 | kfree_skb(buf); |
146 | return 0; | 146 | return NET_RX_DROP; |
147 | } | 147 | } |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * setup_bearer - setup association between Ethernet bearer and interface | 150 | * setup_media - setup association between Ethernet bearer and interface |
151 | */ | 151 | */ |
152 | static void setup_bearer(struct work_struct *work) | 152 | static void setup_media(struct work_struct *work) |
153 | { | 153 | { |
154 | struct eth_bearer *eb_ptr = | 154 | struct eth_media *eb_ptr = |
155 | container_of(work, struct eth_bearer, setup); | 155 | container_of(work, struct eth_media, setup); |
156 | 156 | ||
157 | dev_add_pack(&eb_ptr->tipc_packet_type); | 157 | dev_add_pack(&eb_ptr->tipc_packet_type); |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * enable_bearer - attach TIPC bearer to an Ethernet interface | 161 | * enable_media - attach TIPC bearer to an Ethernet interface |
162 | */ | 162 | */ |
163 | static int enable_bearer(struct tipc_bearer *tb_ptr) | 163 | static int enable_media(struct tipc_bearer *tb_ptr) |
164 | { | 164 | { |
165 | struct net_device *dev; | 165 | struct net_device *dev; |
166 | struct eth_bearer *eb_ptr = ð_bearers[0]; | 166 | struct eth_media *eb_ptr = ð_media_array[0]; |
167 | struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS]; | 167 | struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA]; |
168 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; | 168 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; |
169 | int pending_dev = 0; | 169 | int pending_dev = 0; |
170 | 170 | ||
@@ -188,7 +188,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
188 | eb_ptr->tipc_packet_type.func = recv_msg; | 188 | eb_ptr->tipc_packet_type.func = recv_msg; |
189 | eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr; | 189 | eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr; |
190 | INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list)); | 190 | INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list)); |
191 | INIT_WORK(&eb_ptr->setup, setup_bearer); | 191 | INIT_WORK(&eb_ptr->setup, setup_media); |
192 | schedule_work(&eb_ptr->setup); | 192 | schedule_work(&eb_ptr->setup); |
193 | 193 | ||
194 | /* Associate TIPC bearer with Ethernet bearer */ | 194 | /* Associate TIPC bearer with Ethernet bearer */ |
@@ -205,14 +205,14 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
205 | } | 205 | } |
206 | 206 | ||
207 | /** | 207 | /** |
208 | * cleanup_bearer - break association between Ethernet bearer and interface | 208 | * cleanup_media - break association between Ethernet bearer and interface |
209 | * | 209 | * |
210 | * This routine must be invoked from a work queue because it can sleep. | 210 | * This routine must be invoked from a work queue because it can sleep. |
211 | */ | 211 | */ |
212 | static void cleanup_bearer(struct work_struct *work) | 212 | static void cleanup_media(struct work_struct *work) |
213 | { | 213 | { |
214 | struct eth_bearer *eb_ptr = | 214 | struct eth_media *eb_ptr = |
215 | container_of(work, struct eth_bearer, cleanup); | 215 | container_of(work, struct eth_media, cleanup); |
216 | 216 | ||
217 | dev_remove_pack(&eb_ptr->tipc_packet_type); | 217 | dev_remove_pack(&eb_ptr->tipc_packet_type); |
218 | dev_put(eb_ptr->dev); | 218 | dev_put(eb_ptr->dev); |
@@ -220,18 +220,18 @@ static void cleanup_bearer(struct work_struct *work) | |||
220 | } | 220 | } |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * disable_bearer - detach TIPC bearer from an Ethernet interface | 223 | * disable_media - detach TIPC bearer from an Ethernet interface |
224 | * | 224 | * |
225 | * Mark Ethernet bearer as inactive so that incoming buffers are thrown away, | 225 | * Mark Ethernet bearer as inactive so that incoming buffers are thrown away, |
226 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | 226 | * then get worker thread to complete bearer cleanup. (Can't do cleanup |
227 | * here because cleanup code needs to sleep and caller holds spinlocks.) | 227 | * here because cleanup code needs to sleep and caller holds spinlocks.) |
228 | */ | 228 | */ |
229 | static void disable_bearer(struct tipc_bearer *tb_ptr) | 229 | static void disable_media(struct tipc_bearer *tb_ptr) |
230 | { | 230 | { |
231 | struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle; | 231 | struct eth_media *eb_ptr = (struct eth_media *)tb_ptr->usr_handle; |
232 | 232 | ||
233 | eb_ptr->bearer = NULL; | 233 | eb_ptr->bearer = NULL; |
234 | INIT_WORK(&eb_ptr->cleanup, cleanup_bearer); | 234 | INIT_WORK(&eb_ptr->cleanup, cleanup_media); |
235 | schedule_work(&eb_ptr->cleanup); | 235 | schedule_work(&eb_ptr->cleanup); |
236 | } | 236 | } |
237 | 237 | ||
@@ -245,8 +245,8 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
245 | void *ptr) | 245 | void *ptr) |
246 | { | 246 | { |
247 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | 247 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
248 | struct eth_bearer *eb_ptr = ð_bearers[0]; | 248 | struct eth_media *eb_ptr = ð_media_array[0]; |
249 | struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS]; | 249 | struct eth_media *stop = ð_media_array[MAX_ETH_MEDIA]; |
250 | 250 | ||
251 | if (!net_eq(dev_net(dev), &init_net)) | 251 | if (!net_eq(dev_net(dev), &init_net)) |
252 | return NOTIFY_DONE; | 252 | return NOTIFY_DONE; |
@@ -265,17 +265,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
265 | if (netif_carrier_ok(dev)) | 265 | if (netif_carrier_ok(dev)) |
266 | tipc_continue(eb_ptr->bearer); | 266 | tipc_continue(eb_ptr->bearer); |
267 | else | 267 | else |
268 | tipc_block_bearer(eb_ptr->bearer->name); | 268 | tipc_block_bearer(eb_ptr->bearer); |
269 | break; | 269 | break; |
270 | case NETDEV_UP: | 270 | case NETDEV_UP: |
271 | tipc_continue(eb_ptr->bearer); | 271 | tipc_continue(eb_ptr->bearer); |
272 | break; | 272 | break; |
273 | case NETDEV_DOWN: | 273 | case NETDEV_DOWN: |
274 | tipc_block_bearer(eb_ptr->bearer->name); | 274 | tipc_block_bearer(eb_ptr->bearer); |
275 | break; | 275 | break; |
276 | case NETDEV_CHANGEMTU: | 276 | case NETDEV_CHANGEMTU: |
277 | case NETDEV_CHANGEADDR: | 277 | case NETDEV_CHANGEADDR: |
278 | tipc_block_bearer(eb_ptr->bearer->name); | 278 | tipc_block_bearer(eb_ptr->bearer); |
279 | tipc_continue(eb_ptr->bearer); | 279 | tipc_continue(eb_ptr->bearer); |
280 | break; | 280 | break; |
281 | case NETDEV_UNREGISTER: | 281 | case NETDEV_UNREGISTER: |
@@ -327,8 +327,8 @@ static int eth_msg2addr(const struct tipc_bearer *tb_ptr, | |||
327 | */ | 327 | */ |
328 | static struct tipc_media eth_media_info = { | 328 | static struct tipc_media eth_media_info = { |
329 | .send_msg = send_msg, | 329 | .send_msg = send_msg, |
330 | .enable_bearer = enable_bearer, | 330 | .enable_media = enable_media, |
331 | .disable_bearer = disable_bearer, | 331 | .disable_media = disable_media, |
332 | .addr2str = eth_addr2str, | 332 | .addr2str = eth_addr2str, |
333 | .addr2msg = eth_addr2msg, | 333 | .addr2msg = eth_addr2msg, |
334 | .msg2addr = eth_msg2addr, | 334 | .msg2addr = eth_msg2addr, |
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c index 9934a32bfa87..c13989297464 100644 --- a/net/tipc/ib_media.c +++ b/net/tipc/ib_media.c | |||
@@ -42,17 +42,17 @@ | |||
42 | #include "core.h" | 42 | #include "core.h" |
43 | #include "bearer.h" | 43 | #include "bearer.h" |
44 | 44 | ||
45 | #define MAX_IB_BEARERS MAX_BEARERS | 45 | #define MAX_IB_MEDIA MAX_BEARERS |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * struct ib_bearer - Infiniband bearer data structure | 48 | * struct ib_media - Infiniband media data structure |
49 | * @bearer: ptr to associated "generic" bearer structure | 49 | * @bearer: ptr to associated "generic" bearer structure |
50 | * @dev: ptr to associated Infiniband network device | 50 | * @dev: ptr to associated Infiniband network device |
51 | * @tipc_packet_type: used in binding TIPC to Infiniband driver | 51 | * @tipc_packet_type: used in binding TIPC to Infiniband driver |
52 | * @cleanup: work item used when disabling bearer | 52 | * @cleanup: work item used when disabling bearer |
53 | */ | 53 | */ |
54 | 54 | ||
55 | struct ib_bearer { | 55 | struct ib_media { |
56 | struct tipc_bearer *bearer; | 56 | struct tipc_bearer *bearer; |
57 | struct net_device *dev; | 57 | struct net_device *dev; |
58 | struct packet_type tipc_packet_type; | 58 | struct packet_type tipc_packet_type; |
@@ -61,7 +61,7 @@ struct ib_bearer { | |||
61 | }; | 61 | }; |
62 | 62 | ||
63 | static struct tipc_media ib_media_info; | 63 | static struct tipc_media ib_media_info; |
64 | static struct ib_bearer ib_bearers[MAX_IB_BEARERS]; | 64 | static struct ib_media ib_media_array[MAX_IB_MEDIA]; |
65 | static int ib_started; | 65 | static int ib_started; |
66 | 66 | ||
67 | /** | 67 | /** |
@@ -93,7 +93,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
93 | if (!clone) | 93 | if (!clone) |
94 | return 0; | 94 | return 0; |
95 | 95 | ||
96 | dev = ((struct ib_bearer *)(tb_ptr->usr_handle))->dev; | 96 | dev = ((struct ib_media *)(tb_ptr->usr_handle))->dev; |
97 | delta = dev->hard_header_len - skb_headroom(buf); | 97 | delta = dev->hard_header_len - skb_headroom(buf); |
98 | 98 | ||
99 | if ((delta > 0) && | 99 | if ((delta > 0) && |
@@ -121,43 +121,43 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
121 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | 121 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, |
122 | struct packet_type *pt, struct net_device *orig_dev) | 122 | struct packet_type *pt, struct net_device *orig_dev) |
123 | { | 123 | { |
124 | struct ib_bearer *ib_ptr = (struct ib_bearer *)pt->af_packet_priv; | 124 | struct ib_media *ib_ptr = (struct ib_media *)pt->af_packet_priv; |
125 | 125 | ||
126 | if (!net_eq(dev_net(dev), &init_net)) { | 126 | if (!net_eq(dev_net(dev), &init_net)) { |
127 | kfree_skb(buf); | 127 | kfree_skb(buf); |
128 | return 0; | 128 | return NET_RX_DROP; |
129 | } | 129 | } |
130 | 130 | ||
131 | if (likely(ib_ptr->bearer)) { | 131 | if (likely(ib_ptr->bearer)) { |
132 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | 132 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { |
133 | buf->next = NULL; | 133 | buf->next = NULL; |
134 | tipc_recv_msg(buf, ib_ptr->bearer); | 134 | tipc_recv_msg(buf, ib_ptr->bearer); |
135 | return 0; | 135 | return NET_RX_SUCCESS; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | kfree_skb(buf); | 138 | kfree_skb(buf); |
139 | return 0; | 139 | return NET_RX_DROP; |
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * setup_bearer - setup association between InfiniBand bearer and interface | 143 | * setup_bearer - setup association between InfiniBand bearer and interface |
144 | */ | 144 | */ |
145 | static void setup_bearer(struct work_struct *work) | 145 | static void setup_media(struct work_struct *work) |
146 | { | 146 | { |
147 | struct ib_bearer *ib_ptr = | 147 | struct ib_media *ib_ptr = |
148 | container_of(work, struct ib_bearer, setup); | 148 | container_of(work, struct ib_media, setup); |
149 | 149 | ||
150 | dev_add_pack(&ib_ptr->tipc_packet_type); | 150 | dev_add_pack(&ib_ptr->tipc_packet_type); |
151 | } | 151 | } |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * enable_bearer - attach TIPC bearer to an InfiniBand interface | 154 | * enable_media - attach TIPC bearer to an InfiniBand interface |
155 | */ | 155 | */ |
156 | static int enable_bearer(struct tipc_bearer *tb_ptr) | 156 | static int enable_media(struct tipc_bearer *tb_ptr) |
157 | { | 157 | { |
158 | struct net_device *dev; | 158 | struct net_device *dev; |
159 | struct ib_bearer *ib_ptr = &ib_bearers[0]; | 159 | struct ib_media *ib_ptr = &ib_media_array[0]; |
160 | struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS]; | 160 | struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA]; |
161 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; | 161 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; |
162 | int pending_dev = 0; | 162 | int pending_dev = 0; |
163 | 163 | ||
@@ -181,7 +181,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
181 | ib_ptr->tipc_packet_type.func = recv_msg; | 181 | ib_ptr->tipc_packet_type.func = recv_msg; |
182 | ib_ptr->tipc_packet_type.af_packet_priv = ib_ptr; | 182 | ib_ptr->tipc_packet_type.af_packet_priv = ib_ptr; |
183 | INIT_LIST_HEAD(&(ib_ptr->tipc_packet_type.list)); | 183 | INIT_LIST_HEAD(&(ib_ptr->tipc_packet_type.list)); |
184 | INIT_WORK(&ib_ptr->setup, setup_bearer); | 184 | INIT_WORK(&ib_ptr->setup, setup_media); |
185 | schedule_work(&ib_ptr->setup); | 185 | schedule_work(&ib_ptr->setup); |
186 | 186 | ||
187 | /* Associate TIPC bearer with InfiniBand bearer */ | 187 | /* Associate TIPC bearer with InfiniBand bearer */ |
@@ -204,8 +204,8 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
204 | */ | 204 | */ |
205 | static void cleanup_bearer(struct work_struct *work) | 205 | static void cleanup_bearer(struct work_struct *work) |
206 | { | 206 | { |
207 | struct ib_bearer *ib_ptr = | 207 | struct ib_media *ib_ptr = |
208 | container_of(work, struct ib_bearer, cleanup); | 208 | container_of(work, struct ib_media, cleanup); |
209 | 209 | ||
210 | dev_remove_pack(&ib_ptr->tipc_packet_type); | 210 | dev_remove_pack(&ib_ptr->tipc_packet_type); |
211 | dev_put(ib_ptr->dev); | 211 | dev_put(ib_ptr->dev); |
@@ -213,15 +213,15 @@ static void cleanup_bearer(struct work_struct *work) | |||
213 | } | 213 | } |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * disable_bearer - detach TIPC bearer from an InfiniBand interface | 216 | * disable_media - detach TIPC bearer from an InfiniBand interface |
217 | * | 217 | * |
218 | * Mark InfiniBand bearer as inactive so that incoming buffers are thrown away, | 218 | * Mark InfiniBand bearer as inactive so that incoming buffers are thrown away, |
219 | * then get worker thread to complete bearer cleanup. (Can't do cleanup | 219 | * then get worker thread to complete bearer cleanup. (Can't do cleanup |
220 | * here because cleanup code needs to sleep and caller holds spinlocks.) | 220 | * here because cleanup code needs to sleep and caller holds spinlocks.) |
221 | */ | 221 | */ |
222 | static void disable_bearer(struct tipc_bearer *tb_ptr) | 222 | static void disable_media(struct tipc_bearer *tb_ptr) |
223 | { | 223 | { |
224 | struct ib_bearer *ib_ptr = (struct ib_bearer *)tb_ptr->usr_handle; | 224 | struct ib_media *ib_ptr = (struct ib_media *)tb_ptr->usr_handle; |
225 | 225 | ||
226 | ib_ptr->bearer = NULL; | 226 | ib_ptr->bearer = NULL; |
227 | INIT_WORK(&ib_ptr->cleanup, cleanup_bearer); | 227 | INIT_WORK(&ib_ptr->cleanup, cleanup_bearer); |
@@ -238,8 +238,8 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
238 | void *ptr) | 238 | void *ptr) |
239 | { | 239 | { |
240 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | 240 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
241 | struct ib_bearer *ib_ptr = &ib_bearers[0]; | 241 | struct ib_media *ib_ptr = &ib_media_array[0]; |
242 | struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS]; | 242 | struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA]; |
243 | 243 | ||
244 | if (!net_eq(dev_net(dev), &init_net)) | 244 | if (!net_eq(dev_net(dev), &init_net)) |
245 | return NOTIFY_DONE; | 245 | return NOTIFY_DONE; |
@@ -258,17 +258,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
258 | if (netif_carrier_ok(dev)) | 258 | if (netif_carrier_ok(dev)) |
259 | tipc_continue(ib_ptr->bearer); | 259 | tipc_continue(ib_ptr->bearer); |
260 | else | 260 | else |
261 | tipc_block_bearer(ib_ptr->bearer->name); | 261 | tipc_block_bearer(ib_ptr->bearer); |
262 | break; | 262 | break; |
263 | case NETDEV_UP: | 263 | case NETDEV_UP: |
264 | tipc_continue(ib_ptr->bearer); | 264 | tipc_continue(ib_ptr->bearer); |
265 | break; | 265 | break; |
266 | case NETDEV_DOWN: | 266 | case NETDEV_DOWN: |
267 | tipc_block_bearer(ib_ptr->bearer->name); | 267 | tipc_block_bearer(ib_ptr->bearer); |
268 | break; | 268 | break; |
269 | case NETDEV_CHANGEMTU: | 269 | case NETDEV_CHANGEMTU: |
270 | case NETDEV_CHANGEADDR: | 270 | case NETDEV_CHANGEADDR: |
271 | tipc_block_bearer(ib_ptr->bearer->name); | 271 | tipc_block_bearer(ib_ptr->bearer); |
272 | tipc_continue(ib_ptr->bearer); | 272 | tipc_continue(ib_ptr->bearer); |
273 | break; | 273 | break; |
274 | case NETDEV_UNREGISTER: | 274 | case NETDEV_UNREGISTER: |
@@ -323,8 +323,8 @@ static int ib_msg2addr(const struct tipc_bearer *tb_ptr, | |||
323 | */ | 323 | */ |
324 | static struct tipc_media ib_media_info = { | 324 | static struct tipc_media ib_media_info = { |
325 | .send_msg = send_msg, | 325 | .send_msg = send_msg, |
326 | .enable_bearer = enable_bearer, | 326 | .enable_media = enable_media, |
327 | .disable_bearer = disable_bearer, | 327 | .disable_media = disable_media, |
328 | .addr2str = ib_addr2str, | 328 | .addr2str = ib_addr2str, |
329 | .addr2msg = ib_addr2msg, | 329 | .addr2msg = ib_addr2msg, |
330 | .msg2addr = ib_msg2addr, | 330 | .msg2addr = ib_msg2addr, |
diff --git a/net/tipc/link.c b/net/tipc/link.c index 0cc3d9015c5d..e8153f64d2d6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -75,20 +75,6 @@ static const char *link_unk_evt = "Unknown link event "; | |||
75 | */ | 75 | */ |
76 | #define START_CHANGEOVER 100000u | 76 | #define START_CHANGEOVER 100000u |
77 | 77 | ||
78 | /** | ||
79 | * struct tipc_link_name - deconstructed link name | ||
80 | * @addr_local: network address of node at this end | ||
81 | * @if_local: name of interface at this end | ||
82 | * @addr_peer: network address of node at far end | ||
83 | * @if_peer: name of interface at far end | ||
84 | */ | ||
85 | struct tipc_link_name { | ||
86 | u32 addr_local; | ||
87 | char if_local[TIPC_MAX_IF_NAME]; | ||
88 | u32 addr_peer; | ||
89 | char if_peer[TIPC_MAX_IF_NAME]; | ||
90 | }; | ||
91 | |||
92 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | 78 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, |
93 | struct sk_buff *buf); | 79 | struct sk_buff *buf); |
94 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf); | 80 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf); |
@@ -97,8 +83,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, | |||
97 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); | 83 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); |
98 | static int link_send_sections_long(struct tipc_port *sender, | 84 | static int link_send_sections_long(struct tipc_port *sender, |
99 | struct iovec const *msg_sect, | 85 | struct iovec const *msg_sect, |
100 | u32 num_sect, unsigned int total_len, | 86 | unsigned int len, u32 destnode); |
101 | u32 destnode); | ||
102 | static void link_state_event(struct tipc_link *l_ptr, u32 event); | 87 | static void link_state_event(struct tipc_link *l_ptr, u32 event); |
103 | static void link_reset_statistics(struct tipc_link *l_ptr); | 88 | static void link_reset_statistics(struct tipc_link *l_ptr); |
104 | static void link_print(struct tipc_link *l_ptr, const char *str); | 89 | static void link_print(struct tipc_link *l_ptr, const char *str); |
@@ -161,72 +146,6 @@ int tipc_link_is_active(struct tipc_link *l_ptr) | |||
161 | } | 146 | } |
162 | 147 | ||
163 | /** | 148 | /** |
164 | * link_name_validate - validate & (optionally) deconstruct tipc_link name | ||
165 | * @name: ptr to link name string | ||
166 | * @name_parts: ptr to area for link name components (or NULL if not needed) | ||
167 | * | ||
168 | * Returns 1 if link name is valid, otherwise 0. | ||
169 | */ | ||
170 | static int link_name_validate(const char *name, | ||
171 | struct tipc_link_name *name_parts) | ||
172 | { | ||
173 | char name_copy[TIPC_MAX_LINK_NAME]; | ||
174 | char *addr_local; | ||
175 | char *if_local; | ||
176 | char *addr_peer; | ||
177 | char *if_peer; | ||
178 | char dummy; | ||
179 | u32 z_local, c_local, n_local; | ||
180 | u32 z_peer, c_peer, n_peer; | ||
181 | u32 if_local_len; | ||
182 | u32 if_peer_len; | ||
183 | |||
184 | /* copy link name & ensure length is OK */ | ||
185 | name_copy[TIPC_MAX_LINK_NAME - 1] = 0; | ||
186 | /* need above in case non-Posix strncpy() doesn't pad with nulls */ | ||
187 | strncpy(name_copy, name, TIPC_MAX_LINK_NAME); | ||
188 | if (name_copy[TIPC_MAX_LINK_NAME - 1] != 0) | ||
189 | return 0; | ||
190 | |||
191 | /* ensure all component parts of link name are present */ | ||
192 | addr_local = name_copy; | ||
193 | if_local = strchr(addr_local, ':'); | ||
194 | if (if_local == NULL) | ||
195 | return 0; | ||
196 | *(if_local++) = 0; | ||
197 | addr_peer = strchr(if_local, '-'); | ||
198 | if (addr_peer == NULL) | ||
199 | return 0; | ||
200 | *(addr_peer++) = 0; | ||
201 | if_local_len = addr_peer - if_local; | ||
202 | if_peer = strchr(addr_peer, ':'); | ||
203 | if (if_peer == NULL) | ||
204 | return 0; | ||
205 | *(if_peer++) = 0; | ||
206 | if_peer_len = strlen(if_peer) + 1; | ||
207 | |||
208 | /* validate component parts of link name */ | ||
209 | if ((sscanf(addr_local, "%u.%u.%u%c", | ||
210 | &z_local, &c_local, &n_local, &dummy) != 3) || | ||
211 | (sscanf(addr_peer, "%u.%u.%u%c", | ||
212 | &z_peer, &c_peer, &n_peer, &dummy) != 3) || | ||
213 | (z_local > 255) || (c_local > 4095) || (n_local > 4095) || | ||
214 | (z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) || | ||
215 | (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) || | ||
216 | (if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME)) | ||
217 | return 0; | ||
218 | |||
219 | /* return link name components, if necessary */ | ||
220 | if (name_parts) { | ||
221 | name_parts->addr_local = tipc_addr(z_local, c_local, n_local); | ||
222 | strcpy(name_parts->if_local, if_local); | ||
223 | name_parts->addr_peer = tipc_addr(z_peer, c_peer, n_peer); | ||
224 | strcpy(name_parts->if_peer, if_peer); | ||
225 | } | ||
226 | return 1; | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * link_timeout - handle expiration of link timer | 149 | * link_timeout - handle expiration of link timer |
231 | * @l_ptr: pointer to link | 150 | * @l_ptr: pointer to link |
232 | * | 151 | * |
@@ -1065,8 +984,7 @@ static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
1065 | */ | 984 | */ |
1066 | int tipc_link_send_sections_fast(struct tipc_port *sender, | 985 | int tipc_link_send_sections_fast(struct tipc_port *sender, |
1067 | struct iovec const *msg_sect, | 986 | struct iovec const *msg_sect, |
1068 | const u32 num_sect, unsigned int total_len, | 987 | unsigned int len, u32 destaddr) |
1069 | u32 destaddr) | ||
1070 | { | 988 | { |
1071 | struct tipc_msg *hdr = &sender->phdr; | 989 | struct tipc_msg *hdr = &sender->phdr; |
1072 | struct tipc_link *l_ptr; | 990 | struct tipc_link *l_ptr; |
@@ -1080,8 +998,7 @@ again: | |||
1080 | * Try building message using port's max_pkt hint. | 998 | * Try building message using port's max_pkt hint. |
1081 | * (Must not hold any locks while building message.) | 999 | * (Must not hold any locks while building message.) |
1082 | */ | 1000 | */ |
1083 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, | 1001 | res = tipc_msg_build(hdr, msg_sect, len, sender->max_pkt, &buf); |
1084 | sender->max_pkt, &buf); | ||
1085 | /* Exit if build request was invalid */ | 1002 | /* Exit if build request was invalid */ |
1086 | if (unlikely(res < 0)) | 1003 | if (unlikely(res < 0)) |
1087 | return res; | 1004 | return res; |
@@ -1121,8 +1038,7 @@ exit: | |||
1121 | if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt) | 1038 | if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt) |
1122 | goto again; | 1039 | goto again; |
1123 | 1040 | ||
1124 | return link_send_sections_long(sender, msg_sect, | 1041 | return link_send_sections_long(sender, msg_sect, len, |
1125 | num_sect, total_len, | ||
1126 | destaddr); | 1042 | destaddr); |
1127 | } | 1043 | } |
1128 | tipc_node_unlock(node); | 1044 | tipc_node_unlock(node); |
@@ -1133,8 +1049,8 @@ exit: | |||
1133 | if (buf) | 1049 | if (buf) |
1134 | return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); | 1050 | return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); |
1135 | if (res >= 0) | 1051 | if (res >= 0) |
1136 | return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect, | 1052 | return tipc_port_reject_sections(sender, hdr, msg_sect, |
1137 | total_len, TIPC_ERR_NO_NODE); | 1053 | len, TIPC_ERR_NO_NODE); |
1138 | return res; | 1054 | return res; |
1139 | } | 1055 | } |
1140 | 1056 | ||
@@ -1154,18 +1070,17 @@ exit: | |||
1154 | */ | 1070 | */ |
1155 | static int link_send_sections_long(struct tipc_port *sender, | 1071 | static int link_send_sections_long(struct tipc_port *sender, |
1156 | struct iovec const *msg_sect, | 1072 | struct iovec const *msg_sect, |
1157 | u32 num_sect, unsigned int total_len, | 1073 | unsigned int len, u32 destaddr) |
1158 | u32 destaddr) | ||
1159 | { | 1074 | { |
1160 | struct tipc_link *l_ptr; | 1075 | struct tipc_link *l_ptr; |
1161 | struct tipc_node *node; | 1076 | struct tipc_node *node; |
1162 | struct tipc_msg *hdr = &sender->phdr; | 1077 | struct tipc_msg *hdr = &sender->phdr; |
1163 | u32 dsz = total_len; | 1078 | u32 dsz = len; |
1164 | u32 max_pkt, fragm_sz, rest; | 1079 | u32 max_pkt, fragm_sz, rest; |
1165 | struct tipc_msg fragm_hdr; | 1080 | struct tipc_msg fragm_hdr; |
1166 | struct sk_buff *buf, *buf_chain, *prev; | 1081 | struct sk_buff *buf, *buf_chain, *prev; |
1167 | u32 fragm_crs, fragm_rest, hsz, sect_rest; | 1082 | u32 fragm_crs, fragm_rest, hsz, sect_rest; |
1168 | const unchar *sect_crs; | 1083 | const unchar __user *sect_crs; |
1169 | int curr_sect; | 1084 | int curr_sect; |
1170 | u32 fragm_no; | 1085 | u32 fragm_no; |
1171 | int res = 0; | 1086 | int res = 0; |
@@ -1207,7 +1122,7 @@ again: | |||
1207 | 1122 | ||
1208 | if (!sect_rest) { | 1123 | if (!sect_rest) { |
1209 | sect_rest = msg_sect[++curr_sect].iov_len; | 1124 | sect_rest = msg_sect[++curr_sect].iov_len; |
1210 | sect_crs = (const unchar *)msg_sect[curr_sect].iov_base; | 1125 | sect_crs = msg_sect[curr_sect].iov_base; |
1211 | } | 1126 | } |
1212 | 1127 | ||
1213 | if (sect_rest < fragm_rest) | 1128 | if (sect_rest < fragm_rest) |
@@ -1283,8 +1198,8 @@ reject: | |||
1283 | buf = buf_chain->next; | 1198 | buf = buf_chain->next; |
1284 | kfree_skb(buf_chain); | 1199 | kfree_skb(buf_chain); |
1285 | } | 1200 | } |
1286 | return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect, | 1201 | return tipc_port_reject_sections(sender, hdr, msg_sect, |
1287 | total_len, TIPC_ERR_NO_NODE); | 1202 | len, TIPC_ERR_NO_NODE); |
1288 | } | 1203 | } |
1289 | 1204 | ||
1290 | /* Append chain of fragments to send queue & send them */ | 1205 | /* Append chain of fragments to send queue & send them */ |
@@ -2585,25 +2500,21 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
2585 | static struct tipc_link *link_find_link(const char *name, | 2500 | static struct tipc_link *link_find_link(const char *name, |
2586 | struct tipc_node **node) | 2501 | struct tipc_node **node) |
2587 | { | 2502 | { |
2588 | struct tipc_link_name link_name_parts; | ||
2589 | struct tipc_bearer *b_ptr; | ||
2590 | struct tipc_link *l_ptr; | 2503 | struct tipc_link *l_ptr; |
2504 | struct tipc_node *n_ptr; | ||
2505 | int i; | ||
2591 | 2506 | ||
2592 | if (!link_name_validate(name, &link_name_parts)) | 2507 | list_for_each_entry(n_ptr, &tipc_node_list, list) { |
2593 | return NULL; | 2508 | for (i = 0; i < MAX_BEARERS; i++) { |
2594 | 2509 | l_ptr = n_ptr->links[i]; | |
2595 | b_ptr = tipc_bearer_find_interface(link_name_parts.if_local); | 2510 | if (l_ptr && !strcmp(l_ptr->name, name)) |
2596 | if (!b_ptr) | 2511 | goto found; |
2597 | return NULL; | 2512 | } |
2598 | 2513 | } | |
2599 | *node = tipc_node_find(link_name_parts.addr_peer); | 2514 | l_ptr = NULL; |
2600 | if (!*node) | 2515 | n_ptr = NULL; |
2601 | return NULL; | 2516 | found: |
2602 | 2517 | *node = n_ptr; | |
2603 | l_ptr = (*node)->links[b_ptr->identity]; | ||
2604 | if (!l_ptr || strcmp(l_ptr->name, name)) | ||
2605 | return NULL; | ||
2606 | |||
2607 | return l_ptr; | 2518 | return l_ptr; |
2608 | } | 2519 | } |
2609 | 2520 | ||
@@ -2646,6 +2557,7 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2646 | struct tipc_link *l_ptr; | 2557 | struct tipc_link *l_ptr; |
2647 | struct tipc_bearer *b_ptr; | 2558 | struct tipc_bearer *b_ptr; |
2648 | struct tipc_media *m_ptr; | 2559 | struct tipc_media *m_ptr; |
2560 | int res = 0; | ||
2649 | 2561 | ||
2650 | l_ptr = link_find_link(name, &node); | 2562 | l_ptr = link_find_link(name, &node); |
2651 | if (l_ptr) { | 2563 | if (l_ptr) { |
@@ -2668,9 +2580,12 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2668 | case TIPC_CMD_SET_LINK_WINDOW: | 2580 | case TIPC_CMD_SET_LINK_WINDOW: |
2669 | tipc_link_set_queue_limits(l_ptr, new_value); | 2581 | tipc_link_set_queue_limits(l_ptr, new_value); |
2670 | break; | 2582 | break; |
2583 | default: | ||
2584 | res = -EINVAL; | ||
2585 | break; | ||
2671 | } | 2586 | } |
2672 | tipc_node_unlock(node); | 2587 | tipc_node_unlock(node); |
2673 | return 0; | 2588 | return res; |
2674 | } | 2589 | } |
2675 | 2590 | ||
2676 | b_ptr = tipc_bearer_find(name); | 2591 | b_ptr = tipc_bearer_find(name); |
@@ -2678,15 +2593,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2678 | switch (cmd) { | 2593 | switch (cmd) { |
2679 | case TIPC_CMD_SET_LINK_TOL: | 2594 | case TIPC_CMD_SET_LINK_TOL: |
2680 | b_ptr->tolerance = new_value; | 2595 | b_ptr->tolerance = new_value; |
2681 | return 0; | 2596 | break; |
2682 | case TIPC_CMD_SET_LINK_PRI: | 2597 | case TIPC_CMD_SET_LINK_PRI: |
2683 | b_ptr->priority = new_value; | 2598 | b_ptr->priority = new_value; |
2684 | return 0; | 2599 | break; |
2685 | case TIPC_CMD_SET_LINK_WINDOW: | 2600 | case TIPC_CMD_SET_LINK_WINDOW: |
2686 | b_ptr->window = new_value; | 2601 | b_ptr->window = new_value; |
2687 | return 0; | 2602 | break; |
2603 | default: | ||
2604 | res = -EINVAL; | ||
2605 | break; | ||
2688 | } | 2606 | } |
2689 | return -EINVAL; | 2607 | return res; |
2690 | } | 2608 | } |
2691 | 2609 | ||
2692 | m_ptr = tipc_media_find(name); | 2610 | m_ptr = tipc_media_find(name); |
@@ -2695,15 +2613,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2695 | switch (cmd) { | 2613 | switch (cmd) { |
2696 | case TIPC_CMD_SET_LINK_TOL: | 2614 | case TIPC_CMD_SET_LINK_TOL: |
2697 | m_ptr->tolerance = new_value; | 2615 | m_ptr->tolerance = new_value; |
2698 | return 0; | 2616 | break; |
2699 | case TIPC_CMD_SET_LINK_PRI: | 2617 | case TIPC_CMD_SET_LINK_PRI: |
2700 | m_ptr->priority = new_value; | 2618 | m_ptr->priority = new_value; |
2701 | return 0; | 2619 | break; |
2702 | case TIPC_CMD_SET_LINK_WINDOW: | 2620 | case TIPC_CMD_SET_LINK_WINDOW: |
2703 | m_ptr->window = new_value; | 2621 | m_ptr->window = new_value; |
2704 | return 0; | 2622 | break; |
2623 | default: | ||
2624 | res = -EINVAL; | ||
2625 | break; | ||
2705 | } | 2626 | } |
2706 | return -EINVAL; | 2627 | return res; |
2707 | } | 2628 | } |
2708 | 2629 | ||
2709 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | 2630 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, |
diff --git a/net/tipc/link.h b/net/tipc/link.h index c048ed1cbd76..55cf8554a08b 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
@@ -227,9 +227,7 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf); | |||
227 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector); | 227 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector); |
228 | int tipc_link_send_sections_fast(struct tipc_port *sender, | 228 | int tipc_link_send_sections_fast(struct tipc_port *sender, |
229 | struct iovec const *msg_sect, | 229 | struct iovec const *msg_sect, |
230 | const u32 num_sect, | 230 | unsigned int len, u32 destnode); |
231 | unsigned int total_len, | ||
232 | u32 destnode); | ||
233 | void tipc_link_recv_bundle(struct sk_buff *buf); | 231 | void tipc_link_recv_bundle(struct sk_buff *buf); |
234 | int tipc_link_recv_fragment(struct sk_buff **pending, | 232 | int tipc_link_recv_fragment(struct sk_buff **pending, |
235 | struct sk_buff **fb, | 233 | struct sk_buff **fb, |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index ced60e2fc4f7..e525f8ce1dee 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -73,13 +73,13 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, | |||
73 | * Returns message data size or errno | 73 | * Returns message data size or errno |
74 | */ | 74 | */ |
75 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | 75 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, |
76 | u32 num_sect, unsigned int total_len, int max_size, | 76 | unsigned int len, int max_size, struct sk_buff **buf) |
77 | struct sk_buff **buf) | ||
78 | { | 77 | { |
79 | int dsz, sz, hsz, pos, res, cnt; | 78 | int dsz, sz, hsz; |
79 | unsigned char *to; | ||
80 | 80 | ||
81 | dsz = total_len; | 81 | dsz = len; |
82 | pos = hsz = msg_hdr_sz(hdr); | 82 | hsz = msg_hdr_sz(hdr); |
83 | sz = hsz + dsz; | 83 | sz = hsz + dsz; |
84 | msg_set_size(hdr, sz); | 84 | msg_set_size(hdr, sz); |
85 | if (unlikely(sz > max_size)) { | 85 | if (unlikely(sz > max_size)) { |
@@ -91,16 +91,11 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | |||
91 | if (!(*buf)) | 91 | if (!(*buf)) |
92 | return -ENOMEM; | 92 | return -ENOMEM; |
93 | skb_copy_to_linear_data(*buf, hdr, hsz); | 93 | skb_copy_to_linear_data(*buf, hdr, hsz); |
94 | for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { | 94 | to = (*buf)->data + hsz; |
95 | skb_copy_to_linear_data_offset(*buf, pos, | 95 | if (len && memcpy_fromiovecend(to, msg_sect, 0, dsz)) { |
96 | msg_sect[cnt].iov_base, | 96 | kfree_skb(*buf); |
97 | msg_sect[cnt].iov_len); | 97 | *buf = NULL; |
98 | pos += msg_sect[cnt].iov_len; | 98 | return -EFAULT; |
99 | } | 99 | } |
100 | if (likely(res)) | 100 | return dsz; |
101 | return dsz; | ||
102 | |||
103 | kfree_skb(*buf); | ||
104 | *buf = NULL; | ||
105 | return -EFAULT; | ||
106 | } | 101 | } |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 5e4ccf5c27df..559b73a9bf35 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -722,6 +722,5 @@ u32 tipc_msg_tot_importance(struct tipc_msg *m); | |||
722 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, | 722 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, |
723 | u32 destnode); | 723 | u32 destnode); |
724 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | 724 | int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, |
725 | u32 num_sect, unsigned int total_len, int max_size, | 725 | unsigned int len, int max_size, struct sk_buff **buf); |
726 | struct sk_buff **buf); | ||
727 | #endif | 726 | #endif |
diff --git a/net/tipc/port.c b/net/tipc/port.c index b3ed2fcab4fb..c081a7632302 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -90,8 +90,7 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg) | |||
90 | * tipc_multicast - send a multicast message to local and remote destinations | 90 | * tipc_multicast - send a multicast message to local and remote destinations |
91 | */ | 91 | */ |
92 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | 92 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, |
93 | u32 num_sect, struct iovec const *msg_sect, | 93 | struct iovec const *msg_sect, unsigned int len) |
94 | unsigned int total_len) | ||
95 | { | 94 | { |
96 | struct tipc_msg *hdr; | 95 | struct tipc_msg *hdr; |
97 | struct sk_buff *buf; | 96 | struct sk_buff *buf; |
@@ -114,8 +113,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
114 | msg_set_namelower(hdr, seq->lower); | 113 | msg_set_namelower(hdr, seq->lower); |
115 | msg_set_nameupper(hdr, seq->upper); | 114 | msg_set_nameupper(hdr, seq->upper); |
116 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); | 115 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); |
117 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, | 116 | res = tipc_msg_build(hdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
118 | &buf); | ||
119 | if (unlikely(!buf)) | 117 | if (unlikely(!buf)) |
120 | return res; | 118 | return res; |
121 | 119 | ||
@@ -436,14 +434,13 @@ exit: | |||
436 | } | 434 | } |
437 | 435 | ||
438 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, | 436 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
439 | struct iovec const *msg_sect, u32 num_sect, | 437 | struct iovec const *msg_sect, unsigned int len, |
440 | unsigned int total_len, int err) | 438 | int err) |
441 | { | 439 | { |
442 | struct sk_buff *buf; | 440 | struct sk_buff *buf; |
443 | int res; | 441 | int res; |
444 | 442 | ||
445 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, | 443 | res = tipc_msg_build(hdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
446 | &buf); | ||
447 | if (!buf) | 444 | if (!buf) |
448 | return res; | 445 | return res; |
449 | 446 | ||
@@ -918,15 +915,14 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
918 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 915 | * tipc_port_recv_sections(): Concatenate and deliver sectioned |
919 | * message for this node. | 916 | * message for this node. |
920 | */ | 917 | */ |
921 | static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, | 918 | static int tipc_port_recv_sections(struct tipc_port *sender, |
922 | struct iovec const *msg_sect, | 919 | struct iovec const *msg_sect, |
923 | unsigned int total_len) | 920 | unsigned int len) |
924 | { | 921 | { |
925 | struct sk_buff *buf; | 922 | struct sk_buff *buf; |
926 | int res; | 923 | int res; |
927 | 924 | ||
928 | res = tipc_msg_build(&sender->phdr, msg_sect, num_sect, total_len, | 925 | res = tipc_msg_build(&sender->phdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
929 | MAX_MSG_SIZE, &buf); | ||
930 | if (likely(buf)) | 926 | if (likely(buf)) |
931 | tipc_port_recv_msg(buf); | 927 | tipc_port_recv_msg(buf); |
932 | return res; | 928 | return res; |
@@ -935,8 +931,7 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se | |||
935 | /** | 931 | /** |
936 | * tipc_send - send message sections on connection | 932 | * tipc_send - send message sections on connection |
937 | */ | 933 | */ |
938 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | 934 | int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) |
939 | unsigned int total_len) | ||
940 | { | 935 | { |
941 | struct tipc_port *p_ptr; | 936 | struct tipc_port *p_ptr; |
942 | u32 destnode; | 937 | u32 destnode; |
@@ -950,11 +945,10 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
950 | if (!tipc_port_congested(p_ptr)) { | 945 | if (!tipc_port_congested(p_ptr)) { |
951 | destnode = port_peernode(p_ptr); | 946 | destnode = port_peernode(p_ptr); |
952 | if (likely(!in_own_node(destnode))) | 947 | if (likely(!in_own_node(destnode))) |
953 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 948 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
954 | total_len, destnode); | 949 | len, destnode); |
955 | else | 950 | else |
956 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, | 951 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
957 | total_len); | ||
958 | 952 | ||
959 | if (likely(res != -ELINKCONG)) { | 953 | if (likely(res != -ELINKCONG)) { |
960 | p_ptr->congested = 0; | 954 | p_ptr->congested = 0; |
@@ -965,7 +959,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
965 | } | 959 | } |
966 | if (port_unreliable(p_ptr)) { | 960 | if (port_unreliable(p_ptr)) { |
967 | p_ptr->congested = 0; | 961 | p_ptr->congested = 0; |
968 | return total_len; | 962 | return len; |
969 | } | 963 | } |
970 | return -ELINKCONG; | 964 | return -ELINKCONG; |
971 | } | 965 | } |
@@ -974,8 +968,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, | |||
974 | * tipc_send2name - send message sections to port name | 968 | * tipc_send2name - send message sections to port name |
975 | */ | 969 | */ |
976 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | 970 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, |
977 | unsigned int num_sect, struct iovec const *msg_sect, | 971 | struct iovec const *msg_sect, unsigned int len) |
978 | unsigned int total_len) | ||
979 | { | 972 | { |
980 | struct tipc_port *p_ptr; | 973 | struct tipc_port *p_ptr; |
981 | struct tipc_msg *msg; | 974 | struct tipc_msg *msg; |
@@ -999,36 +992,32 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | |||
999 | 992 | ||
1000 | if (likely(destport || destnode)) { | 993 | if (likely(destport || destnode)) { |
1001 | if (likely(in_own_node(destnode))) | 994 | if (likely(in_own_node(destnode))) |
1002 | res = tipc_port_recv_sections(p_ptr, num_sect, | 995 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
1003 | msg_sect, total_len); | ||
1004 | else if (tipc_own_addr) | 996 | else if (tipc_own_addr) |
1005 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, | 997 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
1006 | num_sect, total_len, | 998 | len, destnode); |
1007 | destnode); | ||
1008 | else | 999 | else |
1009 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, | 1000 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, |
1010 | num_sect, total_len, | 1001 | len, TIPC_ERR_NO_NODE); |
1011 | TIPC_ERR_NO_NODE); | ||
1012 | if (likely(res != -ELINKCONG)) { | 1002 | if (likely(res != -ELINKCONG)) { |
1013 | if (res > 0) | 1003 | if (res > 0) |
1014 | p_ptr->sent++; | 1004 | p_ptr->sent++; |
1015 | return res; | 1005 | return res; |
1016 | } | 1006 | } |
1017 | if (port_unreliable(p_ptr)) { | 1007 | if (port_unreliable(p_ptr)) { |
1018 | return total_len; | 1008 | return len; |
1019 | } | 1009 | } |
1020 | return -ELINKCONG; | 1010 | return -ELINKCONG; |
1021 | } | 1011 | } |
1022 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | 1012 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, len, |
1023 | total_len, TIPC_ERR_NO_NAME); | 1013 | TIPC_ERR_NO_NAME); |
1024 | } | 1014 | } |
1025 | 1015 | ||
1026 | /** | 1016 | /** |
1027 | * tipc_send2port - send message sections to port identity | 1017 | * tipc_send2port - send message sections to port identity |
1028 | */ | 1018 | */ |
1029 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, | 1019 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, |
1030 | unsigned int num_sect, struct iovec const *msg_sect, | 1020 | struct iovec const *msg_sect, unsigned int len) |
1031 | unsigned int total_len) | ||
1032 | { | 1021 | { |
1033 | struct tipc_port *p_ptr; | 1022 | struct tipc_port *p_ptr; |
1034 | struct tipc_msg *msg; | 1023 | struct tipc_msg *msg; |
@@ -1046,21 +1035,20 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, | |||
1046 | msg_set_hdr_sz(msg, BASIC_H_SIZE); | 1035 | msg_set_hdr_sz(msg, BASIC_H_SIZE); |
1047 | 1036 | ||
1048 | if (in_own_node(dest->node)) | 1037 | if (in_own_node(dest->node)) |
1049 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, | 1038 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); |
1050 | total_len); | ||
1051 | else if (tipc_own_addr) | 1039 | else if (tipc_own_addr) |
1052 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1040 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, len, |
1053 | total_len, dest->node); | 1041 | dest->node); |
1054 | else | 1042 | else |
1055 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | 1043 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, len, |
1056 | total_len, TIPC_ERR_NO_NODE); | 1044 | TIPC_ERR_NO_NODE); |
1057 | if (likely(res != -ELINKCONG)) { | 1045 | if (likely(res != -ELINKCONG)) { |
1058 | if (res > 0) | 1046 | if (res > 0) |
1059 | p_ptr->sent++; | 1047 | p_ptr->sent++; |
1060 | return res; | 1048 | return res; |
1061 | } | 1049 | } |
1062 | if (port_unreliable(p_ptr)) { | 1050 | if (port_unreliable(p_ptr)) { |
1063 | return total_len; | 1051 | return len; |
1064 | } | 1052 | } |
1065 | return -ELINKCONG; | 1053 | return -ELINKCONG; |
1066 | } | 1054 | } |
diff --git a/net/tipc/port.h b/net/tipc/port.h index 5a7026b9c345..912253597343 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -151,24 +151,20 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg); | |||
151 | * TIPC messaging routines | 151 | * TIPC messaging routines |
152 | */ | 152 | */ |
153 | int tipc_port_recv_msg(struct sk_buff *buf); | 153 | int tipc_port_recv_msg(struct sk_buff *buf); |
154 | int tipc_send(u32 portref, unsigned int num_sect, struct iovec const *msg_sect, | 154 | int tipc_send(u32 portref, struct iovec const *msg_sect, unsigned int len); |
155 | unsigned int total_len); | ||
156 | 155 | ||
157 | int tipc_send2name(u32 portref, struct tipc_name const *name, u32 domain, | 156 | int tipc_send2name(u32 portref, struct tipc_name const *name, u32 domain, |
158 | unsigned int num_sect, struct iovec const *msg_sect, | 157 | struct iovec const *msg_sect, unsigned int len); |
159 | unsigned int total_len); | ||
160 | 158 | ||
161 | int tipc_send2port(u32 portref, struct tipc_portid const *dest, | 159 | int tipc_send2port(u32 portref, struct tipc_portid const *dest, |
162 | unsigned int num_sect, struct iovec const *msg_sect, | 160 | struct iovec const *msg_sect, unsigned int len); |
163 | unsigned int total_len); | ||
164 | 161 | ||
165 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, | 162 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, |
166 | unsigned int section_count, struct iovec const *msg, | 163 | struct iovec const *msg, unsigned int len); |
167 | unsigned int total_len); | ||
168 | 164 | ||
169 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, | 165 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
170 | struct iovec const *msg_sect, u32 num_sect, | 166 | struct iovec const *msg_sect, unsigned int len, |
171 | unsigned int total_len, int err); | 167 | int err); |
172 | struct sk_buff *tipc_port_get_ports(void); | 168 | struct sk_buff *tipc_port_get_ports(void); |
173 | void tipc_port_recv_proto_msg(struct sk_buff *buf); | 169 | void tipc_port_recv_proto_msg(struct sk_buff *buf); |
174 | void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp); | 170 | void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp); |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 6cc7ddd2fb7c..3906527259d1 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -338,7 +338,7 @@ static int release(struct socket *sock) | |||
338 | buf = __skb_dequeue(&sk->sk_receive_queue); | 338 | buf = __skb_dequeue(&sk->sk_receive_queue); |
339 | if (buf == NULL) | 339 | if (buf == NULL) |
340 | break; | 340 | break; |
341 | if (TIPC_SKB_CB(buf)->handle != 0) | 341 | if (TIPC_SKB_CB(buf)->handle != NULL) |
342 | kfree_skb(buf); | 342 | kfree_skb(buf); |
343 | else { | 343 | else { |
344 | if ((sock->state == SS_CONNECTING) || | 344 | if ((sock->state == SS_CONNECTING) || |
@@ -622,13 +622,11 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
622 | res = tipc_send2name(tport->ref, | 622 | res = tipc_send2name(tport->ref, |
623 | &dest->addr.name.name, | 623 | &dest->addr.name.name, |
624 | dest->addr.name.domain, | 624 | dest->addr.name.domain, |
625 | m->msg_iovlen, | ||
626 | m->msg_iov, | 625 | m->msg_iov, |
627 | total_len); | 626 | total_len); |
628 | } else if (dest->addrtype == TIPC_ADDR_ID) { | 627 | } else if (dest->addrtype == TIPC_ADDR_ID) { |
629 | res = tipc_send2port(tport->ref, | 628 | res = tipc_send2port(tport->ref, |
630 | &dest->addr.id, | 629 | &dest->addr.id, |
631 | m->msg_iovlen, | ||
632 | m->msg_iov, | 630 | m->msg_iov, |
633 | total_len); | 631 | total_len); |
634 | } else if (dest->addrtype == TIPC_ADDR_MCAST) { | 632 | } else if (dest->addrtype == TIPC_ADDR_MCAST) { |
@@ -641,7 +639,6 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
641 | break; | 639 | break; |
642 | res = tipc_multicast(tport->ref, | 640 | res = tipc_multicast(tport->ref, |
643 | &dest->addr.nameseq, | 641 | &dest->addr.nameseq, |
644 | m->msg_iovlen, | ||
645 | m->msg_iov, | 642 | m->msg_iov, |
646 | total_len); | 643 | total_len); |
647 | } | 644 | } |
@@ -707,8 +704,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, | |||
707 | break; | 704 | break; |
708 | } | 705 | } |
709 | 706 | ||
710 | res = tipc_send(tport->ref, m->msg_iovlen, m->msg_iov, | 707 | res = tipc_send(tport->ref, m->msg_iov, total_len); |
711 | total_len); | ||
712 | if (likely(res != -ELINKCONG)) | 708 | if (likely(res != -ELINKCONG)) |
713 | break; | 709 | break; |
714 | if (timeout_val <= 0L) { | 710 | if (timeout_val <= 0L) { |
@@ -1368,7 +1364,7 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf) | |||
1368 | return TIPC_ERR_OVERLOAD; | 1364 | return TIPC_ERR_OVERLOAD; |
1369 | 1365 | ||
1370 | /* Enqueue message */ | 1366 | /* Enqueue message */ |
1371 | TIPC_SKB_CB(buf)->handle = 0; | 1367 | TIPC_SKB_CB(buf)->handle = NULL; |
1372 | __skb_queue_tail(&sk->sk_receive_queue, buf); | 1368 | __skb_queue_tail(&sk->sk_receive_queue, buf); |
1373 | skb_set_owner_r(buf, sk); | 1369 | skb_set_owner_r(buf, sk); |
1374 | 1370 | ||
@@ -1691,7 +1687,7 @@ restart: | |||
1691 | /* Disconnect and send a 'FIN+' or 'FIN-' message to peer */ | 1687 | /* Disconnect and send a 'FIN+' or 'FIN-' message to peer */ |
1692 | buf = __skb_dequeue(&sk->sk_receive_queue); | 1688 | buf = __skb_dequeue(&sk->sk_receive_queue); |
1693 | if (buf) { | 1689 | if (buf) { |
1694 | if (TIPC_SKB_CB(buf)->handle != 0) { | 1690 | if (TIPC_SKB_CB(buf)->handle != NULL) { |
1695 | kfree_skb(buf); | 1691 | kfree_skb(buf); |
1696 | goto restart; | 1692 | goto restart; |
1697 | } | 1693 | } |