Skip to content

Commit

Permalink
rxrpc: Drop rxrpc_conn_parameters from rxrpc_connection and rxrpc_bundle
Browse files Browse the repository at this point in the history
Remove the rxrpc_conn_parameters struct from the rxrpc_connection and
rxrpc_bundle structs and emplace the members directly.  These are going to
get filled in from the rxrpc_call struct in future.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
  • Loading branch information
David Howells committed Dec 1, 2022
1 parent e969c92 commit 2cc8008
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 108 deletions.
16 changes: 14 additions & 2 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,18 @@ enum rxrpc_conn_proto_state {
* RxRPC client connection bundle.
*/
struct rxrpc_bundle {
struct rxrpc_conn_parameters params;
struct rxrpc_local *local; /* Representation of local endpoint */
struct rxrpc_peer *peer; /* Remote endpoint */
struct key *key; /* Security details */
refcount_t ref;
atomic_t active; /* Number of active users */
unsigned int debug_id;
u32 security_level; /* Security level selected */
u16 service_id; /* Service ID for this connection */
bool try_upgrade; /* True if the bundle is attempting upgrade */
bool alloc_conn; /* True if someone's getting a conn */
bool exclusive; /* T if conn is exclusive */
bool upgrade; /* T if service ID can be upgraded */
short alloc_error; /* Error from last conn allocation */
spinlock_t channel_lock;
struct rb_node local_node; /* Node in local->client_conns */
Expand All @@ -424,7 +430,9 @@ struct rxrpc_bundle {
*/
struct rxrpc_connection {
struct rxrpc_conn_proto proto;
struct rxrpc_conn_parameters params;
struct rxrpc_local *local; /* Representation of local endpoint */
struct rxrpc_peer *peer; /* Remote endpoint */
struct key *key; /* Security details */

refcount_t ref;
struct rcu_head rcu;
Expand Down Expand Up @@ -471,9 +479,13 @@ struct rxrpc_connection {
atomic_t serial; /* packet serial number counter */
unsigned int hi_serial; /* highest serial number received */
u32 service_id; /* Service ID, possibly upgraded */
u32 security_level; /* Security level selected */
u8 security_ix; /* security type */
u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
u8 bundle_shift; /* Index into bundle->avail_chans */
bool exclusive; /* T if conn is exclusive */
bool upgrade; /* T if service ID can be upgraded */
u16 orig_service_id; /* Originally requested service ID */
short error; /* Local error code */
};

Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/call_accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx,
b->conn_backlog[conn_tail] = NULL;
smp_store_release(&b->conn_backlog_tail,
(conn_tail + 1) & (RXRPC_BACKLOG_MAX - 1));
conn->params.local = rxrpc_get_local(local);
conn->params.peer = peer;
conn->local = rxrpc_get_local(local);
conn->peer = peer;
rxrpc_see_connection(conn);
rxrpc_new_incoming_connection(rx, conn, sec, skb);
} else {
Expand All @@ -323,7 +323,7 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx,
call->conn = conn;
call->security = conn->security;
call->security_ix = conn->security_ix;
call->peer = rxrpc_get_peer(conn->params.peer);
call->peer = rxrpc_get_peer(conn->peer);
call->cong_ssthresh = call->peer->cong_ssthresh;
call->tx_last_sent = ktime_get_real();
return call;
Expand Down
2 changes: 1 addition & 1 deletion net/rxrpc/call_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void rxrpc_propose_delay_ACK(struct rxrpc_call *call, rxrpc_serial_t serial,
void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_reason,
rxrpc_serial_t serial, enum rxrpc_propose_ack_trace why)
{
struct rxrpc_local *local = call->conn->params.local;
struct rxrpc_local *local = call->conn->local;
struct rxrpc_txbuf *txb;

if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/call_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ void rxrpc_incoming_call(struct rxrpc_sock *rx,
conn->channels[chan].call_id = call->call_id;
rcu_assign_pointer(conn->channels[chan].call, call);

spin_lock(&conn->params.peer->lock);
hlist_add_head_rcu(&call->error_link, &conn->params.peer->error_targets);
spin_unlock(&conn->params.peer->lock);
spin_lock(&conn->peer->lock);
hlist_add_head_rcu(&call->error_link, &conn->peer->error_targets);
spin_unlock(&conn->peer->lock);

rxrpc_start_call_timer(call);
_leave("");
Expand Down
53 changes: 32 additions & 21 deletions net/rxrpc/conn_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle);
static int rxrpc_get_client_connection_id(struct rxrpc_connection *conn,
gfp_t gfp)
{
struct rxrpc_net *rxnet = conn->params.local->rxnet;
struct rxrpc_net *rxnet = conn->local->rxnet;
int id;

_enter("");
Expand Down Expand Up @@ -122,8 +122,13 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_conn_parameters *cp,

bundle = kzalloc(sizeof(*bundle), gfp);
if (bundle) {
bundle->params = *cp;
rxrpc_get_peer(bundle->params.peer);
bundle->local = cp->local;
bundle->peer = rxrpc_get_peer(cp->peer);
bundle->key = cp->key;
bundle->exclusive = cp->exclusive;
bundle->upgrade = cp->upgrade;
bundle->service_id = cp->service_id;
bundle->security_level = cp->security_level;
refcount_set(&bundle->ref, 1);
atomic_set(&bundle->active, 1);
spin_lock_init(&bundle->channel_lock);
Expand All @@ -140,7 +145,7 @@ struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle)

static void rxrpc_free_bundle(struct rxrpc_bundle *bundle)
{
rxrpc_put_peer(bundle->params.peer);
rxrpc_put_peer(bundle->peer);
kfree(bundle);
}

Expand All @@ -164,7 +169,7 @@ static struct rxrpc_connection *
rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
{
struct rxrpc_connection *conn;
struct rxrpc_net *rxnet = bundle->params.local->rxnet;
struct rxrpc_net *rxnet = bundle->local->rxnet;
int ret;

_enter("");
Expand All @@ -177,10 +182,16 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)

refcount_set(&conn->ref, 1);
conn->bundle = bundle;
conn->params = bundle->params;
conn->local = bundle->local;
conn->peer = bundle->peer;
conn->key = bundle->key;
conn->exclusive = bundle->exclusive;
conn->upgrade = bundle->upgrade;
conn->orig_service_id = bundle->service_id;
conn->security_level = bundle->security_level;
conn->out_clientflag = RXRPC_CLIENT_INITIATED;
conn->state = RXRPC_CONN_CLIENT;
conn->service_id = conn->params.service_id;
conn->service_id = conn->orig_service_id;

ret = rxrpc_get_client_connection_id(conn, gfp);
if (ret < 0)
Expand All @@ -196,9 +207,9 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
write_unlock(&rxnet->conn_lock);

rxrpc_get_bundle(bundle);
rxrpc_get_peer(conn->params.peer);
rxrpc_get_local(conn->params.local);
key_get(conn->params.key);
rxrpc_get_peer(conn->peer);
rxrpc_get_local(conn->local);
key_get(conn->key);

trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client,
refcount_read(&conn->ref),
Expand Down Expand Up @@ -228,7 +239,7 @@ static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
if (!conn)
goto dont_reuse;

rxnet = conn->params.local->rxnet;
rxnet = conn->local->rxnet;
if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags))
goto dont_reuse;

Expand Down Expand Up @@ -285,7 +296,7 @@ static struct rxrpc_bundle *rxrpc_look_up_bundle(struct rxrpc_conn_parameters *c
while (p) {
bundle = rb_entry(p, struct rxrpc_bundle, local_node);

#define cmp(X) ((long)bundle->params.X - (long)cp->X)
#define cmp(X) ((long)bundle->X - (long)cp->X)
diff = (cmp(peer) ?:
cmp(key) ?:
cmp(security_level) ?:
Expand Down Expand Up @@ -314,7 +325,7 @@ static struct rxrpc_bundle *rxrpc_look_up_bundle(struct rxrpc_conn_parameters *c
parent = *pp;
bundle = rb_entry(parent, struct rxrpc_bundle, local_node);

#define cmp(X) ((long)bundle->params.X - (long)cp->X)
#define cmp(X) ((long)bundle->X - (long)cp->X)
diff = (cmp(peer) ?:
cmp(key) ?:
cmp(security_level) ?:
Expand Down Expand Up @@ -532,7 +543,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,

rxrpc_see_call(call);
list_del_init(&call->chan_wait_link);
call->peer = rxrpc_get_peer(conn->params.peer);
call->peer = rxrpc_get_peer(conn->peer);
call->conn = rxrpc_get_connection(conn);
call->cid = conn->proto.cid | channel;
call->call_id = call_id;
Expand Down Expand Up @@ -569,7 +580,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
*/
static void rxrpc_unidle_conn(struct rxrpc_bundle *bundle, struct rxrpc_connection *conn)
{
struct rxrpc_net *rxnet = bundle->params.local->rxnet;
struct rxrpc_net *rxnet = bundle->local->rxnet;
bool drop_ref;

if (!list_empty(&conn->cache_link)) {
Expand Down Expand Up @@ -795,7 +806,7 @@ void rxrpc_disconnect_client_call(struct rxrpc_bundle *bundle, struct rxrpc_call
{
struct rxrpc_connection *conn;
struct rxrpc_channel *chan = NULL;
struct rxrpc_net *rxnet = bundle->params.local->rxnet;
struct rxrpc_net *rxnet = bundle->local->rxnet;
unsigned int channel;
bool may_reuse;
u32 cid;
Expand Down Expand Up @@ -936,11 +947,11 @@ static void rxrpc_unbundle_conn(struct rxrpc_connection *conn)
*/
static void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle)
{
struct rxrpc_local *local = bundle->params.local;
struct rxrpc_local *local = bundle->local;
bool need_put = false;

if (atomic_dec_and_lock(&bundle->active, &local->client_bundles_lock)) {
if (!bundle->params.exclusive) {
if (!bundle->exclusive) {
_debug("erase bundle");
rb_erase(&bundle->local_node, &local->client_bundles);
need_put = true;
Expand All @@ -957,7 +968,7 @@ static void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle)
*/
static void rxrpc_kill_client_conn(struct rxrpc_connection *conn)
{
struct rxrpc_local *local = conn->params.local;
struct rxrpc_local *local = conn->local;
struct rxrpc_net *rxnet = local->rxnet;

_enter("C=%x", conn->debug_id);
Expand Down Expand Up @@ -1036,7 +1047,7 @@ void rxrpc_discard_expired_client_conns(struct work_struct *work)
expiry = rxrpc_conn_idle_client_expiry;
if (nr_conns > rxrpc_reap_client_connections)
expiry = rxrpc_conn_idle_client_fast_expiry;
if (conn->params.local->service_closed)
if (conn->local->service_closed)
expiry = rxrpc_closed_conn_expiry * HZ;

conn_expires_at = conn->idle_timestamp + expiry;
Expand Down Expand Up @@ -1110,7 +1121,7 @@ void rxrpc_clean_up_local_conns(struct rxrpc_local *local)

list_for_each_entry_safe(conn, tmp, &rxnet->idle_client_conns,
cache_link) {
if (conn->params.local == local) {
if (conn->local == local) {
trace_rxrpc_client(conn, -1, rxrpc_client_discard);
list_move(&conn->cache_link, &graveyard);
}
Expand Down
26 changes: 13 additions & 13 deletions net/rxrpc/conn_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
if (skb && call_id != sp->hdr.callNumber)
return;

msg.msg_name = &conn->params.peer->srx.transport;
msg.msg_namelen = conn->params.peer->srx.transport_len;
msg.msg_name = &conn->peer->srx.transport;
msg.msg_namelen = conn->peer->srx.transport_len;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
Expand Down Expand Up @@ -86,8 +86,8 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
break;

case RXRPC_PACKET_TYPE_ACK:
mtu = conn->params.peer->if_mtu;
mtu -= conn->params.peer->hdrsize;
mtu = conn->peer->if_mtu;
mtu -= conn->peer->hdrsize;
pkt.ack.bufferSpace = 0;
pkt.ack.maxSkew = htons(skb ? skb->priority : 0);
pkt.ack.firstPacket = htonl(chan->last_seq + 1);
Expand Down Expand Up @@ -131,8 +131,8 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
break;
}

ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, ioc, len);
conn->params.peer->last_tx_at = ktime_get_seconds();
ret = kernel_sendmsg(conn->local->socket, &msg, iov, ioc, len);
conn->peer->last_tx_at = ktime_get_seconds();
if (ret < 0)
trace_rxrpc_tx_fail(chan->call_debug_id, serial, ret,
rxrpc_tx_point_call_final_resend);
Expand Down Expand Up @@ -211,8 +211,8 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
spin_unlock_bh(&conn->state_lock);

msg.msg_name = &conn->params.peer->srx.transport;
msg.msg_namelen = conn->params.peer->srx.transport_len;
msg.msg_name = &conn->peer->srx.transport;
msg.msg_namelen = conn->peer->srx.transport_len;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
Expand Down Expand Up @@ -241,7 +241,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, serial);
whdr.serial = htonl(serial);

ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
ret = kernel_sendmsg(conn->local->socket, &msg, iov, 2, len);
if (ret < 0) {
trace_rxrpc_tx_fail(conn->debug_id, serial, ret,
rxrpc_tx_point_conn_abort);
Expand All @@ -251,7 +251,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,

trace_rxrpc_tx_packet(conn->debug_id, &whdr, rxrpc_tx_point_conn_abort);

conn->params.peer->last_tx_at = ktime_get_seconds();
conn->peer->last_tx_at = ktime_get_seconds();

_leave(" = 0");
return 0;
Expand Down Expand Up @@ -330,7 +330,7 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
return ret;

ret = conn->security->init_connection_security(
conn, conn->params.key->payload.data[0]);
conn, conn->key->payload.data[0]);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -484,9 +484,9 @@ void rxrpc_process_connection(struct work_struct *work)

rxrpc_see_connection(conn);

if (__rxrpc_use_local(conn->params.local)) {
if (__rxrpc_use_local(conn->local)) {
rxrpc_do_process_connection(conn);
rxrpc_unuse_local(conn->params.local);
rxrpc_unuse_local(conn->local);
}

rxrpc_put_connection(conn);
Expand Down
Loading

0 comments on commit 2cc8008

Please sign in to comment.