Commit graph

13461 commits

Author SHA1 Message Date
Thomas Haller
395665902b
dns: don't apply DNS configuration for external connections
External connections are devices that are configured outside of
NetworkManager. Such devices should be mostly ignored and not
be interfered with.

Note that we tend to create external connection profiles for
such devices. That happens for example if you use wg-quick to
manage a WireGuard interface outside of NetworkManager. But it
really happens for any interface.

This generated profile has no DNS configuration. Unless we use
the systemd-resolved backend, they thus don't contribute to the DNS
settings (which is fine).

However, with systemd-resolved, NetworkManager would also reset
the DNS configuration of those external interfaces. That is clearly
wrong. NetworkManager should only care about the interfaces that it
actively manages and leave others alone.

How to reproduce: use systemd-resolved and configure an interface outside
of NetworkManager. Note that `nmcli device` shows the state as
"connected (externally)". Note that `resolvectl` shows the DNS configuration
on that external interface. Do something in NetworkManager to trigger
a DNS update (e.g. SIGHUB or reactivate a profile). Note in `resolvectl`
that the external interface's DNS configuration was wiped.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/563#note_673283
2020-11-17 18:49:58 +01:00
Thomas Haller
f1564caa15
dns: minor cleanup in update_dns() to use gsize for size
g_strv_length() returns a guint. That is not the right size for the length
of an array. Use the right size.
2020-11-17 16:55:15 +01:00
Beniamino Galvani
09c8387114 policy: use the hostname setting
Rework update_system_hostname() to use the new properties from the
hostname setting.

In the default configuration where all the 3 boolean properties
hostname.{from-dhcp,from-dns,only-from-default} are true, the behavior
is the same as before.
2020-11-16 16:43:40 +01:00
Beniamino Galvani
abd002642f all: add hostname setting
Add a new setting that contains properties related to how NM should
get the hostname from the connection.
2020-11-16 16:43:39 +01:00
Beniamino Galvani
adf63c8875 ifcfg: reuse the same variable for different settings 2020-11-16 16:43:39 +01:00
Beniamino Galvani
dc6ec6ce7b core: reverse the order of active connections in the manager
When a new active connection is created, it gets added at the
beginning of manager's list. This means that the list contains most
recently activated connections first. Since the list is doubly-linked,
it is possible to efficiently iterate in both directions, so the order
of the list is mostly a matter of convention.

I think it is preferable to have oldest active connections at the
beginning of the list; let's reverse the order.

In most places where the list is iterated, the order doesn't
matter. Where it does, use the *_prev() variant to maintain the old
iteration order.
2020-11-16 16:43:39 +01:00
Beniamino Galvani
740191f7c0 core: add nm_ip_config_get_first_address() 2020-11-16 16:43:39 +01:00
Aleksander Morgado
5b7ce438d9
wwan: update default connection timeout to 200s
The following merge request in ModemManager introduces a more or less
common timeout value for the connection attempts in all plugin and
protocol implementations:

  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/391

The value chosen by default for the steps that may take long to
complete in a connection attempt is 180s, and 120s for the steps in
the disconnection path.

Until now, every different plugin or protocol had a different timeout
value, all of them <= 180s, and with that change in ModemManager, the
values are now aligned for all.

Note, though, that this does not mean that a connection attempt will
take always less than 180s, as there may be multiple other steps in
addition to the one that took the maximum timeout. The value chosen
for NetworkManager is a compromise between the new defaults from MM
and what the user would expect under e.g. very low quality conditions.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/678
2020-11-16 16:04:06 +01:00
Andrew Zaborowski
c1ff06e119 iwd: Fix a use after free
In connection_removed we use the id.name that was being g_freed a few
lines further down.

Fixes: bea6c40367 ('wifi/iwd: handle forgetting connection profiles')
2020-11-12 19:58:08 +01:00
Thomas Haller
ab3f18b906
ppp: drop unnecessary cast for return value of g_object_new() (manually) 2020-11-12 16:08:17 +01:00
Thomas Haller
a2b5e22f82
all: drop unnecessary cast for return value of g_object_new()
C casts unconditionally force the type, and as such they don't
necessarily improve type safety, but rather overcome restrictions
from the compiler when necessary.

Casting a void pointer is unnecessary (in C), it does not make the
code more readable nor more safe. In particular for g_object_new(),
which is known to return a void pointer of the right type.

Drop such casts.

  sed 's/([A-Za-z_0-9]\+ *\* *) *g_object_new/g_object_new/g' $(git grep -l g_object_new) -i
  ./contrib/scripts/nm-code-format-container.sh
