Skip to content

Commit

Permalink
rxrpc: Tidy up the rxrpc_call struct a bit
Browse files Browse the repository at this point in the history
Do a little tidying of the rxrpc_call struct:

 (1) in_clientflag is no longer compared against the value that's in the
     packet, so keeping it in this form isn't necessary.  Use a flag in
     flags instead and provide a pair of wrapper functions.

 (2) We don't read the epoch value, so that can go.

 (3) Move what remains of the data that were used for hashing up in the
     struct to be with the channel number.

 (4) Get rid of the local pointer.  We can get at this via the socket
     struct and we only use this in the procfs viewer.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
David Howells committed Aug 23, 2016
1 parent 26164e7 commit dabe5a7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
23 changes: 15 additions & 8 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ enum rxrpc_call_flag {
RXRPC_CALL_INIT_ACCEPT, /* acceptance was initiated */
RXRPC_CALL_HAS_USERID, /* has a user ID attached */
RXRPC_CALL_EXPECT_OOS, /* expect out of sequence packets */
RXRPC_CALL_IS_SERVICE, /* Call is service call */
};

/*
Expand Down Expand Up @@ -431,8 +432,11 @@ struct rxrpc_call {
int error_report; /* Network error (ICMP/local transport) */
int error; /* Local error incurred */
enum rxrpc_call_state state : 8; /* current state of call */
int debug_id; /* debug ID for printks */
u8 channel; /* connection channel occupied by this call */
u16 service_id; /* service ID */
u32 call_id; /* call ID on connection */
u32 cid; /* connection ID plus channel index */
int debug_id; /* debug ID for printks */

/* transmission-phase ACK management */
u8 acks_head; /* offset into window of first entry */
Expand Down Expand Up @@ -460,13 +464,6 @@ struct rxrpc_call {
/* received packet records, 1 bit per record */
#define RXRPC_ACKR_WINDOW_ASZ DIV_ROUND_UP(RXRPC_MAXACKS, BITS_PER_LONG)
unsigned long ackr_window[RXRPC_ACKR_WINDOW_ASZ + 1];

u8 in_clientflag; /* Copy of conn->in_clientflag */
struct rxrpc_local *local; /* Local endpoint. */
u32 call_id; /* call ID on connection */
u32 cid; /* connection ID plus channel index */
u32 epoch; /* epoch of this connection */
u16 service_id; /* service ID */
};

/*
Expand Down Expand Up @@ -527,6 +524,16 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *);
void __rxrpc_put_call(struct rxrpc_call *);
void __exit rxrpc_destroy_all_calls(void);

static inline bool rxrpc_is_service_call(const struct rxrpc_call *call)
{
return test_bit(RXRPC_CALL_IS_SERVICE, &call->flags);
}

static inline bool rxrpc_is_client_call(const struct rxrpc_call *call)
{
return !rxrpc_is_service_call(call);
}

/*
* conn_client.c
*/
Expand Down
7 changes: 1 addition & 6 deletions net/rxrpc/call_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx,
sock_hold(&rx->sk);
call->socket = rx;
call->rx_data_post = 1;

call->local = rx->local;
call->service_id = srx->srx_service;
call->in_clientflag = 0;

_leave(" = %p", call);
return call;
Expand Down Expand Up @@ -323,6 +320,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
candidate->channel = chan;
candidate->rx_data_post = 0;
candidate->state = RXRPC_CALL_SERVER_ACCEPTING;
candidate->flags |= (1 << RXRPC_CALL_IS_SERVICE);
if (conn->security_ix > 0)
candidate->state = RXRPC_CALL_SERVER_SECURING;

Expand Down Expand Up @@ -397,10 +395,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
list_add_tail(&call->link, &rxrpc_calls);
write_unlock_bh(&rxrpc_call_lock);

call->local = conn->params.local;
call->epoch = conn->proto.epoch;
call->service_id = conn->params.service_id;
call->in_clientflag = RXRPC_CLIENT_INITIATED;

_net("CALL incoming %d on CONN %d", call->debug_id, call->conn->debug_id);

Expand Down
1 change: 0 additions & 1 deletion net/rxrpc/conn_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ int rxrpc_connect_call(struct rxrpc_call *call,
_debug("found chan");
call->conn = conn;
call->channel = chan;
call->epoch = conn->proto.epoch;
call->cid = conn->proto.cid | chan;
call->call_id = ++conn->channels[chan].call_counter;
conn->channels[chan].call_id = call->call_id;
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
ret = 0;
} else if (cmd != RXRPC_CMD_SEND_DATA) {
ret = -EINVAL;
} else if (!call->in_clientflag &&
} else if (rxrpc_is_client_call(call) &&
call->state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
/* request phase complete for this client call */
ret = -EPROTO;
} else if (call->in_clientflag &&
} else if (rxrpc_is_service_call(call) &&
call->state != RXRPC_CALL_SERVER_ACK_REQUEST &&
call->state != RXRPC_CALL_SERVER_SEND_REPLY) {
/* Reply phase not begun or not complete for service call. */
Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
call = list_entry(v, struct rxrpc_call, link);

sprintf(lbuff, "%pI4:%u",
&call->local->srx.transport.sin.sin_addr,
ntohs(call->local->srx.transport.sin.sin_port));
&call->socket->local->srx.transport.sin.sin_addr,
ntohs(call->socket->local->srx.transport.sin.sin_port));

conn = call->conn;
if (conn)
Expand All @@ -80,7 +80,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
call->service_id,
call->cid,
call->call_id,
call->in_clientflag ? "Svc" : "Clt",
rxrpc_is_service_call(call) ? "Svc" : "Clt",
atomic_read(&call->usage),
rxrpc_call_states[call->state],
call->remote_abort ?: call->local_abort,
Expand Down

0 comments on commit dabe5a7

Please sign in to comment.