Commit dc71db34 authored by David Howells's avatar David Howells

rxrpc: Fix checks as to whether we should set up a new call

There's a check in rxrpc_data_ready() that's checking the CLIENT_INITIATED
flag in the packet type field rather than in the packet flags field.

Fix this by creating a pair of helper functions to check whether the packet
is going to the client or to the server and use them generally.

Fixes: 248f219c ("rxrpc: Rewrite the data and ack handling code")
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 092ffc51
...@@ -463,6 +463,16 @@ struct rxrpc_connection { ...@@ -463,6 +463,16 @@ struct rxrpc_connection {
u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
}; };
static inline bool rxrpc_to_server(const struct rxrpc_skb_priv *sp)
{
return sp->hdr.flags & RXRPC_CLIENT_INITIATED;
}
static inline bool rxrpc_to_client(const struct rxrpc_skb_priv *sp)
{
return !rxrpc_to_server(sp);
}
/* /*
* Flags in call->flags. * Flags in call->flags.
*/ */
......
...@@ -96,7 +96,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, ...@@ -96,7 +96,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local,
k.epoch = sp->hdr.epoch; k.epoch = sp->hdr.epoch;
k.cid = sp->hdr.cid & RXRPC_CIDMASK; k.cid = sp->hdr.cid & RXRPC_CIDMASK;
if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) { if (rxrpc_to_server(sp)) {
/* We need to look up service connections by the full protocol /* We need to look up service connections by the full protocol
* parameter set. We look up the peer first as an intermediate * parameter set. We look up the peer first as an intermediate
* step and then the connection from the peer's tree. * step and then the connection from the peer's tree.
......
...@@ -1177,10 +1177,6 @@ void rxrpc_data_ready(struct sock *udp_sk) ...@@ -1177,10 +1177,6 @@ void rxrpc_data_ready(struct sock *udp_sk)
trace_rxrpc_rx_packet(sp); trace_rxrpc_rx_packet(sp);
_net("Rx RxRPC %s ep=%x call=%x:%x",
sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient",
sp->hdr.epoch, sp->hdr.cid, sp->hdr.callNumber);
if (sp->hdr.type >= RXRPC_N_PACKET_TYPES || if (sp->hdr.type >= RXRPC_N_PACKET_TYPES ||
!((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) { !((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);
...@@ -1189,13 +1185,13 @@ void rxrpc_data_ready(struct sock *udp_sk) ...@@ -1189,13 +1185,13 @@ void rxrpc_data_ready(struct sock *udp_sk)
switch (sp->hdr.type) { switch (sp->hdr.type) {
case RXRPC_PACKET_TYPE_VERSION: case RXRPC_PACKET_TYPE_VERSION:
if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) if (rxrpc_to_client(sp))
goto discard; goto discard;
rxrpc_post_packet_to_local(local, skb); rxrpc_post_packet_to_local(local, skb);
goto out; goto out;
case RXRPC_PACKET_TYPE_BUSY: case RXRPC_PACKET_TYPE_BUSY:
if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) if (rxrpc_to_server(sp))
goto discard; goto discard;
/* Fall through */ /* Fall through */
...@@ -1280,7 +1276,7 @@ void rxrpc_data_ready(struct sock *udp_sk) ...@@ -1280,7 +1276,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
call = rcu_dereference(chan->call); call = rcu_dereference(chan->call);
if (sp->hdr.callNumber > chan->call_id) { if (sp->hdr.callNumber > chan->call_id) {
if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) { if (rxrpc_to_client(sp)) {
rcu_read_unlock(); rcu_read_unlock();
goto reject_packet; goto reject_packet;
} }
...@@ -1303,7 +1299,7 @@ void rxrpc_data_ready(struct sock *udp_sk) ...@@ -1303,7 +1299,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
} }
if (!call || atomic_read(&call->usage) == 0) { if (!call || atomic_read(&call->usage) == 0) {
if (!(sp->hdr.type & RXRPC_CLIENT_INITIATED) || if (rxrpc_to_client(sp) ||
sp->hdr.callNumber == 0 || sp->hdr.callNumber == 0 ||
sp->hdr.type != RXRPC_PACKET_TYPE_DATA) sp->hdr.type != RXRPC_PACKET_TYPE_DATA)
goto bad_message_unlock; goto bad_message_unlock;
......
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