rx: Remove unneeded rxi_ReceiveDataPacket params
[openafs.git] / src / rx / rx.c
index 76d7d69..417e919 100644 (file)
@@ -131,11 +131,10 @@ static struct rx_connection
 static struct rx_packet
        *rxi_ReceiveDataPacket(struct rx_call *call, struct rx_packet *np,
                               int istack, osi_socket socket,
-                              afs_uint32 host, u_short port, int *tnop,
-                              struct rx_call **newcallp);
+                              int *tnop, struct rx_call **newcallp);
 static struct rx_packet
        *rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
-                             int istack);
+                             int istack, int *a_invalid);
 static struct rx_packet
        *rxi_ReceiveResponsePacket(struct rx_connection *conn,
                                   struct rx_packet *np, int istack);
@@ -3294,6 +3293,36 @@ rxi_ReceiveServerCall(osi_socket socket, struct rx_packet *np,
     call = conn->call[channel];
 
     if (!call) {
+       if (np->header.type != RX_PACKET_TYPE_DATA) {
+           /*
+            * Clients must send DATA packets at some point to create a new
+            * call. If the first packet we saw for this call channel is
+            * something else, then either the DATA packets got lost/delayed,
+            * or we were restarted and this is an existing call from before we
+            * were restarted. In the latter case, some clients get confused if
+            * we respond to such requests, so just drop the packet to make
+            * things easier for them.
+            */
+           MUTEX_EXIT(&conn->conn_call_lock);
+           if (rx_stats_active)
+               rx_atomic_inc(&rx_stats.spuriousPacketsRead);
+           return NULL;
+       }
+
+       if (np->header.seq > rx_maxReceiveWindow) {
+           /*
+            * This is a DATA packet for further along in the call than is
+            * possible for a new call. This is probably from an existing call
+            * that was in the middle of running when we were restarted; ignore
+            * it to avoid confusing clients. (See above comment about non-DATA
+            * packets.)
+            */
+           MUTEX_EXIT(&conn->conn_call_lock);
+           if (rx_stats_active)
+               rx_atomic_inc(&rx_stats.spuriousPacketsRead);
+           return NULL;
+       }
+
        if (rxi_AbortIfServerBusy(socket, conn, np)) {
            MUTEX_EXIT(&conn->conn_call_lock);
            return NULL;
@@ -3405,6 +3434,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
     struct rx_connection *conn;
     int type;
     int unknownService = 0;
+    int invalid = 0;
 #ifdef RXDEBUG
     char *packetType;
 #endif
@@ -3582,8 +3612,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
        if (type == RX_CLIENT_CONNECTION && !opr_queue_IsEmpty(&call->tq))
            rxi_AckAllInTransmitQueue(call);
 
-       np = rxi_ReceiveDataPacket(call, np, 1, socket, host, port, tnop,
-                                  newcallp);
+       np = rxi_ReceiveDataPacket(call, np, 1, socket, tnop, newcallp);
        break;
     case RX_PACKET_TYPE_ACK:
        /* Respond immediately to ack packets requesting acknowledgement
@@ -3595,7 +3624,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
                (void)rxi_SendAck(call, 0, np->header.serial,
                                  RX_ACK_PING_RESPONSE, 1);
        }
-       np = rxi_ReceiveAckPacket(call, np, 1);
+       np = rxi_ReceiveAckPacket(call, np, 1, &invalid);
        break;
     case RX_PACKET_TYPE_ABORT: {
        /* An abort packet: reset the call, passing the error up to the user. */
@@ -3628,11 +3657,16 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
        np = rxi_SendCallAbort(call, np, 1, 0);
        break;
     };
-    /* Note when this last legitimate packet was received, for keep-alive
-     * processing.  Note, we delay getting the time until now in the hope that
-     * the packet will be delivered to the user before any get time is required
-     * (if not, then the time won't actually be re-evaluated here). */
-    call->lastReceiveTime = clock_Sec();
+    if (invalid) {
+       if (rx_stats_active)
+           rx_atomic_inc(&rx_stats.spuriousPacketsRead);
+    } else {
+       /*
+        * Note when this last legitimate packet was received, for keep-alive
+        * processing.
+        */
+       call->lastReceiveTime = clock_Sec();
+    }
     MUTEX_EXIT(&call->lock);
     putConnection(conn);
     return np;
@@ -3860,8 +3894,7 @@ TryAttach(struct rx_call *acall, osi_socket socket,
 static struct rx_packet *
 rxi_ReceiveDataPacket(struct rx_call *call,
                      struct rx_packet *np, int istack,
-                     osi_socket socket, afs_uint32 host, u_short port,
-                     int *tnop, struct rx_call **newcallp)
+                     osi_socket socket, int *tnop, struct rx_call **newcallp)
 {
     int ackNeeded = 0;         /* 0 means no, otherwise ack_reason */
     int newPackets = 0;
@@ -3920,7 +3953,7 @@ rxi_ReceiveDataPacket(struct rx_call *call,
        /* The RX_JUMBO_PACKET is set in all but the last packet in each
         * AFS 3.5 jumbogram. */
        if (flags & RX_JUMBO_PACKET) {
-           tnp = rxi_SplitJumboPacket(np, host, port, isFirst);
+           tnp = rxi_SplitJumboPacket(np);
        } else {
            tnp = NULL;
        }
@@ -4288,7 +4321,7 @@ ack_is_valid(struct rx_call *call, afs_uint32 first, afs_uint32 prev)
 /* The real smarts of the whole thing.  */
 static struct rx_packet *
 rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
-                    int istack)
+                    int istack, int *a_invalid)
 {
     struct rx_ackPacket *ap;
     int nAcks;
@@ -4309,6 +4342,8 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
     int pktsize = 0;            /* Set if we need to update the peer mtu */
     int conn_data_locked = 0;
 
+    *a_invalid = 1;
+
     if (rx_stats_active)
         rx_atomic_inc(&rx_stats.ackPacketsRead);
     ap = (struct rx_ackPacket *)rx_DataOf(np);
@@ -4328,6 +4363,8 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
 
     call->tprev = prev;
 
+    *a_invalid = 0;
+
     if (np->header.flags & RX_SLOW_START_OK) {
        call->flags |= RX_CALL_SLOW_START_OK;
     }