diff options
| author | David Howells <dhowells@redhat.com> | 2016-06-27 05:32:02 -0400 |
|---|---|---|
| committer | David Howells <dhowells@redhat.com> | 2016-07-06 05:43:51 -0400 |
| commit | bba304db34ec3ca0d13e7f48e5a4e9896536cacc (patch) | |
| tree | 722839772527934ad566e728e729c3d0290a892c | |
| parent | 5acbee4648789ba1fe9e7942280fb1966c76bd6f (diff) | |
rxrpc: Turn connection #defines into enums and put outside struct def
Turn the connection event and state #define lists into enums and move
outside of the struct definition.
Whilst we're at it, change _SERVER to _SERVICE in those identifiers and add
EV_ into the event name to distinguish them from flags and states.
Also add a symbol indicating the number of states and use that in the state
text array.
Signed-off-by: David Howells <dhowells@redhat.com>
| -rw-r--r-- | net/rxrpc/ar-internal.h | 42 | ||||
| -rw-r--r-- | net/rxrpc/call_accept.c | 6 | ||||
| -rw-r--r-- | net/rxrpc/conn_event.c | 6 | ||||
| -rw-r--r-- | net/rxrpc/conn_object.c | 4 | ||||
| -rw-r--r-- | net/rxrpc/proc.c | 18 |
5 files changed, 47 insertions, 29 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 45aef3ef7609..3f0d0479a4da 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h | |||
| @@ -254,6 +254,35 @@ struct rxrpc_conn_parameters { | |||
| 254 | }; | 254 | }; |
| 255 | 255 | ||
| 256 | /* | 256 | /* |
| 257 | * Bits in the connection flags. | ||
| 258 | */ | ||
| 259 | enum rxrpc_conn_flag { | ||
| 260 | RXRPC_CONN_HAS_IDR, /* Has a client conn ID assigned */ | ||
| 261 | }; | ||
| 262 | |||
| 263 | /* | ||
| 264 | * Events that can be raised upon a connection. | ||
| 265 | */ | ||
| 266 | enum rxrpc_conn_event { | ||
| 267 | RXRPC_CONN_EV_CHALLENGE, /* Send challenge packet */ | ||
| 268 | }; | ||
| 269 | |||
| 270 | /* | ||
| 271 | * The connection protocol state. | ||
| 272 | */ | ||
| 273 | enum rxrpc_conn_proto_state { | ||
| 274 | RXRPC_CONN_UNUSED, /* Connection not yet attempted */ | ||
| 275 | RXRPC_CONN_CLIENT, /* Client connection */ | ||
| 276 | RXRPC_CONN_SERVICE_UNSECURED, /* Service unsecured connection */ | ||
| 277 | RXRPC_CONN_SERVICE_CHALLENGING, /* Service challenging for security */ | ||
| 278 | RXRPC_CONN_SERVICE, /* Service secured connection */ | ||
| 279 | RXRPC_CONN_REMOTELY_ABORTED, /* Conn aborted by peer */ | ||
| 280 | RXRPC_CONN_LOCALLY_ABORTED, /* Conn aborted locally */ | ||
| 281 | RXRPC_CONN_NETWORK_ERROR, /* Conn terminated by network error */ | ||
| 282 | RXRPC_CONN__NR_STATES | ||
| 283 | }; | ||
| 284 | |||
| 285 | /* | ||
| 257 | * RxRPC connection definition | 286 | * RxRPC connection definition |
| 258 | * - matched by { local, peer, epoch, conn_id, direction } | 287 | * - matched by { local, peer, epoch, conn_id, direction } |
| 259 | * - each connection can only handle four simultaneous calls | 288 | * - each connection can only handle four simultaneous calls |
| @@ -279,23 +308,12 @@ struct rxrpc_connection { | |||
| 279 | struct crypto_skcipher *cipher; /* encryption handle */ | 308 | struct crypto_skcipher *cipher; /* encryption handle */ |
| 280 | struct rxrpc_crypt csum_iv; /* packet checksum base */ | 309 | struct rxrpc_crypt csum_iv; /* packet checksum base */ |
| 281 | unsigned long flags; | 310 | unsigned long flags; |
| 282 | #define RXRPC_CONN_HAS_IDR 0 /* - Has a client conn ID assigned */ | ||
| 283 | unsigned long events; | 311 | unsigned long events; |
| 284 | #define RXRPC_CONN_CHALLENGE 0 /* send challenge packet */ | ||
| 285 | unsigned long put_time; /* Time at which last put */ | 312 | unsigned long put_time; /* Time at which last put */ |
| 286 | rwlock_t lock; /* access lock */ | 313 | rwlock_t lock; /* access lock */ |
| 287 | spinlock_t state_lock; /* state-change lock */ | 314 | spinlock_t state_lock; /* state-change lock */ |
| 288 | atomic_t usage; | 315 | atomic_t usage; |
| 289 | enum { /* current state of connection */ | 316 | enum rxrpc_conn_proto_state state : 8; /* current state of connection */ |
| 290 | RXRPC_CONN_UNUSED, /* - connection not yet attempted */ | ||
| 291 | RXRPC_CONN_CLIENT, /* - client connection */ | ||
| 292 | RXRPC_CONN_SERVER_UNSECURED, /* - server unsecured connection */ | ||
| 293 | RXRPC_CONN_SERVER_CHALLENGING, /* - server challenging for security */ | ||
| 294 | RXRPC_CONN_SERVER, /* - server secured connection */ | ||
| 295 | RXRPC_CONN_REMOTELY_ABORTED, /* - conn aborted by peer */ | ||
| 296 | RXRPC_CONN_LOCALLY_ABORTED, /* - conn aborted locally */ | ||
| 297 | RXRPC_CONN_NETWORK_ERROR, /* - conn terminated by network error */ | ||
| 298 | } state; | ||
| 299 | u32 local_abort; /* local abort code */ | 317 | u32 local_abort; /* local abort code */ |
| 300 | u32 remote_abort; /* remote abort code */ | 318 | u32 remote_abort; /* remote abort code */ |
| 301 | int error; /* local error incurred */ | 319 | int error; /* local error incurred */ |
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c index 202e053a3c6d..1c0860df150e 100644 --- a/net/rxrpc/call_accept.c +++ b/net/rxrpc/call_accept.c | |||
| @@ -128,12 +128,12 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local, | |||
| 128 | 128 | ||
| 129 | spin_lock(&call->conn->state_lock); | 129 | spin_lock(&call->conn->state_lock); |
| 130 | if (sp->hdr.securityIndex > 0 && | 130 | if (sp->hdr.securityIndex > 0 && |
| 131 | call->conn->state == RXRPC_CONN_SERVER_UNSECURED) { | 131 | call->conn->state == RXRPC_CONN_SERVICE_UNSECURED) { |
| 132 | _debug("await conn sec"); | 132 | _debug("await conn sec"); |
| 133 | list_add_tail(&call->accept_link, &rx->secureq); | 133 | list_add_tail(&call->accept_link, &rx->secureq); |
| 134 | call->conn->state = RXRPC_CONN_SERVER_CHALLENGING; | 134 | call->conn->state = RXRPC_CONN_SERVICE_CHALLENGING; |
| 135 | rxrpc_get_connection(call->conn); | 135 | rxrpc_get_connection(call->conn); |
| 136 | set_bit(RXRPC_CONN_CHALLENGE, &call->conn->events); | 136 | set_bit(RXRPC_CONN_EV_CHALLENGE, &call->conn->events); |
| 137 | rxrpc_queue_conn(call->conn); | 137 | rxrpc_queue_conn(call->conn); |
| 138 | } else { | 138 | } else { |
| 139 | _debug("conn ready"); | 139 | _debug("conn ready"); |
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c index d7e183c6b5df..b9c39b83eddb 100644 --- a/net/rxrpc/conn_event.c +++ b/net/rxrpc/conn_event.c | |||
| @@ -195,8 +195,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, | |||
| 195 | read_lock_bh(&conn->lock); | 195 | read_lock_bh(&conn->lock); |
| 196 | spin_lock(&conn->state_lock); | 196 | spin_lock(&conn->state_lock); |
| 197 | 197 | ||
| 198 | if (conn->state == RXRPC_CONN_SERVER_CHALLENGING) { | 198 | if (conn->state == RXRPC_CONN_SERVICE_CHALLENGING) { |
| 199 | conn->state = RXRPC_CONN_SERVER; | 199 | conn->state = RXRPC_CONN_SERVICE; |
| 200 | for (loop = 0; loop < RXRPC_MAXCALLS; loop++) | 200 | for (loop = 0; loop < RXRPC_MAXCALLS; loop++) |
| 201 | rxrpc_call_is_secure(conn->channels[loop]); | 201 | rxrpc_call_is_secure(conn->channels[loop]); |
| 202 | } | 202 | } |
| @@ -268,7 +268,7 @@ void rxrpc_process_connection(struct work_struct *work) | |||
| 268 | 268 | ||
| 269 | rxrpc_get_connection(conn); | 269 | rxrpc_get_connection(conn); |
| 270 | 270 | ||
| 271 | if (test_and_clear_bit(RXRPC_CONN_CHALLENGE, &conn->events)) { | 271 | if (test_and_clear_bit(RXRPC_CONN_EV_CHALLENGE, &conn->events)) { |
| 272 | rxrpc_secure_connection(conn); | 272 | rxrpc_secure_connection(conn); |
| 273 | rxrpc_put_connection(conn); | 273 | rxrpc_put_connection(conn); |
| 274 | } | 274 | } |
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c index c2c0926af546..0e022dfab034 100644 --- a/net/rxrpc/conn_object.c +++ b/net/rxrpc/conn_object.c | |||
| @@ -399,9 +399,9 @@ struct rxrpc_connection *rxrpc_incoming_connection(struct rxrpc_local *local, | |||
| 399 | candidate->params.service_id = sp->hdr.serviceId; | 399 | candidate->params.service_id = sp->hdr.serviceId; |
| 400 | candidate->security_ix = sp->hdr.securityIndex; | 400 | candidate->security_ix = sp->hdr.securityIndex; |
| 401 | candidate->out_clientflag = 0; | 401 | candidate->out_clientflag = 0; |
| 402 | candidate->state = RXRPC_CONN_SERVER; | 402 | candidate->state = RXRPC_CONN_SERVICE; |
| 403 | if (candidate->params.service_id) | 403 | if (candidate->params.service_id) |
| 404 | candidate->state = RXRPC_CONN_SERVER_UNSECURED; | 404 | candidate->state = RXRPC_CONN_SERVICE_UNSECURED; |
| 405 | 405 | ||
| 406 | write_lock_bh(&peer->conn_lock); | 406 | write_lock_bh(&peer->conn_lock); |
| 407 | 407 | ||
diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c index 500cdcdc843c..2a25ab425b6f 100644 --- a/net/rxrpc/proc.c +++ b/net/rxrpc/proc.c | |||
| @@ -14,15 +14,15 @@ | |||
| 14 | #include <net/af_rxrpc.h> | 14 | #include <net/af_rxrpc.h> |
| 15 | #include "ar-internal.h" | 15 | #include "ar-internal.h" |
| 16 | 16 | ||
| 17 | static const char *const rxrpc_conn_states[] = { | 17 | static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = { |
| 18 | [RXRPC_CONN_UNUSED] = "Unused ", | 18 | [RXRPC_CONN_UNUSED] = "Unused ", |
| 19 | [RXRPC_CONN_CLIENT] = "Client ", | 19 | [RXRPC_CONN_CLIENT] = "Client ", |
| 20 | [RXRPC_CONN_SERVER_UNSECURED] = "SvUnsec ", | 20 | [RXRPC_CONN_SERVICE_UNSECURED] = "SvUnsec ", |
| 21 | [RXRPC_CONN_SERVER_CHALLENGING] = "SvChall ", | 21 | [RXRPC_CONN_SERVICE_CHALLENGING] = "SvChall ", |
| 22 | [RXRPC_CONN_SERVER] = "SvSecure", | 22 | [RXRPC_CONN_SERVICE] = "SvSecure", |
| 23 | [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort", | 23 | [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort", |
| 24 | [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort", | 24 | [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort", |
| 25 | [RXRPC_CONN_NETWORK_ERROR] = "NetError", | 25 | [RXRPC_CONN_NETWORK_ERROR] = "NetError", |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
