Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ config_syncd_nephos()
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
}

config_syncd_vs()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
}

config_syncd()
{
check_warm_boot
Expand All @@ -154,6 +159,8 @@ config_syncd()
config_syncd_barefoot
elif [ "$SONIC_ASIC_TYPE" == "nephos" ]; then
config_syncd_nephos
elif [ "$SONIC_ASIC_TYPE" == "vs" ]; then
config_syncd_vs
else
echo "Unknown ASIC type $SONIC_ASIC_TYPE"
exit 1
Expand Down
76 changes: 76 additions & 0 deletions vslib/src/sai_vs_hostintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,13 @@ int ifup(const char *dev)
return err;
}

if (ifr.ifr_flags & IFF_UP)
{
close(s);

return 0;
}

ifr.ifr_flags |= IFF_UP;

err = ioctl(s, SIOCSIFFLAGS, &ifr);
Expand All @@ -695,6 +702,57 @@ int ifup(const char *dev)
return err;
}

int promisc(const char *dev)
{
SWSS_LOG_ENTER();

int s = socket(AF_INET, SOCK_DGRAM, 0);

if (s < 0)
{
SWSS_LOG_ERROR("failed to open socket: %d", s);

return -1;
}

struct ifreq ifr;

memset(&ifr, 0, sizeof ifr);

strncpy(ifr.ifr_name, dev , IFNAMSIZ);

int err = ioctl(s, SIOCGIFFLAGS, &ifr);

if (err < 0)
{
SWSS_LOG_ERROR("ioctl SIOCGIFFLAGS on socket %d %s failed, err %d", s, dev, err);

close(s);

return err;
}

if (ifr.ifr_flags & IFF_PROMISC)
{
close(s);

return 0;
}

ifr.ifr_flags |= IFF_PROMISC;

err = ioctl(s, SIOCSIFFLAGS, &ifr);

if (err < 0)
{
SWSS_LOG_ERROR("ioctl SIOCSIFFLAGS on socket %d %s failed, err %d", s, dev, err);
}

close(s);

return err;
}

void veth2tap_fun(std::shared_ptr<hostif_info_t> info)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -812,6 +870,24 @@ bool hostif_create_tap_veth_forwarding(

SWSS_LOG_INFO("interface index = %d %s\n", sock_address.sll_ifindex, vethname.c_str());

if (ifup(vethname.c_str()))
{
SWSS_LOG_ERROR("ifup failed on %s", vethname.c_str());

close(packet_socket);

return false;
}

if (promisc(vethname.c_str()))
{
SWSS_LOG_ERROR("promisc failed on %s", vethname.c_str());

close(packet_socket);

return false;
}

if (bind(packet_socket, (struct sockaddr*) &sock_address, sizeof(sock_address)) < 0)
{
SWSS_LOG_ERROR("bind failed on %s", vethname.c_str());
Expand Down