Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #723 from mtomaschewski/device-up-mtu
ifconfig: set MTU even if device is up (bsc#1059292)
  • Loading branch information
mtomaschewski committed Dec 15, 2017
2 parents 165ddb1 + 01d4838 commit c66af8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 2 additions & 13 deletions src/dbus-objects/interface.c
Expand Up @@ -925,20 +925,9 @@ ni_objectmodel_netif_link_up(ni_dbus_object_t *object, const ni_dbus_method_t *m
}
}

/*
* MTU change on device-up interfaces quite often causes either
* error -16 (busy) or sets all upper interfaces LOWERLAYERDOWN.
*/
if (ni_netdev_device_is_up(dev)) {
ni_debug_objectmodel("Skipping MTU change on %s: device is up",
dev->name);
req->mtu = 0;
}
if (req->mtu != dev->link.mtu)
ni_system_mtu_change(nc, dev, req->mtu);

if (req->mtu != dev->link.mtu &&
ni_system_mtu_change(nc, dev, req->mtu) < 0) {
ni_info("Unable to set %s MTU to %u", dev->name, req->mtu);
}
req->mtu = 0;
}

Expand Down
10 changes: 8 additions & 2 deletions src/ifconfig.c
Expand Up @@ -4039,6 +4039,7 @@ __ni_rtnl_link_change_mtu(ni_netdev_t *dev, unsigned int mtu)
{
struct ifinfomsg ifi;
struct nl_msg *msg;
int err;

if (!dev || !mtu)
return -1;
Expand All @@ -4047,15 +4048,20 @@ __ni_rtnl_link_change_mtu(ni_netdev_t *dev, unsigned int mtu)
ifi.ifi_family = AF_UNSPEC;
ifi.ifi_index = dev->link.ifindex;

msg = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST);
if (!(msg = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST)))
goto nla_put_failure;

if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
goto nla_put_failure;

if (__ni_rtnl_link_put_mtu(msg, mtu) < 0)
goto nla_put_failure;

if (ni_nl_talk(msg, NULL))
if ((err = ni_nl_talk(msg, NULL))) {
ni_error("failed to modify interface %s mtu to %u: %s",
dev->name, mtu, nl_geterror(err));
goto failed;
}

ni_debug_ifconfig("successfully modified interface %s mtu to %u",
dev->name, mtu);
Expand Down

0 comments on commit c66af8a

Please sign in to comment.