[ofa-general] [PATCH][v2] dtest: add private data validation with connect and accept.

Davis, Arlin R arlin.r.davis at intel.com
Tue Apr 8 16:51:34 PDT 2008


Adding private data validation with connect and accept.
Also provide code, with build option, to validate private data 
With consumer reject.

Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
 test/dtest/dtest.c |   88
+++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 81 insertions(+), 7 deletions(-)

diff --git a/test/dtest/dtest.c b/test/dtest/dtest.c
index fa3b9a8..9c8ec71 100755
--- a/test/dtest/dtest.c
+++ b/test/dtest/dtest.c
@@ -559,8 +559,7 @@ complete:
     /* close the device */
     LOGPRINTF("%d Closing Interface Adaptor\n",getpid());
     start = get_time();
-    //ret = dat_ia_close( h_ia, DAT_CLOSE_ABRUPT_FLAG );
-    ret = dat_ia_close( h_ia, DAT_CLOSE_GRACEFUL_FLAG );
+    ret = dat_ia_close( h_ia, DAT_CLOSE_ABRUPT_FLAG );
     stop = get_time();
     time.close += ((stop - start)*1.0e6);
     if(ret != DAT_SUCCESS) {
@@ -730,7 +729,6 @@ send_msg(  void                   *data,
     return DAT_SUCCESS;
 }
 
-
 DAT_RETURN
 connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 {
@@ -743,6 +741,9 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
     DAT_RMR_TRIPLET         r_iov;
     DAT_DTO_COOKIE          cookie;
     int                     i;
+    unsigned char           *buf;
+    DAT_CR_PARAM            cr_param = { 0 };
+    unsigned char	    pdata[48] = { 0 };
     
      /* Register send message buffer */
     LOGPRINTF("%d Registering send Message Buffer %p, len %d\n",
@@ -867,17 +868,45 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id
)
                    getpid(),DT_EventToSTr(event.event_number));
            return( DAT_ABORT );
        }
-
+       
        /* use to test rdma_cma timeout logic */
 #if defined(_WIN32) || defined(_WIN64)
        if (delay) Sleep(delay*1000);
 #else
        if (delay) sleep(delay);
 #endif
+
         /* accept connect request from client */
        h_cr = event.event_data.cr_arrival_event_data.cr_handle;
        LOGPRINTF("%d Accepting connect request from
client\n",getpid());
-       ret = dat_cr_accept( h_cr, h_ep, 0, (DAT_PVOID)0 );
+
+       /* private data - check and send it back */
+       dat_cr_query( h_cr, DAT_CSP_FIELD_ALL, &cr_param); 
+
+       buf = (unsigned char*)cr_param.private_data;
+       LOGPRINTF("%d CONN REQUEST Private Data %p[0]=%d [47]=%d\n",
+                 getpid(),buf,buf[0],buf[47]);
+       for (i=0;i<48;i++) {
+           if (buf[i] != i+1) {
+               fprintf(stderr, "%d Error with CONNECT REQUEST"
+                       " private data: %p[%d]=%d s/be %d\n",
+                       getpid(), buf, i, buf[i], i+1);
+               dat_cr_reject(h_cr, 0, NULL);
+               return(DAT_ABORT);
+           }
+	   buf[i]++; /* change for trip back */
+       }	
+
+#ifdef TEST_REJECT_WITH_PRIVATE_DATA
+       printf("%d REJECT request with 48 bytes of private data\n",
getpid());
+       ret = dat_cr_reject(h_cr, 48, cr_param.private_data);
+       printf("\n%d: DAPL Test Complete. %s\n\n",
+	      getpid(), ret?"FAILED":"PASSED");
+       exit(0);
+#endif
+
+       ret = dat_cr_accept(h_cr, h_ep, 48, cr_param.private_data);
+
        if(ret != DAT_SUCCESS) {
            fprintf(stderr, "%d Error dat_cr_accept: %s\n",
                    getpid(),DT_RetToString(ret));
@@ -911,13 +940,16 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id
)
        remote_addr = *((DAT_IA_ADDRESS_PTR)target->ai_addr);
        freeaddrinfo(target);
 
+       for (i=0;i<48;i++) /* simple pattern in private data */
+           pdata[i]=i+1;
+
        LOGPRINTF("%d Connecting to server\n",getpid());
        ret = dat_ep_connect(   h_ep,
                                &remote_addr,
                                conn_id,
                                CONN_TIMEOUT,
-                               0,
-                               (DAT_PVOID)0,
+                               48,
+                               (DAT_PVOID)pdata,
                                0,
                                DAT_CONNECT_DEFAULT_FLAG  );
        if(ret != DAT_SUCCESS) {
@@ -940,11 +972,53 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id
)
     else
            LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n",
getpid());
 
+#ifdef TEST_REJECT_WITH_PRIVATE_DATA
+    if (event.event_number != DAT_CONNECTION_EVENT_PEER_REJECTED) {
+           fprintf(stderr, "%d expected conn reject event : %s\n",
+
getpid(),DT_EventToSTr(event.event_number));
+           return( DAT_ABORT );
+    }
+    /* get the reject private data and validate */
+    buf = (unsigned
char*)event.event_data.connect_event_data.private_data;
+    printf("%d Received REJECT with private data %p[0]=%d [47]=%d\n",
+           getpid(),buf,buf[0],buf[47]);
+    for (i=0;i<48;i++) {
+        if (buf[i] != i+2) {
+            fprintf(stderr, "%d client: Error with REJECT event"
+                    " private data: %p[%d]=%d s/be %d\n",
+                    getpid(), buf, i, buf[i], i+2);
+            dat_ep_disconnect( h_ep, DAT_CLOSE_ABRUPT_FLAG);
+            return(DAT_ABORT);
+        }
+    }
+    printf("\n%d: DAPL Test Complete. PASSED\n\n", getpid());
+    exit(0);
+#endif
+
     if ( event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED ) {
            fprintf(stderr, "%d Error unexpected conn event : %s\n",
 
getpid(),DT_EventToSTr(event.event_number));
            return( DAT_ABORT );
     }
+
+    /* check private data back from server  */
+    if (!server) {
+        buf = (unsigned
char*)event.event_data.connect_event_data.private_data;
+        LOGPRINTF("%d CONN Private Data %p[0]=%d [47]=%d\n",
+                  getpid(),buf,buf[0],buf[47]);
+        for (i=0;i<48;i++) {
+            if (buf[i] != i+2) {
+                fprintf(stderr, "%d Error with CONNECT event"
+                        " private data: %p[%d]=%d s/be %d\n",
+                        getpid(), buf, i, buf[i], i+2);
+                dat_ep_disconnect(h_ep, DAT_CLOSE_ABRUPT_FLAG);
+                LOGPRINTF("%d waiting for disconnect event...\n",
getpid());
+                dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1,
&event, &nmore);
+                return(DAT_ABORT);
+            }
+        }
+    }
+
     printf("\n%d CONNECTED!\n\n",getpid());
     connected = 1;
 
-- 
1.5.2.5




More information about the general mailing list