Commit 58287cbc authored by Thomas Haller's avatar Thomas Haller Committed by Beniamino Galvani
Browse files

core: rework IP configuration in NetworkManager using layer 3 configuration



Completely rework IP configuration in the daemon. Use NML3Cfg as layer 3
manager for the IP configuration of an interface. Use NML3ConfigData as
pieces of configuration that the various components collect and
configure. NMDevice is managing most of the IP configuration at a higher
level, that is, it starts DHCP and other IP methods. Rework the state
handling there.

This is a huge rework of how NetworkManager daemon handles IP
configuration. Some fallout is to be expected.

It appears the patch deletes many lines of code. That is not accurate, because
you also have to count the files `src/core/nm-l3*`, which were unused previously.

Co-authored-by: Beniamino Galvani's avatarBeniamino Galvani <bgalvani@redhat.com>
parent 403acb1f
......@@ -240,7 +240,6 @@ test-*.trs
/src/core/NetworkManager-all-sym
/src/core/NetworkManager.ver
/src/core/devices/bluetooth/tests/nm-bt-test
/src/core/devices/tests/test-acd
/src/core/devices/tests/test-lldp
/src/core/devices/wifi/tests/test-devices-wifi
/src/core/devices/wwan/tests/test-service-providers
......@@ -249,7 +248,6 @@ test-*.trs
/src/core/dhcp/tests/test-dhcp-options
/src/core/dhcp/tests/test-dhcp-utils
/src/core/dnsmasq/tests/test-dnsmasq-utils
/src/core/nm-iface-helper
/src/core/ndisc/tests/test-ndisc-fake
/src/core/ndisc/tests/test-ndisc-linux
/src/core/platform/tests/monitor
......@@ -406,10 +404,12 @@ test-*.trs
/src/NetworkManager
/src/NetworkManager-all-sym
/src/NetworkManager.ver
/src/core/devices/tests/test-acd
/src/core/initrd/nm-initrd-generator
/src/core/initrd/tests/test-cmdline-reader
/src/core/initrd/tests/test-dt-reader
/src/core/initrd/tests/test-ibft-reader
/src/core/nm-iface-helper
/src/devices/bluetooth/tests/nm-bt-test
/src/devices/tests/test-acd
/src/devices/tests/test-arping
......
......@@ -2074,9 +2074,6 @@ src_core_ldflags = $(CODE_COVERAGE_LDFLAGS)
sbin_PROGRAMS += \
src/core/NetworkManager
libexec_PROGRAMS += \
src/core/nm-iface-helper
noinst_LTLIBRARIES += \
src/core/libNetworkManagerBase.la \
src/core/libNetworkManager.la \
......@@ -2323,8 +2320,6 @@ src_libnm_systemd_core_libnm_systemd_core_la_SOURCES = \
src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-lease.c \
src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c \
src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c \
src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c \
src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c \
src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c \
src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h \
src/libnm-systemd-core/src/libsystemd/sd-event/event-util.c \
......@@ -2342,8 +2337,6 @@ src_libnm_systemd_core_libnm_systemd_core_la_SOURCES = \
src/libnm-systemd-core/src/systemd/sd-dhcp6-option.h \
src/libnm-systemd-core/src/systemd/sd-event.h \
src/libnm-systemd-core/src/systemd/sd-id128.h \
src/libnm-systemd-core/src/systemd/sd-ipv4acd.h \
src/libnm-systemd-core/src/systemd/sd-ipv4ll.h \
src/libnm-systemd-core/src/systemd/sd-lldp-rx.h \
src/libnm-systemd-core/src/systemd/sd-lldp.h \
src/libnm-systemd-core/src/systemd/sd-ndisc.h \
......@@ -2394,10 +2387,6 @@ src_core_libNetworkManagerBase_la_SOURCES = \
src/core/nm-l3cfg.h \
src/core/nm-ip-config.c \
src/core/nm-ip-config.h \
src/core/nm-ip4-config.c \
src/core/nm-ip4-config.h \
src/core/nm-ip6-config.c \
src/core/nm-ip6-config.h \
\
src/core/dhcp/nm-dhcp-client.c \
src/core/dhcp/nm-dhcp-client.h \
......@@ -2436,8 +2425,6 @@ src_core_libNetworkManager_la_SOURCES = \
src/core/nm-checkpoint-manager.c \
src/core/nm-checkpoint-manager.h \
\
src/core/devices/nm-acd-manager.c \
src/core/devices/nm-acd-manager.h \
src/core/devices/nm-lldp-listener.c \
src/core/devices/nm-lldp-listener.h \
src/core/devices/nm-device-utils.c \
......@@ -2513,6 +2500,8 @@ src_core_libNetworkManager_la_SOURCES = \
src/core/dnsmasq/nm-dnsmasq-utils.c \
src/core/dnsmasq/nm-dnsmasq-utils.h \
\
src/core/ppp/nm-ppp-mgr.c \
src/core/ppp/nm-ppp-mgr.h \
src/core/ppp/nm-ppp-manager-call.c \
src/core/ppp/nm-ppp-manager-call.h \
src/core/ppp/nm-ppp-manager.h \
......@@ -2586,8 +2575,6 @@ src_core_libNetworkManager_la_SOURCES = \
src/core/nm-firewall-utils.h \
src/core/nm-firewalld-manager.c \
src/core/nm-firewalld-manager.h \
src/core/nm-proxy-config.c \
src/core/nm-proxy-config.h \
src/core/nm-auth-manager.c \
src/core/nm-auth-manager.h \
src/core/nm-auth-utils.c \
......@@ -2721,44 +2708,6 @@ $(src_core_NetworkManager_OBJECTS): $(src_libnm_core_public_mkenums_h)
###############################################################################
src_core_nm_iface_helper_CPPFLAGS = $(src_core_cppflags)
src_core_nm_iface_helper_SOURCES = \
src/core/nm-iface-helper.c
src_core_nm_iface_helper_LDADD = \
src/core/libNetworkManagerBase.la \
src/libnm-core-aux-extern/libnm-core-aux-extern.la \
src/libnm-core-impl/libnm-core-impl.la \
$(libnm_crypto_lib) \
src/libnm-core-aux-intern/libnm-core-aux-intern.la \
src/libnm-platform/libnm-platform.la \
src/libnm-base/libnm-base.la \
src/libnm-log-core/libnm-log-core.la \
src/libnm-udev-aux/libnm-udev-aux.la \
src/libnm-glib-aux/libnm-glib-aux.la \
src/libnm-std-aux/libnm-std-aux.la \
src/libnm-systemd-core/libnm-systemd-core.la \
src/libnm-systemd-shared/libnm-systemd-shared.la \
src/n-acd/libn-acd.la \
src/n-dhcp4/libn-dhcp4.la \
src/c-rbtree/libc-rbtree.la \
src/c-siphash/libc-siphash.la \
$(SYSTEMD_JOURNAL_LIBS) \
$(GLIB_LIBS) \
$(LIBUDEV_LIBS) \
$(LIBNDP_LIBS) \
$(DL_LIBS) \
$(NULL)
src_core_nm_iface_helper_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-binary.ver" \
$(SANITIZER_EXEC_LDFLAGS)
$(src_core_nm_iface_helper_OBJECTS): $(src_libnm_core_public_mkenums_h)
###############################################################################
noinst_LTLIBRARIES += src/nm-initrd-generator/libnmi-core.la
src_nm_initrd_generator_libnmi_core_la_CPPFLAGS = \
......@@ -4275,20 +4224,14 @@ src_core_devices_tests_ldflags = \
check_programs += \
src/core/devices/tests/test-lldp \
src/core/devices/tests/test-acd
$(NULL)
src_core_devices_tests_test_lldp_CPPFLAGS = $(src_core_cppflags_test)
src_core_devices_tests_test_lldp_LDFLAGS = $(src_core_devices_tests_ldflags)
src_core_devices_tests_test_lldp_LDADD = \
src/core/libNetworkManagerTest.la
src_core_devices_tests_test_acd_CPPFLAGS = $(src_core_cppflags_test)
src_core_devices_tests_test_acd_LDFLAGS = $(src_core_devices_tests_ldflags)
src_core_devices_tests_test_acd_LDADD = \
src/core/libNetworkManagerTest.la
$(src_core_devices_tests_test_lldp_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_devices_tests_test_acd_OBJECTS): $(src_libnm_core_public_mkenums_h)
EXTRA_DIST += \
src/core/devices/tests/meson.build
......@@ -4391,22 +4334,12 @@ check_programs += \
src/core/tests/test-core \
src/core/tests/test-core-with-expect \
src/core/tests/test-dcb \
src/core/tests/test-ip4-config \
src/core/tests/test-ip6-config \
src/core/tests/test-l3cfg \
src/core/tests/test-systemd \
src/core/tests/test-utils \
src/core/tests/test-wired-defname \
$(NULL)
src_core_tests_test_ip4_config_CPPFLAGS = $(src_core_cppflags_test)
src_core_tests_test_ip4_config_LDFLAGS = $(src_core_tests_ldflags)
src_core_tests_test_ip4_config_LDADD = $(src_core_tests_ldadd)
src_core_tests_test_ip6_config_CPPFLAGS = $(src_core_cppflags_test)
src_core_tests_test_ip6_config_LDFLAGS = $(src_core_tests_ldflags)
src_core_tests_test_ip6_config_LDADD = $(src_core_tests_ldadd)
src_core_tests_test_dcb_CPPFLAGS = $(src_core_cppflags_test)
src_core_tests_test_dcb_LDFLAGS = $(src_core_tests_ldflags)
src_core_tests_test_dcb_LDADD = $(src_core_tests_ldadd)
......@@ -4434,8 +4367,6 @@ src_core_tests_test_l3cfg_LDADD = $(src_core_tests_ldadd)
$(src_core_tests_test_core_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_core_with_expect_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_dcb_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_ip4_config_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_ip6_config_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_l3cfg_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_utils_OBJECTS): $(src_libnm_core_public_mkenums_h)
$(src_core_tests_test_wired_defname_OBJECTS): $(src_libnm_core_public_mkenums_h)
......
......@@ -1000,7 +1000,6 @@ fi
%ghost %attr(755, root, root) %{_sbindir}/ifdown
%{_libexecdir}/nm-dhcp-helper
%{_libexecdir}/nm-dispatcher
%{_libexecdir}/nm-iface-helper
%{_libexecdir}/nm-initrd-generator
%{_libexecdir}/nm-daemon-helper
%{_libexecdir}/nm-sudo
......
......@@ -33,7 +33,6 @@ src/core/dns/nm-dns-manager.c
src/core/main-utils.c
src/core/main.c
src/core/nm-config.c
src/core/nm-iface-helper.c
src/core/nm-manager.c
src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
......
......@@ -227,6 +227,21 @@ out:
/*****************************************************************************/
void
nm_utils_ppp_ip_methods_enabled(NMConnection *connection,
gboolean * out_ip4_enabled,
gboolean * out_ip6_enabled)
{
NM_SET_OUT(out_ip4_enabled,
nm_streq0(nm_utils_get_ip_config_method(connection, AF_INET),
NM_SETTING_IP4_CONFIG_METHOD_AUTO));
NM_SET_OUT(out_ip6_enabled,
nm_streq0(nm_utils_get_ip_config_method(connection, AF_INET6),
NM_SETTING_IP6_CONFIG_METHOD_AUTO));
}
/*****************************************************************************/
void
_nm_utils_complete_generic_with_params(NMPlatform * platform,
NMConnection * connection,
......@@ -1298,7 +1313,7 @@ void
nm_utils_ip_route_attribute_to_platform(int addr_family,
NMIPRoute * s_route,
NMPlatformIPRoute *r,
guint32 route_table)
gint64 route_table)
{
GVariant * variant;
guint32 table;
......@@ -1310,6 +1325,8 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
nm_assert(s_route);
nm_assert_addr_family(addr_family);
nm_assert(r);
nm_assert(route_table >= -1);
nm_assert(route_table <= (gint64) G_MAXUINT32);
#define GET_ATTR(name, dst, variant_type, type, dflt) \
G_STMT_START \
......@@ -1336,10 +1353,16 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_TABLE, table, UINT32, uint32, 0);
if (!table && r->type_coerced == nm_platform_route_type_coerce(RTN_LOCAL))
if (table != 0)
r->table_coerced = nm_platform_route_table_coerce(table);
else if (r->type_coerced == nm_platform_route_type_coerce(RTN_LOCAL))
r->table_coerced = nm_platform_route_table_coerce(RT_TABLE_LOCAL);
else if (route_table == 0)
r->table_coerced = nm_platform_route_table_coerce(RT_TABLE_MAIN);
else if (route_table > 0)
r->table_coerced = nm_platform_route_table_coerce(route_table);
else
r->table_coerced = nm_platform_route_table_coerce(table ?: (route_table ?: RT_TABLE_MAIN));
r->table_any = TRUE;
if (NM_IS_IPv4(addr_family)) {
guint8 scope;
......@@ -1395,39 +1418,20 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
/*****************************************************************************/
static int
_addresses_sort_cmp_4(gconstpointer a, gconstpointer b, gpointer user_data)
{
return nm_platform_ip4_address_pretty_sort_cmp(
NMP_OBJECT_CAST_IP4_ADDRESS(*((const NMPObject **) a)),
NMP_OBJECT_CAST_IP4_ADDRESS(*((const NMPObject **) b)));
}
static int
_addresses_sort_cmp_6(gconstpointer a, gconstpointer b, gpointer user_data)
{
return nm_platform_ip6_address_pretty_sort_cmp(
NMP_OBJECT_CAST_IP6_ADDRESS(*((const NMPObject **) a)),
NMP_OBJECT_CAST_IP6_ADDRESS(*((const NMPObject **) b)),
(((NMSettingIP6ConfigPrivacy) GPOINTER_TO_INT(user_data))
== NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR));
}
void
nm_utils_ip_addresses_to_dbus(int addr_family,
const NMDedupMultiHeadEntry *head_entry,
const NMPObject * best_default_route,
NMSettingIP6ConfigPrivacy ipv6_privacy,
GVariant ** out_address_data,
GVariant ** out_addresses)
{
const int IS_IPv4 = NM_IS_IPv4(addr_family);
GVariantBuilder builder_data;
GVariantBuilder builder_legacy;
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
gs_free const NMPObject **addresses = NULL;
guint naddr;
guint i;
const int IS_IPv4 = NM_IS_IPv4(addr_family);
GVariantBuilder builder_data;
GVariantBuilder builder_legacy;
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
NMDedupMultiIter iter;
const NMPObject *obj;
guint i;
nm_assert_addr_family(addr_family);
......@@ -1443,19 +1447,11 @@ nm_utils_ip_addresses_to_dbus(int addr_family,
if (!head_entry)
goto out;
addresses =
(const NMPObject **) nm_dedup_multi_objs_to_array_head(head_entry, NULL, NULL, &naddr);
nm_assert(addresses && naddr);
g_qsort_with_data(addresses,
naddr,
sizeof(addresses[0]),
IS_IPv4 ? _addresses_sort_cmp_4 : _addresses_sort_cmp_6,
GINT_TO_POINTER(ipv6_privacy));
for (i = 0; i < naddr; i++) {
const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(addresses[i]);
i = 0;
nm_dedup_multi_iter_init(&iter, head_entry);
while (
nm_platform_dedup_multi_iter_next_obj(&iter, &obj, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4))) {
const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj);
if (out_address_data) {
GVariantBuilder addr_builder;
......@@ -1527,6 +1523,8 @@ nm_utils_ip_addresses_to_dbus(int addr_family,
: &in6addr_any));
}
}
i++;
}
out:
......@@ -1654,6 +1652,128 @@ nm_utils_ip_routes_to_dbus(int addr_family,
/*****************************************************************************/
NMSetting *
nm_utils_platform_capture_ip_setting(NMPlatform *platform,
int addr_family,
int ifindex,
gboolean maybe_ipv6_disabled)
{
const int IS_IPv4 = NM_IS_IPv4(addr_family);
gs_unref_object NMSettingIPConfig *s_ip = NULL;
NMPLookup lookup;
NMDedupMultiIter iter;
const NMPObject * obj;
const char * method = NULL;
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
const NMPlatformIPXRoute * best_default_route = NULL;
s_ip =
NM_SETTING_IP_CONFIG(IS_IPv4 ? nm_setting_ip4_config_new() : nm_setting_ip6_config_new());
if (ifindex <= 0 || !nm_platform_link_get(platform, ifindex)) {
g_object_set(s_ip,
NM_SETTING_IP_CONFIG_METHOD,
IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED
: NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NULL);
return NM_SETTING(g_steal_pointer(&s_ip));
}
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex);
nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) {
const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj);
nm_auto_unref_ip_address NMIPAddress *s_addr = NULL;
if (!IS_IPv4) {
/* Ignore link-local address. */
if (IN6_IS_ADDR_LINKLOCAL(address->ax.address_ptr)) {
if (!method)
method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL;
continue;
}
}
/* Detect dynamic address */
if (address->ax.lifetime != NM_PLATFORM_LIFETIME_PERMANENT) {
method =
IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_AUTO;
continue;
}
/* Static address found. */
if (IS_IPv4) {
if (!method)
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
} else {
if (NM_IN_STRSET(method, NULL, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
}
s_addr =
nm_ip_address_new_binary(addr_family, address->ax.address_ptr, address->ax.plen, NULL);
if (IS_IPv4) {
if (address->a4.label[0]) {
nm_ip_address_set_attribute(s_addr,
NM_IP_ADDRESS_ATTRIBUTE_LABEL,
g_variant_new_string(address->a4.label));
}
}
nm_setting_ip_config_add_address(s_ip, s_addr);
}
if (!method) {
/* Use 'disabled/ignore' if the method wasn't previously set */
if (IS_IPv4)
method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
else
method = maybe_ipv6_disabled ? NM_SETTING_IP6_CONFIG_METHOD_DISABLED
: NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
}
g_object_set(s_ip, NM_SETTING_IP_CONFIG_METHOD, method, NULL);
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4), ifindex);
nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) {
const NMPlatformIPXRoute *route = NMP_OBJECT_CAST_IPX_ROUTE(obj);
nm_auto_unref_ip_route NMIPRoute *s_route = NULL;
if (!IS_IPv4) {
/* Ignore link-local route. */
if (IN6_IS_ADDR_LINKLOCAL(route->rx.network_ptr))
continue;
}
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) {
if (!best_default_route)
best_default_route = route;
continue;
}
s_route = nm_ip_route_new_binary(addr_family,
route->rx.network_ptr,
route->rx.plen,
nm_platform_ip_route_get_gateway(addr_family, &route->rx),
route->rx.metric,
NULL);
nm_setting_ip_config_add_route(s_ip, s_route);
}
if (best_default_route && nm_setting_ip_config_get_num_addresses(s_ip) > 0) {
g_object_set(s_ip,
NM_SETTING_IP_CONFIG_GATEWAY,
nm_utils_inet_ntop(
addr_family,
nm_platform_ip_route_get_gateway(addr_family, &best_default_route->rx),
sbuf),
NULL);
}
return NM_SETTING(g_steal_pointer(&s_ip));
}
/*****************************************************************************/
/* Singleton NMPlatform subclass instance and cached class object */
NM_DEFINE_SINGLETON_INSTANCE(NMPlatform);
......
......@@ -19,6 +19,10 @@ const char *nm_utils_get_ip_config_method(NMConnection *connection, int addr_fam
const char *nm_utils_get_shared_wifi_permission(NMConnection *connection);
void nm_utils_ppp_ip_methods_enabled(NMConnection *connection,
gboolean * out_ip4_enabled,
gboolean * out_ip6_enabled);
void _nm_utils_complete_generic_with_params(NMPlatform * platform,
NMConnection * connection,
const char * ctype,
......@@ -195,12 +199,11 @@ nm_utils_tfilters_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc,
void nm_utils_ip_route_attribute_to_platform(int addr_family,
NMIPRoute * s_route,
NMPlatformIPRoute *r,
guint32 route_table);
gint64 route_table);
void nm_utils_ip_addresses_to_dbus(int addr_family,
const NMDedupMultiHeadEntry *head_entry,
const NMPObject * best_default_route,
NMSettingIP6ConfigPrivacy ipv6_privacy,
GVariant ** out_address_data,
GVariant ** out_addresses);
......@@ -271,6 +274,13 @@ NM_AUTO_DEFINE_FCN(NMDhcpLease *, _nm_auto_unref_dhcplease, nm_dhcp_lease_unref)
/*****************************************************************************/
NMSetting *nm_utils_platform_capture_ip_setting(NMPlatform *platform,
int addr_family,
int ifindex,
gboolean maybe_ipv6_disabled);
/*****************************************************************************/
void nm_platform_setup(NMPlatform *instance);
NMPlatform *nm_platform_get(void);
......
This diff is collapsed.
Rework `NMIP[46]Config` for `next` branch
=========================================
The `next` branch is a large rework of internals, how IP configuration is done by `NMDevice`.
Previously, there are two `GObject`s named `NMIP4Config` and `NMIP6Config`. These
serve different purposes:
1) They are data containers that can track IP configuration. As such, `NMDevice`
and various parts (like `NMDhcpClient`) create them, pass them around and
mutate/merge them to track the IP configuration.
2) They are also subclasses of `NMDBusObject` and exported on D-Bus as
`/org/freedesktop/NetworkManager/IP4Config/1`, etc. As such, see their
[D-Bus API](../../introspection/org.freedesktop.NetworkManager.IP4Config.xml)
(and [for IPv6](../../introspection/org.freedesktop.NetworkManager.IP6Config.xml)).
`next` branch will replace use 1) with `NML3ConfigData`. `NML3ConfigData` are immutable
(sealable) data containers with little logic. This leaves `NMIP4Config` to only
implement 2).
This needs to be reworked.
* Now `NMIP4Config` and `NMIP6Config` are subclasses of `NMIPConfig`. The goal
is to treat IPv4/IPv6 similar and generically. Probably there should be very
little code in the subclasses left and most should move to the parent classes.
We still need separate GObject types though, because that is how `NMDBusObject`'s
glue code can handle different D-Bus paths.
* Now `NML3Cfg` is a handle for the IP configuration parameters of a device (ifindex).
As `NMIPConfig` mostly is about exporting the current IP configuration, it probably
can get most of it from there (and by listening to signals to that).
* Note that `NMDevice`, `NMActiveConnection` refer `NMIP[46]Config`s, and most
importantly, the respective D-Bus objects refer to them. As `NMVpnConnection`
(and "org.freedesktop.NetworkManager.VPN.Connection" interface) are modeled
as "subclasses" of `NMActiveConnection`, they also have one. That means,
it's not entirely clear what these properties even are. For example, currently,
`NMDevice` does a (terrible) dance of tracking external `NMIP[46]Config` objects,
merging, intersecting and subtracting them with other `NMIP4Config` objects
to get the merged one, which is then exported on D-Bus. That merged object
does therefore not directly expose the IP addresses that are actually
configured on the interface (`ip addr`), but more what NetworkManager
wanted to configure and the (terrible) feedback loop where the platform
addresses get synced. With `next` branch and `NML3Cfg` there is a clear distinction
between what NetworkManager wants to configure vs. what is actually configured.
I think for `NMDevice` and `NMActiveConnection`, the IP addresses on
"org.freedesktop.NetworkManager.IP4Config" should expose the IP addresses
that are actually in platform (`ip addr`). If there is a need to expose
additional information (like things that NetworkManager wanted to configure),
then this should be different/new API.
On the other hand, currently `NMVpnConnection`'s `NMIP4Config` only tracks the
IP addresses that come from the VPN plugin. So it's much more what it wants
to configure (from the VPN plugin), and not at all about what is configured
on the interface.
I think that needs to change. A `NMIPConfig` object on D-Bus exposes IP configuration
information about an netdev interface. Period. That also means that a `NMVpnConnection`
(which currently is like a active connection associated with the device) links to
the same `NMIPConfig` object as the underlying device.
......@@ -15,13 +15,12 @@
#include <unistd.h>
#include <stdlib.h>
#include "nm-ip4-config.h"
#include "devices/nm-device-private.h"
#include "libnm-platform/nm-platform.h"
#include "ppp/nm-ppp-manager-call.h"
#include "ppp/nm-ppp-status.h"
#include "nm-manager.h"
#include "nm-setting-adsl.h"
#include "nm-utils.h"
#include "ppp/nm-ppp-mgr.h"
#define _NMLOG_DEVICE_TYPE NMDeviceAdsl
#include "devices/nm-device-logging.h"
......@@ -34,15 +33,14 @@ typedef struct {
guint carrier_poll_id;
int atm_index;
/* PPP */
NMPPPManager *ppp_manager;
NMPppMgr *ppp_mgr;
/* RFC 2684 bridging (PPPoE over ATM) */
int brfd;
int nas_ifindex;
char *nas_ifname;
guint nas_update_id;
guint nas_update_count;
int brfd;
int nas_ifindex;
char * nas_ifname;
GSource *nas_update_source;
guint nas_update_count;
} NMDeviceAdslPrivate;
struct _NMDeviceAdsl {
......@@ -271,7 +269,7 @@ pppoe_vcc_config(NMDeviceAdsl *self)
}
static gboolean
nas_update_cb(gpointer user_data)
nas_update_timeout_cb(gpointer user_data)
{
NMDeviceAdsl * self = NM_DEVICE_ADSL(user_data);
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self);
......@@ -284,33 +282,35 @@ nas_update_cb(gpointer user_data)
nm_assert(priv->nas_ifindex <= 0);
priv->nas_ifindex =