Skip to content

Commit 0974a43

Browse files
authored
Set MTU value on created tap device for virtual switch (#436)
1 parent e2f50e8 commit 0974a43

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

vslib/src/sai_vs_hostintf.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,33 @@ int promisc(const char *dev)
794794
return err;
795795
}
796796

797+
int vs_set_dev_mtu(
798+
_In_ const char*name,
799+
_In_ int mtu)
800+
{
801+
SWSS_LOG_ENTER();
802+
803+
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
804+
805+
struct ifreq ifr;
806+
807+
strncpy(ifr.ifr_name, name, IFNAMSIZ);
808+
809+
ifr.ifr_mtu = mtu;
810+
811+
int err = ioctl(sock, SIOCSIFMTU, &ifr);
812+
813+
if (err == 0)
814+
{
815+
SWSS_LOG_INFO("success set mtu on %s to %d", name, mtu);
816+
return 0;
817+
}
818+
819+
SWSS_LOG_WARN("failed to set mtu on %s to %d", name, mtu);
820+
return err;
821+
}
822+
823+
797824
#define ETH_FRAME_BUFFER_SIZE (0x4000)
798825
#define CONTROL_MESSAGE_BUFFER_SIZE (0x1000)
799826
#define IEEE_8021Q_ETHER_TYPE (0x8100)
@@ -1190,6 +1217,8 @@ sai_status_t vs_create_hostif_tap_interface(
11901217
return SAI_STATUS_FAILURE;
11911218
}
11921219

1220+
vs_set_dev_mtu(name.c_str(), ETH_FRAME_BUFFER_SIZE);
1221+
11931222
if (!hostif_create_tap_veth_forwarding(name, tapfd, obj_id))
11941223
{
11951224
SWSS_LOG_ERROR("forwarding rule on %s was not added", name.c_str());

0 commit comments

Comments
 (0)