mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 13:08:10 +02:00
ip-config: add @intersect_routes argument to intersect functions
In some cases we want to intersect two IP configurations without considering routes. (cherry picked from commit8f07b3ac4f) (cherry picked from commitbd79e67c55)
This commit is contained in:
parent
4775b1dff2
commit
da46fcaffd
5 changed files with 45 additions and 13 deletions
|
|
@ -12125,7 +12125,9 @@ nm_device_get_firmware_missing (NMDevice *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
intersect_ext_config (NMDevice *self, AppliedConfig *config)
|
intersect_ext_config (NMDevice *self,
|
||||||
|
AppliedConfig *config,
|
||||||
|
gboolean intersect_routes)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
NMIPConfig *ext;
|
NMIPConfig *ext;
|
||||||
|
|
@ -12142,10 +12144,11 @@ intersect_ext_config (NMDevice *self, AppliedConfig *config)
|
||||||
: (NMIPConfig *) priv->ext_ip_config_6;
|
: (NMIPConfig *) priv->ext_ip_config_6;
|
||||||
|
|
||||||
if (config->current)
|
if (config->current)
|
||||||
nm_ip_config_intersect (config->current, ext, penalty);
|
nm_ip_config_intersect (config->current, ext, intersect_routes, penalty);
|
||||||
else {
|
else {
|
||||||
config->current = nm_ip_config_intersect_alloc (config->orig,
|
config->current = nm_ip_config_intersect_alloc (config->orig,
|
||||||
ext,
|
ext,
|
||||||
|
intersect_routes,
|
||||||
penalty);
|
penalty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12177,14 +12180,15 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config
|
||||||
* by the user. */
|
* by the user. */
|
||||||
if (priv->con_ip_config_4) {
|
if (priv->con_ip_config_4) {
|
||||||
nm_ip4_config_intersect (priv->con_ip_config_4, priv->ext_ip_config_4,
|
nm_ip4_config_intersect (priv->con_ip_config_4, priv->ext_ip_config_4,
|
||||||
|
TRUE,
|
||||||
default_route_metric_penalty_get (self, AF_INET));
|
default_route_metric_penalty_get (self, AF_INET));
|
||||||
}
|
}
|
||||||
|
|
||||||
intersect_ext_config (self, &priv->dev_ip4_config);
|
intersect_ext_config (self, &priv->dev_ip4_config, TRUE);
|
||||||
intersect_ext_config (self, &priv->wwan_ip_config_4);
|
intersect_ext_config (self, &priv->wwan_ip_config_4, TRUE);
|
||||||
|
|
||||||
for (iter = priv->vpn_configs_4; iter; iter = iter->next)
|
for (iter = priv->vpn_configs_4; iter; iter = iter->next)
|
||||||
nm_ip4_config_intersect (iter->data, priv->ext_ip_config_4, 0);
|
nm_ip4_config_intersect (iter->data, priv->ext_ip_config_4, TRUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove parts from ext_ip_config_4 to only contain the information that
|
/* Remove parts from ext_ip_config_4 to only contain the information that
|
||||||
|
|
@ -12228,15 +12232,16 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config
|
||||||
* by the user. */
|
* by the user. */
|
||||||
if (priv->con_ip_config_6) {
|
if (priv->con_ip_config_6) {
|
||||||
nm_ip6_config_intersect (priv->con_ip_config_6, priv->ext_ip_config_6,
|
nm_ip6_config_intersect (priv->con_ip_config_6, priv->ext_ip_config_6,
|
||||||
|
TRUE,
|
||||||
default_route_metric_penalty_get (self, AF_INET6));
|
default_route_metric_penalty_get (self, AF_INET6));
|
||||||
}
|
}
|
||||||
|
|
||||||
intersect_ext_config (self, &priv->ac_ip6_config);
|
intersect_ext_config (self, &priv->ac_ip6_config, TRUE);
|
||||||
intersect_ext_config (self, &priv->dhcp6.ip6_config);
|
intersect_ext_config (self, &priv->dhcp6.ip6_config, TRUE);
|
||||||
intersect_ext_config (self, &priv->wwan_ip_config_6);
|
intersect_ext_config (self, &priv->wwan_ip_config_6, TRUE);
|
||||||
|
|
||||||
for (iter = priv->vpn_configs_6; iter; iter = iter->next)
|
for (iter = priv->vpn_configs_6; iter; iter = iter->next)
|
||||||
nm_ip6_config_intersect (iter->data, priv->ext_ip_config_6, 0);
|
nm_ip6_config_intersect (iter->data, priv->ext_ip_config_6, TRUE, 0);
|
||||||
|
|
||||||
if ( priv->ipv6ll_has
|
if ( priv->ipv6ll_has
|
||||||
&& !nm_ip6_config_lookup_address (priv->ext_ip_config_6, &priv->ipv6ll_addr))
|
&& !nm_ip6_config_lookup_address (priv->ext_ip_config_6, &priv->ipv6ll_addr))
|
||||||
|
|
|
||||||
|
|
@ -1498,6 +1498,7 @@ nm_ip4_config_subtract (NMIP4Config *dst,
|
||||||
static gboolean
|
static gboolean
|
||||||
_nm_ip4_config_intersect_helper (NMIP4Config *dst,
|
_nm_ip4_config_intersect_helper (NMIP4Config *dst,
|
||||||
const NMIP4Config *src,
|
const NMIP4Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty,
|
guint32 default_route_metric_penalty,
|
||||||
gboolean update_dst)
|
gboolean update_dst)
|
||||||
{
|
{
|
||||||
|
|
@ -1542,6 +1543,9 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst,
|
||||||
/* ignore nameservers */
|
/* ignore nameservers */
|
||||||
|
|
||||||
/* routes */
|
/* routes */
|
||||||
|
if (!intersect_routes)
|
||||||
|
goto skip_routes;
|
||||||
|
|
||||||
changed = FALSE;
|
changed = FALSE;
|
||||||
new_best_default_route = NULL;
|
new_best_default_route = NULL;
|
||||||
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, dst, &r) {
|
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, dst, &r) {
|
||||||
|
|
@ -1582,6 +1586,7 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst,
|
||||||
_notify (dst, PROP_GATEWAY);
|
_notify (dst, PROP_GATEWAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip_routes:
|
||||||
if (changed) {
|
if (changed) {
|
||||||
_notify_routes (dst);
|
_notify_routes (dst);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
@ -1611,9 +1616,10 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst,
|
||||||
void
|
void
|
||||||
nm_ip4_config_intersect (NMIP4Config *dst,
|
nm_ip4_config_intersect (NMIP4Config *dst,
|
||||||
const NMIP4Config *src,
|
const NMIP4Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
_nm_ip4_config_intersect_helper (dst, src, default_route_metric_penalty, TRUE);
|
_nm_ip4_config_intersect_helper (dst, src, intersect_routes, default_route_metric_penalty, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1634,14 +1640,17 @@ nm_ip4_config_intersect (NMIP4Config *dst,
|
||||||
NMIP4Config *
|
NMIP4Config *
|
||||||
nm_ip4_config_intersect_alloc (const NMIP4Config *a,
|
nm_ip4_config_intersect_alloc (const NMIP4Config *a,
|
||||||
const NMIP4Config *b,
|
const NMIP4Config *b,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
NMIP4Config *a_copy;
|
NMIP4Config *a_copy;
|
||||||
|
|
||||||
if (_nm_ip4_config_intersect_helper ((NMIP4Config *) a, b,
|
if (_nm_ip4_config_intersect_helper ((NMIP4Config *) a, b,
|
||||||
|
intersect_routes,
|
||||||
default_route_metric_penalty, FALSE)) {
|
default_route_metric_penalty, FALSE)) {
|
||||||
a_copy = nm_ip4_config_clone (a);
|
a_copy = nm_ip4_config_clone (a);
|
||||||
_nm_ip4_config_intersect_helper (a_copy, b, default_route_metric_penalty, TRUE);
|
_nm_ip4_config_intersect_helper (a_copy, b, intersect_routes,
|
||||||
|
default_route_metric_penalty, TRUE);
|
||||||
return a_copy;
|
return a_copy;
|
||||||
} else
|
} else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -186,9 +186,11 @@ void nm_ip4_config_subtract (NMIP4Config *dst,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
void nm_ip4_config_intersect (NMIP4Config *dst,
|
void nm_ip4_config_intersect (NMIP4Config *dst,
|
||||||
const NMIP4Config *src,
|
const NMIP4Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
NMIP4Config *nm_ip4_config_intersect_alloc (const NMIP4Config *a,
|
NMIP4Config *nm_ip4_config_intersect_alloc (const NMIP4Config *a,
|
||||||
const NMIP4Config *b,
|
const NMIP4Config *b,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
|
gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
|
||||||
|
|
||||||
|
|
@ -535,11 +537,13 @@ nm_ip_config_best_default_route_get (const NMIPConfig *self)
|
||||||
static inline void
|
static inline void
|
||||||
nm_ip_config_intersect (NMIPConfig *dst,
|
nm_ip_config_intersect (NMIPConfig *dst,
|
||||||
const NMIPConfig *src,
|
const NMIPConfig *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
_NM_IP_CONFIG_DISPATCH_SET_OP (, dst, src,
|
_NM_IP_CONFIG_DISPATCH_SET_OP (, dst, src,
|
||||||
nm_ip4_config_intersect,
|
nm_ip4_config_intersect,
|
||||||
nm_ip6_config_intersect,
|
nm_ip6_config_intersect,
|
||||||
|
intersect_routes,
|
||||||
default_route_metric_penalty);
|
default_route_metric_penalty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,18 +585,21 @@ nm_ip_config_replace (NMIPConfig *dst,
|
||||||
static inline NMIPConfig *
|
static inline NMIPConfig *
|
||||||
nm_ip_config_intersect_alloc (const NMIPConfig *a,
|
nm_ip_config_intersect_alloc (const NMIPConfig *a,
|
||||||
const NMIPConfig *b,
|
const NMIPConfig *b,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
if (NM_IS_IP4_CONFIG (a)) {
|
if (NM_IS_IP4_CONFIG (a)) {
|
||||||
nm_assert (NM_IS_IP4_CONFIG (b));
|
nm_assert (NM_IS_IP4_CONFIG (b));
|
||||||
return (NMIPConfig *) nm_ip4_config_intersect_alloc ((const NMIP4Config *) a,
|
return (NMIPConfig *) nm_ip4_config_intersect_alloc ((const NMIP4Config *) a,
|
||||||
(const NMIP4Config *) b,
|
(const NMIP4Config *) b,
|
||||||
|
intersect_routes,
|
||||||
default_route_metric_penalty);
|
default_route_metric_penalty);
|
||||||
} else {
|
} else {
|
||||||
nm_assert (NM_IS_IP6_CONFIG (a));
|
nm_assert (NM_IS_IP6_CONFIG (a));
|
||||||
nm_assert (NM_IS_IP6_CONFIG (b));
|
nm_assert (NM_IS_IP6_CONFIG (b));
|
||||||
return (NMIPConfig *) nm_ip6_config_intersect_alloc ((const NMIP6Config *) a,
|
return (NMIPConfig *) nm_ip6_config_intersect_alloc ((const NMIP6Config *) a,
|
||||||
(const NMIP6Config *) b,
|
(const NMIP6Config *) b,
|
||||||
|
intersect_routes,
|
||||||
default_route_metric_penalty);
|
default_route_metric_penalty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1084,6 +1084,7 @@ nm_ip6_config_subtract (NMIP6Config *dst,
|
||||||
static gboolean
|
static gboolean
|
||||||
_nm_ip6_config_intersect_helper (NMIP6Config *dst,
|
_nm_ip6_config_intersect_helper (NMIP6Config *dst,
|
||||||
const NMIP6Config *src,
|
const NMIP6Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty,
|
guint32 default_route_metric_penalty,
|
||||||
gboolean update_dst)
|
gboolean update_dst)
|
||||||
{
|
{
|
||||||
|
|
@ -1128,6 +1129,9 @@ _nm_ip6_config_intersect_helper (NMIP6Config *dst,
|
||||||
/* ignore nameservers */
|
/* ignore nameservers */
|
||||||
|
|
||||||
/* routes */
|
/* routes */
|
||||||
|
if (!intersect_routes)
|
||||||
|
goto skip_routes;
|
||||||
|
|
||||||
changed = FALSE;
|
changed = FALSE;
|
||||||
new_best_default_route = NULL;
|
new_best_default_route = NULL;
|
||||||
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, dst, &r) {
|
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, dst, &r) {
|
||||||
|
|
@ -1172,6 +1176,7 @@ _nm_ip6_config_intersect_helper (NMIP6Config *dst,
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip_routes:
|
||||||
/* ignore domains */
|
/* ignore domains */
|
||||||
/* ignore dns searches */
|
/* ignore dns searches */
|
||||||
/* ignore dns options */
|
/* ignore dns options */
|
||||||
|
|
@ -1194,9 +1199,10 @@ _nm_ip6_config_intersect_helper (NMIP6Config *dst,
|
||||||
void
|
void
|
||||||
nm_ip6_config_intersect (NMIP6Config *dst,
|
nm_ip6_config_intersect (NMIP6Config *dst,
|
||||||
const NMIP6Config *src,
|
const NMIP6Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
_nm_ip6_config_intersect_helper (dst, src, default_route_metric_penalty, TRUE);
|
_nm_ip6_config_intersect_helper (dst, src, intersect_routes, default_route_metric_penalty, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1217,14 +1223,17 @@ nm_ip6_config_intersect (NMIP6Config *dst,
|
||||||
NMIP6Config *
|
NMIP6Config *
|
||||||
nm_ip6_config_intersect_alloc (const NMIP6Config *a,
|
nm_ip6_config_intersect_alloc (const NMIP6Config *a,
|
||||||
const NMIP6Config *b,
|
const NMIP6Config *b,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty)
|
guint32 default_route_metric_penalty)
|
||||||
{
|
{
|
||||||
NMIP6Config *a_copy;
|
NMIP6Config *a_copy;
|
||||||
|
|
||||||
if (_nm_ip6_config_intersect_helper ((NMIP6Config *) a, b,
|
if (_nm_ip6_config_intersect_helper ((NMIP6Config *) a, b,
|
||||||
|
intersect_routes,
|
||||||
default_route_metric_penalty, FALSE)) {
|
default_route_metric_penalty, FALSE)) {
|
||||||
a_copy = nm_ip6_config_clone (a);
|
a_copy = nm_ip6_config_clone (a);
|
||||||
_nm_ip6_config_intersect_helper (a_copy, b, default_route_metric_penalty, TRUE);
|
_nm_ip6_config_intersect_helper (a_copy, b, intersect_routes,
|
||||||
|
default_route_metric_penalty, TRUE);
|
||||||
return a_copy;
|
return a_copy;
|
||||||
} else
|
} else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,11 @@ void nm_ip6_config_subtract (NMIP6Config *dst,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
void nm_ip6_config_intersect (NMIP6Config *dst,
|
void nm_ip6_config_intersect (NMIP6Config *dst,
|
||||||
const NMIP6Config *src,
|
const NMIP6Config *src,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
NMIP6Config *nm_ip6_config_intersect_alloc (const NMIP6Config *a,
|
NMIP6Config *nm_ip6_config_intersect_alloc (const NMIP6Config *a,
|
||||||
const NMIP6Config *b,
|
const NMIP6Config *b,
|
||||||
|
gboolean intersect_routes,
|
||||||
guint32 default_route_metric_penalty);
|
guint32 default_route_metric_penalty);
|
||||||
gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes);
|
gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue