Whamcloud - gitweb
b=15984, i=maxim:
authorisaac <isaac>
Thu, 29 Jan 2009 15:23:34 +0000 (15:23 +0000)
committerisaac <isaac>
Thu, 29 Jan 2009 15:23:34 +0000 (15:23 +0000)
-  uptllnd credit overflow fix.

lnet/ChangeLog
lnet/include/lnet/ptllnd_wire.h
lnet/klnds/ptllnd/ptllnd.c
lnet/ulnds/ptllnd/ptllnd.c
lnet/ulnds/ptllnd/ptllnd_cb.c

index 6a05cf6..5231524 100644 (file)
@@ -17,6 +17,12 @@ Bugzilla   :
 Description: 
 Details    : 
 
+Severity   : minor
+Bugzilla   : 15984
+Description: uptllnd credit overflow fix
+Details    : kptl_msg_t::ptlm_credits could be overflown by uptllnd since
+             it is only a __u8.
+
 Severity   : major
 Bugzilla   : 14634
 Description: socklnd prtocol version 3
index 277c51c..2dd7253 100644 (file)
@@ -108,6 +108,9 @@ typedef struct
 
 } kptl_msg_t;
 
+/* kptl_msg_t::ptlm_credits is only a __u8 */
+#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1)
+
 #define PTLLND_MSG_MAGIC                LNET_PROTO_PTL_MAGIC
 #define PTLLND_MSG_VERSION              0x04
 
index 7f2e959..ffa0a2e 100755 (executable)
@@ -497,9 +497,8 @@ kptllnd_startup (lnet_ni_t *ni)
                 return -EINVAL;
         }
 
-        /* kptl_msg_t::ptlm_credits is only a __u8 */
-        if (*kptllnd_tunables.kptl_peercredits > 255) {
-                CERROR("kptl_peercredits must be <= 255\n");
+        if (*kptllnd_tunables.kptl_peercredits > PTLLND_MSG_MAX_CREDITS) {
+                CERROR("peercredits must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
                 return -EINVAL;
         }
 
index 3b504e7..b0ed0ce 100644 (file)
@@ -303,6 +303,10 @@ ptllnd_get_tunables(lnet_ni_t *ni)
                                       PTLLND_MAX_ULND_MSG_SIZE);
         if (rc != 0)
                 return rc;
+        if (plni->plni_peer_credits > PTLLND_MSG_MAX_CREDITS) {
+                CERROR("PTLLND_PEERCREDITS must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
+                return -EINVAL;
+        }
 
         rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
                                       "PTLLND_MSGS_PER_BUFFER", 64);
index c8431df..9cfa071 100644 (file)
@@ -875,9 +875,10 @@ ptllnd_check_sends(ptllnd_peer_t *peer)
                 /*
                  * Return all the credits we have
                  */
-                tx->tx_msg.ptlm_credits = peer->plp_outstanding_credits;
-                peer->plp_sent_credits += peer->plp_outstanding_credits;
-                peer->plp_outstanding_credits = 0;
+                tx->tx_msg.ptlm_credits = MIN(PTLLND_MSG_MAX_CREDITS,
+                                              peer->plp_outstanding_credits);
+                peer->plp_sent_credits += tx->tx_msg.ptlm_credits;
+                peer->plp_outstanding_credits -= tx->tx_msg.ptlm_credits;
 
                 /*
                  * One less credit