2008-08-14 Dan Williams <dcbw@redhat.com>

* src/NetworkManagerSystem.c
		- (nm_system_device_is_up_with_iface): ensure ifreq is cleared before using
		- (nm_system_device_set_up_down_with_iface): cleanups; only return
			success if the operation really was successful



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3959 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-08-14 16:52:06 +00:00
parent cb79727fa2
commit 91497f2949

View File

@@ -428,10 +428,10 @@ gboolean nm_system_device_set_up_down (NMDevice *dev, gboolean up)
gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up) gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up)
{ {
struct rtnl_link *request = NULL, *old = NULL;
struct nl_handle *nlh;
gboolean success = FALSE; gboolean success = FALSE;
guint32 idx; guint32 idx;
struct rtnl_link * request = NULL;
struct rtnl_link * old = NULL;
g_return_val_if_fail (iface != NULL, FALSE); g_return_val_if_fail (iface != NULL, FALSE);
@@ -446,16 +446,13 @@ gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up
idx = nm_netlink_iface_to_index (iface); idx = nm_netlink_iface_to_index (iface);
old = nm_netlink_index_to_rtnl_link (idx); old = nm_netlink_index_to_rtnl_link (idx);
if (old) { if (old) {
struct nl_handle *nlh;
nlh = nm_netlink_get_default_handle (); nlh = nm_netlink_get_default_handle ();
if (nlh) if (nlh)
rtnl_link_change (nlh, old, request, 0); success = (rtnl_link_change (nlh, old, request, 0) == 0) ? TRUE : FALSE;
} }
rtnl_link_put (old); rtnl_link_put (old);
rtnl_link_put (request); rtnl_link_put (request);
success = TRUE;
out: out:
return success; return success;
@@ -483,6 +480,7 @@ nm_system_device_is_up_with_iface (const char *iface)
} }
/* Get device's flags */ /* Get device's flags */
memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, iface, IFNAMSIZ); strncpy (ifr.ifr_name, iface, IFNAMSIZ);
if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) { if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) {
if (errno != ENODEV) { if (errno != ENODEV) {