summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--isys/iface.c49
-rw-r--r--isys/iface.h1
-rw-r--r--loader2/net.c42
3 files changed, 84 insertions, 8 deletions
diff --git a/isys/iface.c b/isys/iface.c
index 51f923c06..6f274bc76 100644
--- a/isys/iface.c
+++ b/isys/iface.c
@@ -231,3 +231,52 @@ mac2str_error2:
return buf;
}
+
+/*
+ * Set the MTU on the specified device.
+ */
+int iface_set_interface_mtu(char *ifname, int mtu) {
+ int ret = 0;
+ struct nl_handle *handle = NULL;
+ struct nl_cache *cache = NULL;
+ struct rtnl_link *link = NULL;
+ struct rtnl_link *request = NULL;
+
+ if (ifname == NULL) {
+ perror("Missing ifname in iface_set_interface_mtu()");
+ return -1;
+ }
+
+ if (mtu <= 0) {
+ perror("MTU cannot be <= 0 in iface_set_interface_mtu()");
+ return -2;
+ }
+
+ if ((cache = iface_get_link_cache(&handle)) == NULL) {
+ perror("iface_get_link_cache() failure in iface_set_interface_mtu()");
+ return -3;
+ }
+
+ if ((link = rtnl_link_get_by_name(cache, ifname)) == NULL) {
+ perror("rtnl_link_get_by_name() failure in iface_set_interface_mtu()");
+ ret = -4;
+ goto ifacemtu_error1;
+ }
+
+ request = rtnl_link_alloc();
+ rtnl_link_set_mtu(request, mtu);
+
+ if (rtnl_link_change(handle, link, request, 0)) {
+ perror("rtnl_link_change() failure in iface_set_interface_mtu()");
+ ret = -5;
+ goto ifacemtu_error2;
+ }
+
+ifacemtu_error2:
+ rtnl_link_put(link);
+ifacemtu_error1:
+ nl_close(handle);
+ nl_handle_destroy(handle);
+
+ return ret;
+}
diff --git a/isys/iface.h b/isys/iface.h
index cc1f81330..4b0e50f2d 100644
--- a/isys/iface.h
+++ b/isys/iface.h
@@ -26,3 +26,4 @@
struct nl_cache *iface_get_link_cache(struct nl_handle **handle);
char *iface_mac2str(char *ifname);
char *iface_ip2str(char *ifname);
+int iface_set_interface_mtu(char *ifname, int mtu);
diff --git a/loader2/net.c b/loader2/net.c
index 3477c4204..f26a748ec 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -1418,13 +1418,15 @@ char *doDhcp(struct networkDeviceConfig *dev) {
int loglevel;
DHCP_Preference pref = 0;
struct utsname kv;
+ int mturet;
i = &dev->dev;
- if (dev->dhcpTimeout < 0)
- timeout = 45;
- else
- timeout = dev->dhcpTimeout;
+ if (dev->dhcpTimeout < 0) {
+ timeout = 45;
+ } else {
+ timeout = dev->dhcpTimeout;
+ }
if (dev->vendor_class != NULL) {
class = dev->vendor_class;
@@ -1443,10 +1445,21 @@ char *doDhcp(struct networkDeviceConfig *dev) {
}
}
- if (getLogLevel() == DEBUGLVL)
+ if (getLogLevel() == DEBUGLVL) {
loglevel = LOG_DEBUG;
- else
+ } else {
loglevel = LOG_INFO;
+ }
+
+ /* set interface MTU */
+ if (i->set & PUMP_INTFINFO_HAS_MTU) {
+ mturet = iface_set_interface_mtu((char *) i->device, i->mtu);
+
+ if (mturet) {
+ logMessage(ERROR, "unable to set %s mtu to %d (code %d)",
+ (char *) i->device, i->mtu, mturet);
+ }
+ }
/* dhcp preferences are in /usr/include/libdhcp/dhcp_nic.h */
@@ -1484,9 +1497,22 @@ char *doDhcp(struct networkDeviceConfig *dev) {
int configureNetwork(struct networkDeviceConfig * dev) {
char *rc;
+ int mturet;
+ struct pumpNetIntf *i = &dev->dev;
setupWireless(dev);
- rc = pumpSetupInterface(&dev->dev);
+
+ /* set interface MTU */
+ if (i->set & PUMP_INTFINFO_HAS_MTU) {
+ mturet = iface_set_interface_mtu((char *) i->device, i->mtu);
+
+ if (mturet) {
+ logMessage(ERROR, "unable to set %s mtu to %d (code %d)",
+ (char *) i->device, i->mtu, mturet);
+ }
+ }
+
+ rc = pumpSetupInterface(i);
if (rc != NULL) {
logMessage(INFO, "result of pumpSetupInterface is %s", rc);
return 1;
@@ -1495,7 +1521,7 @@ int configureNetwork(struct networkDeviceConfig * dev) {
/* we need to wait for a link after setting up the interface as some
* switches decide to reconfigure themselves after that (#115825)
*/
- waitForLink((char *)&dev->dev.device);
+ waitForLink((char *) i->device);
return 0;
}