core: ensure generated connections has no gateway if it has no addresses
Fixes: f17699f4e3
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -430,7 +430,8 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Gateway */
|
/* Gateway */
|
||||||
if (gateway) {
|
if ( gateway
|
||||||
|
&& nm_setting_ip_config_get_num_addresses (s_ip4) > 0) {
|
||||||
g_object_set (s_ip4,
|
g_object_set (s_ip4,
|
||||||
NM_SETTING_IP_CONFIG_GATEWAY, nm_utils_inet4_ntop (gateway, NULL),
|
NM_SETTING_IP_CONFIG_GATEWAY, nm_utils_inet4_ntop (gateway, NULL),
|
||||||
NULL);
|
NULL);
|
||||||
@@ -586,6 +587,9 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src)
|
|||||||
if (nm_ip4_config_get_gateway (src) == nm_ip4_config_get_gateway (dst))
|
if (nm_ip4_config_get_gateway (src) == nm_ip4_config_get_gateway (dst))
|
||||||
nm_ip4_config_set_gateway (dst, 0);
|
nm_ip4_config_set_gateway (dst, 0);
|
||||||
|
|
||||||
|
if (!nm_ip4_config_get_num_addresses (dst))
|
||||||
|
nm_ip4_config_set_gateway (dst, 0);
|
||||||
|
|
||||||
/* routes */
|
/* routes */
|
||||||
for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) {
|
for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) {
|
||||||
const NMPlatformIP4Route *src_route = nm_ip4_config_get_route (src, i);
|
const NMPlatformIP4Route *src_route = nm_ip4_config_get_route (src, i);
|
||||||
|
@@ -538,7 +538,8 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Gateway */
|
/* Gateway */
|
||||||
if (gateway) {
|
if ( gateway
|
||||||
|
&& nm_setting_ip_config_get_num_addresses (s_ip6) > 0) {
|
||||||
g_object_set (s_ip6,
|
g_object_set (s_ip6,
|
||||||
NM_SETTING_IP_CONFIG_GATEWAY, nm_utils_inet6_ntop (gateway, NULL),
|
NM_SETTING_IP_CONFIG_GATEWAY, nm_utils_inet6_ntop (gateway, NULL),
|
||||||
NULL);
|
NULL);
|
||||||
@@ -700,6 +701,9 @@ nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src)
|
|||||||
if (src_tmp && dst_tmp && IN6_ARE_ADDR_EQUAL (src_tmp, dst_tmp))
|
if (src_tmp && dst_tmp && IN6_ARE_ADDR_EQUAL (src_tmp, dst_tmp))
|
||||||
nm_ip6_config_set_gateway (dst, NULL);
|
nm_ip6_config_set_gateway (dst, NULL);
|
||||||
|
|
||||||
|
if (!nm_ip6_config_get_num_addresses (dst))
|
||||||
|
nm_ip6_config_set_gateway (dst, NULL);
|
||||||
|
|
||||||
/* routes */
|
/* routes */
|
||||||
for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) {
|
for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) {
|
||||||
const NMPlatformIP6Route *src_route = nm_ip6_config_get_route (src, i);
|
const NMPlatformIP6Route *src_route = nm_ip6_config_get_route (src, i);
|
||||||
|
Reference in New Issue
Block a user