Skip to content

Commit

Permalink
Support MTU greater than 1500 bytes. Handle SIOCSIFMTU in the virtio-…
Browse files Browse the repository at this point in the history
…net driver rather than delegating to ether_ioctl.
  • Loading branch information
jmkho-spirent committed Aug 30, 2019
1 parent 7cbf0db commit 6886bc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/dhcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,10 @@ namespace dhcp {
dm.get_interface_mtu() != 0 ? dm.get_interface_mtu() : ETHERMTU);

if (dm.get_interface_mtu() != 0) {
osv::if_set_mtu(_ifp->if_xname, dm.get_interface_mtu());
int error = osv::if_set_mtu(_ifp->if_xname, dm.get_interface_mtu());
if (error != 0) {
dhcp_i("Unable to set MTU on %s: %s", _ifp->if_xname, strerror(error));
}
}
osv::start_if(_ifp->if_xname,
dm.get_your_ip().to_string().c_str(),
Expand Down
12 changes: 12 additions & 0 deletions drivers/virtio-net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <osv/ioctl.h>
#include <bsd/sys/net/ethernet.h>
#include <bsd/sys/net/if_types.h>
#include <bsd/sys/net/if.h>
#include <bsd/sys/sys/param.h>

#include <bsd/sys/net/ethernet.h>
Expand Down Expand Up @@ -94,6 +95,17 @@ static int if_ioctl(struct ifnet* ifp, u_long command, caddr_t data)
case SIOCDELMULTI:
net_d("SIOCDELMULTI");
break;
case SIOCSIFMTU:
{
net_d("SIOCSIFMTU");
struct bsd_ifreq *ifr = (struct bsd_ifreq *)data;
if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU_JUMBO) {
error = EINVAL;
} else {
ifp->if_mtu = ifr->ifr_mtu;
}
}
break;
default:
net_d("redirecting to ether_ioctl()...");
error = ether_ioctl(ifp, command, data);
Expand Down

0 comments on commit 6886bc8

Please sign in to comment.