diff options
author | wenxian li <wofanli@gmail.com> | 2016-03-24 01:41:10 -0400 |
---|---|---|
committer | wenxian li <wofanli@gmail.com> | 2016-03-24 01:41:10 -0400 |
commit | 6bdc3bd98fd899f48b792f9d1ae82a313c159450 (patch) | |
tree | 2b880c837f90e262c94a331c7a62db1b93aad28d | |
parent | e7814e9b5b57b8c2bcc21067803a4670a6260344 (diff) |
Fix crash when # of mac-ip mapping entries exceed than 255.
-rwxr-xr-x | src/tuple_gen.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tuple_gen.cpp b/src/tuple_gen.cpp index d3538ce6..36f70c39 100755 --- a/src/tuple_gen.cpp +++ b/src/tuple_gen.cpp @@ -84,13 +84,16 @@ void CClientPool::Create(IP_DIST_t dist_value, if (total_ip > ((l_flow*t_cps/MAX_PORT))) { if (has_mac_map) { + int skip_cnt=0; for(int idx=0;idx<total_ip;idx++){ mac_addr_align_t *mac_adr = NULL; mac_adr = mac_info->get_mac_addr_by_ip( min_ip+idx); if (mac_adr != NULL) { - m_ip_info[idx] = new CClientInfoL(has_mac_map); - m_ip_info[idx]->set_ip(min_ip+idx); - m_ip_info[idx]->set_mac(mac_adr); + m_ip_info[idx-skip_cnt] = new CClientInfoL(has_mac_map); + m_ip_info[idx-skip_cnt]->set_ip(min_ip+idx); + m_ip_info[idx-skip_cnt]->set_mac(mac_adr); + } else { + skip_cnt++; } } } else { @@ -101,13 +104,16 @@ void CClientPool::Create(IP_DIST_t dist_value, } } else { if (has_mac_map) { + int skip_cnt=0; for(int idx=0;idx<total_ip;idx++){ mac_addr_align_t *mac_adr = NULL; mac_adr = mac_info->get_mac_addr_by_ip(min_ip+idx); if (mac_adr != NULL) { - m_ip_info[idx] = new CClientInfo(has_mac_map); - m_ip_info[idx]->set_ip(min_ip+idx); - m_ip_info[idx]->set_mac(mac_adr); + m_ip_info[idx-skip_cnt] = new CClientInfo(has_mac_map); + m_ip_info[idx-skip_cnt]->set_ip(min_ip+idx); + m_ip_info[idx-skip_cnt]->set_mac(mac_adr); + } else { + skip_cnt++; } } } else { |