Merge branch 'master'
authorimarom <[email protected]>
Wed, 23 Nov 2016 08:32:25 +0000 (10:32 +0200)
committerimarom <[email protected]>
Wed, 23 Nov 2016 08:32:25 +0000 (10:32 +0200)
Signed-off-by: imarom <[email protected]>
Conflicts:
src/main_dpdk.cpp

1  2 
linux/ws_main.py
linux_dpdk/ws_main.py
src/common/basic_utils.cpp
src/common/basic_utils.h
src/main_dpdk.cpp

@@@ -118,8 -119,8 +119,9 @@@ main_src = SrcGroup(dir='src'
               'time_histogram.cpp',
               'utl_json.cpp',
               'utl_cpuu.cpp',
+              'utl_ip.cpp',
               'msg_manager.cpp',
 +             'trex_port_attr.cpp',
               'publisher/trex_publisher.cpp',
               'stateful_rx_core.cpp',
               'flow_stat.cpp',
Simple merge
Simple merge
@@@ -85,10 -85,8 +85,11 @@@ inline void utl_swap(T& a, T& b) 
  bool utl_is_file_exists (const std::string& name) ;
  
  void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output);
+ std::string utl_macaddr_to_str(const uint8_t *macaddr);
  
 +std::string utl_macaddr_to_str(const uint8_t *macaddr);
 +bool utl_str_to_macaddr(const std::string &s, uint8_t *mac);
 +
  std::string utl_generate_random_str(unsigned int &seed, int len);
  
  /**
@@@ -3211,46 -3267,62 +3276,72 @@@ void CGlobalTRex::pre_test() 
          ret = pretest.resolve_all();
          count++;
      } while ((ret != true) && (count < 10));
+     if (ret != true) {
+         resolve_failed = true;
+     }
  
-     if ( CGlobalInfo::m_options.preview.getVMode() > 0) {
+     if ( CGlobalInfo::m_options.preview.getVMode() > 1) {
+         fprintf(stdout, "*******Pretest after resolving ********\n");
          pretest.dump(stdout);
      }
-     uint8_t mac[ETHER_ADDR_LEN];
-     for (int port_id = 0; port_id < m_max_ports; port_id++) {
-         if (! memcmp(CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest, empty_mac, ETHER_ADDR_LEN)) {
-             // we don't have dest MAC. Get it from what we resolved.
-             uint32_t ip = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw();
-             if (! pretest.get_mac(port_id, ip, mac)) {
-                 fprintf(stderr, "Failed resolving dest MAC for default gateway:%d.%d.%d.%d on port %d\n"
-                         , (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF, port_id);
-                 exit(1);
+     if (CGlobalInfo::m_options.preview.get_is_client_cfg_enable()) {
+         CManyIPInfo pretest_result;
+         pretest.get_results(pretest_result);
+         if (resolve_failed) {
+             fprintf(stderr, "Resolution of following IPs failed. Exiting.\n");
+             for (const COneIPInfo *ip=pretest_result.get_next(); ip != NULL;
+                    ip = pretest_result.get_next()) {
+                 ip->dump(stderr);
              }
-             memcpy(CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest, mac, ETHER_ADDR_LEN);
-              
-             // if port is connected in loopback, no need to send gratuitous ARP. It will only confuse our ingress counters.
-             if (pretest.is_loopback(port_id))
-                 CGlobalInfo::m_options.m_ip_cfg[port_id].set_grat_arp_needed(false);
+             exit(-1);
+         }
+         m_fl.set_client_config_resolved_macs(pretest_result);
+         if ( CGlobalInfo::m_options.preview.getVMode() > 1) {
+             m_fl.dump_client_config(stdout);
          }
  
-         // update statistics baseline, so we can ignore what happened in pre test phase
-         CPhyEthIF *pif = &m_ports[port_id];
-         CPreTestStats pre_stats = pretest.get_stats(port_id);
-         pif->set_ignore_stats_base(pre_stats);
-         // Configure port back to normal mode. Only relevant packets handled by software.
-         CTRexExtendedDriverDb::Ins()->get_drv()->set_rcv_all(pif, false);
-         
+     } else {
+         uint8_t mac[ETHER_ADDR_LEN];
+         for (int port_id = 0; port_id < m_max_ports; port_id++) {
+             if (! memcmp(CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest, empty_mac, ETHER_ADDR_LEN)) {
+                 // we don't have dest MAC. Get it from what we resolved.
+                 uint32_t ip = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw();
+                 uint16_t vlan = CGlobalInfo::m_options.m_ip_cfg[port_id].get_vlan();
+                 if (! pretest.get_mac(port_id, ip, vlan, mac)) {
+                     fprintf(stderr, "Failed resolving dest MAC for default gateway:%d.%d.%d.%d on port %d\n"
+                             , (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF, port_id);
+                     exit(1);
+                 }
+                 memcpy(CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest, mac, ETHER_ADDR_LEN);
+                 // if port is connected in loopback, no need to send gratuitous ARP. It will only confuse our ingress counters.
+                 if (need_grat_arp[port_id] && (! pretest.is_loopback(port_id))) {
+                     COneIPv4Info ipv4(CGlobalInfo::m_options.m_ip_cfg[port_id].get_ip()
+                                       , CGlobalInfo::m_options.m_ip_cfg[port_id].get_vlan()
+                                       , CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src
+                                       , port_id);
+                     m_mg.add_grat_arp_src(ipv4);
+                 }
+             }
  
-         /* set resolved IPv4 */
-         uint32_t dg = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw();
-         const uint8_t *dst_mac = CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest;
-         if (dg) {
-             m_ports[port_id].get_port_attr()->get_dest().set_dest_ipv4(dg, dst_mac);
-         } else {
-             m_ports[port_id].get_port_attr()->get_dest().set_dest_mac(dst_mac);
-         }
+             // update statistics baseline, so we can ignore what happened in pre test phase
+             CPhyEthIF *pif = &m_ports[port_id];
+             CPreTestStats pre_stats = pretest.get_stats(port_id);
+             pif->set_ignore_stats_base(pre_stats);
+             // Configure port back to normal mode. Only relevant packets handled by software.
+             CTRexExtendedDriverDb::Ins()->get_drv()->set_rcv_all(pif, false);
 -        }
++
++           /* set resolved IPv4 */
++           uint32_t dg = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw();
++           const uint8_t *dst_mac = CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest;
++           if (dg) {
++               m_ports[port_id].get_port_attr()->get_dest().set_dest_ipv4(dg, dst_mac);
++           } else {
++               m_ports[port_id].get_port_attr()->get_dest().set_dest_mac(dst_mac);
++           }
 +        
 +
      }
  }