@@ -901,7 +901,9 @@ void send_port_up_notification(
901
901
902
902
int ifup (
903
903
_In_ const char *dev,
904
- _In_ sai_object_id_t port_id)
904
+ _In_ sai_object_id_t port_id,
905
+ _In_ bool up,
906
+ _In_ bool explicitNotification)
905
907
{
906
908
SWSS_LOG_ENTER ();
907
909
@@ -931,7 +933,7 @@ int ifup(
931
933
return err;
932
934
}
933
935
934
- if (ifr.ifr_flags & IFF_UP)
936
+ if (up && explicitNotification && ( ifr.ifr_flags & IFF_UP) )
935
937
{
936
938
close (s);
937
939
@@ -946,7 +948,14 @@ int ifup(
946
948
return 0 ;
947
949
}
948
950
949
- ifr.ifr_flags |= IFF_UP;
951
+ if (up)
952
+ {
953
+ ifr.ifr_flags |= IFF_UP;
954
+ }
955
+ else
956
+ {
957
+ ifr.ifr_flags &= ~IFF_UP;
958
+ }
950
959
951
960
err = ioctl (s, SIOCSIFFLAGS, &ifr);
952
961
@@ -1094,8 +1103,11 @@ void hostif_info_t::veth2tap_fun()
1094
1103
1095
1104
if (size < 0 )
1096
1105
{
1097
- SWSS_LOG_ERROR (" failed to read from socket fd %d, errno(%d): %s" ,
1098
- packet_socket, errno, strerror (errno));
1106
+ if (errno != ENETDOWN)
1107
+ {
1108
+ SWSS_LOG_ERROR (" failed to read from socket fd %d, errno(%d): %s" ,
1109
+ packet_socket, errno, strerror (errno));
1110
+ }
1099
1111
1100
1112
continue ;
1101
1113
}
@@ -1215,8 +1227,11 @@ void hostif_info_t::tap2veth_fun()
1215
1227
1216
1228
if (write (packet_socket, buffer, (int )size) < 0 )
1217
1229
{
1218
- SWSS_LOG_ERROR (" failed to write to socket fd %d, errno(%d): %s" ,
1219
- packet_socket, errno, strerror (errno));
1230
+ if (errno != ENETDOWN)
1231
+ {
1232
+ SWSS_LOG_ERROR (" failed to write to socket fd %d, errno(%d): %s" ,
1233
+ packet_socket, errno, strerror (errno));
1234
+ }
1220
1235
1221
1236
continue ;
1222
1237
}
@@ -1319,7 +1334,7 @@ bool hostif_create_tap_veth_forwarding(
1319
1334
1320
1335
SWSS_LOG_INFO (" interface index = %d %s\n " , sock_address.sll_ifindex , vethname.c_str ());
1321
1336
1322
- if (ifup (vethname.c_str (), port_id))
1337
+ if (ifup (vethname.c_str (), port_id, true , true ))
1323
1338
{
1324
1339
SWSS_LOG_ERROR (" ifup failed on %s" , vethname.c_str ());
1325
1340
@@ -1681,6 +1696,37 @@ sai_status_t vs_create_hostif(
1681
1696
&vs_create_hostif_int);
1682
1697
}
1683
1698
1699
+ sai_status_t vs_set_admin_state (
1700
+ _In_ sai_object_id_t portId,
1701
+ _In_ bool up)
1702
+ {
1703
+ SWSS_LOG_ENTER ();
1704
+
1705
+ // find corresponding host if interface and bring it down !
1706
+ for (auto & kvp: hostif_info_map)
1707
+ {
1708
+ auto tapname = kvp.first ;
1709
+
1710
+ if (kvp.second ->portid == portId)
1711
+ {
1712
+ std::string vethname = vs_get_veth_name (tapname, portId);
1713
+
1714
+ if (ifup (vethname.c_str (), portId, up, false ))
1715
+ {
1716
+ SWSS_LOG_ERROR (" if admin %s failed on %s failed: %s" , (up ? " UP" : " DOWN" ), vethname.c_str (), strerror (errno));
1717
+
1718
+ return SAI_STATUS_FAILURE;
1719
+ }
1720
+
1721
+ SWSS_LOG_NOTICE (" if admin %s success on %s" , (up ? " UP" : " DOWN" ), vethname.c_str ());
1722
+
1723
+ break ;
1724
+ }
1725
+ }
1726
+
1727
+ return SAI_STATUS_SUCCESS;
1728
+ }
1729
+
1684
1730
// TODO set must also be supported when we change operational status up/down
1685
1731
// and probably also generate notification then
1686
1732
0 commit comments