Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifconfig: set MTU even if device is up (bsc#1059292) #723

Merged
merged 1 commit into from
Dec 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/dbus-objects/interface.c
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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