@@ -605,14 +605,15 @@ int dp_find_new_port(struct snat_data *snat_data,
605605 uint32_t iface_src_info_hash ;
606606 uint16_t min_port = snat_data -> nat_port_range [0 ];
607607 uint16_t max_port = snat_data -> nat_port_range [1 ];
608+ uint16_t port_range = max_port - min_port ;
608609 uint16_t tmp_port ;
609610 uint64_t timestamp ;
610611 int ret ;
611612
612613 iface_src_info_hash = (uint32_t )rte_hash_hash (ipv4_netnat_portmap_tbl , portmap_key );
613614
614- for (uint16_t p = 0 ; p < max_port - min_port ; ++ p ) {
615- tmp_port = min_port + (uint16_t )((iface_src_info_hash + p ) % ( uint32_t )( max_port - min_port ) );
615+ for (uint16_t p = 0 ; p < port_range ; ++ p ) {
616+ tmp_port = min_port + (uint16_t )((iface_src_info_hash + p ) % port_range );
616617 portoverload_tbl_key -> nat_port = tmp_port ;
617618 ret = rte_hash_lookup (ipv4_netnat_portoverload_tbl , portoverload_tbl_key );
618619 if (ret == - ENOENT ) {
@@ -632,10 +633,10 @@ int dp_find_new_port(struct snat_data *snat_data,
632633 snat_data -> log_timestamp = timestamp ;
633634 if (portmap_key -> src_ip .is_v6 ) {
634635 DPS_LOG_WARNING ("NAT64 portmap range is full" , DP_LOG_IPV4 (snat_data -> nat_ip ), DP_LOG_VNI (portmap_key -> vni ),
635- DP_LOG_SRC_IPV6 (portmap_key -> src_ip .ipv6 ), DP_LOG_SRC_PORT (portmap_key -> iface_src_port ));
636+ DP_LOG_SRC_IPV6 (portmap_key -> src_ip .ipv6 ), DP_LOG_SRC_PORT (portmap_key -> iface_src_port ), DP_LOG_VALUE ( port_range ) );
636637 } else {
637638 DPS_LOG_WARNING ("NAT portmap range is full" , DP_LOG_IPV4 (snat_data -> nat_ip ), DP_LOG_VNI (portmap_key -> vni ),
638- DP_LOG_SRC_IPV4 (portmap_key -> src_ip .ipv4 ), DP_LOG_SRC_PORT (portmap_key -> iface_src_port ));
639+ DP_LOG_SRC_IPV4 (portmap_key -> src_ip .ipv4 ), DP_LOG_SRC_PORT (portmap_key -> iface_src_port ), DP_LOG_VALUE ( port_range ) );
639640 }
640641 }
641642
0 commit comments