@@ -424,7 +424,7 @@ eResult module::neighbor_interfaces_switch()
424424
425425 if (changed)
426426 {
427- NEIGHBOR_INFO (" neighbor_interfaces_switch changed" );
427+ NEIGHBOR_INFO (" neighbor_interfaces_switch changed\n " );
428428#ifdef CONFIG_YADECAP_AUTOTEST
429429 UpdateFromCache (true );
430430#else // CONFIG_YADECAP_AUTOTEST
@@ -463,8 +463,7 @@ void module::StartResolveJob()
463463 std::optional<std::string> interface_name = GetInterfaceName (key.interface_id );
464464 if (interface_name.has_value () && neighbor_cache_.NeedResolve (*interface_name, key.address , key.flags & flag_is_ipv6, timestamp))
465465 {
466- common::ip_address_t ip_address (key.flags & flag_is_ipv6 ? 6 : 4 , key.address .bytes );
467- resolve (*interface_name, ip_address);
466+ resolve (*interface_name, key.address , key.flags & flag_is_ipv6);
468467 }
469468 }
470469
@@ -537,43 +536,42 @@ void module::Remove(std::string iface_name, const ipv6_address_t& dst, bool is_v
537536 }
538537}
539538
540- bool module::resolve (const std::string& interface_name, const common:: ip_address_t & ip_address)
539+ bool module::resolve (const std::string& interface_name, const ipv6_address_t & ip_address, bool is_v6 )
541540{
542541 stats.resolve ++;
543542
544- NEIGHBOR_DEBUG (" neighbor resolve: %s, %s\n " , interface_name.c_str (), ip_address.toString ().c_str ());
543+ NEIGHBOR_DEBUG (" neighbor resolve: %s, %s\n " ,
544+ interface_name.c_str (),
545+ common::ip_address_t (is_v6 ? 6 : 4 , ip_address.bytes ).toString ().c_str ());
545546 YANET_LOG_DEBUG (" resolve: %s, %s\n " ,
546547 interface_name.data (),
547- ip_address.toString ().data ());
548+ common::ip_address_t (is_v6 ? 6 : 4 , ip_address. bytes ) .toString ().data ());
548549
549550 bool result = true ;
550551#ifdef CONFIG_YADECAP_AUTOTEST
551552 NEIGHBOR_INFO (" Mocking resolve: %s, %s\n " ,
552553 interface_name.data (),
553- ip_address.toString ().data ());
554+ common::ip_address_t (is_v6 ? 6 : 4 , ip_address. bytes ) .toString ().data ());
554555 value value;
555556 value.ether_address .addr_bytes [0 ] = 44 ;
556557 value.ether_address .addr_bytes [1 ] = 44 ;
557- if (ip_address. is_ipv6 () )
558+ if (is_v6 )
558559 {
559560 value.ether_address .addr_bytes [0 ] = 66 ;
560561 value.ether_address .addr_bytes [1 ] = 66 ;
561562 }
562563
563564 dataplane::neighbor::key key;
564565 memset (&key, 0 , sizeof (key));
565- if (ip_address.is_ipv4 ())
566+ key.address = ip_address;
567+ if (is_v6)
566568 {
567- key.address .mapped_ipv4_address = ipv4_address_t::convert (ip_address.get_ipv4 ());
568- }
569- else
570- {
571- key.address = ipv6_address_t::convert (ip_address.get_ipv6 ());
569+
572570 key.flags |= flag_is_ipv6;
573571 }
574572 *((uint32_t *)&value.ether_address .addr_bytes [2 ]) = rte_hash_crc (key.address .bytes , 16 , 0 );
575573
576- neighbor_cache_.Insert (interface_name, key.address , ip_address. is_ipv6 () , value.ether_address , current_time_provider_ (), false );
574+ neighbor_cache_.Insert (interface_name, key.address , is_v6 , value.ether_address , current_time_provider_ (), false );
577575
578576 std::optional<tInterfaceId> interface_id = GetInterfaceId (interface_name);
579577 if (interface_id.has_value ())
@@ -603,7 +601,7 @@ bool module::resolve(const std::string& interface_name, const common::ip_address
603601
604602 int family = AF_INET;
605603 int protocol = IPPROTO_ICMP;
606- if (ip_address. is_ipv6 () )
604+ if (is_v6 )
607605 {
608606 family = AF_INET6;
609607 protocol = IPPROTO_ICMPV6;
@@ -640,19 +638,19 @@ bool module::resolve(const std::string& interface_name, const common::ip_address
640638
641639 socklen_t address_length = sizeof (address_v4);
642640
643- if (ip_address. is_ipv6 () )
641+ if (is_v6 )
644642 {
645643 address_v6.sin6_family = AF_INET6;
646644 address_v6.sin6_port = 0 ;
647- memcpy (address_v6.sin6_addr .__in6_u .__u6_addr8 , ip_address.get_ipv6 (). data () , 16 );
645+ memcpy (address_v6.sin6_addr .__in6_u .__u6_addr8 , ip_address.bytes , 16 );
648646
649647 address_length = sizeof (address_v6);
650648 }
651649 else
652650 {
653651 address_v4.sin_family = AF_INET;
654652 address_v4.sin_port = 0 ;
655- address_v4.sin_addr .s_addr = ip_address.get_ipv6 (). get_mapped_ipv4_address () ;
653+ address_v4.sin_addr .s_addr = ip_address.mapped_ipv4_address . address ;
656654 }
657655
658656 icmphdr header;
@@ -722,8 +720,7 @@ void module::NeighborThreadAction(uint32_t current_time)
722720 // resolve
723721 for (const key_cache& cur_key : keys_to_resolve)
724722 {
725- common::ip_address_t ip_address (cur_key.is_v6 ? 6 : 4 , cur_key.address .bytes );
726- if (resolve (cur_key.iface_name , ip_address))
723+ if (resolve (cur_key.iface_name , cur_key.address , cur_key.is_v6 ))
727724 {
728725 neighbor_cache_.SetSentResolve (cur_key, current_time_provider_ ());
729726 }
0 commit comments