Commit 94f7153e authored by David S. Miller's avatar David S. Miller

Merge tag 'rxrpc-rewrite-20160304' of...

Merge tag 'rxrpc-rewrite-20160304' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

David Howells says:

====================
RxRPC: Rewrite part 1

Here's the first set of patches from my RxRPC rewrite, aimed at net-next.
These do some clean ups and bug fixes.  Most of the changes are small, but
there are a couple of bigger changes:

 (*) Convert call flag numbers and event numbers into enums.  Then rename
     the event numbers to all have _EV_ in their name to stop confusion.
     Fix one instance of an event bit being used instead of a flag bit.

 (*) A copy of the Rx protocol header is kept in the sk_buff private data.
     Keep this in host byte order rather than network byte order as it
     makes more sense.  A number of other fields then get converted into
     host byte order too.

     Conversion between host and network byte order is then done at the
     packet reception/generation stage.

This is based on net-next/master
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3d1c6df8 a4373a48
...@@ -22,7 +22,7 @@ typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */ ...@@ -22,7 +22,7 @@ typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */
* on-the-wire Rx packet header * on-the-wire Rx packet header
* - all multibyte fields should be in network byte order * - all multibyte fields should be in network byte order
*/ */
struct rxrpc_header { struct rxrpc_wire_header {
__be32 epoch; /* client boot timestamp */ __be32 epoch; /* client boot timestamp */
__be32 cid; /* connection and channel ID */ __be32 cid; /* connection and channel ID */
...@@ -68,10 +68,19 @@ struct rxrpc_header { ...@@ -68,10 +68,19 @@ struct rxrpc_header {
} __packed; } __packed;
#define __rxrpc_header_off(X) offsetof(struct rxrpc_header,X)
extern const char *rxrpc_pkts[]; extern const char *rxrpc_pkts[];
#define RXRPC_SUPPORTED_PACKET_TYPES ( \
(1 << RXRPC_PACKET_TYPE_DATA) | \
(1 << RXRPC_PACKET_TYPE_ACK) | \
(1 << RXRPC_PACKET_TYPE_BUSY) | \
(1 << RXRPC_PACKET_TYPE_ABORT) | \
(1 << RXRPC_PACKET_TYPE_ACKALL) | \
(1 << RXRPC_PACKET_TYPE_CHALLENGE) | \
(1 << RXRPC_PACKET_TYPE_RESPONSE) | \
/*(1 << RXRPC_PACKET_TYPE_DEBUG) | */ \
(1 << RXRPC_PACKET_TYPE_VERSION))
/*****************************************************************************/ /*****************************************************************************/
/* /*
* jumbo packet secondary header * jumbo packet secondary header
......
...@@ -37,7 +37,7 @@ static struct proto rxrpc_proto; ...@@ -37,7 +37,7 @@ static struct proto rxrpc_proto;
static const struct proto_ops rxrpc_rpc_ops; static const struct proto_ops rxrpc_rpc_ops;
/* local epoch for detecting local-end reset */ /* local epoch for detecting local-end reset */
__be32 rxrpc_epoch; u32 rxrpc_epoch;
/* current debugging ID */ /* current debugging ID */
atomic_t rxrpc_debug_id; atomic_t rxrpc_debug_id;
...@@ -81,6 +81,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -81,6 +81,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
struct sockaddr_rxrpc *srx, struct sockaddr_rxrpc *srx,
int len) int len)
{ {
unsigned tail;
if (len < sizeof(struct sockaddr_rxrpc)) if (len < sizeof(struct sockaddr_rxrpc))
return -EINVAL; return -EINVAL;
...@@ -103,9 +105,7 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -103,9 +105,7 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
_debug("INET: %x @ %pI4", _debug("INET: %x @ %pI4",
ntohs(srx->transport.sin.sin_port), ntohs(srx->transport.sin.sin_port),
&srx->transport.sin.sin_addr); &srx->transport.sin.sin_addr);
if (srx->transport_len > 8) tail = offsetof(struct sockaddr_rxrpc, transport.sin.__pad);
memset((void *)&srx->transport + 8, 0,
srx->transport_len - 8);
break; break;
case AF_INET6: case AF_INET6:
...@@ -113,6 +113,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -113,6 +113,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
} }
if (tail < len)
memset((void *)srx + tail, 0, len - tail);
return 0; return 0;
} }
...@@ -121,11 +123,10 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -121,11 +123,10 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
*/ */
static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len)
{ {
struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *) saddr; struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *)saddr;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct rxrpc_local *local; struct rxrpc_local *local;
struct rxrpc_sock *rx = rxrpc_sk(sk), *prx; struct rxrpc_sock *rx = rxrpc_sk(sk), *prx;
__be16 service_id;
int ret; int ret;
_enter("%p,%p,%d", rx, saddr, len); _enter("%p,%p,%d", rx, saddr, len);
...@@ -143,7 +144,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) ...@@ -143,7 +144,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len)
memcpy(&rx->srx, srx, sizeof(rx->srx)); memcpy(&rx->srx, srx, sizeof(rx->srx));
/* find a local transport endpoint if we don't have one already */ /* Find or create a local transport endpoint to use */
local = rxrpc_lookup_local(&rx->srx); local = rxrpc_lookup_local(&rx->srx);
if (IS_ERR(local)) { if (IS_ERR(local)) {
ret = PTR_ERR(local); ret = PTR_ERR(local);
...@@ -152,14 +153,12 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) ...@@ -152,14 +153,12 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len)
rx->local = local; rx->local = local;
if (srx->srx_service) { if (srx->srx_service) {
service_id = htons(srx->srx_service);
write_lock_bh(&local->services_lock); write_lock_bh(&local->services_lock);
list_for_each_entry(prx, &local->services, listen_link) { list_for_each_entry(prx, &local->services, listen_link) {
if (prx->service_id == service_id) if (prx->srx.srx_service == srx->srx_service)
goto service_in_use; goto service_in_use;
} }
rx->service_id = service_id;
list_add_tail(&rx->listen_link, &local->services); list_add_tail(&rx->listen_link, &local->services);
write_unlock_bh(&local->services_lock); write_unlock_bh(&local->services_lock);
...@@ -276,7 +275,6 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, ...@@ -276,7 +275,6 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
struct rxrpc_transport *trans; struct rxrpc_transport *trans;
struct rxrpc_call *call; struct rxrpc_call *call;
struct rxrpc_sock *rx = rxrpc_sk(sock->sk); struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
__be16 service_id;
_enter(",,%x,%lx", key_serial(key), user_call_ID); _enter(",,%x,%lx", key_serial(key), user_call_ID);
...@@ -299,16 +297,14 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, ...@@ -299,16 +297,14 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
atomic_inc(&trans->usage); atomic_inc(&trans->usage);
} }
service_id = rx->service_id; if (!srx)
if (srx) srx = &rx->srx;
service_id = htons(srx->srx_service);
if (!key) if (!key)
key = rx->key; key = rx->key;
if (key && !key->payload.data[0]) if (key && !key->payload.data[0])
key = NULL; /* a no-security key */ key = NULL; /* a no-security key */
bundle = rxrpc_get_bundle(rx, trans, key, service_id, gfp); bundle = rxrpc_get_bundle(rx, trans, key, srx->srx_service, gfp);
if (IS_ERR(bundle)) { if (IS_ERR(bundle)) {
call = ERR_CAST(bundle); call = ERR_CAST(bundle);
goto out; goto out;
...@@ -324,7 +320,6 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, ...@@ -324,7 +320,6 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
_leave(" = %p", call); _leave(" = %p", call);
return call; return call;
} }
EXPORT_SYMBOL(rxrpc_kernel_begin_call); EXPORT_SYMBOL(rxrpc_kernel_begin_call);
/** /**
...@@ -340,7 +335,6 @@ void rxrpc_kernel_end_call(struct rxrpc_call *call) ...@@ -340,7 +335,6 @@ void rxrpc_kernel_end_call(struct rxrpc_call *call)
rxrpc_remove_user_ID(call->socket, call); rxrpc_remove_user_ID(call->socket, call);
rxrpc_put_call(call); rxrpc_put_call(call);
} }
EXPORT_SYMBOL(rxrpc_kernel_end_call); EXPORT_SYMBOL(rxrpc_kernel_end_call);
/** /**
...@@ -425,7 +419,6 @@ static int rxrpc_connect(struct socket *sock, struct sockaddr *addr, ...@@ -425,7 +419,6 @@ static int rxrpc_connect(struct socket *sock, struct sockaddr *addr,
} }
rx->trans = trans; rx->trans = trans;
rx->service_id = htons(srx->srx_service);
rx->sk.sk_state = RXRPC_CLIENT_CONNECTED; rx->sk.sk_state = RXRPC_CLIENT_CONNECTED;
release_sock(&rx->sk); release_sock(&rx->sk);
...@@ -622,7 +615,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol, ...@@ -622,7 +615,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol,
if (!net_eq(net, &init_net)) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* we support transport protocol UDP only */ /* we support transport protocol UDP/UDP6 only */
if (protocol != PF_INET) if (protocol != PF_INET)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
...@@ -754,7 +747,7 @@ static int rxrpc_release(struct socket *sock) ...@@ -754,7 +747,7 @@ static int rxrpc_release(struct socket *sock)
* RxRPC network protocol * RxRPC network protocol
*/ */
static const struct proto_ops rxrpc_rpc_ops = { static const struct proto_ops rxrpc_rpc_ops = {
.family = PF_UNIX, .family = PF_RXRPC,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.release = rxrpc_release, .release = rxrpc_release,
.bind = rxrpc_bind, .bind = rxrpc_bind,
...@@ -778,7 +771,7 @@ static struct proto rxrpc_proto = { ...@@ -778,7 +771,7 @@ static struct proto rxrpc_proto = {
.name = "RXRPC", .name = "RXRPC",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.obj_size = sizeof(struct rxrpc_sock), .obj_size = sizeof(struct rxrpc_sock),
.max_header = sizeof(struct rxrpc_header), .max_header = sizeof(struct rxrpc_wire_header),
}; };
static const struct net_proto_family rxrpc_family_ops = { static const struct net_proto_family rxrpc_family_ops = {
...@@ -796,7 +789,7 @@ static int __init af_rxrpc_init(void) ...@@ -796,7 +789,7 @@ static int __init af_rxrpc_init(void)
BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > FIELD_SIZEOF(struct sk_buff, cb)); BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > FIELD_SIZEOF(struct sk_buff, cb));
rxrpc_epoch = htonl(get_seconds()); rxrpc_epoch = get_seconds();
ret = -ENOMEM; ret = -ENOMEM;
rxrpc_call_jar = kmem_cache_create( rxrpc_call_jar = kmem_cache_create(
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* generate a connection-level abort * generate a connection-level abort
*/ */
static int rxrpc_busy(struct rxrpc_local *local, struct sockaddr_rxrpc *srx, static int rxrpc_busy(struct rxrpc_local *local, struct sockaddr_rxrpc *srx,
struct rxrpc_header *hdr) struct rxrpc_wire_header *whdr)
{ {
struct msghdr msg; struct msghdr msg;
struct kvec iov[1]; struct kvec iov[1];
...@@ -36,25 +36,21 @@ static int rxrpc_busy(struct rxrpc_local *local, struct sockaddr_rxrpc *srx, ...@@ -36,25 +36,21 @@ static int rxrpc_busy(struct rxrpc_local *local, struct sockaddr_rxrpc *srx,
_enter("%d,,", local->debug_id); _enter("%d,,", local->debug_id);
whdr->type = RXRPC_PACKET_TYPE_BUSY;
whdr->serial = htonl(1);
msg.msg_name = &srx->transport.sin; msg.msg_name = &srx->transport.sin;
msg.msg_namelen = sizeof(srx->transport.sin); msg.msg_namelen = sizeof(srx->transport.sin);
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = 0; msg.msg_flags = 0;
hdr->seq = 0; iov[0].iov_base = whdr;
hdr->type = RXRPC_PACKET_TYPE_BUSY; iov[0].iov_len = sizeof(*whdr);
hdr->flags = 0;
hdr->userStatus = 0;
hdr->_rsvd = 0;
iov[0].iov_base = hdr;
iov[0].iov_len = sizeof(*hdr);
len = iov[0].iov_len; len = iov[0].iov_len;
hdr->serial = htonl(1); _proto("Tx BUSY %%1");
_proto("Tx BUSY %%%u", ntohl(hdr->serial));
ret = kernel_sendmsg(local->socket, &msg, iov, 1, len); ret = kernel_sendmsg(local->socket, &msg, iov, 1, len);
if (ret < 0) { if (ret < 0) {
...@@ -185,8 +181,8 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local, ...@@ -185,8 +181,8 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local,
read_unlock_bh(&local->services_lock); read_unlock_bh(&local->services_lock);
read_lock_bh(&call->state_lock); read_lock_bh(&call->state_lock);
if (!test_bit(RXRPC_CALL_RELEASE, &call->flags) && if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) &&
!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events)) { !test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events)) {
rxrpc_get_call(call); rxrpc_get_call(call);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
...@@ -211,8 +207,8 @@ void rxrpc_accept_incoming_calls(struct work_struct *work) ...@@ -211,8 +207,8 @@ void rxrpc_accept_incoming_calls(struct work_struct *work)
struct rxrpc_skb_priv *sp; struct rxrpc_skb_priv *sp;
struct sockaddr_rxrpc srx; struct sockaddr_rxrpc srx;
struct rxrpc_sock *rx; struct rxrpc_sock *rx;
struct rxrpc_wire_header whdr;
struct sk_buff *skb; struct sk_buff *skb;
__be16 service_id;
int ret; int ret;
_enter("%d", local->debug_id); _enter("%d", local->debug_id);
...@@ -240,6 +236,19 @@ void rxrpc_accept_incoming_calls(struct work_struct *work) ...@@ -240,6 +236,19 @@ void rxrpc_accept_incoming_calls(struct work_struct *work)
sp = rxrpc_skb(skb); sp = rxrpc_skb(skb);
/* Set up a response packet header in case we need it */
whdr.epoch = htonl(sp->hdr.epoch);
whdr.cid = htonl(sp->hdr.cid);
whdr.callNumber = htonl(sp->hdr.callNumber);
whdr.seq = htonl(sp->hdr.seq);
whdr.serial = 0;
whdr.flags = 0;
whdr.type = 0;
whdr.userStatus = 0;
whdr.securityIndex = sp->hdr.securityIndex;
whdr._rsvd = 0;
whdr.serviceId = htons(sp->hdr.serviceId);
/* determine the remote address */ /* determine the remote address */
memset(&srx, 0, sizeof(srx)); memset(&srx, 0, sizeof(srx));
srx.srx_family = AF_RXRPC; srx.srx_family = AF_RXRPC;
...@@ -256,10 +265,9 @@ void rxrpc_accept_incoming_calls(struct work_struct *work) ...@@ -256,10 +265,9 @@ void rxrpc_accept_incoming_calls(struct work_struct *work)
} }
/* get the socket providing the service */ /* get the socket providing the service */
service_id = sp->hdr.serviceId;
read_lock_bh(&local->services_lock); read_lock_bh(&local->services_lock);
list_for_each_entry(rx, &local->services, listen_link) { list_for_each_entry(rx, &local->services, listen_link) {
if (rx->service_id == service_id && if (rx->srx.srx_service == sp->hdr.serviceId &&
rx->sk.sk_state != RXRPC_CLOSE) rx->sk.sk_state != RXRPC_CLOSE)
goto found_service; goto found_service;
} }
...@@ -267,7 +275,7 @@ void rxrpc_accept_incoming_calls(struct work_struct *work) ...@@ -267,7 +275,7 @@ void rxrpc_accept_incoming_calls(struct work_struct *work)
goto invalid_service; goto invalid_service;
found_service: found_service:
_debug("found service %hd", ntohs(rx->service_id)); _debug("found service %hd", rx->srx.srx_service);
if (sk_acceptq_is_full(&rx->sk)) if (sk_acceptq_is_full(&rx->sk))
goto backlog_full; goto backlog_full;
sk_acceptq_added(&rx->sk); sk_acceptq_added(&rx->sk);
...@@ -296,7 +304,7 @@ void rxrpc_accept_incoming_calls(struct work_struct *work) ...@@ -296,7 +304,7 @@ void rxrpc_accept_incoming_calls(struct work_struct *work)
backlog_full: backlog_full:
read_unlock_bh(&local->services_lock); read_unlock_bh(&local->services_lock);
busy: busy:
rxrpc_busy(local, &srx, &sp->hdr); rxrpc_busy(local, &srx, &whdr);
rxrpc_free_skb(skb); rxrpc_free_skb(skb);
goto process_next_packet; goto process_next_packet;
...@@ -379,7 +387,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx, ...@@ -379,7 +387,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx,
rb_insert_color(&call->sock_node, &rx->calls); rb_insert_color(&call->sock_node, &rx->calls);
if (test_and_set_bit(RXRPC_CALL_HAS_USERID, &call->flags)) if (test_and_set_bit(RXRPC_CALL_HAS_USERID, &call->flags))
BUG(); BUG();
if (test_and_set_bit(RXRPC_CALL_ACCEPTED, &call->events)) if (test_and_set_bit(RXRPC_CALL_EV_ACCEPTED, &call->events))
BUG(); BUG();
rxrpc_queue_call(call); rxrpc_queue_call(call);
...@@ -395,7 +403,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx, ...@@ -395,7 +403,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx,
out_release: out_release:
_debug("release %p", call); _debug("release %p", call);
if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) && if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) &&
!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
out_discard: out_discard:
write_unlock_bh(&call->state_lock); write_unlock_bh(&call->state_lock);
...@@ -407,7 +415,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx, ...@@ -407,7 +415,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx,
} }
/* /*
* handle rejectance of a call by userspace * Handle rejection of a call by userspace
* - reject the call at the front of the queue * - reject the call at the front of the queue
*/ */
int rxrpc_reject_call(struct rxrpc_sock *rx) int rxrpc_reject_call(struct rxrpc_sock *rx)
...@@ -434,7 +442,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx) ...@@ -434,7 +442,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx)
switch (call->state) { switch (call->state) {
case RXRPC_CALL_SERVER_ACCEPTING: case RXRPC_CALL_SERVER_ACCEPTING:
call->state = RXRPC_CALL_SERVER_BUSY; call->state = RXRPC_CALL_SERVER_BUSY;
if (test_and_set_bit(RXRPC_CALL_REJECT_BUSY, &call->events)) if (test_and_set_bit(RXRPC_CALL_EV_REJECT_BUSY, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
ret = 0; ret = 0;
goto out_release; goto out_release;
...@@ -458,7 +466,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx) ...@@ -458,7 +466,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx)
out_release: out_release:
_debug("release %p", call); _debug("release %p", call);
if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) && if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) &&
!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
out_discard: out_discard:
write_unlock_bh(&call->state_lock); write_unlock_bh(&call->state_lock);
...@@ -487,7 +495,6 @@ struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *sock, ...@@ -487,7 +495,6 @@ struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *sock,
_leave(" = %p", call); _leave(" = %p", call);
return call; return call;
} }
EXPORT_SYMBOL(rxrpc_kernel_accept_call); EXPORT_SYMBOL(rxrpc_kernel_accept_call);
/** /**
...@@ -506,5 +513,4 @@ int rxrpc_kernel_reject_call(struct socket *sock) ...@@ -506,5 +513,4 @@ int rxrpc_kernel_reject_call(struct socket *sock)
_leave(" = %d", ret); _leave(" = %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL(rxrpc_kernel_reject_call); EXPORT_SYMBOL(rxrpc_kernel_reject_call);
This diff is collapsed.
...@@ -28,7 +28,7 @@ unsigned rxrpc_max_call_lifetime = 60 * HZ; ...@@ -28,7 +28,7 @@ unsigned rxrpc_max_call_lifetime = 60 * HZ;
*/ */
unsigned rxrpc_dead_call_expiry = 2 * HZ; unsigned rxrpc_dead_call_expiry = 2 * HZ;
const char *const rxrpc_call_states[] = { const char *const rxrpc_call_states[NR__RXRPC_CALL_STATES] = {
[RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq", [RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq",
[RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl", [RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl",
[RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl", [RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl",
...@@ -64,11 +64,11 @@ static DEFINE_HASHTABLE(rxrpc_call_hash, 10); ...@@ -64,11 +64,11 @@ static DEFINE_HASHTABLE(rxrpc_call_hash, 10);
* Hash function for rxrpc_call_hash * Hash function for rxrpc_call_hash
*/ */
static unsigned long rxrpc_call_hashfunc( static unsigned long rxrpc_call_hashfunc(
u8 clientflag, u8 in_clientflag,
__be32 cid, u32 cid,
__be32 call_id, u32 call_id,
__be32 epoch, u32 epoch,
__be16 service_id, u16 service_id,
sa_family_t proto, sa_family_t proto,
void *localptr, void *localptr,
unsigned int addr_size, unsigned int addr_size,
...@@ -77,7 +77,6 @@ static unsigned long rxrpc_call_hashfunc( ...@@ -77,7 +77,6 @@ static unsigned long rxrpc_call_hashfunc(
const u16 *p; const u16 *p;
unsigned int i; unsigned int i;
unsigned long key; unsigned long key;
u32 hcid = ntohl(cid);
_enter(""); _enter("");
...@@ -85,12 +84,12 @@ static unsigned long rxrpc_call_hashfunc( ...@@ -85,12 +84,12 @@ static unsigned long rxrpc_call_hashfunc(
/* We just want to add up the __be32 values, so forcing the /* We just want to add up the __be32 values, so forcing the
* cast should be okay. * cast should be okay.
*/ */
key += (__force u32)epoch; key += epoch;
key += (__force u16)service_id; key += service_id;
key += (__force u32)call_id; key += call_id;
key += (hcid & RXRPC_CIDMASK) >> RXRPC_CIDSHIFT; key += (cid & RXRPC_CIDMASK) >> RXRPC_CIDSHIFT;
key += hcid & RXRPC_CHANNELMASK; key += cid & RXRPC_CHANNELMASK;
key += clientflag; key += in_clientflag;
key += proto; key += proto;
/* Step through the peer address in 16-bit portions for speed */ /* Step through the peer address in 16-bit portions for speed */
for (i = 0, p = (const u16 *)peer_addr; i < addr_size >> 1; i++, p++) for (i = 0, p = (const u16 *)peer_addr; i < addr_size >> 1; i++, p++)
...@@ -148,19 +147,16 @@ static void rxrpc_call_hash_del(struct rxrpc_call *call) ...@@ -148,19 +147,16 @@ static void rxrpc_call_hash_del(struct rxrpc_call *call)
* isn't there. * isn't there.
*/ */
struct rxrpc_call *rxrpc_find_call_hash( struct rxrpc_call *rxrpc_find_call_hash(
u8 clientflag, struct rxrpc_host_header *hdr,
__be32 cid,
__be32 call_id,
__be32 epoch,
__be16 service_id,
void *localptr, void *localptr,
sa_family_t proto, sa_family_t proto,
const u8 *peer_addr) const void *peer_addr)
{ {
unsigned long key; unsigned long key;
unsigned int addr_size = 0; unsigned int addr_size = 0;
struct rxrpc_call *call = NULL; struct rxrpc_call *call = NULL;
struct rxrpc_call *ret = NULL; struct rxrpc_call *ret = NULL;
u8 in_clientflag = hdr->flags & RXRPC_CLIENT_INITIATED;
_enter(""); _enter("");
switch (proto) { switch (proto) {
...@@ -174,20 +170,21 @@ struct rxrpc_call *rxrpc_find_call_hash( ...@@ -174,20 +170,21 @@ struct rxrpc_call *rxrpc_find_call_hash(
break; break;
} }
key = rxrpc_call_hashfunc(clientflag, cid, call_id, epoch, key = rxrpc_call_hashfunc(in_clientflag, hdr->cid, hdr->callNumber,
service_id, proto, localptr, addr_size, hdr->epoch, hdr->serviceId,
proto, localptr, addr_size,
peer_addr); peer_addr);
hash_for_each_possible_rcu(rxrpc_call_hash, call, hash_node, key) { hash_for_each_possible_rcu(rxrpc_call_hash, call, hash_node, key) {
if (call->hash_key == key && if (call->hash_key == key &&
call->call_id == call_id && call->call_id == hdr->callNumber &&
call->cid == cid && call->cid == hdr->cid &&
call->in_clientflag == clientflag && call->in_clientflag == in_clientflag &&
call->service_id == service_id && call->service_id == hdr->serviceId &&
call->proto == proto && call->proto == proto &&
call->local == localptr && call->local == localptr &&
memcmp(call->peer_ip.ipv6_addr, peer_addr, memcmp(call->peer_ip.ipv6_addr, peer_addr,
addr_size) == 0 && addr_size) == 0 &&
call->epoch == epoch) { call->epoch == hdr->epoch) {
ret = call; ret = call;
break; break;
} }
...@@ -414,12 +411,12 @@ struct rxrpc_call *rxrpc_get_client_call(struct rxrpc_sock *rx, ...@@ -414,12 +411,12 @@ struct rxrpc_call *rxrpc_get_client_call(struct rxrpc_sock *rx,
*/ */
struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx, struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
struct rxrpc_connection *conn, struct rxrpc_connection *conn,
struct rxrpc_header *hdr, struct rxrpc_host_header *hdr,
gfp_t gfp) gfp_t gfp)
{ {
struct rxrpc_call *call, *candidate; struct rxrpc_call *call, *candidate;
struct rb_node **p, *parent; struct rb_node **p, *parent;
__be32 call_id; u32 call_id;
_enter(",%d,,%x", conn->debug_id, gfp); _enter(",%d,,%x", conn->debug_id, gfp);
...@@ -433,7 +430,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx, ...@@ -433,7 +430,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
candidate->conn = conn; candidate->conn = conn;
candidate->cid = hdr->cid; candidate->cid = hdr->cid;
candidate->call_id = hdr->callNumber; candidate->call_id = hdr->callNumber;
candidate->channel = ntohl(hdr->cid) & RXRPC_CHANNELMASK; candidate->channel = hdr->cid & RXRPC_CHANNELMASK;
candidate->rx_data_post = 0; candidate->rx_data_post = 0;
candidate->state = RXRPC_CALL_SERVER_ACCEPTING; candidate->state = RXRPC_CALL_SERVER_ACCEPTING;
if (conn->security_ix > 0) if (conn->security_ix > 0)
...@@ -452,7 +449,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx, ...@@ -452,7 +449,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
read_lock(&call->state_lock); read_lock(&call->state_lock);
switch (call->state) { switch (call->state) {
case RXRPC_CALL_LOCALLY_ABORTED: case RXRPC_CALL_LOCALLY_ABORTED:
if (!test_and_set_bit(RXRPC_CALL_ABORT, &call->events)) if (!test_and_set_bit(RXRPC_CALL_EV_ABORT, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
case RXRPC_CALL_REMOTELY_ABORTED: case RXRPC_CALL_REMOTELY_ABORTED:
read_unlock(&call->state_lock); read_unlock(&call->state_lock);
...@@ -492,9 +489,9 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx, ...@@ -492,9 +489,9 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
/* The tree is sorted in order of the __be32 value without /* The tree is sorted in order of the __be32 value without
* turning it into host order. * turning it into host order.
*/ */
if ((__force u32)call_id < (__force u32)call->call_id) if (call_id < call->call_id)
p = &(*p)->rb_left; p = &(*p)->rb_left;
else if ((__force u32)call_id > (__force u32)call->call_id) else if (call_id > call->call_id)
p = &(*p)->rb_right; p = &(*p)->rb_right;
else else
goto old_call; goto old_call;
...@@ -686,7 +683,7 @@ void rxrpc_release_call(struct rxrpc_call *call) ...@@ -686,7 +683,7 @@ void rxrpc_release_call(struct rxrpc_call *call)
_debug("+++ ABORTING STATE %d +++\n", call->state); _debug("+++ ABORTING STATE %d +++\n", call->state);
call->state = RXRPC_CALL_LOCALLY_ABORTED; call->state = RXRPC_CALL_LOCALLY_ABORTED;
call->abort_code = RX_CALL_DEAD; call->abort_code = RX_CALL_DEAD;
set_bit(RXRPC_CALL_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
write_unlock(&call->state_lock); write_unlock(&call->state_lock);
...@@ -714,8 +711,7 @@ void rxrpc_release_call(struct rxrpc_call *call) ...@@ -714,8 +711,7 @@ void rxrpc_release_call(struct rxrpc_call *call)
_debug("- zap %s %%%u #%u", _debug("- zap %s %%%u #%u",
rxrpc_pkts[sp->hdr.type], rxrpc_pkts[sp->hdr.type],
ntohl(sp->hdr.serial), sp->hdr.serial, sp->hdr.seq);
ntohl(sp->hdr.seq));
rxrpc_free_skb(skb); rxrpc_free_skb(skb);
spin_lock_bh(&call->lock); spin_lock_bh(&call->lock);
} }
...@@ -763,10 +759,10 @@ static void rxrpc_mark_call_released(struct rxrpc_call *call) ...@@ -763,10 +759,10 @@ static void rxrpc_mark_call_released(struct rxrpc_call *call)
_debug("abort call %p", call); _debug("abort call %p", call);
call->state = RXRPC_CALL_LOCALLY_ABORTED; call->state = RXRPC_CALL_LOCALLY_ABORTED;
call->abort_code = RX_CALL_DEAD; call->abort_code = RX_CALL_DEAD;
if (!test_and_set_bit(RXRPC_CALL_ABORT, &call->events)) if (!test_and_set_bit(RXRPC_CALL_EV_ABORT, &call->events))
sched = true; sched = true;
} }
if (!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events)) if (!test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
sched = true; sched = true;
if (sched) if (sched)
rxrpc_queue_call(call); rxrpc_queue_call(call);
...@@ -873,9 +869,9 @@ static void rxrpc_cleanup_call(struct rxrpc_call *call) ...@@ -873,9 +869,9 @@ static void rxrpc_cleanup_call(struct rxrpc_call *call)
unsigned long _skb; unsigned long _skb;
_skb = call->acks_window[call->acks_tail] & ~1; _skb = call->acks_window[call->acks_tail] & ~1;
sp = rxrpc_skb((struct sk_buff *) _skb); sp = rxrpc_skb((struct sk_buff *)_skb);
_debug("+++ clear Tx %u", ntohl(sp->hdr.seq)); _debug("+++ clear Tx %u", sp->hdr.seq);
rxrpc_free_skb((struct sk_buff *) _skb); rxrpc_free_skb((struct sk_buff *)_skb);
call->acks_tail = call->acks_tail =
(call->acks_tail + 1) & (call->acks_winsz - 1); (call->acks_tail + 1) & (call->acks_winsz - 1);
} }
...@@ -975,7 +971,7 @@ static void rxrpc_call_life_expired(unsigned long _call) ...@@ -975,7 +971,7 @@ static void rxrpc_call_life_expired(unsigned long _call)
_enter("{%d}", call->debug_id); _enter("{%d}", call->debug_id);
read_lock_bh(&call->state_lock); read_lock_bh(&call->state_lock);
if (call->state < RXRPC_CALL_COMPLETE) { if (call->state < RXRPC_CALL_COMPLETE) {
set_bit(RXRPC_CALL_LIFE_TIMER, &call->events); set_bit(RXRPC_CALL_EV_LIFE_TIMER, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
read_unlock_bh(&call->state_lock); read_unlock_bh(&call->state_lock);
...@@ -995,7 +991,7 @@ static void rxrpc_resend_time_expired(unsigned long _call) ...@@ -995,7 +991,7 @@ static void rxrpc_resend_time_expired(unsigned long _call)
return; return;
clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags); clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
if (!test_and_set_bit(RXRPC_CALL_RESEND_TIMER, &call->events)) if (!test_and_set_bit(RXRPC_CALL_EV_RESEND_TIMER, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
...@@ -1013,7 +1009,7 @@ static void rxrpc_ack_time_expired(unsigned long _call) ...@@ -1013,7 +1009,7 @@ static void rxrpc_ack_time_expired(unsigned long _call)
read_lock_bh(&call->state_lock); read_lock_bh(&call->state_lock);
if (call->state < RXRPC_CALL_COMPLETE && if (call->state < RXRPC_CALL_COMPLETE &&
!test_and_set_bit(RXRPC_CALL_ACK, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_ACK, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
read_unlock_bh(&call->state_lock); read_unlock_bh(&call->state_lock);
} }
...@@ -57,10 +57,10 @@ static struct rxrpc_conn_bundle *rxrpc_alloc_bundle(gfp_t gfp) ...@@ -57,10 +57,10 @@ static struct rxrpc_conn_bundle *rxrpc_alloc_bundle(gfp_t gfp)
*/ */
static inline static inline
int rxrpc_cmp_bundle(const struct rxrpc_conn_bundle *bundle, int rxrpc_cmp_bundle(const struct rxrpc_conn_bundle *bundle,
struct key *key, __be16 service_id) struct key *key, u16 service_id)
{ {
return (bundle->service_id - service_id) ?: return (bundle->service_id - service_id) ?:
((unsigned long) bundle->key - (unsigned long) key); ((unsigned long)bundle->key - (unsigned long)key);
} }
/* /*
...@@ -69,14 +69,14 @@ int rxrpc_cmp_bundle(const struct rxrpc_conn_bundle *bundle, ...@@ -69,14 +69,14 @@ int rxrpc_cmp_bundle(const struct rxrpc_conn_bundle *bundle,
struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *rx, struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *rx,
struct rxrpc_transport *trans, struct rxrpc_transport *trans,
struct key *key, struct key *key,
__be16 service_id, u16 service_id,
gfp_t gfp) gfp_t gfp)
{ {
struct rxrpc_conn_bundle *bundle, *candidate; struct rxrpc_conn_bundle *bundle, *candidate;
struct rb_node *p, *parent, **pp; struct rb_node *p, *parent, **pp;
_enter("%p{%x},%x,%hx,", _enter("%p{%x},%x,%hx,",
rx, key_serial(key), trans->debug_id, ntohs(service_id)); rx, key_serial(key), trans->debug_id, service_id);
if (rx->trans == trans && rx->bundle) { if (rx->trans == trans && rx->bundle) {
atomic_inc(&rx->bundle->usage); atomic_inc(&rx->bundle->usage);
...@@ -213,7 +213,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp) ...@@ -213,7 +213,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
conn->debug_id = atomic_inc_return(&rxrpc_debug_id); conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
conn->avail_calls = RXRPC_MAXCALLS; conn->avail_calls = RXRPC_MAXCALLS;
conn->size_align = 4; conn->size_align = 4;
conn->header_size = sizeof(struct rxrpc_header); conn->header_size = sizeof(struct rxrpc_wire_header);
} }
_leave(" = %p{%d}", conn, conn ? conn->debug_id : 0); _leave(" = %p{%d}", conn, conn ? conn->debug_id : 0);
...@@ -230,7 +230,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn) ...@@ -230,7 +230,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
struct rxrpc_connection *xconn; struct rxrpc_connection *xconn;
struct rb_node *parent, **p; struct rb_node *parent, **p;
__be32 epoch; __be32 epoch;
u32 real_conn_id; u32 cid;
_enter(""); _enter("");
...@@ -241,7 +241,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn) ...@@ -241,7 +241,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
conn->trans->conn_idcounter += RXRPC_CID_INC; conn->trans->conn_idcounter += RXRPC_CID_INC;
if (conn->trans->conn_idcounter < RXRPC_CID_INC) if (conn->trans->conn_idcounter < RXRPC_CID_INC)
conn->trans->conn_idcounter = RXRPC_CID_INC; conn->trans->conn_idcounter = RXRPC_CID_INC;
real_conn_id = conn->trans->conn_idcounter; cid = conn->trans->conn_idcounter;
attempt_insertion: attempt_insertion:
parent = NULL; parent = NULL;
...@@ -255,9 +255,9 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn) ...@@ -255,9 +255,9 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
p = &(*p)->rb_left; p = &(*p)->rb_left;
else if (epoch > xconn->epoch) else if (epoch > xconn->epoch)
p = &(*p)->rb_right; p = &(*p)->rb_right;
else if (real_conn_id < xconn->real_conn_id) else if (cid < xconn->cid)
p = &(*p)->rb_left; p = &(*p)->rb_left;
else if (real_conn_id > xconn->real_conn_id) else if (cid > xconn->cid)
p = &(*p)->rb_right; p = &(*p)->rb_right;
else else
goto id_exists; goto id_exists;
...@@ -268,20 +268,19 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn) ...@@ -268,20 +268,19 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
rb_link_node(&conn->node, parent, p); rb_link_node(&conn->node, parent, p);
rb_insert_color(&conn->node, &conn->trans->client_conns); rb_insert_color(&conn->node, &conn->trans->client_conns);
conn->real_conn_id = real_conn_id; conn->cid = cid;
conn->cid = htonl(real_conn_id);
write_unlock_bh(&conn->trans->conn_lock); write_unlock_bh(&conn->trans->conn_lock);
_leave(" [CONNID %x CID %x]", real_conn_id, ntohl(conn->cid)); _leave(" [CID %x]", cid);
return; return;
/* we found a connection with the proposed ID - walk the tree from that /* we found a connection with the proposed ID - walk the tree from that
* point looking for the next unused ID */ * point looking for the next unused ID */
id_exists: id_exists:
for (;;) { for (;;) {
real_conn_id += RXRPC_CID_INC; cid += RXRPC_CID_INC;
if (real_conn_id < RXRPC_CID_INC) { if (cid < RXRPC_CID_INC) {
real_conn_id = RXRPC_CID_INC; cid = RXRPC_CID_INC;
conn->trans->conn_idcounter = real_conn_id; conn->trans->conn_idcounter = cid;
goto attempt_insertion; goto attempt_insertion;
} }
...@@ -291,7 +290,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn) ...@@ -291,7 +290,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
xconn = rb_entry(parent, struct rxrpc_connection, node); xconn = rb_entry(parent, struct rxrpc_connection, node);
if (epoch < xconn->epoch || if (epoch < xconn->epoch ||
real_conn_id < xconn->real_conn_id) cid < xconn->cid)
goto attempt_insertion; goto attempt_insertion;
} }
} }
...@@ -334,7 +333,7 @@ static void rxrpc_add_call_ID_to_conn(struct rxrpc_connection *conn, ...@@ -334,7 +333,7 @@ static void rxrpc_add_call_ID_to_conn(struct rxrpc_connection *conn,
*/ */
static int rxrpc_connect_exclusive(struct rxrpc_sock *rx, static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
struct rxrpc_transport *trans, struct rxrpc_transport *trans,
__be16 service_id, u16 service_id,
struct rxrpc_call *call, struct rxrpc_call *call,
gfp_t gfp) gfp_t gfp)
{ {
...@@ -404,11 +403,11 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx, ...@@ -404,11 +403,11 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
conn->channels[chan] = call; conn->channels[chan] = call;
call->conn = conn; call->conn = conn;
call->channel = chan; call->channel = chan;
call->cid = conn->cid | htonl(chan); call->cid = conn->cid | chan;
call->call_id = htonl(++conn->call_counter); call->call_id = ++conn->call_counter;
_net("CONNECT client on conn %d chan %d as call %x", _net("CONNECT client on conn %d chan %d as call %x",
conn->debug_id, chan, ntohl(call->call_id)); conn->debug_id, chan, call->call_id);
spin_unlock(&trans->client_lock); spin_unlock(&trans->client_lock);
...@@ -593,11 +592,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, ...@@ -593,11 +592,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
conn->channels[chan] = call; conn->channels[chan] = call;
call->conn = conn; call->conn = conn;
call->channel = chan; call->channel = chan;
call->cid = conn->cid | htonl(chan); call->cid = conn->cid | chan;
call->call_id = htonl(++conn->call_counter); call->call_id = ++conn->call_counter;
_net("CONNECT client on conn %d chan %d as call %x", _net("CONNECT client on conn %d chan %d as call %x",
conn->debug_id, chan, ntohl(call->call_id)); conn->debug_id, chan, call->call_id);
ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS); ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS);
spin_unlock(&trans->client_lock); spin_unlock(&trans->client_lock);
...@@ -620,21 +619,21 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, ...@@ -620,21 +619,21 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
*/ */
struct rxrpc_connection * struct rxrpc_connection *
rxrpc_incoming_connection(struct rxrpc_transport *trans, rxrpc_incoming_connection(struct rxrpc_transport *trans,
struct rxrpc_header *hdr, struct rxrpc_host_header *hdr,
gfp_t gfp) gfp_t gfp)
{ {
struct rxrpc_connection *conn, *candidate = NULL; struct rxrpc_connection *conn, *candidate = NULL;
struct rb_node *p, **pp; struct rb_node *p, **pp;
const char *new = "old"; const char *new = "old";
__be32 epoch; __be32 epoch;
u32 conn_id; u32 cid;
_enter(""); _enter("");
ASSERT(hdr->flags & RXRPC_CLIENT_INITIATED); ASSERT(hdr->flags & RXRPC_CLIENT_INITIATED);
epoch = hdr->epoch; epoch = hdr->epoch;
conn_id = ntohl(hdr->cid) & RXRPC_CIDMASK; cid = hdr->cid & RXRPC_CIDMASK;
/* search the connection list first */ /* search the connection list first */
read_lock_bh(&trans->conn_lock); read_lock_bh(&trans->conn_lock);
...@@ -643,15 +642,15 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans, ...@@ -643,15 +642,15 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
while (p) { while (p) {
conn = rb_entry(p, struct rxrpc_connection, node); conn = rb_entry(p, struct rxrpc_connection, node);
_debug("maybe %x", conn->real_conn_id); _debug("maybe %x", conn->cid);
if (epoch < conn->epoch) if (epoch < conn->epoch)
p = p->rb_left; p = p->rb_left;
else if (epoch > conn->epoch) else if (epoch > conn->epoch)
p = p->rb_right; p = p->rb_right;
else if (conn_id < conn->real_conn_id) else if (cid < conn->cid)
p = p->rb_left; p = p->rb_left;
else if (conn_id > conn->real_conn_id) else if (cid > conn->cid)
p = p->rb_right; p = p->rb_right;
else else
goto found_extant_connection; goto found_extant_connection;
...@@ -668,12 +667,11 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans, ...@@ -668,12 +667,11 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
candidate->trans = trans; candidate->trans = trans;
candidate->epoch = hdr->epoch; candidate->epoch = hdr->epoch;
candidate->cid = hdr->cid & cpu_to_be32(RXRPC_CIDMASK); candidate->cid = hdr->cid & RXRPC_CIDMASK;
candidate->service_id = hdr->serviceId; candidate->service_id = hdr->serviceId;
candidate->security_ix = hdr->securityIndex; candidate->security_ix = hdr->securityIndex;
candidate->in_clientflag = RXRPC_CLIENT_INITIATED; candidate->in_clientflag = RXRPC_CLIENT_INITIATED;
candidate->out_clientflag = 0; candidate->out_clientflag = 0;
candidate->real_conn_id = conn_id;
candidate->state = RXRPC_CONN_SERVER; candidate->state = RXRPC_CONN_SERVER;
if (candidate->service_id) if (candidate->service_id)
candidate->state = RXRPC_CONN_SERVER_UNSECURED; candidate->state = RXRPC_CONN_SERVER_UNSECURED;
...@@ -690,9 +688,9 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans, ...@@ -690,9 +688,9 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
pp = &(*pp)->rb_left; pp = &(*pp)->rb_left;
else if (epoch > conn->epoch) else if (epoch > conn->epoch)
pp = &(*pp)->rb_right; pp = &(*pp)->rb_right;
else if (conn_id < conn->real_conn_id) else if (cid < conn->cid)
pp = &(*pp)->rb_left; pp = &(*pp)->rb_left;
else if (conn_id > conn->real_conn_id) else if (cid > conn->cid)
pp = &(*pp)->rb_right; pp = &(*pp)->rb_right;
else else
goto found_extant_second; goto found_extant_second;
...@@ -714,7 +712,7 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans, ...@@ -714,7 +712,7 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
new = "new"; new = "new";
success: success:
_net("CONNECTION %s %d {%x}", new, conn->debug_id, conn->real_conn_id); _net("CONNECTION %s %d {%x}", new, conn->debug_id, conn->cid);
_leave(" = %p {u=%d}", conn, atomic_read(&conn->usage)); _leave(" = %p {u=%d}", conn, atomic_read(&conn->usage));
return conn; return conn;
...@@ -751,18 +749,17 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans, ...@@ -751,18 +749,17 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
* packet * packet
*/ */
struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *trans, struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *trans,
struct rxrpc_header *hdr) struct rxrpc_host_header *hdr)
{ {
struct rxrpc_connection *conn; struct rxrpc_connection *conn;
struct rb_node *p; struct rb_node *p;
__be32 epoch; u32 epoch, cid;
u32 conn_id;
_enter(",{%x,%x}", ntohl(hdr->cid), hdr->flags); _enter(",{%x,%x}", hdr->cid, hdr->flags);
read_lock_bh(&trans->conn_lock); read_lock_bh(&trans->conn_lock);
conn_id = ntohl(hdr->cid) & RXRPC_CIDMASK; cid = hdr->cid & RXRPC_CIDMASK;
epoch = hdr->epoch; epoch = hdr->epoch;
if (hdr->flags & RXRPC_CLIENT_INITIATED) if (hdr->flags & RXRPC_CLIENT_INITIATED)
...@@ -773,15 +770,15 @@ struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *trans, ...@@ -773,15 +770,15 @@ struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *trans,
while (p) { while (p) {
conn = rb_entry(p, struct rxrpc_connection, node); conn = rb_entry(p, struct rxrpc_connection, node);
_debug("maybe %x", conn->real_conn_id); _debug("maybe %x", conn->cid);
if (epoch < conn->epoch) if (epoch < conn->epoch)
p = p->rb_left; p = p->rb_left;
else if (epoch > conn->epoch) else if (epoch > conn->epoch)
p = p->rb_right; p = p->rb_right;
else if (conn_id < conn->real_conn_id) else if (cid < conn->cid)
p = p->rb_left; p = p->rb_left;
else if (conn_id > conn->real_conn_id) else if (cid > conn->cid)
p = p->rb_right; p = p->rb_right;
else else
goto found; goto found;
......
...@@ -42,9 +42,9 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state, ...@@ -42,9 +42,9 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state,
call->state = state; call->state = state;
call->abort_code = abort_code; call->abort_code = abort_code;
if (state == RXRPC_CALL_LOCALLY_ABORTED) if (state == RXRPC_CALL_LOCALLY_ABORTED)
set_bit(RXRPC_CALL_CONN_ABORT, &call->events); set_bit(RXRPC_CALL_EV_CONN_ABORT, &call->events);
else else
set_bit(RXRPC_CALL_RCVD_ABORT, &call->events); set_bit(RXRPC_CALL_EV_RCVD_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
write_unlock(&call->state_lock); write_unlock(&call->state_lock);
...@@ -60,11 +60,12 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state, ...@@ -60,11 +60,12 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state,
static int rxrpc_abort_connection(struct rxrpc_connection *conn, static int rxrpc_abort_connection(struct rxrpc_connection *conn,
u32 error, u32 abort_code) u32 error, u32 abort_code)
{ {
struct rxrpc_header hdr; struct rxrpc_wire_header whdr;
struct msghdr msg; struct msghdr msg;
struct kvec iov[2]; struct kvec iov[2];
__be32 word; __be32 word;
size_t len; size_t len;
u32 serial;
int ret; int ret;
_enter("%d,,%u,%u", conn->debug_id, error, abort_code); _enter("%d,,%u,%u", conn->debug_id, error, abort_code);
...@@ -89,28 +90,29 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn, ...@@ -89,28 +90,29 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = 0; msg.msg_flags = 0;
hdr.epoch = conn->epoch; whdr.epoch = htonl(conn->epoch);
hdr.cid = conn->cid; whdr.cid = htonl(conn->cid);
hdr.callNumber = 0; whdr.callNumber = 0;
hdr.seq = 0; whdr.seq = 0;
hdr.type = RXRPC_PACKET_TYPE_ABORT; whdr.type = RXRPC_PACKET_TYPE_ABORT;
hdr.flags = conn->out_clientflag; whdr.flags = conn->out_clientflag;
hdr.userStatus = 0; whdr.userStatus = 0;
hdr.securityIndex = conn->security_ix; whdr.securityIndex = conn->security_ix;
hdr._rsvd = 0; whdr._rsvd = 0;
hdr.serviceId = conn->service_id; whdr.serviceId = htons(conn->service_id);
word = htonl(abort_code); word = htonl(abort_code);
iov[0].iov_base = &hdr; iov[0].iov_base = &whdr;
iov[0].iov_len = sizeof(hdr); iov[0].iov_len = sizeof(whdr);
iov[1].iov_base = &word; iov[1].iov_base = &word;
iov[1].iov_len = sizeof(word); iov[1].iov_len = sizeof(word);
len = iov[0].iov_len + iov[1].iov_len; len = iov[0].iov_len + iov[1].iov_len;
hdr.serial = htonl(atomic_inc_return(&conn->serial)); serial = atomic_inc_return(&conn->serial);
_proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code); whdr.serial = htonl(serial);
_proto("Tx CONN ABORT %%%u { %d }", serial, abort_code);
ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len); ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
if (ret < 0) { if (ret < 0) {
...@@ -132,7 +134,7 @@ static void rxrpc_call_is_secure(struct rxrpc_call *call) ...@@ -132,7 +134,7 @@ static void rxrpc_call_is_secure(struct rxrpc_call *call)
if (call) { if (call) {
read_lock(&call->state_lock); read_lock(&call->state_lock);
if (call->state < RXRPC_CALL_COMPLETE && if (call->state < RXRPC_CALL_COMPLETE &&
!test_and_set_bit(RXRPC_CALL_SECURED, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_SECURED, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
read_unlock(&call->state_lock); read_unlock(&call->state_lock);
} }
...@@ -146,8 +148,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, ...@@ -146,8 +148,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
u32 *_abort_code) u32 *_abort_code)
{ {
struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
__be32 tmp; __be32 wtmp;
u32 serial; u32 abort_code;
int loop, ret; int loop, ret;
if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) { if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
...@@ -155,19 +157,18 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, ...@@ -155,19 +157,18 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
return -ECONNABORTED; return -ECONNABORTED;
} }
serial = ntohl(sp->hdr.serial); _enter("{%d},{%u,%%%u},", conn->debug_id, sp->hdr.type, sp->hdr.serial);
_enter("{%d},{%u,%%%u},", conn->debug_id, sp->hdr.type, serial);
switch (sp->hdr.type) { switch (sp->hdr.type) {
case RXRPC_PACKET_TYPE_ABORT: case RXRPC_PACKET_TYPE_ABORT:
if (skb_copy_bits(skb, 0, &tmp, sizeof(tmp)) < 0) if (skb_copy_bits(skb, 0, &wtmp, sizeof(wtmp)) < 0)
return -EPROTO; return -EPROTO;
_proto("Rx ABORT %%%u { ac=%d }", serial, ntohl(tmp)); abort_code = ntohl(wtmp);
_proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
conn->state = RXRPC_CONN_REMOTELY_ABORTED; conn->state = RXRPC_CONN_REMOTELY_ABORTED;
rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
ntohl(tmp)); abort_code);
return -ECONNABORTED; return -ECONNABORTED;
case RXRPC_PACKET_TYPE_CHALLENGE: case RXRPC_PACKET_TYPE_CHALLENGE:
...@@ -335,7 +336,7 @@ void rxrpc_reject_packets(struct work_struct *work) ...@@ -335,7 +336,7 @@ void rxrpc_reject_packets(struct work_struct *work)
struct sockaddr_in sin; struct sockaddr_in sin;
} sa; } sa;
struct rxrpc_skb_priv *sp; struct rxrpc_skb_priv *sp;
struct rxrpc_header hdr; struct rxrpc_wire_header whdr;
struct rxrpc_local *local; struct rxrpc_local *local;
struct sk_buff *skb; struct sk_buff *skb;
struct msghdr msg; struct msghdr msg;
...@@ -348,11 +349,11 @@ void rxrpc_reject_packets(struct work_struct *work) ...@@ -348,11 +349,11 @@ void rxrpc_reject_packets(struct work_struct *work)
_enter("%d", local->debug_id); _enter("%d", local->debug_id);
iov[0].iov_base = &hdr; iov[0].iov_base = &whdr;
iov[0].iov_len = sizeof(hdr); iov[0].iov_len = sizeof(whdr);
iov[1].iov_base = &code; iov[1].iov_base = &code;
iov[1].iov_len = sizeof(code); iov[1].iov_len = sizeof(code);
size = sizeof(hdr) + sizeof(code); size = sizeof(whdr) + sizeof(code);
msg.msg_name = &sa; msg.msg_name = &sa;
msg.msg_control = NULL; msg.msg_control = NULL;
...@@ -370,8 +371,8 @@ void rxrpc_reject_packets(struct work_struct *work) ...@@ -370,8 +371,8 @@ void rxrpc_reject_packets(struct work_struct *work)
break; break;
} }
memset(&hdr, 0, sizeof(hdr)); memset(&whdr, 0, sizeof(whdr));
hdr.type = RXRPC_PACKET_TYPE_ABORT; whdr.type = RXRPC_PACKET_TYPE_ABORT;
while ((skb = skb_dequeue(&local->reject_queue))) { while ((skb = skb_dequeue(&local->reject_queue))) {
sp = rxrpc_skb(skb); sp = rxrpc_skb(skb);
...@@ -381,13 +382,13 @@ void rxrpc_reject_packets(struct work_struct *work) ...@@ -381,13 +382,13 @@ void rxrpc_reject_packets(struct work_struct *work)
sa.sin.sin_addr.s_addr = ip_hdr(skb)->saddr; sa.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
code = htonl(skb->priority); code = htonl(skb->priority);
hdr.epoch = sp->hdr.epoch; whdr.epoch = htonl(sp->hdr.epoch);
hdr.cid = sp->hdr.cid; whdr.cid = htonl(sp->hdr.cid);
hdr.callNumber = sp->hdr.callNumber; whdr.callNumber = htonl(sp->hdr.callNumber);
hdr.serviceId = sp->hdr.serviceId; whdr.serviceId = htons(sp->hdr.serviceId);
hdr.flags = sp->hdr.flags; whdr.flags = sp->hdr.flags;
hdr.flags ^= RXRPC_CLIENT_INITIATED; whdr.flags ^= RXRPC_CLIENT_INITIATED;
hdr.flags &= RXRPC_CLIENT_INITIATED; whdr.flags &= RXRPC_CLIENT_INITIATED;
kernel_sendmsg(local->socket, &msg, iov, 2, size); kernel_sendmsg(local->socket, &msg, iov, 2, size);
break; break;
......
...@@ -115,7 +115,6 @@ void rxrpc_UDP_error_report(struct sock *sk) ...@@ -115,7 +115,6 @@ void rxrpc_UDP_error_report(struct sock *sk)
/* pass the transport ref to error_handler to release */ /* pass the transport ref to error_handler to release */
skb_queue_tail(&trans->error_queue, skb); skb_queue_tail(&trans->error_queue, skb);
rxrpc_queue_work(&trans->error_handler); rxrpc_queue_work(&trans->error_handler);
_leave(""); _leave("");
} }
...@@ -152,28 +151,18 @@ void rxrpc_UDP_error_handler(struct work_struct *work) ...@@ -152,28 +151,18 @@ void rxrpc_UDP_error_handler(struct work_struct *work)
switch (ee->ee_code) { switch (ee->ee_code) {
case ICMP_NET_UNREACH: case ICMP_NET_UNREACH:
_net("Rx Received ICMP Network Unreachable"); _net("Rx Received ICMP Network Unreachable");
err = ENETUNREACH;
break; break;
case ICMP_HOST_UNREACH: case ICMP_HOST_UNREACH:
_net("Rx Received ICMP Host Unreachable"); _net("Rx Received ICMP Host Unreachable");
err = EHOSTUNREACH;
break; break;
case ICMP_PORT_UNREACH: case ICMP_PORT_UNREACH:
_net("Rx Received ICMP Port Unreachable"); _net("Rx Received ICMP Port Unreachable");
err = ECONNREFUSED;
break;
case ICMP_FRAG_NEEDED:
_net("Rx Received ICMP Fragmentation Needed (%d)",
ee->ee_info);
err = 0; /* dealt with elsewhere */
break; break;
case ICMP_NET_UNKNOWN: case ICMP_NET_UNKNOWN:
_net("Rx Received ICMP Unknown Network"); _net("Rx Received ICMP Unknown Network");
err = ENETUNREACH;
break; break;
case ICMP_HOST_UNKNOWN: case ICMP_HOST_UNKNOWN:
_net("Rx Received ICMP Unknown Host"); _net("Rx Received ICMP Unknown Host");
err = EHOSTUNREACH;
break; break;
default: default:
_net("Rx Received ICMP DestUnreach code=%u", _net("Rx Received ICMP DestUnreach code=%u",
...@@ -222,7 +211,7 @@ void rxrpc_UDP_error_handler(struct work_struct *work) ...@@ -222,7 +211,7 @@ void rxrpc_UDP_error_handler(struct work_struct *work)
if (call->state != RXRPC_CALL_COMPLETE && if (call->state != RXRPC_CALL_COMPLETE &&
call->state < RXRPC_CALL_NETWORK_ERROR) { call->state < RXRPC_CALL_NETWORK_ERROR) {
call->state = RXRPC_CALL_NETWORK_ERROR; call->state = RXRPC_CALL_NETWORK_ERROR;
set_bit(RXRPC_CALL_RCVD_ERROR, &call->events); set_bit(RXRPC_CALL_EV_RCVD_ERROR, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
write_unlock(&call->state_lock); write_unlock(&call->state_lock);
......
...@@ -231,7 +231,7 @@ static int rxrpc_fast_process_data(struct rxrpc_call *call, ...@@ -231,7 +231,7 @@ static int rxrpc_fast_process_data(struct rxrpc_call *call,
_debug("drain rx oos now"); _debug("drain rx oos now");
read_lock(&call->state_lock); read_lock(&call->state_lock);
if (call->state < RXRPC_CALL_COMPLETE && if (call->state < RXRPC_CALL_COMPLETE &&
!test_and_set_bit(RXRPC_CALL_DRAIN_RX_OOS, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_DRAIN_RX_OOS, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
read_unlock(&call->state_lock); read_unlock(&call->state_lock);
} }
...@@ -287,12 +287,12 @@ static void rxrpc_assume_implicit_ackall(struct rxrpc_call *call, u32 serial) ...@@ -287,12 +287,12 @@ static void rxrpc_assume_implicit_ackall(struct rxrpc_call *call, u32 serial)
call->acks_latest = serial; call->acks_latest = serial;
_debug("implicit ACKALL %%%u", call->acks_latest); _debug("implicit ACKALL %%%u", call->acks_latest);
set_bit(RXRPC_CALL_RCVD_ACKALL, &call->events); set_bit(RXRPC_CALL_EV_RCVD_ACKALL, &call->events);
write_unlock_bh(&call->state_lock); write_unlock_bh(&call->state_lock);
if (try_to_del_timer_sync(&call->resend_timer) >= 0) { if (try_to_del_timer_sync(&call->resend_timer) >= 0) {
clear_bit(RXRPC_CALL_RESEND_TIMER, &call->events); clear_bit(RXRPC_CALL_EV_RESEND_TIMER, &call->events);
clear_bit(RXRPC_CALL_RESEND, &call->events); clear_bit(RXRPC_CALL_EV_RESEND, &call->events);
clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags); clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
} }
break; break;
...@@ -310,8 +310,8 @@ static void rxrpc_assume_implicit_ackall(struct rxrpc_call *call, u32 serial) ...@@ -310,8 +310,8 @@ static void rxrpc_assume_implicit_ackall(struct rxrpc_call *call, u32 serial)
void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
{ {
struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
__be32 _abort_code; __be32 wtmp;
u32 serial, hi_serial, seq, abort_code; u32 hi_serial, abort_code;
_enter("%p,%p", call, skb); _enter("%p,%p", call, skb);
...@@ -330,16 +330,15 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -330,16 +330,15 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
/* track the latest serial number on this connection for ACK packet /* track the latest serial number on this connection for ACK packet
* information */ * information */
serial = ntohl(sp->hdr.serial);
hi_serial = atomic_read(&call->conn->hi_serial); hi_serial = atomic_read(&call->conn->hi_serial);
while (serial > hi_serial) while (sp->hdr.serial > hi_serial)
hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial, hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
serial); sp->hdr.serial);
/* request ACK generation for any ACK or DATA packet that requests /* request ACK generation for any ACK or DATA packet that requests
* it */ * it */
if (sp->hdr.flags & RXRPC_REQUEST_ACK) { if (sp->hdr.flags & RXRPC_REQUEST_ACK) {
_proto("ACK Requested on %%%u", serial); _proto("ACK Requested on %%%u", sp->hdr.serial);
rxrpc_propose_ACK(call, RXRPC_ACK_REQUESTED, sp->hdr.serial, false); rxrpc_propose_ACK(call, RXRPC_ACK_REQUESTED, sp->hdr.serial, false);
} }
...@@ -347,24 +346,23 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -347,24 +346,23 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
case RXRPC_PACKET_TYPE_ABORT: case RXRPC_PACKET_TYPE_ABORT:
_debug("abort"); _debug("abort");
if (skb_copy_bits(skb, 0, &_abort_code, if (skb_copy_bits(skb, 0, &wtmp, sizeof(wtmp)) < 0)
sizeof(_abort_code)) < 0)
goto protocol_error; goto protocol_error;
abort_code = ntohl(_abort_code); abort_code = ntohl(wtmp);
_proto("Rx ABORT %%%u { %x }", serial, abort_code); _proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code);
write_lock_bh(&call->state_lock); write_lock_bh(&call->state_lock);
if (call->state < RXRPC_CALL_COMPLETE) { if (call->state < RXRPC_CALL_COMPLETE) {
call->state = RXRPC_CALL_REMOTELY_ABORTED; call->state = RXRPC_CALL_REMOTELY_ABORTED;
call->abort_code = abort_code; call->abort_code = abort_code;
set_bit(RXRPC_CALL_RCVD_ABORT, &call->events); set_bit(RXRPC_CALL_EV_RCVD_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
goto free_packet_unlock; goto free_packet_unlock;
case RXRPC_PACKET_TYPE_BUSY: case RXRPC_PACKET_TYPE_BUSY:
_proto("Rx BUSY %%%u", serial); _proto("Rx BUSY %%%u", sp->hdr.serial);
if (call->conn->out_clientflag) if (call->conn->out_clientflag)
goto protocol_error; goto protocol_error;
...@@ -373,7 +371,7 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -373,7 +371,7 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
switch (call->state) { switch (call->state) {
case RXRPC_CALL_CLIENT_SEND_REQUEST: case RXRPC_CALL_CLIENT_SEND_REQUEST:
call->state = RXRPC_CALL_SERVER_BUSY; call->state = RXRPC_CALL_SERVER_BUSY;
set_bit(RXRPC_CALL_RCVD_BUSY, &call->events); set_bit(RXRPC_CALL_EV_RCVD_BUSY, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
case RXRPC_CALL_SERVER_BUSY: case RXRPC_CALL_SERVER_BUSY:
goto free_packet_unlock; goto free_packet_unlock;
...@@ -382,15 +380,13 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -382,15 +380,13 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
} }
default: default:
_proto("Rx %s %%%u", rxrpc_pkts[sp->hdr.type], serial); _proto("Rx %s %%%u", rxrpc_pkts[sp->hdr.type], sp->hdr.serial);
goto protocol_error; goto protocol_error;
case RXRPC_PACKET_TYPE_DATA: case RXRPC_PACKET_TYPE_DATA:
seq = ntohl(sp->hdr.seq); _proto("Rx DATA %%%u { #%u }", sp->hdr.serial, sp->hdr.seq);
_proto("Rx DATA %%%u { #%u }", serial, seq); if (sp->hdr.seq == 0)
if (seq == 0)
goto protocol_error; goto protocol_error;
call->ackr_prev_seq = sp->hdr.seq; call->ackr_prev_seq = sp->hdr.seq;
...@@ -398,9 +394,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -398,9 +394,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
/* received data implicitly ACKs all of the request packets we /* received data implicitly ACKs all of the request packets we
* sent when we're acting as a client */ * sent when we're acting as a client */
if (call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY) if (call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY)
rxrpc_assume_implicit_ackall(call, serial); rxrpc_assume_implicit_ackall(call, sp->hdr.serial);
switch (rxrpc_fast_process_data(call, skb, seq)) { switch (rxrpc_fast_process_data(call, skb, sp->hdr.seq)) {
case 0: case 0:
skb = NULL; skb = NULL;
goto done; goto done;
...@@ -433,7 +429,7 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -433,7 +429,7 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
if (call->state <= RXRPC_CALL_COMPLETE) { if (call->state <= RXRPC_CALL_COMPLETE) {
call->state = RXRPC_CALL_LOCALLY_ABORTED; call->state = RXRPC_CALL_LOCALLY_ABORTED;
call->abort_code = RX_PROTOCOL_ERROR; call->abort_code = RX_PROTOCOL_ERROR;
set_bit(RXRPC_CALL_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
free_packet_unlock: free_packet_unlock:
...@@ -481,12 +477,12 @@ static void rxrpc_process_jumbo_packet(struct rxrpc_call *call, ...@@ -481,12 +477,12 @@ static void rxrpc_process_jumbo_packet(struct rxrpc_call *call,
if (!pskb_pull(jumbo, sizeof(jhdr))) if (!pskb_pull(jumbo, sizeof(jhdr)))
BUG(); BUG();
sp->hdr.seq = htonl(ntohl(sp->hdr.seq) + 1); sp->hdr.seq += 1;
sp->hdr.serial = htonl(ntohl(sp->hdr.serial) + 1); sp->hdr.serial += 1;
sp->hdr.flags = jhdr.flags; sp->hdr.flags = jhdr.flags;
sp->hdr._rsvd = jhdr._rsvd; sp->hdr._rsvd = jhdr._rsvd;
_proto("Rx DATA Jumbo %%%u", ntohl(sp->hdr.serial) - 1); _proto("Rx DATA Jumbo %%%u", sp->hdr.serial - 1);
rxrpc_fast_process_packet(call, part); rxrpc_fast_process_packet(call, part);
part = NULL; part = NULL;
...@@ -505,7 +501,7 @@ static void rxrpc_process_jumbo_packet(struct rxrpc_call *call, ...@@ -505,7 +501,7 @@ static void rxrpc_process_jumbo_packet(struct rxrpc_call *call,
if (call->state <= RXRPC_CALL_COMPLETE) { if (call->state <= RXRPC_CALL_COMPLETE) {
call->state = RXRPC_CALL_LOCALLY_ABORTED; call->state = RXRPC_CALL_LOCALLY_ABORTED;
call->abort_code = RX_PROTOCOL_ERROR; call->abort_code = RX_PROTOCOL_ERROR;
set_bit(RXRPC_CALL_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
write_unlock_bh(&call->state_lock); write_unlock_bh(&call->state_lock);
...@@ -530,7 +526,7 @@ static void rxrpc_post_packet_to_call(struct rxrpc_call *call, ...@@ -530,7 +526,7 @@ static void rxrpc_post_packet_to_call(struct rxrpc_call *call,
read_lock(&call->state_lock); read_lock(&call->state_lock);
switch (call->state) { switch (call->state) {
case RXRPC_CALL_LOCALLY_ABORTED: case RXRPC_CALL_LOCALLY_ABORTED:
if (!test_and_set_bit(RXRPC_CALL_ABORT, &call->events)) { if (!test_and_set_bit(RXRPC_CALL_EV_ABORT, &call->events)) {
rxrpc_queue_call(call); rxrpc_queue_call(call);
goto free_unlock; goto free_unlock;
} }
...@@ -546,7 +542,7 @@ static void rxrpc_post_packet_to_call(struct rxrpc_call *call, ...@@ -546,7 +542,7 @@ static void rxrpc_post_packet_to_call(struct rxrpc_call *call,
/* resend last packet of a completed call */ /* resend last packet of a completed call */
_debug("final ack again"); _debug("final ack again");
rxrpc_get_call(call); rxrpc_get_call(call);
set_bit(RXRPC_CALL_ACK_FINAL, &call->events); set_bit(RXRPC_CALL_EV_ACK_FINAL, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
goto free_unlock; goto free_unlock;
default: default:
...@@ -607,6 +603,35 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local, ...@@ -607,6 +603,35 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local,
rxrpc_queue_work(&local->event_processor); rxrpc_queue_work(&local->event_processor);
} }
/*
* Extract the wire header from a packet and translate the byte order.
*/
static noinline
int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb)
{
struct rxrpc_wire_header whdr;
/* dig out the RxRPC connection details */
if (skb_copy_bits(skb, sizeof(struct udphdr), &whdr, sizeof(whdr)) < 0)
return -EBADMSG;
if (!pskb_pull(skb, sizeof(struct udphdr) + sizeof(whdr)))
BUG();
memset(sp, 0, sizeof(*sp));
sp->hdr.epoch = ntohl(whdr.epoch);
sp->hdr.cid = ntohl(whdr.cid);
sp->hdr.callNumber = ntohl(whdr.callNumber);
sp->hdr.seq = ntohl(whdr.seq);
sp->hdr.serial = ntohl(whdr.serial);
sp->hdr.flags = whdr.flags;
sp->hdr.type = whdr.type;
sp->hdr.userStatus = whdr.userStatus;
sp->hdr.securityIndex = whdr.securityIndex;
sp->hdr._rsvd = ntohs(whdr._rsvd);
sp->hdr.serviceId = ntohs(whdr.serviceId);
return 0;
}
static struct rxrpc_connection *rxrpc_conn_from_local(struct rxrpc_local *local, static struct rxrpc_connection *rxrpc_conn_from_local(struct rxrpc_local *local,
struct sk_buff *skb, struct sk_buff *skb,
struct rxrpc_skb_priv *sp) struct rxrpc_skb_priv *sp)
...@@ -686,29 +711,25 @@ void rxrpc_data_ready(struct sock *sk) ...@@ -686,29 +711,25 @@ void rxrpc_data_ready(struct sock *sk)
UDP_INC_STATS_BH(&init_net, UDP_MIB_INDATAGRAMS, 0); UDP_INC_STATS_BH(&init_net, UDP_MIB_INDATAGRAMS, 0);
/* the socket buffer we have is owned by UDP, with UDP's data all over /* The socket buffer we have is owned by UDP, with UDP's data all over
* it, but we really want our own */ * it, but we really want our own data there.
*/
skb_orphan(skb); skb_orphan(skb);
sp = rxrpc_skb(skb); sp = rxrpc_skb(skb);
memset(sp, 0, sizeof(*sp));
_net("Rx UDP packet from %08x:%04hu", _net("Rx UDP packet from %08x:%04hu",
ntohl(ip_hdr(skb)->saddr), ntohs(udp_hdr(skb)->source)); ntohl(ip_hdr(skb)->saddr), ntohs(udp_hdr(skb)->source));
/* dig out the RxRPC connection details */ /* dig out the RxRPC connection details */
if (skb_copy_bits(skb, sizeof(struct udphdr), &sp->hdr, if (rxrpc_extract_header(sp, skb) < 0)
sizeof(sp->hdr)) < 0)
goto bad_message; goto bad_message;
if (!pskb_pull(skb, sizeof(struct udphdr) + sizeof(sp->hdr)))
BUG();
_net("Rx RxRPC %s ep=%x call=%x:%x", _net("Rx RxRPC %s ep=%x call=%x:%x",
sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient", sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient",
ntohl(sp->hdr.epoch), sp->hdr.epoch, sp->hdr.cid, sp->hdr.callNumber);
ntohl(sp->hdr.cid),
ntohl(sp->hdr.callNumber));
if (sp->hdr.type == 0 || sp->hdr.type >= RXRPC_N_PACKET_TYPES) { if (sp->hdr.type >= RXRPC_N_PACKET_TYPES ||
!((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) {
_proto("Rx Bad Packet Type %u", sp->hdr.type); _proto("Rx Bad Packet Type %u", sp->hdr.type);
goto bad_message; goto bad_message;
} }
...@@ -737,14 +758,9 @@ void rxrpc_data_ready(struct sock *sk) ...@@ -737,14 +758,9 @@ void rxrpc_data_ready(struct sock *sk)
rxrpc_put_connection(conn); rxrpc_put_connection(conn);
} else { } else {
struct rxrpc_call *call; struct rxrpc_call *call;
u8 in_clientflag = 0;
call = rxrpc_find_call_hash(&sp->hdr, local,
if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) AF_INET, &ip_hdr(skb)->saddr);
in_clientflag = RXRPC_CLIENT_INITIATED;
call = rxrpc_find_call_hash(in_clientflag, sp->hdr.cid,
sp->hdr.callNumber, sp->hdr.epoch,
sp->hdr.serviceId, local, AF_INET,
(u8 *)&ip_hdr(skb)->saddr);
if (call) if (call)
rxrpc_post_packet_to_call(call, skb); rxrpc_post_packet_to_call(call, skb);
else else
...@@ -759,7 +775,7 @@ void rxrpc_data_ready(struct sock *sk) ...@@ -759,7 +775,7 @@ void rxrpc_data_ready(struct sock *sk)
_debug("can't route call"); _debug("can't route call");
if (sp->hdr.flags & RXRPC_CLIENT_INITIATED && if (sp->hdr.flags & RXRPC_CLIENT_INITIATED &&
sp->hdr.type == RXRPC_PACKET_TYPE_DATA) { sp->hdr.type == RXRPC_PACKET_TYPE_DATA) {
if (sp->hdr.seq == cpu_to_be32(1)) { if (sp->hdr.seq == 1) {
_debug("first packet"); _debug("first packet");
skb_queue_tail(&local->accept_queue, skb); skb_queue_tail(&local->accept_queue, skb);
rxrpc_queue_work(&local->acceptor); rxrpc_queue_work(&local->acceptor);
......
This diff is collapsed.
...@@ -323,9 +323,11 @@ void __exit rxrpc_destroy_all_locals(void) ...@@ -323,9 +323,11 @@ void __exit rxrpc_destroy_all_locals(void)
* Reply to a version request * Reply to a version request
*/ */
static void rxrpc_send_version_request(struct rxrpc_local *local, static void rxrpc_send_version_request(struct rxrpc_local *local,
struct rxrpc_header *hdr, struct rxrpc_host_header *hdr,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct rxrpc_wire_header whdr;
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
struct sockaddr_in sin; struct sockaddr_in sin;
struct msghdr msg; struct msghdr msg;
struct kvec iov[2]; struct kvec iov[2];
...@@ -344,15 +346,20 @@ static void rxrpc_send_version_request(struct rxrpc_local *local, ...@@ -344,15 +346,20 @@ static void rxrpc_send_version_request(struct rxrpc_local *local,
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = 0; msg.msg_flags = 0;
hdr->seq = 0; whdr.epoch = htonl(sp->hdr.epoch);
hdr->serial = 0; whdr.cid = htonl(sp->hdr.cid);
hdr->type = RXRPC_PACKET_TYPE_VERSION; whdr.callNumber = htonl(sp->hdr.callNumber);
hdr->flags = RXRPC_LAST_PACKET | (~hdr->flags & RXRPC_CLIENT_INITIATED); whdr.seq = 0;
hdr->userStatus = 0; whdr.serial = 0;
hdr->_rsvd = 0; whdr.type = RXRPC_PACKET_TYPE_VERSION;
whdr.flags = RXRPC_LAST_PACKET | (~hdr->flags & RXRPC_CLIENT_INITIATED);
iov[0].iov_base = hdr; whdr.userStatus = 0;
iov[0].iov_len = sizeof(*hdr); whdr.securityIndex = 0;
whdr._rsvd = 0;
whdr.serviceId = htons(sp->hdr.serviceId);
iov[0].iov_base = &whdr;
iov[0].iov_len = sizeof(whdr);
iov[1].iov_base = (char *)rxrpc_version_string; iov[1].iov_base = (char *)rxrpc_version_string;
iov[1].iov_len = sizeof(rxrpc_version_string); iov[1].iov_len = sizeof(rxrpc_version_string);
...@@ -383,7 +390,7 @@ static void rxrpc_process_local_events(struct work_struct *work) ...@@ -383,7 +390,7 @@ static void rxrpc_process_local_events(struct work_struct *work)
while ((skb = skb_dequeue(&local->event_queue))) { while ((skb = skb_dequeue(&local->event_queue))) {
struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
kdebug("{%d},{%u}", local->debug_id, sp->hdr.type); _debug("{%d},{%u}", local->debug_id, sp->hdr.type);
switch (sp->hdr.type) { switch (sp->hdr.type) {
case RXRPC_PACKET_TYPE_VERSION: case RXRPC_PACKET_TYPE_VERSION:
......
...@@ -111,11 +111,11 @@ static void rxrpc_send_abort(struct rxrpc_call *call, u32 abort_code) ...@@ -111,11 +111,11 @@ static void rxrpc_send_abort(struct rxrpc_call *call, u32 abort_code)
if (call->state <= RXRPC_CALL_COMPLETE) { if (call->state <= RXRPC_CALL_COMPLETE) {
call->state = RXRPC_CALL_LOCALLY_ABORTED; call->state = RXRPC_CALL_LOCALLY_ABORTED;
call->abort_code = abort_code; call->abort_code = abort_code;
set_bit(RXRPC_CALL_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
del_timer_sync(&call->resend_timer); del_timer_sync(&call->resend_timer);
del_timer_sync(&call->ack_timer); del_timer_sync(&call->ack_timer);
clear_bit(RXRPC_CALL_RESEND_TIMER, &call->events); clear_bit(RXRPC_CALL_EV_RESEND_TIMER, &call->events);
clear_bit(RXRPC_CALL_ACK, &call->events); clear_bit(RXRPC_CALL_EV_ACK, &call->events);
clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags); clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
...@@ -136,7 +136,7 @@ int rxrpc_client_sendmsg(struct rxrpc_sock *rx, struct rxrpc_transport *trans, ...@@ -136,7 +136,7 @@ int rxrpc_client_sendmsg(struct rxrpc_sock *rx, struct rxrpc_transport *trans,
struct rxrpc_call *call; struct rxrpc_call *call;
unsigned long user_call_ID = 0; unsigned long user_call_ID = 0;
struct key *key; struct key *key;
__be16 service_id; u16 service_id;
u32 abort_code = 0; u32 abort_code = 0;
int ret; int ret;
...@@ -151,11 +151,11 @@ int rxrpc_client_sendmsg(struct rxrpc_sock *rx, struct rxrpc_transport *trans, ...@@ -151,11 +151,11 @@ int rxrpc_client_sendmsg(struct rxrpc_sock *rx, struct rxrpc_transport *trans,
bundle = NULL; bundle = NULL;
if (trans) { if (trans) {
service_id = rx->service_id; service_id = rx->srx.srx_service;
if (msg->msg_name) { if (msg->msg_name) {
DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx,
msg->msg_name); msg->msg_name);
service_id = htons(srx->srx_service); service_id = srx->srx_service;
} }
key = rx->key; key = rx->key;
if (key && !rx->key->payload.data[0]) if (key && !rx->key->payload.data[0])
...@@ -348,7 +348,7 @@ int rxrpc_send_packet(struct rxrpc_transport *trans, struct sk_buff *skb) ...@@ -348,7 +348,7 @@ int rxrpc_send_packet(struct rxrpc_transport *trans, struct sk_buff *skb)
/* send the packet with the don't fragment bit set if we currently /* send the packet with the don't fragment bit set if we currently
* think it's small enough */ * think it's small enough */
if (skb->len - sizeof(struct rxrpc_header) < trans->peer->maxdata) { if (skb->len - sizeof(struct rxrpc_wire_header) < trans->peer->maxdata) {
down_read(&trans->local->defrag_sem); down_read(&trans->local->defrag_sem);
/* send the packet by UDP /* send the packet by UDP
* - returns -EMSGSIZE if UDP would have to fragment the packet * - returns -EMSGSIZE if UDP would have to fragment the packet
...@@ -401,7 +401,8 @@ static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx, ...@@ -401,7 +401,8 @@ static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
int ret; int ret;
_enter(",{%d},%ld", _enter(",{%d},%ld",
CIRC_SPACE(call->acks_head, call->acks_tail, call->acks_winsz), CIRC_SPACE(call->acks_head, ACCESS_ONCE(call->acks_tail),
call->acks_winsz),
*timeo); *timeo);
add_wait_queue(&call->tx_waitq, &myself); add_wait_queue(&call->tx_waitq, &myself);
...@@ -409,7 +410,7 @@ static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx, ...@@ -409,7 +410,7 @@ static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
ret = 0; ret = 0;
if (CIRC_SPACE(call->acks_head, call->acks_tail, if (CIRC_SPACE(call->acks_head, ACCESS_ONCE(call->acks_tail),
call->acks_winsz) > 0) call->acks_winsz) > 0)
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -437,7 +438,7 @@ static inline void rxrpc_instant_resend(struct rxrpc_call *call) ...@@ -437,7 +438,7 @@ static inline void rxrpc_instant_resend(struct rxrpc_call *call)
if (try_to_del_timer_sync(&call->resend_timer) >= 0) { if (try_to_del_timer_sync(&call->resend_timer) >= 0) {
clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags); clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
if (call->state < RXRPC_CALL_COMPLETE && if (call->state < RXRPC_CALL_COMPLETE &&
!test_and_set_bit(RXRPC_CALL_RESEND_TIMER, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_RESEND_TIMER, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
read_unlock_bh(&call->state_lock); read_unlock_bh(&call->state_lock);
...@@ -480,8 +481,7 @@ static void rxrpc_queue_packet(struct rxrpc_call *call, struct sk_buff *skb, ...@@ -480,8 +481,7 @@ static void rxrpc_queue_packet(struct rxrpc_call *call, struct sk_buff *skb,
write_unlock_bh(&call->state_lock); write_unlock_bh(&call->state_lock);
} }
_proto("Tx DATA %%%u { #%u }", _proto("Tx DATA %%%u { #%u }", sp->hdr.serial, sp->hdr.seq);
ntohl(sp->hdr.serial), ntohl(sp->hdr.seq));
sp->need_resend = false; sp->need_resend = false;
sp->resend_at = jiffies + rxrpc_resend_timeout; sp->resend_at = jiffies + rxrpc_resend_timeout;
...@@ -512,6 +512,29 @@ static void rxrpc_queue_packet(struct rxrpc_call *call, struct sk_buff *skb, ...@@ -512,6 +512,29 @@ static void rxrpc_queue_packet(struct rxrpc_call *call, struct sk_buff *skb,
_leave(""); _leave("");
} }
/*
* Convert a host-endian header into a network-endian header.
*/
static void rxrpc_insert_header(struct sk_buff *skb)
{
struct rxrpc_wire_header whdr;
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
whdr.epoch = htonl(sp->hdr.epoch);
whdr.cid = htonl(sp->hdr.cid);
whdr.callNumber = htonl(sp->hdr.callNumber);
whdr.seq = htonl(sp->hdr.seq);
whdr.serial = htonl(sp->hdr.serial);
whdr.type = sp->hdr.type;
whdr.flags = sp->hdr.flags;
whdr.userStatus = sp->hdr.userStatus;
whdr.securityIndex = sp->hdr.securityIndex;
whdr._rsvd = htons(sp->hdr._rsvd);
whdr.serviceId = htons(sp->hdr.serviceId);
memcpy(skb->head, &whdr, sizeof(whdr));
}
/* /*
* send data through a socket * send data through a socket
* - must be called in process context * - must be called in process context
...@@ -548,7 +571,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ...@@ -548,7 +571,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
_debug("alloc"); _debug("alloc");
if (CIRC_SPACE(call->acks_head, call->acks_tail, if (CIRC_SPACE(call->acks_head,
ACCESS_ONCE(call->acks_tail),
call->acks_winsz) <= 0) { call->acks_winsz) <= 0) {
ret = -EAGAIN; ret = -EAGAIN;
if (msg->msg_flags & MSG_DONTWAIT) if (msg->msg_flags & MSG_DONTWAIT)
...@@ -650,22 +674,22 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ...@@ -650,22 +674,22 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
seq = atomic_inc_return(&call->sequence); seq = atomic_inc_return(&call->sequence);
sp->hdr.epoch = conn->epoch; sp->hdr.epoch = conn->epoch;
sp->hdr.cid = call->cid; sp->hdr.cid = call->cid;
sp->hdr.callNumber = call->call_id; sp->hdr.callNumber = call->call_id;
sp->hdr.seq = htonl(seq); sp->hdr.seq = seq;
sp->hdr.serial = sp->hdr.serial = atomic_inc_return(&conn->serial);
htonl(atomic_inc_return(&conn->serial)); sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
sp->hdr.userStatus = 0; sp->hdr.userStatus = 0;
sp->hdr.securityIndex = conn->security_ix; sp->hdr.securityIndex = conn->security_ix;
sp->hdr._rsvd = 0; sp->hdr._rsvd = 0;
sp->hdr.serviceId = conn->service_id; sp->hdr.serviceId = call->service_id;
sp->hdr.flags = conn->out_clientflag; sp->hdr.flags = conn->out_clientflag;
if (msg_data_left(msg) == 0 && !more) if (msg_data_left(msg) == 0 && !more)
sp->hdr.flags |= RXRPC_LAST_PACKET; sp->hdr.flags |= RXRPC_LAST_PACKET;
else if (CIRC_SPACE(call->acks_head, call->acks_tail, else if (CIRC_SPACE(call->acks_head,
ACCESS_ONCE(call->acks_tail),
call->acks_winsz) > 1) call->acks_winsz) > 1)
sp->hdr.flags |= RXRPC_MORE_PACKETS; sp->hdr.flags |= RXRPC_MORE_PACKETS;
if (more && seq & 1) if (more && seq & 1)
...@@ -673,12 +697,11 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ...@@ -673,12 +697,11 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
ret = rxrpc_secure_packet( ret = rxrpc_secure_packet(
call, skb, skb->mark, call, skb, skb->mark,
skb->head + sizeof(struct rxrpc_header)); skb->head + sizeof(struct rxrpc_wire_header));
if (ret < 0) if (ret < 0)
goto out; goto out;
memcpy(skb->head, &sp->hdr, rxrpc_insert_header(skb);
sizeof(struct rxrpc_header));
rxrpc_queue_packet(call, skb, !msg_data_left(msg) && !more); rxrpc_queue_packet(call, skb, !msg_data_left(msg) && !more);
skb = NULL; skb = NULL;
} }
......
...@@ -92,7 +92,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx, ...@@ -92,7 +92,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
BUG(); BUG();
} }
peer->hdrsize += sizeof(struct rxrpc_header); peer->hdrsize += sizeof(struct rxrpc_wire_header);
peer->maxdata = peer->mtu - peer->hdrsize; peer->maxdata = peer->mtu - peer->hdrsize;
} }
......
...@@ -74,9 +74,9 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v) ...@@ -74,9 +74,9 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
" %-8.8s %08x %lx\n", " %-8.8s %08x %lx\n",
lbuff, lbuff,
rbuff, rbuff,
ntohs(call->conn->service_id), call->conn->service_id,
ntohl(call->conn->cid), call->cid,
ntohl(call->call_id), call->call_id,
call->conn->in_clientflag ? "Svc" : "Clt", call->conn->in_clientflag ? "Svc" : "Clt",
atomic_read(&call->usage), atomic_read(&call->usage),
rxrpc_call_states[call->state], rxrpc_call_states[call->state],
...@@ -157,8 +157,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v) ...@@ -157,8 +157,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
" %s %08x %08x %08x\n", " %s %08x %08x %08x\n",
lbuff, lbuff,
rbuff, rbuff,
ntohs(conn->service_id), conn->service_id,
ntohl(conn->cid), conn->cid,
conn->call_counter, conn->call_counter,
conn->in_clientflag ? "Svc" : "Clt", conn->in_clientflag ? "Svc" : "Clt",
atomic_read(&conn->usage), atomic_read(&conn->usage),
......
...@@ -33,7 +33,7 @@ void rxrpc_remove_user_ID(struct rxrpc_sock *rx, struct rxrpc_call *call) ...@@ -33,7 +33,7 @@ void rxrpc_remove_user_ID(struct rxrpc_sock *rx, struct rxrpc_call *call)
read_lock_bh(&call->state_lock); read_lock_bh(&call->state_lock);
if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) && if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) &&
!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events)) !test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
rxrpc_queue_call(call); rxrpc_queue_call(call);
read_unlock_bh(&call->state_lock); read_unlock_bh(&call->state_lock);
} }
...@@ -158,7 +158,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, ...@@ -158,7 +158,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
goto receive_non_data_message; goto receive_non_data_message;
_debug("recvmsg DATA #%u { %d, %d }", _debug("recvmsg DATA #%u { %d, %d }",
ntohl(sp->hdr.seq), skb->len, sp->offset); sp->hdr.seq, skb->len, sp->offset);
if (!continue_call) { if (!continue_call) {
/* only set the control data once per recvmsg() */ /* only set the control data once per recvmsg() */
...@@ -169,11 +169,11 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, ...@@ -169,11 +169,11 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
ASSERT(test_bit(RXRPC_CALL_HAS_USERID, &call->flags)); ASSERT(test_bit(RXRPC_CALL_HAS_USERID, &call->flags));
} }
ASSERTCMP(ntohl(sp->hdr.seq), >=, call->rx_data_recv); ASSERTCMP(sp->hdr.seq, >=, call->rx_data_recv);
ASSERTCMP(ntohl(sp->hdr.seq), <=, call->rx_data_recv + 1); ASSERTCMP(sp->hdr.seq, <=, call->rx_data_recv + 1);
call->rx_data_recv = ntohl(sp->hdr.seq); call->rx_data_recv = sp->hdr.seq;
ASSERTCMP(ntohl(sp->hdr.seq), >, call->rx_data_eaten); ASSERTCMP(sp->hdr.seq, >, call->rx_data_eaten);
offset = sp->offset; offset = sp->offset;
copy = skb->len - offset; copy = skb->len - offset;
...@@ -364,11 +364,11 @@ void rxrpc_kernel_data_delivered(struct sk_buff *skb) ...@@ -364,11 +364,11 @@ void rxrpc_kernel_data_delivered(struct sk_buff *skb)
struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
struct rxrpc_call *call = sp->call; struct rxrpc_call *call = sp->call;
ASSERTCMP(ntohl(sp->hdr.seq), >=, call->rx_data_recv); ASSERTCMP(sp->hdr.seq, >=, call->rx_data_recv);
ASSERTCMP(ntohl(sp->hdr.seq), <=, call->rx_data_recv + 1); ASSERTCMP(sp->hdr.seq, <=, call->rx_data_recv + 1);
call->rx_data_recv = ntohl(sp->hdr.seq); call->rx_data_recv = sp->hdr.seq;
ASSERTCMP(ntohl(sp->hdr.seq), >, call->rx_data_eaten); ASSERTCMP(sp->hdr.seq, >, call->rx_data_eaten);
rxrpc_free_skb(skb); rxrpc_free_skb(skb);
} }
......
...@@ -167,11 +167,11 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn) ...@@ -167,11 +167,11 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn)
struct rxrpc_sock *rx; struct rxrpc_sock *rx;
struct key *key; struct key *key;
key_ref_t kref; key_ref_t kref;
char kdesc[5+1+3+1]; char kdesc[5 + 1 + 3 + 1];
_enter(""); _enter("");
sprintf(kdesc, "%u:%u", ntohs(conn->service_id), conn->security_ix); sprintf(kdesc, "%u:%u", conn->service_id, conn->security_ix);
sec = rxrpc_security_lookup(conn->security_ix); sec = rxrpc_security_lookup(conn->security_ix);
if (!sec) { if (!sec) {
...@@ -182,7 +182,7 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn) ...@@ -182,7 +182,7 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn)
/* find the service */ /* find the service */
read_lock_bh(&local->services_lock); read_lock_bh(&local->services_lock);
list_for_each_entry(rx, &local->services, listen_link) { list_for_each_entry(rx, &local->services, listen_link) {
if (rx->service_id == conn->service_id) if (rx->srx.srx_service == conn->service_id)
goto found_service; goto found_service;
} }
......
...@@ -34,7 +34,7 @@ static void rxrpc_request_final_ACK(struct rxrpc_call *call) ...@@ -34,7 +34,7 @@ static void rxrpc_request_final_ACK(struct rxrpc_call *call)
/* get an extra ref on the call for the final-ACK generator to /* get an extra ref on the call for the final-ACK generator to
* release */ * release */
rxrpc_get_call(call); rxrpc_get_call(call);
set_bit(RXRPC_CALL_ACK_FINAL, &call->events); set_bit(RXRPC_CALL_EV_ACK_FINAL, &call->events);
if (try_to_del_timer_sync(&call->ack_timer) >= 0) if (try_to_del_timer_sync(&call->ack_timer) >= 0)
rxrpc_queue_call(call); rxrpc_queue_call(call);
break; break;
...@@ -59,7 +59,7 @@ static void rxrpc_hard_ACK_data(struct rxrpc_call *call, ...@@ -59,7 +59,7 @@ static void rxrpc_hard_ACK_data(struct rxrpc_call *call,
spin_lock_bh(&call->lock); spin_lock_bh(&call->lock);
_debug("hard ACK #%u", ntohl(sp->hdr.seq)); _debug("hard ACK #%u", sp->hdr.seq);
for (loop = 0; loop < RXRPC_ACKR_WINDOW_ASZ; loop++) { for (loop = 0; loop < RXRPC_ACKR_WINDOW_ASZ; loop++) {
call->ackr_window[loop] >>= 1; call->ackr_window[loop] >>= 1;
...@@ -67,7 +67,7 @@ static void rxrpc_hard_ACK_data(struct rxrpc_call *call, ...@@ -67,7 +67,7 @@ static void rxrpc_hard_ACK_data(struct rxrpc_call *call,
call->ackr_window[loop + 1] << (BITS_PER_LONG - 1); call->ackr_window[loop + 1] << (BITS_PER_LONG - 1);
} }
seq = ntohl(sp->hdr.seq); seq = sp->hdr.seq;
ASSERTCMP(seq, ==, call->rx_data_eaten + 1); ASSERTCMP(seq, ==, call->rx_data_eaten + 1);
call->rx_data_eaten = seq; call->rx_data_eaten = seq;
...@@ -133,5 +133,4 @@ void rxrpc_kernel_free_skb(struct sk_buff *skb) ...@@ -133,5 +133,4 @@ void rxrpc_kernel_free_skb(struct sk_buff *skb)
{ {
rxrpc_free_skb(skb); rxrpc_free_skb(skb);
} }
EXPORT_SYMBOL(rxrpc_kernel_free_skb); EXPORT_SYMBOL(rxrpc_kernel_free_skb);
...@@ -51,6 +51,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local, ...@@ -51,6 +51,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
spin_lock_init(&trans->client_lock); spin_lock_init(&trans->client_lock);
rwlock_init(&trans->conn_lock); rwlock_init(&trans->conn_lock);
atomic_set(&trans->usage, 1); atomic_set(&trans->usage, 1);
trans->conn_idcounter = peer->srx.srx_service << 16;
trans->debug_id = atomic_inc_return(&rxrpc_debug_id); trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
if (peer->srx.transport.family == AF_INET) { if (peer->srx.transport.family == AF_INET) {
......
This diff is collapsed.
...@@ -115,7 +115,7 @@ static struct ctl_table rxrpc_sysctl_table[] = { ...@@ -115,7 +115,7 @@ static struct ctl_table rxrpc_sysctl_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = (void *)&one, .extra1 = (void *)&one,
.extra1 = (void *)&n_65535, .extra2 = (void *)&n_65535,
}, },
{ {
.procname = "rx_jumbo_max", .procname = "rx_jumbo_max",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment