Skip to content

Commit

Permalink
rxrpc: Kill off the rxrpc_transport struct
Browse files Browse the repository at this point in the history
The rxrpc_transport struct is now redundant, given that the rxrpc_peer
struct is now per peer port rather than per peer host, so get rid of it.

Service connection lists are transferred to the rxrpc_peer struct, as is
the conn_lock.  Previous patches moved the client connection handling out
of the rxrpc_transport struct and discarded the connection bundling code.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
David Howells committed Jun 22, 2016
1 parent 999b69f commit aa390bb
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 451 deletions.
1 change: 0 additions & 1 deletion net/rxrpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ af-rxrpc-y := \
recvmsg.o \
security.o \
skbuff.o \
transport.o \
utils.o

af-rxrpc-$(CONFIG_PROC_FS) += proc.o
Expand Down
46 changes: 1 addition & 45 deletions net/rxrpc/af_rxrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,37 +224,6 @@ static int rxrpc_listen(struct socket *sock, int backlog)
return ret;
}

/*
* find a transport by address
*/
struct rxrpc_transport *
rxrpc_name_to_transport(struct rxrpc_conn_parameters *cp,
struct sockaddr *addr,
int addr_len,
gfp_t gfp)
{
struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *) addr;
struct rxrpc_transport *trans;

_enter("%p,%d", addr, addr_len);

if (cp->local->srx.transport_type != srx->transport_type)
return ERR_PTR(-ESOCKTNOSUPPORT);
if (cp->local->srx.transport.family != srx->transport.family)
return ERR_PTR(-EAFNOSUPPORT);

/* find a remote transport endpoint from the local one */
cp->peer = rxrpc_lookup_peer(cp->local, srx, gfp);
if (!cp->peer)
return ERR_PTR(-ENOMEM);

/* find a transport */
trans = rxrpc_get_transport(cp->local, cp->peer, gfp);
rxrpc_put_peer(cp->peer);
_leave(" = %p", trans);
return trans;
}

/**
* rxrpc_kernel_begin_call - Allow a kernel service to begin a call
* @sock: The socket on which to make the call
Expand All @@ -276,7 +245,6 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
gfp_t gfp)
{
struct rxrpc_conn_parameters cp;
struct rxrpc_transport *trans;
struct rxrpc_call *call;
struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
int ret;
Expand All @@ -300,19 +268,8 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
cp.security_level = 0;
cp.exclusive = false;
cp.service_id = srx->srx_service;
call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, gfp);

trans = rxrpc_name_to_transport(&cp, (struct sockaddr *)srx,
sizeof(*srx), gfp);
if (IS_ERR(trans)) {
call = ERR_CAST(trans);
trans = NULL;
goto out_notrans;
}
cp.peer = trans->peer;

call = rxrpc_new_client_call(rx, &cp, trans, srx, user_call_ID, gfp);
rxrpc_put_transport(trans);
out_notrans:
release_sock(&rx->sk);
_leave(" = %p", call);
return call;
Expand Down Expand Up @@ -831,7 +788,6 @@ static void __exit af_rxrpc_exit(void)
proto_unregister(&rxrpc_proto);
rxrpc_destroy_all_calls();
rxrpc_destroy_all_connections();
rxrpc_destroy_all_transports();

ASSERTCMP(atomic_read(&rxrpc_n_skbs), ==, 0);

Expand Down
57 changes: 10 additions & 47 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ struct rxrpc_peer {
struct rxrpc_local *local;
struct hlist_head error_targets; /* targets for net error distribution */
struct work_struct error_distributor;
struct rb_root service_conns; /* Service connections */
rwlock_t conn_lock;
spinlock_t lock; /* access lock */
unsigned int if_mtu; /* interface MTU for this peer */
unsigned int mtu; /* network MTU for this peer */
Expand All @@ -225,22 +227,6 @@ struct rxrpc_peer {
suseconds_t rtt_cache[RXRPC_RTT_CACHE_SIZE]; /* calculated RTT cache */
};

/*
* RxRPC point-to-point transport / connection manager definition
* - handles a bundle of connections between two endpoints
* - matched by { local, peer }
*/
struct rxrpc_transport {
struct rxrpc_local *local; /* local transport endpoint */
struct rxrpc_peer *peer; /* remote transport endpoint */
struct rb_root server_conns; /* server connections on this transport */
struct list_head link; /* link in master session list */
unsigned long put_time; /* time at which to reap */
rwlock_t conn_lock; /* lock for active/dead connections */
atomic_t usage;
int debug_id; /* debug ID for printks */
};

