diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/port.c | 28 | ||||
-rw-r--r-- | net/tipc/socket.c | 15 |
2 files changed, 17 insertions, 26 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index 2e0cff408ff9..ffba1e7f06d2 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/port.c: TIPC port code | 2 | * net/tipc/port.c: TIPC port code |
3 | * | 3 | * |
4 | * Copyright (c) 1992-2007, Ericsson AB | 4 | * Copyright (c) 1992-2007, Ericsson AB |
5 | * Copyright (c) 2004-2007, Wind River Systems | 5 | * Copyright (c) 2004-2008, 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 |
@@ -213,16 +213,13 @@ exit: | |||
213 | /** | 213 | /** |
214 | * tipc_createport_raw - create a generic TIPC port | 214 | * tipc_createport_raw - create a generic TIPC port |
215 | * | 215 | * |
216 | * Returns port reference, or 0 if unable to create it | 216 | * Returns pointer to (locked) TIPC port, or NULL if unable to create it |
217 | * | ||
218 | * Note: The newly created port is returned in the locked state. | ||
219 | */ | 217 | */ |
220 | 218 | ||
221 | u32 tipc_createport_raw(void *usr_handle, | 219 | struct tipc_port *tipc_createport_raw(void *usr_handle, |
222 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), | 220 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), |
223 | void (*wakeup)(struct tipc_port *), | 221 | void (*wakeup)(struct tipc_port *), |
224 | const u32 importance, | 222 | const u32 importance) |
225 | struct tipc_port **tp_ptr) | ||
226 | { | 223 | { |
227 | struct port *p_ptr; | 224 | struct port *p_ptr; |
228 | struct tipc_msg *msg; | 225 | struct tipc_msg *msg; |
@@ -231,13 +228,13 @@ u32 tipc_createport_raw(void *usr_handle, | |||
231 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); | 228 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); |
232 | if (!p_ptr) { | 229 | if (!p_ptr) { |
233 | warn("Port creation failed, no memory\n"); | 230 | warn("Port creation failed, no memory\n"); |
234 | return 0; | 231 | return NULL; |
235 | } | 232 | } |
236 | ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); | 233 | ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); |
237 | if (!ref) { | 234 | if (!ref) { |
238 | warn("Port creation failed, reference table exhausted\n"); | 235 | warn("Port creation failed, reference table exhausted\n"); |
239 | kfree(p_ptr); | 236 | kfree(p_ptr); |
240 | return 0; | 237 | return NULL; |
241 | } | 238 | } |
242 | 239 | ||
243 | p_ptr->publ.usr_handle = usr_handle; | 240 | p_ptr->publ.usr_handle = usr_handle; |
@@ -260,8 +257,7 @@ u32 tipc_createport_raw(void *usr_handle, | |||
260 | INIT_LIST_HEAD(&p_ptr->port_list); | 257 | INIT_LIST_HEAD(&p_ptr->port_list); |
261 | list_add_tail(&p_ptr->port_list, &ports); | 258 | list_add_tail(&p_ptr->port_list, &ports); |
262 | spin_unlock_bh(&tipc_port_list_lock); | 259 | spin_unlock_bh(&tipc_port_list_lock); |
263 | *tp_ptr = &p_ptr->publ; | 260 | return &(p_ptr->publ); |
264 | return ref; | ||
265 | } | 261 | } |
266 | 262 | ||
267 | int tipc_deleteport(u32 ref) | 263 | int tipc_deleteport(u32 ref) |
@@ -1044,21 +1040,18 @@ int tipc_createport(u32 user_ref, | |||
1044 | { | 1040 | { |
1045 | struct user_port *up_ptr; | 1041 | struct user_port *up_ptr; |
1046 | struct port *p_ptr; | 1042 | struct port *p_ptr; |
1047 | struct tipc_port *tp_ptr; | ||
1048 | u32 ref; | ||
1049 | 1043 | ||
1050 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); | 1044 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); |
1051 | if (!up_ptr) { | 1045 | if (!up_ptr) { |
1052 | warn("Port creation failed, no memory\n"); | 1046 | warn("Port creation failed, no memory\n"); |
1053 | return -ENOMEM; | 1047 | return -ENOMEM; |
1054 | } | 1048 | } |
1055 | ref = tipc_createport_raw(NULL, port_dispatcher, port_wakeup, | 1049 | p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher, |
1056 | importance, &tp_ptr); | 1050 | port_wakeup, importance); |
1057 | if (ref == 0) { | 1051 | if (!p_ptr) { |
1058 | kfree(up_ptr); | 1052 | kfree(up_ptr); |
1059 | return -ENOMEM; | 1053 | return -ENOMEM; |
1060 | } | 1054 | } |
1061 | p_ptr = (struct port *)tp_ptr; | ||
1062 | 1055 | ||
1063 | p_ptr->user_port = up_ptr; | 1056 | p_ptr->user_port = up_ptr; |
1064 | up_ptr->user_ref = user_ref; | 1057 | up_ptr->user_ref = user_ref; |
@@ -1074,7 +1067,6 @@ int tipc_createport(u32 user_ref, | |||
1074 | INIT_LIST_HEAD(&up_ptr->uport_list); | 1067 | INIT_LIST_HEAD(&up_ptr->uport_list); |
1075 | tipc_reg_add_port(up_ptr); | 1068 | tipc_reg_add_port(up_ptr); |
1076 | *portref = p_ptr->publ.ref; | 1069 | *portref = p_ptr->publ.ref; |
1077 | dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref); | ||
1078 | tipc_port_unlock(p_ptr); | 1070 | tipc_port_unlock(p_ptr); |
1079 | return TIPC_OK; | 1071 | return TIPC_OK; |
1080 | } | 1072 | } |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 38f48795b40e..9c362c5759ba 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/socket.c: TIPC socket API | 2 | * net/tipc/socket.c: TIPC socket API |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2007, Ericsson AB | 4 | * Copyright (c) 2001-2007, Ericsson AB |
5 | * Copyright (c) 2004-2007, Wind River Systems | 5 | * Copyright (c) 2004-2008, 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 |
@@ -189,7 +189,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
189 | socket_state state; | 189 | socket_state state; |
190 | struct sock *sk; | 190 | struct sock *sk; |
191 | struct tipc_port *tp_ptr; | 191 | struct tipc_port *tp_ptr; |
192 | u32 portref; | ||
193 | 192 | ||
194 | /* Validate arguments */ | 193 | /* Validate arguments */ |
195 | 194 | ||
@@ -225,9 +224,9 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
225 | 224 | ||
226 | /* Allocate TIPC port for socket to use */ | 225 | /* Allocate TIPC port for socket to use */ |
227 | 226 | ||
228 | portref = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, | 227 | tp_ptr = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, |
229 | TIPC_LOW_IMPORTANCE, &tp_ptr); | 228 | TIPC_LOW_IMPORTANCE); |
230 | if (unlikely(portref == 0)) { | 229 | if (unlikely(!tp_ptr)) { |
231 | sk_free(sk); | 230 | sk_free(sk); |
232 | return -ENOMEM; | 231 | return -ENOMEM; |
233 | } | 232 | } |
@@ -240,14 +239,14 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
240 | sock_init_data(sock, sk); | 239 | sock_init_data(sock, sk); |
241 | sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); | 240 | sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); |
242 | sk->sk_backlog_rcv = backlog_rcv; | 241 | sk->sk_backlog_rcv = backlog_rcv; |
243 | tipc_sk(sk)->p = tipc_get_port(portref); | 242 | tipc_sk(sk)->p = tp_ptr; |
244 | 243 | ||
245 | spin_unlock_bh(tp_ptr->lock); | 244 | spin_unlock_bh(tp_ptr->lock); |
246 | 245 | ||
247 | if (sock->state == SS_READY) { | 246 | if (sock->state == SS_READY) { |
248 | tipc_set_portunreturnable(portref, 1); | 247 | tipc_set_portunreturnable(tp_ptr->ref, 1); |
249 | if (sock->type == SOCK_DGRAM) | 248 | if (sock->type == SOCK_DGRAM) |
250 | tipc_set_portunreliable(portref, 1); | 249 | tipc_set_portunreliable(tp_ptr->ref, 1); |
251 | } | 250 | } |
252 | 251 | ||
253 | atomic_inc(&tipc_user_count); | 252 | atomic_inc(&tipc_user_count); |