Whamcloud - gitweb
i=liangzhen,i=maxim,b=16022:
authorisaac <isaac>
Wed, 30 Jul 2008 01:24:45 +0000 (01:24 +0000)
committerisaac <isaac>
Wed, 30 Jul 2008 01:24:45 +0000 (01:24 +0000)
-   added more stringent parameter checks.

lnet/lnet/lib-md.c
lnet/lnet/lib-move.c

index 228f7d6..27c7e07 100644 (file)
@@ -220,11 +220,14 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
 
         LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
 
         LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
-        
+
         if ((umd.options & (LNET_MD_KIOV | LNET_MD_IOVEC)) != 0 &&
             umd.length > LNET_MAX_IOV) /* too many fragments */
                 return -EINVAL;
 
         if ((umd.options & (LNET_MD_KIOV | LNET_MD_IOVEC)) != 0 &&
             umd.length > LNET_MAX_IOV) /* too many fragments */
                 return -EINVAL;
 
+        if ((umd.options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) == 0)
+                return -EINVAL;
+
         md = lnet_md_alloc(&umd);
         if (md == NULL)
                 return -ENOMEM;
         md = lnet_md_alloc(&umd);
         if (md == NULL)
                 return -ENOMEM;
@@ -266,11 +269,14 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle)
 
         LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
 
         LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
-        
+
         if ((umd.options & (LNET_MD_KIOV | LNET_MD_IOVEC)) != 0 &&
             umd.length > LNET_MAX_IOV) /* too many fragments */
                 return -EINVAL;
 
         if ((umd.options & (LNET_MD_KIOV | LNET_MD_IOVEC)) != 0 &&
             umd.length > LNET_MAX_IOV) /* too many fragments */
                 return -EINVAL;
 
+        if ((umd.options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) != 0)
+                return -EINVAL;
+
         md = lnet_md_alloc(&umd);
         if (md == NULL)
                 return -ENOMEM;
         md = lnet_md_alloc(&umd);
         if (md == NULL)
                 return -ENOMEM;
index c72f047..5da7050 100644 (file)
@@ -1759,13 +1759,16 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
 
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.reply.dst_wmd);
 
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.reply.dst_wmd);
-        if (md == NULL || md->md_threshold == 0) {
+        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                 CDEBUG(D_NETERROR, "%s: Dropping REPLY from %s for %s "
                        "MD "LPX64"."LPX64"\n", 
                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.reply.dst_wmd.wh_interface_cookie,
                        hdr->msg.reply.dst_wmd.wh_object_cookie);
                 CDEBUG(D_NETERROR, "%s: Dropping REPLY from %s for %s "
                        "MD "LPX64"."LPX64"\n", 
                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.reply.dst_wmd.wh_interface_cookie,
                        hdr->msg.reply.dst_wmd.wh_object_cookie);
+                if (md != NULL && md->md_me != NULL)
+                        CERROR("REPLY MD also attached to portal %d\n",
+                               md->md_me->me_portal);
 
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve: OK but no match */
 
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve: OK but no match */
@@ -1832,7 +1835,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
 
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.ack.dst_wmd);
 
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.ack.dst_wmd);
-        if (md == NULL || md->md_threshold == 0) {
+        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                 /* Don't moan; this is expected */
                 CDEBUG(D_NET,
                        "%s: Dropping ACK from %s to %s MD "LPX64"."LPX64"\n",
                 /* Don't moan; this is expected */
                 CDEBUG(D_NET,
                        "%s: Dropping ACK from %s to %s MD "LPX64"."LPX64"\n",
@@ -1840,6 +1843,10 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.ack.dst_wmd.wh_interface_cookie,
                        hdr->msg.ack.dst_wmd.wh_object_cookie);
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.ack.dst_wmd.wh_interface_cookie,
                        hdr->msg.ack.dst_wmd.wh_object_cookie);
+                if (md != NULL && md->md_me != NULL)
+                        CERROR("Source MD also attached to portal %d\n",
+                               md->md_me->me_portal);
+
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve! */
         }
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve! */
         }
@@ -2206,12 +2213,17 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
         LNET_LOCK();
 
         md = lnet_handle2md(&mdh);
         LNET_LOCK();
 
         md = lnet_handle2md(&mdh);
-        if (md == NULL || md->md_threshold == 0) {
+        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                 lnet_msg_free(msg);
                 lnet_msg_free(msg);
-                LNET_UNLOCK();
 
 
-                CERROR("Dropping PUT to %s: MD invalid\n", 
-                       libcfs_id2str(target));
+                CERROR("Dropping PUT ("LPU64":%d:%s): MD (%d) invalid\n",
+                       match_bits, portal, libcfs_id2str(target),
+                       md == NULL ? -1 : md->md_threshold);
+                if (md != NULL && md->md_me != NULL)
+                        CERROR("Source MD also attached to portal %d\n",
+                               md->md_me->me_portal);
+
+                LNET_UNLOCK();
                 return -ENOENT;
         }
 
                 return -ENOENT;
         }
 
@@ -2383,12 +2395,17 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
         LNET_LOCK();
 
         md = lnet_handle2md(&mdh);
         LNET_LOCK();
 
         md = lnet_handle2md(&mdh);
-        if (md == NULL || md->md_threshold == 0) {
+        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                 lnet_msg_free(msg);
                 lnet_msg_free(msg);
-                LNET_UNLOCK();
 
 
-                CERROR("Dropping GET to %s: MD invalid\n",
-                       libcfs_id2str(target));
+                CERROR("Dropping GET ("LPU64":%d:%s): MD (%d) invalid\n",
+                       match_bits, portal, libcfs_id2str(target),
+                       md == NULL ? -1 : md->md_threshold);
+                if (md != NULL && md->md_me != NULL)
+                        CERROR("REPLY MD also attached to portal %d\n",
+                               md->md_me->me_portal);
+
+                LNET_UNLOCK();
                 return -ENOENT;
         }
 
                 return -ENOENT;
         }