/*
* Keys for matching a connection.
*/
Expand Down Expand Up @@ -271,11 +257,10 @@ struct rxrpc_conn_parameters {

/*
* RxRPC connection definition
* - matched by { transport, service_id, conn_id, direction, key }
* - matched by { local, peer, epoch, conn_id, direction }
* - each connection can only handle four simultaneous calls
*/
struct rxrpc_connection {
struct rxrpc_transport *trans; /* transport session */
struct rxrpc_conn_proto proto;
struct rxrpc_conn_parameters params;

Expand All @@ -286,7 +271,7 @@ struct rxrpc_connection {
struct work_struct processor; /* connection event processor */
union {
struct rb_node client_node; /* Node in local->client_conns */
struct rb_node service_node; /* Node in trans->server_conns */
struct rb_node service_node; /* Node in peer->service_conns */
};
struct list_head link; /* link in master connection list */
struct rb_root calls; /* calls on this connection */
Expand Down Expand Up @@ -494,10 +479,6 @@ extern u32 rxrpc_epoch;
extern atomic_t rxrpc_debug_id;
extern struct workqueue_struct *rxrpc_workqueue;

extern struct rxrpc_transport *rxrpc_name_to_transport(struct rxrpc_conn_parameters *,
struct sockaddr *,
int, gfp_t);

/*
* call_accept.c
*/
Expand Down Expand Up @@ -526,7 +507,6 @@ struct rxrpc_call *rxrpc_find_call_hash(struct rxrpc_host_header *,
struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned long);
struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *,
struct rxrpc_conn_parameters *,
struct rxrpc_transport *,
struct sockaddr_rxrpc *,
unsigned long, gfp_t);
struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *,
Expand Down Expand Up @@ -560,15 +540,16 @@ extern struct list_head rxrpc_connections;
extern rwlock_t rxrpc_connection_lock;

int rxrpc_connect_call(struct rxrpc_call *, struct rxrpc_conn_parameters *,
struct rxrpc_transport *,
struct sockaddr_rxrpc *, gfp_t);
struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_local *,
struct rxrpc_peer *,
struct sk_buff *);
void rxrpc_disconnect_call(struct rxrpc_call *);
void rxrpc_put_connection(struct rxrpc_connection *);
void __exit rxrpc_destroy_all_connections(void);
struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *,
struct sk_buff *);
extern struct rxrpc_connection *
rxrpc_incoming_connection(struct rxrpc_transport *, struct sk_buff *);
struct rxrpc_connection *rxrpc_incoming_connection(struct rxrpc_local *,
struct rxrpc_peer *,
struct sk_buff *);

static inline bool rxrpc_conn_is_client(const struct rxrpc_connection *conn)
{
Expand All @@ -585,12 +566,6 @@ static inline void rxrpc_get_connection(struct rxrpc_connection *conn)
atomic_inc(&conn->usage);
}

static inline
struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *conn)
{
return atomic_inc_not_zero(&conn->usage) ? conn : NULL;
}

/*
* input.c
*/
Expand Down Expand Up @@ -744,18 +719,6 @@ static inline int __init rxrpc_sysctl_init(void) { return 0; }
static inline void rxrpc_sysctl_exit(void) {}
#endif

/*
* transport.c
*/
extern unsigned int rxrpc_transport_expiry;

struct rxrpc_transport *rxrpc_get_transport(struct rxrpc_local *,
struct rxrpc_peer *, gfp_t);
void rxrpc_put_transport(struct rxrpc_transport *);
void __exit rxrpc_destroy_all_transports(void);
struct rxrpc_transport *rxrpc_find_transport(struct rxrpc_local *,
struct rxrpc_peer *);

/*
* utils.c
*/
Expand Down
11 changes: 1 addition & 10 deletions net/rxrpc/call_accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local,
struct sockaddr_rxrpc *srx)
{
struct rxrpc_connection *conn;
struct rxrpc_transport *trans;
struct rxrpc_skb_priv *sp, *nsp;
struct rxrpc_peer *peer;
struct rxrpc_call *call;
Expand Down Expand Up @@ -102,16 +101,8 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local,
goto error;
}

trans = rxrpc_get_transport(local, peer, GFP_NOIO);
conn = rxrpc_incoming_connection(local, peer, skb);
rxrpc_put_peer(peer);
if (IS_ERR(trans)) {
_debug("no trans");
ret = -EBUSY;
goto error;
}

conn = rxrpc_incoming_connection(trans, skb);
rxrpc_put_transport(trans);
if (IS_ERR(conn)) {
_debug("no conn");
ret = PTR_ERR(conn);
Expand Down
16 changes: 6 additions & 10 deletions net/rxrpc/call_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,9 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
/*
* Allocate a new client call.
*/
static struct rxrpc_call *rxrpc_alloc_client_call(
struct rxrpc_sock *rx,
struct rxrpc_conn_parameters *cp,
struct sockaddr_rxrpc *srx,
gfp_t gfp)
static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx,
struct sockaddr_rxrpc *srx,
gfp_t gfp)
{
struct rxrpc_call *call;

Expand Down Expand Up @@ -333,7 +331,6 @@ static struct rxrpc_call *rxrpc_alloc_client_call(
*/
static int rxrpc_begin_client_call(struct rxrpc_call *call,
struct rxrpc_conn_parameters *cp,
struct rxrpc_transport *trans,
struct sockaddr_rxrpc *srx,
gfp_t gfp)
{
Expand All @@ -342,7 +339,7 @@ static int rxrpc_begin_client_call(struct rxrpc_call *call,
/* Set up or get a connection record and set the protocol parameters,
* including channel number and call ID.
*/
ret = rxrpc_connect_call(call, cp, trans, srx, gfp);
ret = rxrpc_connect_call(call, cp, srx, gfp);
if (ret < 0)
return ret;

Expand All @@ -366,7 +363,6 @@ static int rxrpc_begin_client_call(struct rxrpc_call *call,
*/
struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
struct rxrpc_conn_parameters *cp,
struct rxrpc_transport *trans,
struct sockaddr_rxrpc *srx,
unsigned long user_call_ID,
gfp_t gfp)
Expand All @@ -377,7 +373,7 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,

_enter("%p,%lx", rx, user_call_ID);

call = rxrpc_alloc_client_call(rx, cp, srx, gfp);
call = rxrpc_alloc_client_call(rx, srx, gfp);
if (IS_ERR(call)) {
_leave(" = %ld", PTR_ERR(call));
return call;
Expand Down Expand Up @@ -413,7 +409,7 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
list_add_tail(&call->link, &rxrpc_calls);
write_unlock_bh(&rxrpc_call_lock);

ret = rxrpc_begin_client_call(call, cp, trans, srx, gfp);
ret = rxrpc_begin_client_call(call, cp, srx, gfp);
if (ret < 0)
goto error;

Expand Down
Loading

0 comments on commit aa390bb

Please sign in to comment.