Skip to content
Snippets Groups Projects
Commit 69bf74a7 authored by Dmitry Fleytman's avatar Dmitry Fleytman Committed by Pekka Enberg
Browse files

DHCP: Support MTU option


This patch introduces support for MTU option as described in
RFC2132, chapter 5.1. Interface MTU Option

Amazon EC2 networking uses this option in some cases and it gives
throughput improvement of about 250% on big instances with 10G networking.

Netperf results for hi1.4xlarge instances, TCP_MAERTS test, OSv runs netserver:

Send buffer size     Throughput w/ patch (Mbps)     Throughput w/o patch (Mbps)     Improvement (%)

32                   4912.29                        1386.28                         254
64                   4832.01                        1385.99                         249
128                  4835.09                        1401.46                         245
256                  4746.41                        1382.28                         243
512                  4849.04                        1375.23                         253
1024                 4631.8                         1356.69                         241
2048                 4859.59                        1371.92                         254
4096                 4864.99                        1383.67                         252
8192                 4627.07                        1364.05                         239
16384                4868.73                        1366.48                         256
32768                4822.69                        1366.63                         253
65536                4837.67                        1353.87                         257

Signed-off-by: default avatarDmitry Fleytman <dmitry@daynix.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 88a2c035
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,29 @@ void for_each_if(std::function<void (std::string)> func)
IFNET_RUNLOCK_NOSLEEP();
}
int if_set_mtu(std::string if_name, u16 mtu)
{
if (if_name.empty()) {
return (EINVAL);
}
struct bsd_ifreq ifreq = {0};
/* IF Name */
strncpy(ifreq.ifr_name, if_name.c_str(), IFNAMSIZ);
auto ifp = ifunit_ref(if_name.c_str());
if (!ifp) {
return (ENOENT);
}
/* MTU */
ifreq.ifr_mtu = mtu;
auto error = in_control(NULL, SIOCSIFMTU, (caddr_t)&ifreq, ifp, NULL);
if_rele(ifp);
return (error);
}
int start_if(std::string if_name, std::string ip_addr, std::string mask_addr)
{
int error, success;
......
......@@ -8,6 +8,7 @@
#ifndef __NETWORKING_H__
#define __NETWORKING_H__
#include <osv/types.h>
#include <sys/cdefs.h>
#include <string>
#include <functional>
......@@ -15,6 +16,7 @@
namespace osv {
void for_each_if(std::function<void (std::string)> func);
/* Interface Functions */
int if_set_mtu(std::string if_name, u16 mtu);
int start_if(std::string if_name, std::string ip_addr,
std::string mask_addr);
int ifup(std::string if_name);
......
......@@ -506,15 +506,20 @@ namespace dhcp {
// TODO: check that the IP address is not responding with ARP
// RFC2131 section 3.1.5
dhcp_i("Configuring %s: ip %s subnet mask %s gateway %s",
dhcp_i("Configuring %s: ip %s subnet mask %s gateway %s MTU %d",
_ifp->if_xname,
dm.get_your_ip().to_string().c_str(),
dm.get_subnet_mask().to_string().c_str(),
dm.get_router_ip().to_string().c_str());
dm.get_router_ip().to_string().c_str(),
dm.get_interface_mtu());
osv::start_if(_ifp->if_xname,
dm.get_your_ip().to_string().c_str(),
dm.get_subnet_mask().to_string().c_str());
if (dm.get_interface_mtu() != 0) {
osv::if_set_mtu(_ifp->if_xname, dm.get_interface_mtu());
}
osv_route_add_network("0.0.0.0",
"0.0.0.0",
dm.get_router_ip().to_string().c_str());
......
......@@ -139,6 +139,7 @@ namespace dhcp {
std::vector<boost::asio::ip::address> get_dns_ips() { return _dns_ips; }
boost::asio::ip::address_v4 get_subnet_mask() { return _subnet_mask; }
boost::asio::ip::address_v4 get_broadcast_ip() { return _broadcast_ip; }
u16 get_interface_mtu() { return _mtu; }
int get_lease_time_sec() { return _lease_time_sec; }
int get_renewal_time_sec() { return _renewal_time_sec; }
int get_rebind_time_sec() { return _rebind_time_sec; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment