mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 23:30:28 +01:00
libnm-base,all: add and use NM_LOOPBACK_IFINDEX define
Co-authored-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
75349dc566
commit
ef51d0f980
4 changed files with 11 additions and 4 deletions
|
|
@ -2737,7 +2737,8 @@ _ethtool_state_set(NMDevice *self)
|
|||
static gboolean
|
||||
is_loopback(NMDevice *self)
|
||||
{
|
||||
return NM_IS_DEVICE_GENERIC(self) && NM_DEVICE_GET_PRIVATE(self)->ifindex == 1;
|
||||
return NM_IS_DEVICE_GENERIC(self)
|
||||
&& NM_DEVICE_GET_PRIVATE(self)->ifindex == NM_LOOPBACK_IFINDEX;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -7087,7 +7087,7 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde
|
|||
ifindex = nm_device_get_ip_ifindex(device);
|
||||
if (ifindex <= 0)
|
||||
return FALSE;
|
||||
if (ifindex == 1) {
|
||||
if (ifindex == NM_LOOPBACK_IFINDEX) {
|
||||
/* ignore loopback */
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,6 +393,12 @@ typedef struct {
|
|||
|
||||
#define NM_BOND_PORT_QUEUE_ID_DEF 0
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* ifindex generation is per-net namespace, and loopback is always the first
|
||||
* device in the network namespace, thus any loopback device should get ifindex 1. */
|
||||
#define NM_LOOPBACK_IFINDEX 1
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* NM_CRYPTO_ERROR is part of public API in libnm (implemented in libnm-core).
|
||||
|
|
|
|||
|
|
@ -948,9 +948,9 @@ _link_get_all_presort(gconstpointer p_a, gconstpointer p_b, gpointer sort_by_nam
|
|||
const NMPlatformLink *b = NMP_OBJECT_CAST_LINK(*((const NMPObject **) p_b));
|
||||
|
||||
/* Loopback always first */
|
||||
if (a->ifindex == 1)
|
||||
if (a->ifindex == NM_LOOPBACK_IFINDEX)
|
||||
return -1;
|
||||
if (b->ifindex == 1)
|
||||
if (b->ifindex == NM_LOOPBACK_IFINDEX)
|
||||
return 1;
|
||||
|
||||
if (GPOINTER_TO_INT(sort_by_name)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue