static gboolean options_hash_match (NMSettingBond *s_bond, GHashTable *options1, GHashTable *options2) { GHashTableIter iter; const char *key, *value, *value2; g_hash_table_iter_init (&iter, options1); while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) { value2 = g_hash_table_lookup (options2, key); if (!value2) { if (nm_streq (key, "num_grat_arp")) value2 = g_hash_table_lookup (options2, "num_unsol_na"); else if (nm_streq (key, "num_unsol_na")) value2 = g_hash_table_lookup (options2, "num_grat_arp"); } if (value2) { if (nm_streq (value, value2)) continue; } else { if (nm_streq (value, nm_setting_bond_get_option_default (s_bond, key))) continue; } return FALSE; } return TRUE; }
static void update_connection (NMDevice *device, NMConnection *connection) { NMSettingBond *s_bond = nm_connection_get_setting_bond (connection); int ifindex = nm_device_get_ifindex (device); const char **options; if (!s_bond) { s_bond = (NMSettingBond *) nm_setting_bond_new (); nm_connection_add_setting (connection, (NMSetting *) s_bond); } /* Read bond options from sysfs and update the Bond setting to match */ options = nm_setting_bond_get_valid_options (s_bond); while (options && *options) { gs_free char *value = nm_platform_sysctl_master_get_option (nm_device_get_platform(device), ifindex, *options); const char *defvalue = nm_setting_bond_get_option_default (s_bond, *options); if (value && !ignore_if_zero (*options, value) && (g_strcmp0 (value, defvalue) != 0)) { /* Replace " " with "," for arp_ip_targets from the kernel */ if (strcmp (*options, "arp_ip_target") == 0) { char *p = value; while (p && *p) { if (*p == ' ') *p = ','; p++; } } nm_setting_bond_add_option (s_bond, *options, value); } options++; } }
static void set_simple_option (NMDevice *device, const char *attr, NMSettingBond *s_bond, const char *opt) { const char *value; value = nm_setting_bond_get_option_by_name (s_bond, opt); if (!value) value = nm_setting_bond_get_option_default (s_bond, opt); set_bond_attr (device, attr, value); }