summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-07-16 19:06:01 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-07-16 19:06:01 -1000
commit230d0f47484e9299077de5649ad81567e5ff4b16 (patch)
tree59f637a70b794fcb64c99dddf47fdd89bc9368b3 /isys
parentd5dba5848d5475d71c3d4945d8cbe1b6d8c8c9fb (diff)
downloadanaconda-230d0f47484e9299077de5649ad81567e5ff4b16.tar.gz
anaconda-230d0f47484e9299077de5649ad81567e5ff4b16.tar.xz
anaconda-230d0f47484e9299077de5649ad81567e5ff4b16.zip
Set interface MTU if user specified mtu= param (#435874)
If the user passed mtu=X as a boot parameter, set the interface MTU to that value before configuring the network.
Diffstat (limited to 'isys')
-rw-r--r--isys/iface.c49
-rw-r--r--isys/iface.h1
2 files changed, 50 insertions, 0 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);