]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rxrpc: Fix checks as to whether we should set up a new call
authorDavid Howells <dhowells@redhat.com>
Thu, 27 Sep 2018 14:13:08 +0000 (15:13 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 28 Sep 2018 09:31:20 +0000 (10:31 +0100)
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: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
Signed-off-by: David Howells <dhowells@redhat.com>
net/rxrpc/ar-internal.h
net/rxrpc/conn_object.c
net/rxrpc/input.c

index c9755871042159bdf32a7bd980d8ee4d3a9a51bf..9fcb3e197b144a72279f9370a0915f27eb6b6c5e 100644 (file)
@@ -463,6 +463,16 @@ struct rxrpc_connection {
        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.
  */
index 1746b48cb165e3bebf604c7c3eaf94b489628a98..390ba50cfab4f2dd92784a41e752cbe6e5b19a87 100644 (file)
@@ -96,7 +96,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local,
        k.epoch = sp->hdr.epoch;
        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
                 * parameter set.  We look up the peer first as an intermediate
                 * step and then the connection from the peer's tree.
index cfdc199c63510255c1d8cd60baed3c5f66b93d28..ec299c627f7728180b8ab41583b8fe9ffb47594c 100644 (file)
@@ -1177,10 +1177,6 @@ void rxrpc_data_ready(struct sock *udp_sk)
 
        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 ||
            !((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) {
                _proto("Rx Bad Packet Type %u", sp->hdr.type);
@@ -1189,13 +1185,13 @@ void rxrpc_data_ready(struct sock *udp_sk)
 
        switch (sp->hdr.type) {
        case RXRPC_PACKET_TYPE_VERSION:
-               if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED))
+               if (rxrpc_to_client(sp))
                        goto discard;
                rxrpc_post_packet_to_local(local, skb);
                goto out;
 
        case RXRPC_PACKET_TYPE_BUSY:
-               if (sp->hdr.flags & RXRPC_CLIENT_INITIATED)
+               if (rxrpc_to_server(sp))
                        goto discard;
                /* Fall through */
 
@@ -1280,7 +1276,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
                call = rcu_dereference(chan->call);
 
                if (sp->hdr.callNumber > chan->call_id) {
-                       if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) {
+                       if (rxrpc_to_client(sp)) {
                                rcu_read_unlock();
                                goto reject_packet;
                        }
@@ -1303,7 +1299,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
        }
 
        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.type != RXRPC_PACKET_TYPE_DATA)
                        goto bad_message_unlock;