Skip to content

Commit

Permalink
Set MTU value on created tap device for virtual switch (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Mar 25, 2019
1 parent e2f50e8 commit 0974a43
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions vslib/src/sai_vs_hostintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,33 @@ int promisc(const char *dev)
return err;
}

int vs_set_dev_mtu(
_In_ const char*name,
_In_ int mtu)
{
SWSS_LOG_ENTER();

int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);

struct ifreq ifr;

strncpy(ifr.ifr_name, name, IFNAMSIZ);

ifr.ifr_mtu = mtu;

int err = ioctl(sock, SIOCSIFMTU, &ifr);

if (err == 0)
{
SWSS_LOG_INFO("success set mtu on %s to %d", name, mtu);
return 0;
}

SWSS_LOG_WARN("failed to set mtu on %s to %d", name, mtu);
return err;
}


#define ETH_FRAME_BUFFER_SIZE (0x4000)
#define CONTROL_MESSAGE_BUFFER_SIZE (0x1000)
#define IEEE_8021Q_ETHER_TYPE (0x8100)
Expand Down Expand Up @@ -1190,6 +1217,8 @@ sai_status_t vs_create_hostif_tap_interface(
return SAI_STATUS_FAILURE;
}

vs_set_dev_mtu(name.c_str(), ETH_FRAME_BUFFER_SIZE);

if (!hostif_create_tap_veth_forwarding(name, tapfd, obj_id))
{
SWSS_LOG_ERROR("forwarding rule on %s was not added", name.c_str());
Expand Down

0 comments on commit 0974a43

Please sign in to comment.