diff options
author | Dan Williams <dcbw@redhat.com> | 2012-02-10 13:25:39 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-02-16 15:20:50 -0600 |
commit | c1a66936f343122e5991a25f07dd1d74a05ff68a (patch) | |
tree | 04960e16c94e22a07cf054f8fe830245c0b1e588 /src/nm-system.c | |
parent | add5f97b3874cbd2155d9da8aa88c38023c6a2af (diff) | |
download | NetworkManager-c1a66936f343122e5991a25f07dd1d74a05ff68a.tar.gz |
core: don't create virtual interfaces we already have
Make sure we don't already have an NMDevice for this interface
before creating it, and also when creating the interface, make
a new NMDevice for it immediately to prevent a race between
telling the kernel to create the interface via netlink, and when
udev later tells us about it. In between there we could be
triggered to try creating the interface again.
Diffstat (limited to 'src/nm-system.c')
-rw-r--r-- | src/nm-system.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/nm-system.c b/src/nm-system.c index 04fc954a98..8202d821e1 100644 --- a/src/nm-system.c +++ b/src/nm-system.c @@ -1281,34 +1281,30 @@ nm_system_apply_bonding_config (NMSettingBond *s_bond) /** * nm_system_add_bonding_master: - * @setting: bonding setting + * @iface: the interface name for the new bond master * * Adds a virtual bonding device if it does not exist yet. * * Returns: %TRUE on success, %FALSE on failure */ gboolean -nm_system_add_bonding_master (NMSettingBond *setting) +nm_system_add_bonding_master (const char *iface) { struct nl_sock *sock; - const char *name; int err; + g_return_val_if_fail (iface != NULL, FALSE); + sock = nm_netlink_get_default_handle (); - name = nm_setting_bond_get_interface_name (setting); - g_assert (name); /* Existing bonding devices with matching name will be reused */ - err = rtnl_link_bond_add (sock, name, NULL); + err = rtnl_link_bond_add (sock, iface, NULL); if (err < 0) { nm_log_err (LOGD_DEVICE, "(%s): error %d returned from " "rtnl_link_bond_add(): %s", - name, err, nl_geterror (err)); + iface, err, nl_geterror (err)); return FALSE; } - - nm_system_apply_bonding_config (setting); - return TRUE; } |