diff options
| author | Michael Biebl <biebl@debian.org> | 2024-08-09 18:57:15 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-08-09 18:57:15 +0200 |
| commit | e96d74409128c6a977e31f24fad9b267d2feb9a1 (patch) | |
| tree | 12dad71135c6c291de457568cb973208ea8a0024 /src/libnm-platform | |
| parent | 45a364c60a9d6d34e614c4f1f507c69336ad1e69 (diff) | |
New upstream version 1.48.8 upstream/1.48.8
Diffstat (limited to 'src/libnm-platform')
| -rw-r--r-- | src/libnm-platform/nm-linux-platform.c | 218 | ||||
| -rw-r--r-- | src/libnm-platform/nm-platform.c | 139 | ||||
| -rw-r--r-- | src/libnm-platform/nm-platform.h | 48 | ||||
| -rw-r--r-- | src/libnm-platform/nmp-base.c | 4 | ||||
| -rw-r--r-- | src/libnm-platform/nmp-object.c | 112 | ||||
| -rw-r--r-- | src/libnm-platform/nmp-object.h | 24 |
6 files changed, 279 insertions, 266 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 5b595a9b..dd4be614 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -108,6 +108,9 @@ typedef enum _nm_packed { /*****************************************************************************/ +#define IFLA_INFO_PORT_KIND IFLA_INFO_SLAVE_KIND +#define IFLA_INFO_PORT_DATA IFLA_INFO_SLAVE_DATA + #ifndef IFLA_PROMISCUITY #define IFLA_PROMISCUITY 30 #endif @@ -161,6 +164,10 @@ typedef enum _nm_packed { #define __IFLA_TUN_MAX 10 #define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1) +#define IFLA_CONTROLLER IFLA_MASTER + +#define BRIDGE_FLAGS_CONTROLLER BRIDGE_FLAGS_MASTER + G_STATIC_ASSERT(RTA_MAX == (__RTA_MAX - 1)); #define RTA_PREF 20 #undef RTA_MAX @@ -180,7 +187,10 @@ G_STATIC_ASSERT(RTA_MAX == (__RTA_MAX - 1)); /*****************************************************************************/ -#define IFLA_BOND_SLAVE_PRIO 9 +#define IFLA_BOND_ACTIVE_PORT IFLA_BOND_ACTIVE_SLAVE +#define IFLA_BOND_PORT_PRIO IFLA_BOND_SLAVE_PRIO +#define IFLA_BOND_ALL_PORTS_ACTIVE IFLA_BOND_ALL_SLAVES_ACTIVE +#define IFLA_BOND_PACKETS_PER_PORT IFLA_BOND_PACKETS_PER_SLAVE #define IFLA_BOND_PEER_NOTIF_DELAY 28 #define IFLA_BOND_AD_LACP_ACTIVE 29 @@ -427,7 +437,7 @@ typedef enum _nm_packed { DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_RTNL = 1 << 12, DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_GENL = 1 << 13, DELAYED_ACTION_TYPE_REFRESH_LINK = 1 << 14, - DELAYED_ACTION_TYPE_MASTER_CONNECTED = 1 << 15, + DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED = 1 << 15, __DELAYED_ACTION_TYPE_MAX, @@ -554,7 +564,7 @@ typedef struct { * by type. */ int refresh_all_in_progress[_REFRESH_ALL_TYPE_NUM]; - GPtrArray *list_master_connected; + GPtrArray *list_controller_connected; GPtrArray *list_refresh_link; union { struct { @@ -1618,7 +1628,7 @@ _parse_lnk_bond(const char *kind, struct nlattr *info_data) { static const struct nla_policy policy[] = { [IFLA_BOND_MODE] = {.type = NLA_U8}, - [IFLA_BOND_ACTIVE_SLAVE] = {.type = NLA_U32}, + [IFLA_BOND_ACTIVE_PORT] = {.type = NLA_U32}, [IFLA_BOND_MIIMON] = {.type = NLA_U32}, [IFLA_BOND_UPDELAY] = {.type = NLA_U32}, [IFLA_BOND_DOWNDELAY] = {.type = NLA_U32}, @@ -1633,10 +1643,10 @@ _parse_lnk_bond(const char *kind, struct nlattr *info_data) [IFLA_BOND_XMIT_HASH_POLICY] = {.type = NLA_U8}, [IFLA_BOND_RESEND_IGMP] = {.type = NLA_U32}, [IFLA_BOND_NUM_PEER_NOTIF] = {.type = NLA_U8}, - [IFLA_BOND_ALL_SLAVES_ACTIVE] = {.type = NLA_U8}, + [IFLA_BOND_ALL_PORTS_ACTIVE] = {.type = NLA_U8}, [IFLA_BOND_MIN_LINKS] = {.type = NLA_U32}, [IFLA_BOND_LP_INTERVAL] = {.type = NLA_U32}, - [IFLA_BOND_PACKETS_PER_SLAVE] = {.type = NLA_U32}, + [IFLA_BOND_PACKETS_PER_PORT] = {.type = NLA_U32}, [IFLA_BOND_AD_LACP_RATE] = {.type = NLA_U8}, [IFLA_BOND_AD_SELECT] = {.type = NLA_U8}, [IFLA_BOND_AD_ACTOR_SYS_PRIO] = {.type = NLA_U16}, @@ -1732,16 +1742,16 @@ _parse_lnk_bond(const char *kind, struct nlattr *info_data) } if (tb[IFLA_BOND_NUM_PEER_NOTIF]) props->num_grat_arp = nla_get_u8(tb[IFLA_BOND_NUM_PEER_NOTIF]); - if (tb[IFLA_BOND_ALL_SLAVES_ACTIVE]) - props->all_ports_active = nla_get_u8(tb[IFLA_BOND_ALL_SLAVES_ACTIVE]); + if (tb[IFLA_BOND_ALL_PORTS_ACTIVE]) + props->all_ports_active = nla_get_u8(tb[IFLA_BOND_ALL_PORTS_ACTIVE]); if (tb[IFLA_BOND_MISSED_MAX]) props->arp_missed_max = nla_get_u8(tb[IFLA_BOND_MISSED_MAX]); if (tb[IFLA_BOND_MIN_LINKS]) props->min_links = nla_get_u32(tb[IFLA_BOND_MIN_LINKS]); if (tb[IFLA_BOND_LP_INTERVAL]) props->lp_interval = nla_get_u32(tb[IFLA_BOND_LP_INTERVAL]); - if (tb[IFLA_BOND_PACKETS_PER_SLAVE]) - props->packets_per_port = nla_get_u32(tb[IFLA_BOND_PACKETS_PER_SLAVE]); + if (tb[IFLA_BOND_PACKETS_PER_PORT]) + props->packets_per_port = nla_get_u32(tb[IFLA_BOND_PACKETS_PER_PORT]); if (tb[IFLA_BOND_AD_LACP_RATE]) props->lacp_rate = nla_get_u8(tb[IFLA_BOND_AD_LACP_RATE]); if (tb[IFLA_BOND_AD_LACP_ACTIVE]) { @@ -3372,7 +3382,7 @@ _new_from_nl_link(NMPlatform *platform, [IFLA_GRO_MAX_SIZE] = {.type = NLA_U32}, [IFLA_LINK] = {.type = NLA_U32}, [IFLA_WEIGHT] = {.type = NLA_U32}, - [IFLA_MASTER] = {.type = NLA_U32}, + [IFLA_CONTROLLER] = {.type = NLA_U32}, [IFLA_OPERSTATE] = {.type = NLA_U8}, [IFLA_LINKMODE] = {.type = NLA_U8}, [IFLA_LINKINFO] = {.type = NLA_NESTED}, @@ -3454,11 +3464,11 @@ _new_from_nl_link(NMPlatform *platform, if (tb[IFLA_LINKINFO]) { static const struct nla_policy policy_link_info[] = { - [IFLA_INFO_KIND] = {.type = NLA_STRING}, - [IFLA_INFO_DATA] = {.type = NLA_NESTED}, - [IFLA_INFO_XSTATS] = {.type = NLA_NESTED}, - [IFLA_INFO_SLAVE_KIND] = {.type = NLA_STRING}, - [IFLA_INFO_SLAVE_DATA] = {.type = NLA_NESTED}, + [IFLA_INFO_KIND] = {.type = NLA_STRING}, + [IFLA_INFO_DATA] = {.type = NLA_NESTED}, + [IFLA_INFO_XSTATS] = {.type = NLA_NESTED}, + [IFLA_INFO_PORT_KIND] = {.type = NLA_STRING}, + [IFLA_INFO_PORT_DATA] = {.type = NLA_NESTED}, }; struct nlattr *li[G_N_ELEMENTS(policy_link_info)]; @@ -3470,8 +3480,8 @@ _new_from_nl_link(NMPlatform *platform, nl_info_data = li[IFLA_INFO_DATA]; - if (li[IFLA_INFO_SLAVE_KIND]) { - const char *s = nla_get_string(li[IFLA_INFO_SLAVE_KIND]); + if (li[IFLA_INFO_PORT_KIND]) { + const char *s = nla_get_string(li[IFLA_INFO_PORT_KIND]); if (nm_streq(s, "bond")) obj->link.port_kind = NM_PORT_KIND_BOND; @@ -3479,10 +3489,10 @@ _new_from_nl_link(NMPlatform *platform, obj->link.port_kind = NM_PORT_KIND_BRIDGE; } - if (li[IFLA_INFO_SLAVE_DATA]) { + if (li[IFLA_INFO_PORT_DATA]) { static const struct nla_policy policy_bond_port[] = { [IFLA_BOND_SLAVE_QUEUE_ID] = {.type = NLA_U16}, - [IFLA_BOND_SLAVE_PRIO] = {.type = NLA_S32}, + [IFLA_BOND_PORT_PRIO] = {.type = NLA_S32}, }; struct nlattr *bp[G_N_ELEMENTS(policy_bond_port)]; static const struct nla_policy policy_bridge_port[] = { @@ -3494,30 +3504,30 @@ _new_from_nl_link(NMPlatform *platform, switch (obj->link.port_kind) { case NM_PORT_KIND_BOND: - if (nla_parse_nested_arr(bp, li[IFLA_INFO_SLAVE_DATA], policy_bond_port) < 0) + if (nla_parse_nested_arr(bp, li[IFLA_INFO_PORT_DATA], policy_bond_port) < 0) return NULL; if (bp[IFLA_BOND_SLAVE_QUEUE_ID]) obj->link.port_data.bond.queue_id = nla_get_u16(bp[IFLA_BOND_SLAVE_QUEUE_ID]); - if (bp[IFLA_BOND_SLAVE_PRIO]) { - obj->link.port_data.bond.prio = nla_get_s32(bp[IFLA_BOND_SLAVE_PRIO]); + if (bp[IFLA_BOND_PORT_PRIO]) { + obj->link.port_data.bond.prio = nla_get_s32(bp[IFLA_BOND_PORT_PRIO]); obj->link.port_data.bond.prio_has = TRUE; if (!_nm_platform_kernel_support_detected( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_SLAVE_PRIO)) { - /* support for IFLA_BOND_SLAVE_PRIO was added in 0a2ff7cc8ad48a86939a91bd3457f38e59e741a1, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_PORT_PRIO)) { + /* support for IFLA_BOND_PORT_PRIO was added in 0a2ff7cc8ad48a86939a91bd3457f38e59e741a1, * kernel 6.0, 2 October 2022. * * We can only detect support if the attribute is present. A missing attribute * is not conclusive. */ _nm_platform_kernel_support_init( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_SLAVE_PRIO, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_PORT_PRIO, 1); } } break; case NM_PORT_KIND_BRIDGE: - if (nla_parse_nested_arr(brp, li[IFLA_INFO_SLAVE_DATA], policy_bridge_port) < 0) + if (nla_parse_nested_arr(brp, li[IFLA_INFO_PORT_DATA], policy_bridge_port) < 0) return NULL; if (brp[IFLA_BRPORT_COST]) @@ -3572,8 +3582,8 @@ _new_from_nl_link(NMPlatform *platform, &link_cached, &obj->link.kind); - if (tb[IFLA_MASTER]) - obj->link.master = nla_get_u32(tb[IFLA_MASTER]); + if (tb[IFLA_CONTROLLER]) + obj->link.controller = nla_get_u32(tb[IFLA_CONTROLLER]); if (tb[IFLA_LINK]) { if (!tb[IFLA_LINK_NETNSID]) @@ -4937,7 +4947,7 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo if (props->min_links) NLA_PUT_U32(msg, IFLA_BOND_MIN_LINKS, props->min_links); if (props->packets_per_port) - NLA_PUT_U32(msg, IFLA_BOND_PACKETS_PER_SLAVE, props->packets_per_port); + NLA_PUT_U32(msg, IFLA_BOND_PACKETS_PER_PORT, props->packets_per_port); if (props->peer_notif_delay_has) NLA_PUT_U32(msg, IFLA_BOND_PEER_NOTIF_DELAY, props->peer_notif_delay); if (props->primary > 0) @@ -4960,7 +4970,7 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo if (props->arp_missed_max) NLA_PUT_U8(msg, IFLA_BOND_MISSED_MAX, props->arp_missed_max); - NLA_PUT_U8(msg, IFLA_BOND_ALL_SLAVES_ACTIVE, props->all_ports_active); + NLA_PUT_U8(msg, IFLA_BOND_ALL_PORTS_ACTIVE, props->all_ports_active); if (props->fail_over_mac) NLA_PUT_U8(msg, IFLA_BOND_FAIL_OVER_MAC, props->fail_over_mac); @@ -6769,7 +6779,7 @@ static NM_UTILS_LOOKUP_STR_DEFINE( NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_REFRESH_ALL_GENL_FAMILIES, "refresh-all-genl-families"), NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_REFRESH_LINK, "refresh-link"), - NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_MASTER_CONNECTED, "master-connected"), + NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED, "controller-connected"), NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_READ_RTNL, "read-rtnl"), NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_READ_GENL, "read-genl"), NM_UTILS_LOOKUP_STR_ITEM(DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_RTNL, "wait-for-response-rtnl"), @@ -6797,8 +6807,8 @@ delayed_action_to_string_full(DelayedActionType action_type, nm_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type)); switch (action_type) { - case DELAYED_ACTION_TYPE_MASTER_CONNECTED: - nm_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data)); + case DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED: + nm_strbuf_append(&buf, &buf_size, " (controller-ifindex %d)", GPOINTER_TO_INT(user_data)); break; case DELAYED_ACTION_TYPE_REFRESH_LINK: nm_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data)); @@ -6979,16 +6989,16 @@ delayed_action_wait_for_nl_response_complete_all(NMPlatform *platfor /*****************************************************************************/ static void -delayed_action_handle_MASTER_CONNECTED(NMPlatform *platform, int master_ifindex) +delayed_action_handle_CONTROLLER_CONNECTED(NMPlatform *platform, int controller_ifindex) { nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; NMPCacheOpsType cache_op; - cache_op = nmp_cache_update_link_master_connected(nm_platform_get_cache(platform), - master_ifindex, - &obj_old, - &obj_new); + cache_op = nmp_cache_update_link_controller_connected(nm_platform_get_cache(platform), + controller_ifindex, + &obj_old, + &obj_new); if (cache_op == NMP_CACHE_OPS_UNCHANGED) return; cache_on_change(platform, cache_op, obj_old, obj_new); @@ -7030,27 +7040,27 @@ delayed_action_handle_one(NMPlatform *platform) if (priv->delayed_action.flags == DELAYED_ACTION_TYPE_NONE) return FALSE; - /* First process DELAYED_ACTION_TYPE_MASTER_CONNECTED actions. + /* First process DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED actions. * This type of action is entirely cache-internal and is here to resolve a * cache inconsistency. It should be fixed right away. */ - if (NM_FLAGS_HAS(priv->delayed_action.flags, DELAYED_ACTION_TYPE_MASTER_CONNECTED)) { - nm_assert(priv->delayed_action.list_master_connected->len > 0); + if (NM_FLAGS_HAS(priv->delayed_action.flags, DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED)) { + nm_assert(priv->delayed_action.list_controller_connected->len > 0); - user_data = priv->delayed_action.list_master_connected->pdata[0]; - g_ptr_array_remove_index_fast(priv->delayed_action.list_master_connected, 0); - if (priv->delayed_action.list_master_connected->len == 0) - priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_MASTER_CONNECTED; + user_data = priv->delayed_action.list_controller_connected->pdata[0]; + g_ptr_array_remove_index_fast(priv->delayed_action.list_controller_connected, 0); + if (priv->delayed_action.list_controller_connected->len == 0) + priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED; nm_assert(nm_utils_ptrarray_find_first( - (gconstpointer *) priv->delayed_action.list_master_connected->pdata, - priv->delayed_action.list_master_connected->len, + (gconstpointer *) priv->delayed_action.list_controller_connected->pdata, + priv->delayed_action.list_controller_connected->len, user_data) < 0); - _LOGt_delayed_action(DELAYED_ACTION_TYPE_MASTER_CONNECTED, user_data, "handle"); - delayed_action_handle_MASTER_CONNECTED(platform, GPOINTER_TO_INT(user_data)); + _LOGt_delayed_action(DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED, user_data, "handle"); + delayed_action_handle_CONTROLLER_CONNECTED(platform, GPOINTER_TO_INT(user_data)); return TRUE; } - nm_assert(priv->delayed_action.list_master_connected->len == 0); + nm_assert(priv->delayed_action.list_controller_connected->len == 0); /* Next we prefer read-genl/read-rtnl, because the buffer size is limited and we want to process events * from netlink early. */ @@ -7166,13 +7176,13 @@ delayed_action_schedule(NMPlatform *platform, DelayedActionType action_type, gpo < 0) g_ptr_array_add(priv->delayed_action.list_refresh_link, user_data); break; - case DELAYED_ACTION_TYPE_MASTER_CONNECTED: + case DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED: if (nm_utils_ptrarray_find_first( - (gconstpointer *) priv->delayed_action.list_master_connected->pdata, - priv->delayed_action.list_master_connected->len, + (gconstpointer *) priv->delayed_action.list_controller_connected->pdata, + priv->delayed_action.list_controller_connected->len, user_data) < 0) - g_ptr_array_add(priv->delayed_action.list_master_connected, user_data); + g_ptr_array_add(priv->delayed_action.list_controller_connected, user_data); break; case DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_RTNL: g_array_append_vals(priv->delayed_action.list_wait_for_response_rtnl, user_data, 1); @@ -7186,7 +7196,7 @@ delayed_action_schedule(NMPlatform *platform, DelayedActionType action_type, gpo nm_assert(!user_data); nm_assert(!NM_FLAGS_ANY(action_type, DELAYED_ACTION_TYPE_REFRESH_LINK - | DELAYED_ACTION_TYPE_MASTER_CONNECTED + | DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED | DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_RTNL | DELAYED_ACTION_TYPE_WAIT_FOR_RESPONSE_GENL)); break; @@ -7353,30 +7363,30 @@ cache_on_change(NMPlatform *platform, switch (klass->obj_type) { case NMP_OBJECT_TYPE_LINK: { - /* check whether changing a slave link can cause a master link (bridge or bond) to go up/down */ + /* check whether changing a port link can cause a controller link (bridge or bond) to go up/down */ if (obj_old && nmp_cache_link_connected_needs_toggle_by_ifindex(cache, - obj_old->link.master, + obj_old->link.controller, obj_new, obj_old)) delayed_action_schedule(platform, - DELAYED_ACTION_TYPE_MASTER_CONNECTED, - GINT_TO_POINTER(obj_old->link.master)); - if (obj_new && (!obj_old || obj_old->link.master != obj_new->link.master) + DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED, + GINT_TO_POINTER(obj_old->link.controller)); + if (obj_new && (!obj_old || obj_old->link.controller != obj_new->link.controller) && nmp_cache_link_connected_needs_toggle_by_ifindex(cache, - obj_new->link.master, + obj_new->link.controller, obj_new, obj_old)) delayed_action_schedule(platform, - DELAYED_ACTION_TYPE_MASTER_CONNECTED, - GINT_TO_POINTER(obj_new->link.master)); + DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED, + GINT_TO_POINTER(obj_new->link.controller)); } { - /* check whether we are about to change a master link that needs toggling connected state. */ + /* check whether we are about to change a controller link that needs toggling connected state. */ if (obj_new /* <-- nonsensical, make coverity happy */ && nmp_cache_link_connected_needs_toggle(cache, obj_new, obj_new, obj_old)) delayed_action_schedule(platform, - DELAYED_ACTION_TYPE_MASTER_CONNECTED, + DELAYED_ACTION_TYPE_CONTROLLER_CONNECTED, GINT_TO_POINTER(obj_new->link.ifindex)); } { @@ -7515,16 +7525,16 @@ cache_on_change(NMPlatform *platform, } } { - /* on enslave/release, we also refresh the master. */ + /* on attach/release, we also refresh the controller. */ int ifindex1 = 0, ifindex2 = 0; - gboolean changed_master, changed_connected; + gboolean changed_controller, changed_connected; - changed_master = - (obj_new && obj_new->_link.netlink.is_in_netlink && obj_new->link.master > 0 - ? obj_new->link.master + changed_controller = + (obj_new && obj_new->_link.netlink.is_in_netlink && obj_new->link.controller > 0 + ? obj_new->link.controller : 0) - != (obj_old && obj_old->_link.netlink.is_in_netlink && obj_old->link.master > 0 - ? obj_old->link.master + != (obj_old && obj_old->_link.netlink.is_in_netlink && obj_old->link.controller > 0 + ? obj_old->link.controller : 0); changed_connected = (obj_new && obj_new->_link.netlink.is_in_netlink ? NM_FLAGS_HAS(obj_new->link.n_ifi_flags, IFF_LOWER_UP) @@ -7533,15 +7543,15 @@ cache_on_change(NMPlatform *platform, ? NM_FLAGS_HAS(obj_old->link.n_ifi_flags, IFF_LOWER_UP) : 2); - if (changed_master || changed_connected) { - ifindex1 = - (obj_old && obj_old->_link.netlink.is_in_netlink && obj_old->link.master > 0) - ? obj_old->link.master - : 0; - ifindex2 = - (obj_new && obj_new->_link.netlink.is_in_netlink && obj_new->link.master > 0) - ? obj_new->link.master - : 0; + if (changed_controller || changed_connected) { + ifindex1 = (obj_old && obj_old->_link.netlink.is_in_netlink + && obj_old->link.controller > 0) + ? obj_old->link.controller + : 0; + ifindex2 = (obj_new && obj_new->_link.netlink.is_in_netlink + && obj_new->link.controller > 0) + ? obj_new->link.controller + : 0; if (ifindex1 > 0) delayed_action_schedule(platform, @@ -8564,13 +8574,13 @@ link_add(NMPlatform *platform, if (type == NM_LINK_TYPE_BOND) { /* When the kernel loads the bond module, either via explicit modprobe - * or automatically in response to creating a bond master, it will also + * or automatically in response to creating a bond controller, it will also * create a 'bond0' interface. Since the bond we're about to create may * or may not be named 'bond0' prevent potential confusion about a bond * that the user didn't want by telling the bonding module not to create * bond0 automatically. */ - if (!g_file_test("/sys/class/net/bonding_masters", G_FILE_TEST_EXISTS)) + if (!g_file_test("/sys/class/net/bonding_controllers", G_FILE_TEST_EXISTS)) (void) nmp_utils_modprobe(NULL, TRUE, "bonding", "max_bonds=0", NULL); } @@ -8646,15 +8656,15 @@ link_change(NMPlatform *platform, goto nla_put_failure; nm_assert(nm_streq0("bond", nm_link_type_to_rtnl_type_string(NM_LINK_TYPE_BOND))); - NLA_PUT_STRING(nlmsg, IFLA_INFO_SLAVE_KIND, "bond"); + NLA_PUT_STRING(nlmsg, IFLA_INFO_PORT_KIND, "bond"); - if (!(nl_port_data = nla_nest_start(nlmsg, IFLA_INFO_SLAVE_DATA))) + if (!(nl_port_data = nla_nest_start(nlmsg, IFLA_INFO_PORT_DATA))) goto nla_put_failure; NLA_PUT_U16(nlmsg, IFLA_BOND_SLAVE_QUEUE_ID, port_data->bond.queue_id); if (port_data->bond.prio_has) - NLA_PUT_S32(nlmsg, IFLA_BOND_SLAVE_PRIO, port_data->bond.prio); + NLA_PUT_S32(nlmsg, IFLA_BOND_PORT_PRIO, port_data->bond.prio); nla_nest_end(nlmsg, nl_port_data); nla_nest_end(nlmsg, nl_info); @@ -8667,9 +8677,9 @@ link_change(NMPlatform *platform, goto nla_put_failure; nm_assert(nm_streq0("bridge", nm_link_type_to_rtnl_type_string(NM_LINK_TYPE_BRIDGE))); - NLA_PUT_STRING(nlmsg, IFLA_INFO_SLAVE_KIND, "bridge"); + NLA_PUT_STRING(nlmsg, IFLA_INFO_PORT_KIND, "bridge"); - if (!(nl_port_data = nla_nest_start(nlmsg, IFLA_INFO_SLAVE_DATA))) + if (!(nl_port_data = nla_nest_start(nlmsg, IFLA_INFO_PORT_DATA))) goto nla_put_failure; NLA_PUT_U32(nlmsg, IFLA_BRPORT_COST, port_data->bridge.path_cost); @@ -9394,7 +9404,7 @@ nla_put_failure: static gboolean link_set_bridge_vlans(NMPlatform *platform, int ifindex, - gboolean on_master, + gboolean on_controller, const NMPlatformBridgeVlan *const *vlans) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; @@ -9416,7 +9426,9 @@ link_set_bridge_vlans(NMPlatform *platform, if (!(list = nla_nest_start(nlmsg, IFLA_AF_SPEC))) goto nla_put_failure; - NLA_PUT_U16(nlmsg, IFLA_BRIDGE_FLAGS, on_master ? BRIDGE_FLAGS_MASTER : BRIDGE_FLAGS_SELF); + NLA_PUT_U16(nlmsg, + IFLA_BRIDGE_FLAGS, + on_controller ? BRIDGE_FLAGS_CONTROLLER : BRIDGE_FLAGS_SELF); if (vlans) { /* Add VLANs */ @@ -9721,16 +9733,16 @@ link_vlan_change(NMPlatform *platform, } static gboolean -link_enslave(NMPlatform *platform, int master, int slave) +link_attach_port(NMPlatform *platform, int controller, int port) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - int ifindex = slave; + int ifindex = port; nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL); if (!nlmsg) return FALSE; - NLA_PUT_U32(nlmsg, IFLA_MASTER, master); + NLA_PUT_U32(nlmsg, IFLA_CONTROLLER, controller); return (do_change_link(platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0); nla_put_failure: @@ -9738,9 +9750,9 @@ nla_put_failure: } static gboolean -link_release(NMPlatform *platform, int master, int slave) +link_release_port(NMPlatform *platform, int controller, int port) { - return link_enslave(platform, 0, slave); + return link_attach_port(platform, 0, port); } /*****************************************************************************/ @@ -9970,7 +9982,7 @@ link_can_assume(NMPlatform *platform, int ifindex) if (!NM_FLAGS_HAS(link->link.n_ifi_flags, IFF_UP)) return FALSE; - if (link->link.master > 0) + if (link->link.controller > 0) return TRUE; nmp_lookup_init_object_by_ifindex(&lookup, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex); @@ -11505,8 +11517,8 @@ nm_linux_platform_init(NMLinuxPlatform *self) c_list_init(&priv->sysctl_clear_cache_lst); c_list_init(&priv->sysctl_list); - priv->delayed_action.list_master_connected = g_ptr_array_new(); - priv->delayed_action.list_refresh_link = g_ptr_array_new(); + priv->delayed_action.list_controller_connected = g_ptr_array_new(); + priv->delayed_action.list_refresh_link = g_ptr_array_new(); priv->delayed_action.list_wait_for_response_rtnl = g_array_new(FALSE, TRUE, sizeof(DelayedActionWaitForNlResponseData)); priv->delayed_action.list_wait_for_response_genl = @@ -11719,7 +11731,7 @@ dispose(GObject *object) WAIT_FOR_NL_RESPONSE_RESULT_FAILED_DISPOSING); priv->delayed_action.flags = DELAYED_ACTION_TYPE_NONE; - g_ptr_array_set_size(priv->delayed_action.list_master_connected, 0); + g_ptr_array_set_size(priv->delayed_action.list_controller_connected, 0); g_ptr_array_set_size(priv->delayed_action.list_refresh_link, 0); G_OBJECT_CLASS(nm_linux_platform_parent_class)->dispose(object); @@ -11730,7 +11742,7 @@ finalize(GObject *object) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(object); - g_ptr_array_unref(priv->delayed_action.list_master_connected); + g_ptr_array_unref(priv->delayed_action.list_controller_connected); g_ptr_array_unref(priv->delayed_action.list_refresh_link); g_array_unref(priv->delayed_action.list_wait_for_response_rtnl); g_array_unref(priv->delayed_action.list_wait_for_response_genl); @@ -11808,8 +11820,8 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass) platform_class->link_supports_vlans = link_supports_vlans; platform_class->link_supports_sriov = link_supports_sriov; - platform_class->link_enslave = link_enslave; - platform_class->link_release = link_release; + platform_class->link_attach_port = link_attach_port; + platform_class->link_release_port = link_release_port; platform_class->link_can_assume = link_can_assume; diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index cd5a54bb..f82de7f9 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -1056,7 +1056,7 @@ nm_platform_link_get_all(NMPlatform *self) return NULL; /* first sort the links by their name. Below we will sort - * further by moving children/slaves to the end. */ + * further by moving children/ports to the end. */ g_ptr_array_sort(links, _link_get_all_presort); unseen = g_hash_table_new(nm_direct_hash, NULL); @@ -1074,10 +1074,10 @@ nm_platform_link_get_all(NMPlatform *self) if (!item->ifindex) continue; - if (item->master != 0) { - g_warn_if_fail(item->master > 0); - g_warn_if_fail(item->master != item->ifindex); - g_warn_if_fail(g_hash_table_contains(unseen, GINT_TO_POINTER(item->master))); + if (item->controller != 0) { + g_warn_if_fail(item->controller > 0); + g_warn_if_fail(item->controller != item->ifindex); + g_warn_if_fail(g_hash_table_contains(unseen, GINT_TO_POINTER(item->controller))); } if (item->parent != 0) { if (item->parent != NM_PLATFORM_LINK_OTHER_NETNS) { @@ -1089,7 +1089,7 @@ nm_platform_link_get_all(NMPlatform *self) } #endif - /* Re-order the links list such that children/slaves come after all ancestors */ + /* Re-order the links list such that children/ports come after all ancestors */ nm_assert(g_hash_table_size(unseen) == links->len); nresult = links->len; result = g_ptr_array_new_full(nresult, (GDestroyNotify) nmp_object_unref); @@ -1106,7 +1106,8 @@ nm_platform_link_get_all(NMPlatform *self) g_assert(g_hash_table_contains(unseen, GINT_TO_POINTER(item->ifindex))); - if (item->master > 0 && g_hash_table_contains(unseen, GINT_TO_POINTER(item->master))) + if (item->controller > 0 + && g_hash_table_contains(unseen, GINT_TO_POINTER(item->controller))) goto skip; if (item->parent > 0 && g_hash_table_contains(unseen, GINT_TO_POINTER(item->parent))) goto skip; @@ -1712,7 +1713,7 @@ nm_platform_link_is_software(NMPlatform *self, int ifindex) } /** - * nm_platform_link_supports_slaves: + * nm_platform_link_supports_ports: * @self: platform instance * @ifindex: Interface index. * @@ -1720,9 +1721,9 @@ nm_platform_link_is_software(NMPlatform *self, int ifindex) * other interfaces. */ gboolean -nm_platform_link_supports_slaves(NMPlatform *self, int ifindex) +nm_platform_link_supports_ports(NMPlatform *self, int ifindex) { - return nm_link_type_supports_slaves(nm_platform_link_get_type(self, ifindex)); + return nm_link_type_supports_ports(nm_platform_link_get_type(self, ifindex)); } /** @@ -2071,7 +2072,7 @@ nm_platform_link_set_sriov_vfs(NMPlatform *self, int ifindex, const NMPlatformVF gboolean nm_platform_link_set_bridge_vlans(NMPlatform *self, int ifindex, - gboolean on_master, + gboolean on_controller, const NMPlatformBridgeVlan *const *vlans) { guint i; @@ -2082,7 +2083,7 @@ nm_platform_link_set_bridge_vlans(NMPlatform *self, if (_LOGD_ENABLED()) { _LOG3D("link: %s bridge VLANs on %s", vlans ? "setting" : "clearing", - on_master ? "master" : "self"); + on_controller ? "controller" : "self"); if (vlans) { for (i = 0; vlans[i]; i++) { char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE]; @@ -2094,7 +2095,7 @@ nm_platform_link_set_bridge_vlans(NMPlatform *self, } } - return klass->link_set_bridge_vlans(self, ifindex, on_master, vlans); + return klass->link_set_bridge_vlans(self, ifindex, on_controller, vlans); } gboolean @@ -2376,65 +2377,65 @@ nm_platform_link_get_driver_info(NMPlatform *self, } /** - * nm_platform_link_enslave: + * nm_platform_link_attach_port: * @self: platform instance - * @master: Interface index of the master - * @ifindex: Interface index of the slave + * @controller: Interface index of the controller + * @ifindex: Interface index of the port * - * Enslave @ifindex to @master. + * Enport @ifindex to @controller. */ gboolean -nm_platform_link_enslave(NMPlatform *self, int master, int ifindex) +nm_platform_link_attach_port(NMPlatform *self, int controller, int ifindex) { _CHECK_SELF(self, klass, FALSE); - g_return_val_if_fail(master > 0, FALSE); + g_return_val_if_fail(controller > 0, FALSE); g_return_val_if_fail(ifindex > 0, FALSE); - _LOG3D("link: enslaving to master '%s'", nm_platform_link_get_name(self, master)); - return klass->link_enslave(self, master, ifindex); + _LOG3D("link: enslaving to controller '%s'", nm_platform_link_get_name(self, controller)); + return klass->link_attach_port(self, controller, ifindex); } /** - * nm_platform_link_release: + * nm_platform_link_release_port: * @self: platform instance - * @master: Interface index of the master - * @ifindex: Interface index of the slave + * @controller: Interface index of the controller + * @ifindex: Interface index of the port * - * Release @slave from @master. + * Release @port from @controller. */ gboolean -nm_platform_link_release(NMPlatform *self, int master, int ifindex) +nm_platform_link_release_port(NMPlatform *self, int controller, int ifindex) { _CHECK_SELF(self, klass, FALSE); - g_return_val_if_fail(master > 0, FALSE); + g_return_val_if_fail(controller > 0, FALSE); g_return_val_if_fail(ifindex > 0, FALSE); - if (nm_platform_link_get_master(self, ifindex) != master) + if (nm_platform_link_get_controller(self, ifindex) != controller) return FALSE; - _LOG3D("link: releasing %d from master '%s' (%d)", + _LOG3D("link: releasing %d from controller '%s' (%d)", ifindex, - nm_platform_link_get_name(self, master), - master); - return klass->link_release(self, master, ifindex); + nm_platform_link_get_name(self, controller), + controller); + return klass->link_release_port(self, controller, ifindex); } /** - * nm_platform_link_get_master: + * nm_platform_link_get_controller: * @self: platform instance - * @slave: Interface index of the slave. + * @port: Interface index of the port. * - * Returns: Interface index of the slave's master. + * Returns: Interface index of the port's controller. */ int -nm_platform_link_get_master(NMPlatform *self, int slave) +nm_platform_link_get_controller(NMPlatform *self, int port) { const NMPlatformLink *pllink; - pllink = nm_platform_link_get(self, slave); - return pllink ? pllink->master : 0; + pllink = nm_platform_link_get(self, port); + return pllink ? pllink->controller : 0; } /*****************************************************************************/ @@ -2852,9 +2853,9 @@ link_get_option(NMPlatform *self, int ifindex, const char *category, const char } static const char * -master_category(NMPlatform *self, int master) +controller_category(NMPlatform *self, int controller) { - switch (nm_platform_link_get_type(self, master)) { + switch (nm_platform_link_get_type(self, controller)) { case NM_LINK_TYPE_BRIDGE: return "bridge"; case NM_LINK_TYPE_BOND: @@ -2865,28 +2866,28 @@ master_category(NMPlatform *self, int master) } static const char * -slave_category(NMPlatform *self, int slave) +port_category(NMPlatform *self, int port) { - int master = nm_platform_link_get_master(self, slave); + int controller = nm_platform_link_get_controller(self, port); - if (master <= 0) + if (controller <= 0) return NULL; - switch (nm_platform_link_get_type(self, master)) { + switch (nm_platform_link_get_type(self, controller)) { case NM_LINK_TYPE_BRIDGE: return "brport"; case NM_LINK_TYPE_BOND: - return "bonding_slave"; + return "bonding_port"; default: return NULL; } } gboolean -nm_platform_sysctl_master_set_option(NMPlatform *self, - int ifindex, - const char *option, - const char *value) +nm_platform_sysctl_controller_set_option(NMPlatform *self, + int ifindex, + const char *option, + const char *value) { _CHECK_SELF(self, klass, FALSE); @@ -2894,25 +2895,25 @@ nm_platform_sysctl_master_set_option(NMPlatform *self, g_return_val_if_fail(option, FALSE); g_return_val_if_fail(value, FALSE); - return link_set_option(self, ifindex, master_category(self, ifindex), option, value); + return link_set_option(self, ifindex, controller_category(self, ifindex), option, value); } char * -nm_platform_sysctl_master_get_option(NMPlatform *self, int ifindex, const char *option) +nm_platform_sysctl_controller_get_option(NMPlatform *self, int ifindex, const char *option) { _CHECK_SELF(self, klass, NULL); g_return_val_if_fail(ifindex > 0, FALSE); g_return_val_if_fail(option, FALSE); - return link_get_option(self, ifindex, master_category(self, ifindex), option); + return link_get_option(self, ifindex, controller_category(self, ifindex), option); } gboolean -nm_platform_sysctl_slave_set_option(NMPlatform *self, - int ifindex, - const char *option, - const char *value) +nm_platform_sysctl_port_set_option(NMPlatform *self, + int ifindex, + const char *option, + const char *value) { _CHECK_SELF(self, klass, FALSE); @@ -2920,18 +2921,18 @@ nm_platform_sysctl_slave_set_option(NMPlatform *self, g_return_val_if_fail(option, FALSE); g_return_val_if_fail(value, FALSE); - return link_set_option(self, ifindex, slave_category(self, ifindex), option, value); + return link_set_option(self, ifindex, port_category(self, ifindex), option, value); } char * -nm_platform_sysctl_slave_get_option(NMPlatform *self, int ifindex, const char *option) +nm_platform_sysctl_port_get_option(NMPlatform *self, int ifindex, const char *option) { _CHECK_SELF(self, klass, NULL); g_return_val_if_fail(ifindex > 0, FALSE); g_return_val_if_fail(option, FALSE); - return link_get_option(self, ifindex, slave_category(self, ifindex), option); + return link_get_option(self, ifindex, port_category(self, ifindex), option); } /*****************************************************************************/ @@ -4866,8 +4867,8 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, return NULL; lnk_vrf = nm_platform_link_get_lnk_vrf(self, ifindex, &pllink); - if (!lnk_vrf && pllink && pllink->master > 0) - lnk_vrf = nm_platform_link_get_lnk_vrf(self, pllink->master, NULL); + if (!lnk_vrf && pllink && pllink->controller > 0) + lnk_vrf = nm_platform_link_get_lnk_vrf(self, pllink->controller, NULL); local_table = lnk_vrf ? lnk_vrf->table : RT_TABLE_LOCAL; c_list_for_each (iter, &head_entry->lst_entries_head) { @@ -6049,7 +6050,7 @@ nm_platform_vlan_qos_mapping_to_string(const char *name, const char * nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) { - char master[20]; + char controller[20]; char parent[20]; char str_flags[1 + NM_PLATFORM_LINK_FLAGS2STR_MAX_LEN + 1]; char str_highlighted_flags[50]; @@ -6084,10 +6085,10 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) } else str_flags[0] = '\0'; - if (link->master) - g_snprintf(master, sizeof(master), " master %d", link->master); + if (link->controller) + g_snprintf(controller, sizeof(controller), " controller %d", link->controller); else - master[0] = 0; + controller[0] = 0; if (link->parent > 0) g_snprintf(parent, sizeof(parent), "@%d", link->parent); @@ -6115,7 +6116,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) "%s" /* parent */ " <%s%s>" /* flags */ " mtu %d" - "%s" /* master */ + "%s" /* controller */ " arp %u" /* arptype */ " %s" /* link->type */ "%s%s" /* kind */ @@ -6139,7 +6140,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) str_highlighted_flags, str_flags, link->mtu, - master, + controller, link->arptype, str_link_type ?: "???", link->kind ? (g_strcmp0(str_link_type, link->kind) ? "/" : "*") : "?", @@ -8032,7 +8033,7 @@ nm_platform_link_hash_update(const NMPlatformLink *obj, NMHashState *h) { nm_hash_update_vals(h, obj->ifindex, - obj->master, + obj->controller, obj->parent, obj->n_ifi_flags, obj->mtu, @@ -8095,7 +8096,7 @@ nm_platform_link_cmp(const NMPlatformLink *a, const NMPlatformLink *b) NM_CMP_FIELD(a, b, ifindex); NM_CMP_FIELD(a, b, type); NM_CMP_FIELD_STR(a, b, name); - NM_CMP_FIELD(a, b, master); + NM_CMP_FIELD(a, b, controller); NM_CMP_FIELD(a, b, parent); NM_CMP_FIELD(a, b, n_ifi_flags); NM_CMP_FIELD_UNSAFE(a, b, connected); diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index f6a6ba08..b05b1297 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -198,7 +198,7 @@ struct _NMPlatformLink { /* NMPlatform initializes this field with a static string. */ const char *driver; - int master; + int controller; /* rtnl_link_get_link(), IFLA_LINK. * If IFLA_LINK_NETNSID indicates that the parent is in another namespace, @@ -241,11 +241,11 @@ struct _NMPlatformLink { /* an interface can only hold IFLA_INFO_SLAVE_DATA for one link type */ NMPlatformLinkPortData port_data; - /* IFLA_INFO_SLAVE_KIND */ + /* IFLA_INFO_PORT_KIND */ NMPortKind port_kind; - /* @connected is mostly identical to (@n_ifi_flags & IFF_UP). Except for bridge/bond masters, - * where we coerce the link as disconnect if it has no slaves. */ + /* @connected is mostly identical to (@n_ifi_flags & IFF_UP). Except for bridge/bond controllers, + * where we coerce the link as disconnect if it has no ports. */ bool connected : 1; bool initialized : 1; @@ -1052,7 +1052,7 @@ typedef enum { * were added at the same time. */ NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_IP_PROTO, - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_SLAVE_PRIO, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_PORT_PRIO, _NM_PLATFORM_KERNEL_SUPPORT_NUM, } NMPlatformKernelSupportType; @@ -1187,7 +1187,7 @@ typedef struct { gboolean (*link_set_sriov_vfs)(NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs); gboolean (*link_set_bridge_vlans)(NMPlatform *self, int ifindex, - gboolean on_master, + gboolean on_controller, const NMPlatformBridgeVlan *const *vlans); gboolean (*link_set_bridge_info)(NMPlatform *self, int ifindex, @@ -1206,8 +1206,8 @@ typedef struct { gboolean (*link_supports_vlans)(NMPlatform *self, int ifindex); gboolean (*link_supports_sriov)(NMPlatform *self, int ifindex); - gboolean (*link_enslave)(NMPlatform *self, int master, int slave); - gboolean (*link_release)(NMPlatform *self, int master, int slave); + gboolean (*link_attach_port)(NMPlatform *self, int controller, int port); + gboolean (*link_release_port)(NMPlatform *self, int controller, int port); gboolean (*link_can_assume)(NMPlatform *self, int ifindex); @@ -1973,12 +1973,12 @@ int nm_platform_link_get_inet6_addr_gen_mode(NMPlatform *self, int ifind gconstpointer nm_platform_link_get_address(NMPlatform *self, int ifindex, size_t *length); -int nm_platform_link_get_master(NMPlatform *self, int slave); +int nm_platform_link_get_controller(NMPlatform *self, int port); gboolean nm_platform_link_can_assume(NMPlatform *self, int ifindex); NMOptionBool nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex); -gboolean nm_platform_link_supports_slaves(NMPlatform *self, int ifindex); +gboolean nm_platform_link_supports_ports(NMPlatform *self, int ifindex); const char *nm_platform_link_get_type_name(NMPlatform *self, int ifindex); gboolean nm_platform_link_refresh(NMPlatform *self, int ifindex); @@ -2051,7 +2051,7 @@ gboolean nm_platform_link_set_sriov_vfs(NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs); gboolean nm_platform_link_set_bridge_vlans(NMPlatform *self, int ifindex, - gboolean on_master, + gboolean on_controller, const NMPlatformBridgeVlan *const *vlans); gboolean nm_platform_link_set_bridge_info(NMPlatform *self, int ifindex, @@ -2070,19 +2070,19 @@ gboolean nm_platform_link_supports_carrier_detect(NMPlatform *self, int ifindex) gboolean nm_platform_link_supports_vlans(NMPlatform *self, int ifindex); gboolean nm_platform_link_supports_sriov(NMPlatform *self, int ifindex); -gboolean nm_platform_link_enslave(NMPlatform *self, int master, int slave); -gboolean nm_platform_link_release(NMPlatform *self, int master, int slave); +gboolean nm_platform_link_attach_port(NMPlatform *self, int controller, int port); +gboolean nm_platform_link_release_port(NMPlatform *self, int controller, int port); -gboolean nm_platform_sysctl_master_set_option(NMPlatform *self, - int ifindex, - const char *option, - const char *value); -char *nm_platform_sysctl_master_get_option(NMPlatform *self, int ifindex, const char *option); -gboolean nm_platform_sysctl_slave_set_option(NMPlatform *self, - int ifindex, - const char *option, - const char *value); -char *nm_platform_sysctl_slave_get_option(NMPlatform *self, int ifindex, const char *option); +gboolean nm_platform_sysctl_controller_set_option(NMPlatform *self, + int ifindex, + const char *option, + const char *value); +char *nm_platform_sysctl_controller_get_option(NMPlatform *self, int ifindex, const char *option); +gboolean nm_platform_sysctl_port_set_option(NMPlatform *self, + int ifindex, + const char *option, + const char *value); +char *nm_platform_sysctl_port_get_option(NMPlatform *self, int ifindex, const char *option); const NMPObject *nm_platform_link_get_lnk(NMPlatform *self, int ifindex, @@ -2569,7 +2569,7 @@ void nm_platform_mptcp_addr_hash_update(const NMPlatformMptcpAddr *obj, NMHashSt guint nm_platform_mptcp_addr_index_addr_cmp(gconstpointer data); gboolean nm_platform_mptcp_addr_index_addr_equal(gconstpointer data_a, gconstpointer data_b); -#define NM_PLATFORM_LINK_FLAGS2STR_MAX_LEN ((gsize) 162) +#define NM_PLATFORM_LINK_FLAGS2STR_MAX_LEN ((gsize) 165) gboolean nm_platform_ethtool_set_wake_on_lan(NMPlatform *self, int ifindex, diff --git a/src/libnm-platform/nmp-base.c b/src/libnm-platform/nmp-base.c index c23190b3..9d13b78a 100644 --- a/src/libnm-platform/nmp-base.c +++ b/src/libnm-platform/nmp-base.c @@ -22,8 +22,8 @@ NM_UTILS_FLAGS2STR_DEFINE(nm_platform_link_flags2str, NM_UTILS_FLAGS2STR(IFF_NOARP, "noarp"), NM_UTILS_FLAGS2STR(IFF_ALLMULTI, "allmulti"), NM_UTILS_FLAGS2STR(IFF_PROMISC, "promisc"), - NM_UTILS_FLAGS2STR(IFF_MASTER, "master"), - NM_UTILS_FLAGS2STR(IFF_SLAVE, "slave"), + NM_UTILS_FLAGS2STR(IFF_MASTER, "controller"), + NM_UTILS_FLAGS2STR(IFF_SLAVE, "port"), NM_UTILS_FLAGS2STR(IFF_DEBUG, "debug"), NM_UTILS_FLAGS2STR(IFF_DYNAMIC, "dynamic"), NM_UTILS_FLAGS2STR(IFF_AUTOMEDIA, "automedia"), diff --git a/src/libnm-platform/nmp-object.c b/src/libnm-platform/nmp-object.c index 4ba9773c..1fdaa275 100644 --- a/src/libnm-platform/nmp-object.c +++ b/src/libnm-platform/nmp-object.c @@ -701,9 +701,9 @@ _nmp_object_fixup_link_udev_fields(NMPObject **obj_new, NMPObject *obj_orig, gbo } static void -_nmp_object_fixup_link_master_connected(NMPObject **obj_new, - NMPObject *obj_orig, - const NMPCache *cache) +_nmp_object_fixup_link_controller_connected(NMPObject **obj_new, + NMPObject *obj_orig, + const NMPCache *cache) { NMPObject *obj; @@ -2035,58 +2035,58 @@ nmp_cache_use_udev_get(const NMPCache *cache) /*****************************************************************************/ gboolean -nmp_cache_link_connected_for_slave(int ifindex_master, const NMPObject *slave) +nmp_cache_link_connected_for_port(int ifindex_controller, const NMPObject *port) { - nm_assert(NMP_OBJECT_GET_TYPE(slave) == NMP_OBJECT_TYPE_LINK); + nm_assert(NMP_OBJECT_GET_TYPE(port) == NMP_OBJECT_TYPE_LINK); - return ifindex_master > 0 && slave->link.master == ifindex_master && slave->link.connected - && nmp_object_is_visible(slave); + return ifindex_controller > 0 && port->link.controller == ifindex_controller + && port->link.connected && nmp_object_is_visible(port); } /** * nmp_cache_link_connected_needs_toggle: * @cache: the platform cache - * @master: the link object, that is checked whether its connected property + * @controller: the link object, that is checked whether its connected property * needs to be toggled. - * @potential_slave: (nullable): an additional link object that is treated + * @potential_port: (nullable): an additional link object that is treated * as if it was inside @cache. If given, it shaddows a link in the cache * with the same ifindex. - * @ignore_slave: (nullable): if set, the check will pretend that @ignore_slave + * @ignore_port: (nullable): if set, the check will pretend that @ignore_port * is not in the cache. * - * NMPlatformLink has two connected flags: (master->link.flags&IFF_LOWER_UP) (as reported - * from netlink) and master->link.connected. For bond and bridge master, kernel reports - * those links as IFF_LOWER_UP if they have no slaves attached. We want to present instead - * a combined @connected flag that shows masters without slaves as down. + * NMPlatformLink has two connected flags: (controller->link.flags&IFF_LOWER_UP) (as reported + * from netlink) and controller->link.connected. For bond and bridge controller, kernel reports + * those links as IFF_LOWER_UP if they have no ports attached. We want to present instead + * a combined @connected flag that shows controllers without ports as down. * - * Check if the connected flag of @master should be toggled according to the content - * of @cache (including @potential_slave). + * Check if the connected flag of @controller should be toggled according to the content + * of @cache (including @potential_port). * - * Returns: %TRUE, if @master->link.connected should be flipped/toggled. + * Returns: %TRUE, if @controller->link.connected should be flipped/toggled. **/ gboolean nmp_cache_link_connected_needs_toggle(const NMPCache *cache, - const NMPObject *master, - const NMPObject *potential_slave, - const NMPObject *ignore_slave) + const NMPObject *controller, + const NMPObject *potential_port, + const NMPObject *ignore_port) { gboolean is_lower_up = FALSE; - if (!master || NMP_OBJECT_GET_TYPE(master) != NMP_OBJECT_TYPE_LINK || master->link.ifindex <= 0 - || !nmp_object_is_visible(master) - || !NM_IN_SET(master->link.type, NM_LINK_TYPE_BRIDGE, NM_LINK_TYPE_BOND)) + if (!controller || NMP_OBJECT_GET_TYPE(controller) != NMP_OBJECT_TYPE_LINK + || controller->link.ifindex <= 0 || !nmp_object_is_visible(controller) + || !NM_IN_SET(controller->link.type, NM_LINK_TYPE_BRIDGE, NM_LINK_TYPE_BOND)) return FALSE; /* if native IFF_LOWER_UP is down, link.connected must also be down - * regardless of the slaves. */ - if (!NM_FLAGS_HAS(master->link.n_ifi_flags, IFF_LOWER_UP)) - return !!master->link.connected; + * regardless of the ports. */ + if (!NM_FLAGS_HAS(controller->link.n_ifi_flags, IFF_LOWER_UP)) + return !!controller->link.connected; - if (potential_slave && NMP_OBJECT_GET_TYPE(potential_slave) != NMP_OBJECT_TYPE_LINK) - potential_slave = NULL; + if (potential_port && NMP_OBJECT_GET_TYPE(potential_port) != NMP_OBJECT_TYPE_LINK) + potential_port = NULL; - if (potential_slave - && nmp_cache_link_connected_for_slave(master->link.ifindex, potential_slave)) + if (potential_port + && nmp_cache_link_connected_for_port(controller->link.ifindex, potential_port)) is_lower_up = TRUE; else { NMPLookup lookup; @@ -2099,48 +2099,48 @@ nmp_cache_link_connected_needs_toggle(const NMPCache *cache, &link) { const NMPObject *obj = NMP_OBJECT_UP_CAST((NMPlatformObject *) link); - if ((!potential_slave || potential_slave->link.ifindex != link->ifindex) - && ignore_slave != obj - && nmp_cache_link_connected_for_slave(master->link.ifindex, obj)) { + if ((!potential_port || potential_port->link.ifindex != link->ifindex) + && ignore_port != obj + && nmp_cache_link_connected_for_port(controller->link.ifindex, obj)) { is_lower_up = TRUE; break; } } } - return !!master->link.connected != is_lower_up; + return !!controller->link.connected != is_lower_up; } /** * nmp_cache_link_connected_needs_toggle_by_ifindex: * @cache: - * @master_ifindex: the ifindex of a potential master that should be checked + * @controller_ifindex: the ifindex of a potential controller that should be checked * whether it needs toggling. - * @potential_slave: (nullable): passed to nmp_cache_link_connected_needs_toggle(). - * It considers @potential_slave as being inside the cache, replacing an existing + * @potential_port: (nullable): passed to nmp_cache_link_connected_needs_toggle(). + * It considers @potential_port as being inside the cache, replacing an existing * link with the same ifindex. - * @ignore_slave: (nullable): passed to nmp_cache_link_connected_needs_toggle(). + * @ignore_port: (nullable): passed to nmp_cache_link_connected_needs_toggle(). * * The flag obj->link.connected depends on the state of other links in the * @cache. See also nmp_cache_link_connected_needs_toggle(). Given an ifindex - * of a master, check if the cache contains such a master link that needs + * of a controller, check if the cache contains such a controller link that needs * toggling of the connected flag. * - * Returns: NULL if there is no master link with ifindex @master_ifindex that should be toggled. + * Returns: NULL if there is no controller link with ifindex @controller_ifindex that should be toggled. * Otherwise, return the link object from inside the cache with the given ifindex. - * The connected flag of that master should be toggled. + * The connected flag of that controller should be toggled. */ const NMPObject * nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache *cache, - int master_ifindex, - const NMPObject *potential_slave, - const NMPObject *ignore_slave) + int controller_ifindex, + const NMPObject *potential_port, + const NMPObject *ignore_port) { - const NMPObject *master; + const NMPObject *controller; - if (master_ifindex > 0) { - master = nmp_cache_lookup_link(cache, master_ifindex); - if (nmp_cache_link_connected_needs_toggle(cache, master, potential_slave, ignore_slave)) - return master; + if (controller_ifindex > 0) { + controller = nmp_cache_lookup_link(cache, controller_ifindex); + if (nmp_cache_link_connected_needs_toggle(cache, controller, potential_port, ignore_port)) + return controller; } return NULL; } @@ -2804,7 +2804,7 @@ nmp_cache_remove_netlink(NMPCache *cache, obj_new = nmp_object_clone(obj_old, FALSE); obj_new->_link.netlink.is_in_netlink = FALSE; - _nmp_object_fixup_link_master_connected(&obj_new, NULL, cache); + _nmp_object_fixup_link_controller_connected(&obj_new, NULL, cache); _nmp_object_fixup_link_udev_fields(&obj_new, NULL, cache->use_udev); _idxcache_update(cache, entry_old, obj_new, FALSE, &entry_new); @@ -2878,7 +2878,7 @@ nmp_cache_update_netlink(NMPCache *cache, } if (NMP_OBJECT_GET_TYPE(obj_hand_over) == NMP_OBJECT_TYPE_LINK) { - _nmp_object_fixup_link_master_connected(&obj_hand_over, NULL, cache); + _nmp_object_fixup_link_controller_connected(&obj_hand_over, NULL, cache); _nmp_object_fixup_link_udev_fields(&obj_hand_over, NULL, cache->use_udev); } @@ -2914,7 +2914,7 @@ nmp_cache_update_netlink(NMPCache *cache, is_alive = TRUE; if (is_alive) { - _nmp_object_fixup_link_master_connected(&obj_hand_over, NULL, cache); + _nmp_object_fixup_link_controller_connected(&obj_hand_over, NULL, cache); /* Merge the netlink parts with what we have from udev. */ udev_device_unref(obj_hand_over->_link.udev.device); @@ -3193,10 +3193,10 @@ nmp_cache_update_link_udev(NMPCache *cache, } NMPCacheOpsType -nmp_cache_update_link_master_connected(NMPCache *cache, - int ifindex, - const NMPObject **out_obj_old, - const NMPObject **out_obj_new) +nmp_cache_update_link_controller_connected(NMPCache *cache, + int ifindex, + const NMPObject **out_obj_old, + const NMPObject **out_obj_new) { const NMDedupMultiEntry *entry_old; const NMDedupMultiEntry *entry_new = NULL; diff --git a/src/libnm-platform/nmp-object.h b/src/libnm-platform/nmp-object.h index 9406f651..cd1793d4 100644 --- a/src/libnm-platform/nmp-object.h +++ b/src/libnm-platform/nmp-object.h @@ -952,15 +952,15 @@ const NMPObject *nmp_cache_lookup_link_full(const NMPCache *cache, NMPObjectMatchFn match_fn, gpointer user_data); -gboolean nmp_cache_link_connected_for_slave(int ifindex_master, const NMPObject *slave); +gboolean nmp_cache_link_connected_for_port(int ifindex_controller, const NMPObject *port); gboolean nmp_cache_link_connected_needs_toggle(const NMPCache *cache, - const NMPObject *master, - const NMPObject *potential_slave, - const NMPObject *ignore_slave); -const NMPObject *nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache *cache, - int master_ifindex, - const NMPObject *potential_slave, - const NMPObject *ignore_slave); + const NMPObject *controller, + const NMPObject *potential_port, + const NMPObject *ignore_port); +const NMPObject *nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache *cache, + int controller_ifindex, + const NMPObject *potential_port, + const NMPObject *ignore_port); gboolean nmp_cache_use_udev_get(const NMPCache *cache); @@ -994,10 +994,10 @@ NMPCacheOpsType nmp_cache_update_link_udev(NMPCache *cache, struct udev_device *udevice, const NMPObject **out_obj_old, const NMPObject **out_obj_new); -NMPCacheOpsType nmp_cache_update_link_master_connected(NMPCache *cache, - int ifindex, - const NMPObject **out_obj_old, - const NMPObject **out_obj_new); +NMPCacheOpsType nmp_cache_update_link_controller_connected(NMPCache *cache, + int ifindex, + const NMPObject **out_obj_old, + const NMPObject **out_obj_new); static inline const NMDedupMultiEntry * nmp_cache_reresolve_main_entry(NMPCache *cache, |