@@ -827,54 +827,63 @@ void tap2veth_fun(std::shared_ptr<hostif_info_t> info)
827
827
SWSS_LOG_NOTICE (" ending thread proc for %s" , info->name .c_str ());
828
828
}
829
829
830
- bool hostif_create_tap_veth_forwarding (
831
- _In_ const std::string &tapname,
832
- _In_ int tapfd,
830
+ std::string vs_get_veth_name (
831
+ _In_ const std::string& tapname,
833
832
_In_ sai_object_id_t port_id)
834
833
{
835
834
SWSS_LOG_ENTER ();
836
835
837
- // we assume here that veth devices were added by user before creating this
838
- // host interface, vEthernetX will be used for packet transfer between ip
839
- // namespaces
840
-
841
836
std::string vethname = SAI_VS_VETH_PREFIX + tapname;
842
837
843
838
// check if user override interface names
844
839
845
- {
846
- sai_attribute_t attr;
840
+ sai_attribute_t attr;
841
+
842
+ uint32_t lanes[4 ];
847
843
848
- uint32_t lanes[ 4 ] ;
844
+ attr. id = SAI_PORT_ATTR_HW_LANE_LIST ;
849
845
850
- attr.id = SAI_PORT_ATTR_HW_LANE_LIST;
846
+ attr.value .u32list .count = 4 ;
847
+ attr.value .u32list .list = lanes;
851
848
852
- attr.value .u32list .count = 4 ;
853
- attr.value .u32list .list = lanes;
849
+ if (vs_generic_get (SAI_OBJECT_TYPE_PORT, port_id, 1 , &attr) != SAI_STATUS_SUCCESS)
850
+ {
851
+ SWSS_LOG_WARN (" failed to get port %s lanes, using veth: %s" ,
852
+ sai_serialize_object_id (port_id).c_str (),
853
+ vethname.c_str ());
854
+ }
855
+ else
856
+ {
857
+ auto it = g_lane_to_ifname.find (lanes[0 ]);
854
858
855
- if (vs_generic_get (SAI_OBJECT_TYPE_PORT, port_id, 1 , &attr) != SAI_STATUS_SUCCESS )
859
+ if (it == g_lane_to_ifname. end () )
856
860
{
857
- SWSS_LOG_WARN (" failed to get port %s lanes, using veth: %s" ,
858
- sai_serialize_object_id (port_id).c_str (),
859
- vethname.c_str ());
861
+ SWSS_LOG_WARN (" failed to get ifname from lane number %u" , lanes[0 ]);
860
862
}
861
863
else
862
864
{
863
- auto it = g_lane_to_ifname. find (lanes[ 0 ] );
865
+ SWSS_LOG_NOTICE ( " using %s instead of %s " , it-> second . c_str (), vethname. c_str () );
864
866
865
- if (it == g_lane_to_ifname.end ())
866
- {
867
- SWSS_LOG_WARN (" failed to get ifname from lane number %u" , lanes[0 ]);
868
- }
869
- else
870
- {
871
- SWSS_LOG_NOTICE (" using %s instead of %s" , it->second .c_str (), vethname.c_str ());
872
-
873
- vethname = it->second ;
874
- }
867
+ vethname = it->second ;
875
868
}
876
869
}
877
870
871
+ return vethname;
872
+ }
873
+
874
+ bool hostif_create_tap_veth_forwarding (
875
+ _In_ const std::string &tapname,
876
+ _In_ int tapfd,
877
+ _In_ sai_object_id_t port_id)
878
+ {
879
+ SWSS_LOG_ENTER ();
880
+
881
+ // we assume here that veth devices were added by user before creating this
882
+ // host interface, vEthernetX will be used for packet transfer between ip
883
+ // namespaces or ethernet device name used in lane map if provided
884
+
885
+ std::string vethname = vs_get_veth_name (tapname, port_id);
886
+
878
887
int packet_socket = socket (AF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
879
888
880
889
if (packet_socket < 0 )
@@ -1081,7 +1090,7 @@ sai_status_t vs_create_hostif_int(
1081
1090
SWSS_LOG_ERROR (" forwarding rule on %s was not added" , name.c_str ());
1082
1091
}
1083
1092
1084
- std::string vname = SAI_VS_VETH_PREFIX + name;
1093
+ std::string vname = vs_get_veth_name ( name, obj_id) ;
1085
1094
1086
1095
SWSS_LOG_INFO (" mapping interface %s to port id %s" ,
1087
1096
vname.c_str (),
0 commit comments