diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2019-03-12 15:13:33 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2019-03-12 15:13:33 +0100 |
| commit | dd428301eb6f02542015121d7b08d9997f137e50 (patch) | |
| tree | 5530189f63510287d65268fc36025bdbc9414c00 /src/nm-ip4-config.c | |
| parent | bbae86d3d2997a853ca0365e8eb7a3ca7489ee09 (diff) | |
New upstream version 1.15.91
Diffstat (limited to 'src/nm-ip4-config.c')
| -rw-r--r-- | src/nm-ip4-config.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 1179a77f..1c06a42c 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -23,7 +23,6 @@ #include "nm-ip4-config.h" -#include <string.h> #include <arpa/inet.h> #include <resolv.h> #include <linux/rtnetlink.h> @@ -1512,6 +1511,7 @@ nm_ip4_config_subtract (NMIP4Config *dst, static gboolean _nm_ip4_config_intersect_helper (NMIP4Config *dst, const NMIP4Config *src, + gboolean intersect_addresses, gboolean intersect_routes, guint32 default_route_metric_penalty, gboolean update_dst) @@ -1534,24 +1534,26 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst, g_object_freeze_notify (G_OBJECT (dst)); /* addresses */ - changed = FALSE; - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, dst, &a) { - if (nm_dedup_multi_index_lookup_obj (src_priv->multi_idx, - &src_priv->idx_ip4_addresses, - NMP_OBJECT_UP_CAST (a))) - continue; - - if (!update_dst) - return TRUE; - - if (nm_dedup_multi_index_remove_entry (dst_priv->multi_idx, - ipconf_iter.current) != 1) - nm_assert_not_reached (); - changed = TRUE; - } - if (changed) { - _notify_addresses (dst); - result = TRUE; + if (intersect_addresses) { + changed = FALSE; + nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, dst, &a) { + if (nm_dedup_multi_index_lookup_obj (src_priv->multi_idx, + &src_priv->idx_ip4_addresses, + NMP_OBJECT_UP_CAST (a))) + continue; + + if (!update_dst) + return TRUE; + + if (nm_dedup_multi_index_remove_entry (dst_priv->multi_idx, + ipconf_iter.current) != 1) + nm_assert_not_reached (); + changed = TRUE; + } + if (changed) { + _notify_addresses (dst); + result = TRUE; + } } /* ignore nameservers */ @@ -1600,12 +1602,12 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst, _notify (dst, PROP_GATEWAY); } -skip_routes: if (changed) { _notify_routes (dst); result = TRUE; } +skip_routes: /* ignore domains */ /* ignore dns searches */ /* ignore dns options */ @@ -1623,6 +1625,8 @@ skip_routes: * nm_ip4_config_intersect: * @dst: a configuration to be updated * @src: another configuration + * @intersect_addresses: whether addresses should be intersected + * @intersect_routes: whether routes should be intersected * @default_route_metric_penalty: the default route metric penalty * * Computes the intersection between @src and @dst and updates @dst in place @@ -1631,16 +1635,24 @@ skip_routes: void nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src, + gboolean intersect_addresses, gboolean intersect_routes, guint32 default_route_metric_penalty) { - _nm_ip4_config_intersect_helper (dst, src, intersect_routes, default_route_metric_penalty, TRUE); + _nm_ip4_config_intersect_helper (dst, + src, + intersect_addresses, + intersect_routes, + default_route_metric_penalty, + TRUE); } /** * nm_ip4_config_intersect_alloc: * @a: a configuration * @b: another configuration + * @intersect_addresses: whether addresses should be intersected + * @intersect_routes: whether routes should be intersected * @default_route_metric_penalty: the default route metric penalty * * Computes the intersection between @a and @b and returns the result in a newly @@ -1655,17 +1667,24 @@ nm_ip4_config_intersect (NMIP4Config *dst, NMIP4Config * nm_ip4_config_intersect_alloc (const NMIP4Config *a, const NMIP4Config *b, + gboolean intersect_addresses, gboolean intersect_routes, guint32 default_route_metric_penalty) { NMIP4Config *a_copy; if (_nm_ip4_config_intersect_helper ((NMIP4Config *) a, b, + intersect_addresses, intersect_routes, - default_route_metric_penalty, FALSE)) { + default_route_metric_penalty, + FALSE)) { a_copy = nm_ip4_config_clone (a); - _nm_ip4_config_intersect_helper (a_copy, b, intersect_routes, - default_route_metric_penalty, TRUE); + _nm_ip4_config_intersect_helper (a_copy, + b, + intersect_addresses, + intersect_routes, + default_route_metric_penalty, + TRUE); return a_copy; } else return NULL; @@ -2153,7 +2172,7 @@ nm_ip4_config_get_first_address (const NMIP4Config *self) const NMPlatformIP4Address * _nmtst_ip4_config_get_address (const NMIP4Config *self, guint i) { - NMDedupMultiIter iter; + NMDedupMultiIter iter = { }; const NMPlatformIP4Address *a = NULL; guint j; @@ -2261,7 +2280,7 @@ _add_route (NMIP4Config *self, * nm_ip4_config_add_route: * @self: the #NMIP4Config * @new: the new route to add to @self - * @out_obj_new: (allow-none): (out): the added route object. Must be unrefed + * @out_obj_new: (allow-none) (out): the added route object. Must be unrefed * by caller. * * Adds the new route to @self. If a route with the same basic properties @@ -2901,7 +2920,7 @@ nm_ip4_config_nmpobj_remove (NMIP4Config *self, /*****************************************************************************/ -static inline void +static void hash_u32 (GChecksum *sum, guint32 n) { g_checksum_update (sum, (const guint8 *) &n, sizeof (n)); |