2020-11-12 16:03:09 +01:00
Thomas Haller
2f83777054
core/trivial: fix clang-format code formatting 2020-11-12 15:34:59 +01:00
Andrew Zaborowski
33b9fa3a3c manager: Keep volatile/external connections while referenced by async_op_lst
If an NMSettingsConnection with the VOLATILE or EXTENRAL flags is created
and passed to nm_manager_activate_connection, it's immediately scheduled
for deletion in an idle callback and will likely be deleted before the
authorization step in nm_manager_activate_connection finishes and the
connection will be aborted.  This is because there's no
NMActiveConnection in priv->active_connection_lst_head referencing it
until _internal_activate_device().  Change
active_connection_find_by_connection to also look for connections in
priv->async_op_lst_head.

New _delete_volatile_connection_do() calls are added.  Previously it
would be called when an active connection may have been removed from
priv->active_connection_lst_head, now also call it when an active
connection may have been removed from priv->async_op_lst_head without
being added to priv->active_connection_lst_head.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/671
2020-11-12 15:04:56 +01:00
Thomas Haller
31940037fa
device: fix _Generic() types for _NM_DEVICE_CAST() macro (2)
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device.c:957:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice *const') not compatible with any generic association type
            _LOGT(LOGD_DEVICE,
            ^~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:162:20: note: expanded from macro '_LOGT'
    #define _LOGT(...) _NMLOG(_LOGL_TRACE, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:34:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:14:63: note: expanded from macro '_NM_DEVICE_CAST'
        #define _NM_DEVICE_CAST(self) _NM_ENSURE_TYPE(NMDevice *, self)
                                                                  ^
    ../shared/nm-glib-aux/nm-macros-internal.h:664:53: note: expanded from macro '_NM_ENSURE_TYPE'
        #define _NM_ENSURE_TYPE(type, value) (_Generic((value), type : (value)))
                                                        ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 22:54:32 +01:00
Thomas Haller
71eeec8c78
device: fix _Generic() types for _NM_DEVICE_CAST() macro
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device-6lowpan.c:161:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice6Lowpan *const') not compatible with any generic association type
            _LOGW(LOGD_DEVICE, "could not get 6lowpan properties");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:165:20: note: expanded from macro '_LOGW'
    #define _LOGW(...) _NMLOG(_LOGL_WARN, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:32:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:17:19: note: expanded from macro '_NM_DEVICE_CAST'
            _Generic((self), _NMLOG_DEVICE_TYPE *        \
                      ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 19:44:10 +01:00
Thomas Haller
bac5dc99d7
core/ovs: refactor duplicate code in ovsdb_next_command() 2020-11-09 17:53:19 +01:00
Thomas Haller
9b5bb3e45c
core/ovs: split payload out of OvsdbMethodCall struct
Before, ovsdb_call_method() has a long list of arguments
to account for all possible commands. That does not scale.

Instead, introduce a separate OvsdbMethodPayload type and
only add a macro to allow passing the right parameters.
2020-11-09 17:53:18 +01:00
Thomas Haller
81863c959b
core/ovs: rename logging output for _LOGT_call()
The text should match the OvsdbCommand enum. If the enum
value is named OVSDB_ADD_INTERFACE, then we should print
"add-interface". Or alternatively, if you think spelling
out interface is too long, then the enum should be renamed.
I don't care, but name should correspond.
2020-11-09 17:53:18 +01:00
Thomas Haller
487c78733e
core/ovs: name union fields in OvsdbMethodCall
As we add more command types, the union gets more members.
Name each union field explicitly to match the OvsdbCommand
type.
2020-11-09 17:53:18 +01:00
Thomas Haller
2d8c5e9efa
core/ovs: cleanup debug logging for OVS command
- always print the JSON string as last (if present). Previously
  that didn't happen with OVSDB_SET_INTERFACE_MTU.

- introduce _QUOTE_MSG() macro.
2020-11-09 17:53:18 +01:00
Thomas Haller
1eeca3c606
core/ovs: track external-ids for cached ovsdb objects
We will need them later.
2020-11-09 17:53:18 +01:00
Thomas Haller
7cf1f7fe02
core/ovs: cleanup logic in update handling of ovsdb_got_update()
ovsdb sends monitor updates, with "new" and "old" values that indicate
whether this is an addition, and update, or a removal.

Since we also cache the entries, we might not agree with what ovsdb
says. E.g. if ovsdb says this is an update, but we didn't have the
interface in our cache, we should rather pretend that the interface
was added. Even if this possibly indicates some inconsistency between
what OVS says and what we have cached, we should make the best of it.

Rework the code. On update, we compare the result with our cache
and care less about the "new" / "old" values.
2020-11-09 17:53:18 +01:00
Thomas Haller
f6d3b5f5f4
core/ovs: change function signature of _free_{bridge,port,interface}
We will call the function directly as well. Lets aim to
get the types right.

Also the compiler would warn if the cast to (GDestroyNotify)
would be to a fundamtally different function signature.
2020-11-09 17:53:18 +01:00
Thomas Haller
7dc4d0c666
core/ovs: use helper functions to emit NM_OVSDB_* signals 2020-11-09 17:53:18 +01:00
Thomas Haller
cb3b6a2417
core/ovs: move code in "nm-ovsdb.c" around to have simple helpers at the top 2020-11-09 17:53:17 +01:00
Thomas Haller
e403f76544
core/ovs: track key for OpenvswitchInterface in same struct 2020-11-09 17:53:17 +01:00
Thomas Haller
51495e4e9a
core/ovs: track key for OpenvswitchPort in same struct 2020-11-09 17:53:17 +01:00
Thomas Haller
2094cbb5d1
core/ovs: track key for OpenvswitchBridge in same struct
GHashTable is optimized for data that has no separate value
pointer. We can use the OpenvswitchBridge structs as key themselves,
by having the id as first field of the structure and only use
g_hash_table_add().
2020-11-09 17:53:17 +01:00
Thomas Haller
263e92bf49
core/ovs: minor cleanup of logic in _add_interface() 2020-11-09 17:53:17 +01:00
Thomas Haller
8d78f8effb
core/ovs: avoid possible crash in _add_interface() 2020-11-09 17:53:17 +01:00
Thomas Haller
5d5b35285e
core/ovs: use streq() instead of strcmp() 2020-11-09 17:53:16 +01:00
Thomas Haller
7738955c2f
core/ovs: cleanup uses of g_slice_*() in "nm-ovsdb.c" 2020-11-09 17:53:16 +01:00
Thomas Haller
4cad3cfe88
core/ovs: fix using unsigned "mtu" value to json_pack()
Of course, in practice "mtu" is much smaller than 2^31, and
also is sizeof(int) >= sizeof(uint32_t) (on our systems). Hence,
this was correct. Still, it feels ugly to pass a unsigned integer
where not the entire range is covered.
2020-11-09 17:53:16 +01:00
Thomas Haller
e05edcfd7e
core/ovs: cleanup handling of call id for OVS commands
- rename "id" to something more distinct: "call_id".

- consistently use guint64 type. We don't want nor need
  to handle negative values. For CALL_ID_UNSPEC we can use
  G_MAXUINT64.

- don't use "i" format string for the call id. That expects
  an "int", so it's not clear how this was working correctly
  previously. Also, "int" has a smaller range than our 64bits.
  Use instead "json_int_t" and cast properly in the variadic
  arguments of json_pack().
2020-11-09 17:53:16 +01:00
Thomas Haller
609b08e2eb
core/ovs: fix leak of "NMOvsdbPrivate.db_uuid
Also, never update the value to %NULL. If the current
message does not contain a UUID, keep the previous one.

Fixes: 830a5a14cb ('device: add support for OpenVSwitch devices')
2020-11-09 17:53:16 +01:00
Thomas Haller
46e0a3374b
core/trivial: add FIXME comment about immutable applied-connection 2020-11-09 17:53:16 +01:00
Thomas Haller
d75c31afd0
device: refactor NMDevice's can_reapply_change() to return early
Don't have if-else-if structure, if we can always return from an
"if" block, once we matched the setting-name.
2020-11-09 17:53:16 +01:00
Thomas Haller
cc35dc3bdf
device: improve "nm-device-logging.h" to support a self pointer of NMDevice type
"nm-device-logging.h" defines logging macros for a NMDevice instance.
It also expects a "self" variable in the call environment, and that
variable had to be in the type of NMDevice or the NMDevice subclass.

Extend the macro foo, so that @self can be either a NMDevice* pointer
or a NMDevice$SUBTYPE.

Of course, that would have always been possible, if we would simply cast
to "(NMDevice *)" where we need it. The trick is that the macro only
works if @self is one of the two expected types, and not some arbitrary
unrelated type.
2020-11-09 17:53:16 +01:00
Thomas Haller
7d5ec103df
format: mark json_{object,array}_foreach() macors as ForEachMacros for clang-format 2020-11-09 17:53:15 +01:00
Beniamino Galvani
d6457902d1 dns: sd-resolved: fix hash table initialization
The hash table was not initialized if there was no D-Bus connection at
the time of object creation.

Fixes: f70ee67058 ('dns: sd-resolved: reset interface configuration on deactivation')

https://bugzilla.redhat.com/show_bug.cgi?id=1894839
2020-11-06 23:39:46 +01:00
Thomas Haller
03d9ec27fa
introspection: avoid compiler warning in generated introspection files
Disable "-Wincompatible-pointer-types-discards-qualifiers" warning, as
this breaks build of the gdbus-codegen files.

With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
get a failure to build generated code:

    introspection/org.freedesktop.NetworkManager.AccessPoint.c:438:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_INTERFACE (NMDBusAccessPoint, nmdbus_access_point, G_TYPE_OBJECT)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1784:47: note: expanded from macro 'G_DEFINE_INTERFACE'
    #define G_DEFINE_INTERFACE(TN, t_n, T_P)                    G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1803:61: note: expanded from macro 'G_DEFINE_INTERFACE_WITH_CODE'
    #define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2042:7: note: expanded from macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:944:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointProxy, nmdbus_access_point_proxy, G_TYPE_DBUS_PROXY,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:1729:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointSkeleton, nmdbus_access_point_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
2020-11-03 15:39:00 +01:00
Thomas Haller
11068cf936
device: fix crash in nm_device_reactivate_ip_config()
Fixes: 87f69f0050 ('device: merge nm_device_reactivate_ip_config() implementations for IPv4/IPv6')
2020-11-03 12:32:54 +01:00
Antonio Cardace
e23798a5e5
bridge: force (hack)-set of the MTU when explicitly set in the profile
Kernel does a auto-mtu adjusting process whenever a port is added/removed from
the bridge, this can cause issues when NM wants to explicitly set an MTU which is
equal to the bridge default one (1500) because if later a port is added with a
different MTU the kernel will assign the bridge that port's MTU resulting in the bridge
runtime configuration differing from the bridge's NM connection profile.

What we can do is to always apply the MTU manually for the bridge (if explicitly
set by the profile), after doing so the kernel won't modify the MTU anymore,
which is what we want, problem is that kernel won't actually apply the MTU
to the netdev if it's not actually changing so we first apply it to
MTU-1 and then to the desired value.

https://bugzilla.redhat.com/show_bug.cgi?id=1778590

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-11-02 17:23:22 +01:00
Antonio Cardace
516c623618
bridge: set MTU at link creation time
https://bugzilla.redhat.com/show_bug.cgi?id=1778590

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-11-02 17:23:16 +01:00
Antonio Cardace
ba2ee46254
platform: allow setting the MTU at link creation time
Add a parameter to the 'link_add()' virtual function so that
the MTU will be configured (via netlink) by the kernel when
creating the link.

https://bugzilla.redhat.com/show_bug.cgi?id=1778590

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-11-02 17:23:05 +01:00
Thomas Haller
6c9a289451
core: cleanup IPv4/IPv6 checks using NM_IS_IPv4()
- we commonly use "int addr_family" as parameters to functions.
  But then inside the function, we often need to do something for
  IPv4 or IPv6 specifically. Instead of having lots of redundant
  "if (addr_family == AF_INET)" checks, prefer to have a variable
  IS_IPv4 and/or use NM_IS_IPv4() macro.

- don't make the "IS_IPv4" variable a gboolean but an int. gboolean
  is a typedef for int, so it's in practice exactly the same. However,
  we use "IS_IPv4" as index to arrays of length 2, where at position
  "1" we have the value related to IPv4. Using a gboolean to index
  an array is a bit odd. Maybe a "int" is preferable here.
  This is more about doing consistently one or the other. There are
  no strong reasons to prefer gboolean or int.
2020-10-30 16:52:59 +01:00
Thomas Haller
6767ba1205
device: allow AF_UNSPEC for nm_device_get_connectivity_state()
Apparently it is not actually used, but the function implements
a return value for AF_UNSPEC, while also asserting that the addr_family
is AF_INET/AF_INET6. Drop the assertions.
2020-10-30 16:52:58 +01:00
Thomas Haller
f20d0d6984
device: merge activate_stage5_ip_config_result_[46]() 2020-10-30 16:52:57 +01:00
Thomas Haller
399684538b
device: abort on failure in activate_stage5_ip_config_result_6()
This is analog to what the IPv4 code does at this place. Abort.
2020-10-30 16:52:57 +01:00
Thomas Haller
15e287a351
device: merge activate_stage4_ip_config_timeout_[46]() 2020-10-30 16:52:56 +01:00