some minor changes to test code: DEV.NETAPI.01.00.00.10
authorDavid Lide <a0216552@gtudci01.(none)>
Thu, 14 Nov 2013 14:57:31 +0000 (09:57 -0500)
committerDavid Lide <a0216552@gtudci01.(none)>
Thu, 14 Nov 2013 14:57:31 +0000 (09:57 -0500)
 - bug in net_test_router double counting rx pkts
 - handle other crypto modes in router.c
 - support NULL crypto/auth combinations in net_test_sa_utils.c
 -

ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/net_test_sa_utils.c
ti/runtime/netapi/test/router.c

index 81e8131c179d7ab37f45fd52890016ec614445b8..670578e5c0eee3e8e80521c738e6f42210d2fc8b 100755 (executable)
@@ -650,7 +650,6 @@ void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
         tip = p_recv[i];
         Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
         len = Pktlib_getPacketLen(tip)-4;//real length, subtract mac trailer
-        stats[coreid].rx+=1;
         appid = ((unsigned int)meta[i].u.rx_meta->appId)&0xff000000;
         switch(appid)
         {
index 1d8d6b92abe58107b6b5f202bdbcdfaf7a05a845..1e28ea9bc844c186d81642c9d506940508245e97 100755 (executable)
@@ -138,6 +138,68 @@ void  netTest_utilBuildSADB(int i)
            trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
         }
     }
+    else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+             (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
+                                                netTest_IP_HEADER_LEN;
+
+        sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+                                               netTest_IP_HEADER_LEN +
+                                               netTest_ESP_HEADER_LEN +
+                                               netTest_AES_CTR_IV_LEN;
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+
+        sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+        sa_info[i].authMode = netTestCfg.sa[i].authMode;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = 0;
+        sa_info[i].iv_len=8;
+        sa_info[i].bl=8;
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+        sa_info[i].key_params = &netTestCfg.key_params[i];
+
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+        sa_info[i].dir =netTestCfg.sa[i].dir;
+        tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+        tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
+        sa_info[i].spi =tmp_spi;
+        sa_info[i].tunnel_id = tmp_tunnel;
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
+        if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+        {
+           trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+        }
+        else
+        {
+           trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+        }
+    }
     else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
              (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
     {
@@ -373,6 +435,64 @@ void  netTest_utilBuildSADB(int i)
            trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
         }
     }
+    else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+             (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
+                                                netTest_IP_HEADER_LEN;
+         sa_info[i].tx_payload_info.encOffset =         netTest_MAC_HEADER_LEN +
+                                                       netTest_IP_HEADER_LEN +
+                                                       netTest_ESP_HEADER_LEN;
+
+        sa_info[i].iv_len=0;
+        sa_info[i].bl=0;
+
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+
+        sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+        sa_info[i].authMode = netTestCfg.sa[i].authMode;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = 0;
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
+                                         NWAL_TX_FLAG1_DO_UDP_CHKSUM |
+                                         NWAL_TX_FLAG1_META_DATA_VALID;
+
+        sa_info[i].dir =netTestCfg.sa[i].dir;
+        tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+        tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
+        sa_info[i].spi =tmp_spi;
+        sa_info[i].tunnel_id = tmp_tunnel;
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
+        if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+        {
+           trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+        }
+        else
+        {
+           trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+        }
+
+    }
     else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
              (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
     {
index fd433b4b11815cb52bcd76c8c6d2da6448da8a8f..00e341e8dcdd95d9281db96fc25dae767b736e73 100755 (executable)
@@ -80,19 +80,40 @@ pc[1]=50;
 pc= (unsigned char*)&Phead->w1;
 pl_len=  ((pc[2]<<8) | (pc[3]));  
 
-//pad length
-nb = pl_len/p_sec->bl;       //128 for AES
-pad_len =   pl_len - nb*p_sec->bl;
-switch(pad_len)
+//only for non-zero bl
+if (p_sec->bl)
 {
-  case(15):
-   pad_len=15;
-   break;
-  default:
-    pad_len = p_sec->bl-pad_len-2;
+  nb = pl_len/ (p_sec->bl);       //128bits for AES
+  pad_len =   pl_len - nb*p_sec->bl;
+  if (p_sec->bl==16) //AES based
+  {
+    switch(pad_len)
+    {
+    case(15):
+      pad_len=15;
+      break;
+    default:
+      pad_len = p_sec->bl-pad_len-2;
+    }
+  }
+  else //assume 8 byte block (DES)
+  {
+    switch(pad_len)
+    {
+    case(7):
+      pad_len=7;
+      break;
+    default:
+      pad_len = p_sec->bl-pad_len-2;
+    }
+  }
+}
+else
+{
+   pad_len=0;
 }
 
-new_pl_len = pl_len + +20+ 8 + p_sec->iv_len + pad_len + p_sec->auth_tag_size +2;
+new_pl_len = pl_len  +20+ 8 + p_sec->iv_len + pad_len + p_sec->auth_tag_size +2;
 pc[2] =  (new_pl_len&0xff00)>>8;
 pc[3] =  (new_pl_len&0xff);
 memcpy(&sb[14],Phead,20);  //copy outer ip header into buffer