mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 14:00:11 +01:00
connectivity: merge branch 'th/connectivity-per-af-fixes'
https://github.com/NetworkManager/NetworkManager/pull/255
This commit is contained in:
commit
b7429d0a95
19 changed files with 750 additions and 504 deletions
|
|
@ -1394,7 +1394,7 @@ nmc_error_get_simple_message (GError *error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE (nm_connectivity_to_string_no_l10n, NMConnectivityState,
|
||||
NM_UTILS_LOOKUP_STR_DEFINE (nm_connectivity_to_string, NMConnectivityState,
|
||||
NM_UTILS_LOOKUP_DEFAULT (N_("unknown")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_CONNECTIVITY_NONE, N_("none")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_CONNECTIVITY_PORTAL, N_("portal")),
|
||||
|
|
@ -1402,9 +1402,3 @@ NM_UTILS_LOOKUP_STR_DEFINE (nm_connectivity_to_string_no_l10n, NMConnectivitySta
|
|||
NM_UTILS_LOOKUP_ITEM (NM_CONNECTIVITY_FULL, N_("full")),
|
||||
NM_UTILS_LOOKUP_ITEM_IGNORE (NM_CONNECTIVITY_UNKNOWN),
|
||||
);
|
||||
|
||||
const char *
|
||||
nm_connectivity_to_string (NMConnectivityState connectivity)
|
||||
{
|
||||
return _(nm_connectivity_to_string_no_l10n (connectivity));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,5 @@ extern const NmcMetaGenericInfo *const metagen_ip6_config[];
|
|||
extern const NmcMetaGenericInfo *const metagen_dhcp_config[];
|
||||
|
||||
const char *nm_connectivity_to_string (NMConnectivityState connectivity);
|
||||
const char *nm_connectivity_to_string_no_l10n (NMConnectivityState connectivity);
|
||||
|
||||
#endif /* NMC_COMMON_H */
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (nm_state_to_string_no_l10n, NMState,
|
||||
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (nm_state_to_string, NMState,
|
||||
NM_UTILS_LOOKUP_DEFAULT (N_("unknown")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_STATE_ASLEEP, N_("asleep")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_STATE_CONNECTING, N_("connecting")),
|
||||
|
|
@ -49,12 +49,6 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (nm_state_to_string_no_l10n, NMState,
|
|||
NM_UTILS_LOOKUP_ITEM_IGNORE (NM_STATE_UNKNOWN),
|
||||
);
|
||||
|
||||
static const char *
|
||||
nm_state_to_string (NMState state)
|
||||
{
|
||||
return _(nm_state_to_string_no_l10n (state));
|
||||
}
|
||||
|
||||
static NMMetaColor
|
||||
state_to_color (NMState state)
|
||||
{
|
||||
|
|
@ -136,7 +130,7 @@ permission_to_string (NMClientPermission perm)
|
|||
}
|
||||
}
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (permission_result_to_string_no_l10n, NMClientPermissionResult,
|
||||
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (permission_result_to_string, NMClientPermissionResult,
|
||||
NM_UTILS_LOOKUP_DEFAULT (N_("unknown")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_CLIENT_PERMISSION_RESULT_YES, N_("yes")),
|
||||
NM_UTILS_LOOKUP_ITEM (NM_CLIENT_PERMISSION_RESULT_NO, N_("no")),
|
||||
|
|
@ -177,7 +171,7 @@ _metagen_general_status_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
case NMC_GENERIC_INFO_TYPE_GENERAL_STATUS_STATE:
|
||||
state = nm_client_get_state (nmc->client);
|
||||
NMC_HANDLE_COLOR (state_to_color (state));
|
||||
value = nm_state_to_string_no_l10n (state);
|
||||
value = nm_state_to_string (state);
|
||||
goto translate_and_out;
|
||||
case NMC_GENERIC_INFO_TYPE_GENERAL_STATUS_STARTUP:
|
||||
v_bool = nm_client_get_startup (nmc->client);
|
||||
|
|
@ -187,7 +181,7 @@ _metagen_general_status_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
case NMC_GENERIC_INFO_TYPE_GENERAL_STATUS_CONNECTIVITY:
|
||||
connectivity = nm_client_get_connectivity (nmc->client);
|
||||
NMC_HANDLE_COLOR (connectivity_to_color (connectivity));
|
||||
value = nm_connectivity_to_string_no_l10n (connectivity);
|
||||
value = nm_connectivity_to_string (connectivity);
|
||||
goto translate_and_out;
|
||||
case NMC_GENERIC_INFO_TYPE_GENERAL_STATUS_NETWORKING:
|
||||
v_bool = nm_client_networking_get_enabled (nmc->client);
|
||||
|
|
@ -271,7 +265,7 @@ _metagen_general_permissions_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
case NMC_GENERIC_INFO_TYPE_GENERAL_PERMISSIONS_VALUE:
|
||||
perm_result = nm_client_get_permission_result (nmc->client, perm);
|
||||
NMC_HANDLE_COLOR (permission_result_to_color (perm_result));
|
||||
s = permission_result_to_string_no_l10n (perm_result);
|
||||
s = permission_result_to_string (perm_result);
|
||||
if (get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
|
||||
return _(s);
|
||||
return s;
|
||||
|
|
@ -1098,7 +1092,8 @@ client_connectivity (NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
|
||||
g_object_get (client, NM_CLIENT_CONNECTIVITY, &connectivity, NULL);
|
||||
str = nmc_colorize (&nmc->nmc_config, connectivity_to_color (connectivity),
|
||||
_("Connectivity is now '%s'\n"), nm_connectivity_to_string (connectivity));
|
||||
_("Connectivity is now '%s'\n"),
|
||||
gettext (nm_connectivity_to_string (connectivity)));
|
||||
g_print ("%s", str);
|
||||
g_free (str);
|
||||
}
|
||||
|
|
@ -1112,7 +1107,7 @@ client_state (NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
g_object_get (client, NM_CLIENT_STATE, &state, NULL);
|
||||
str = nmc_colorize (&nmc->nmc_config, state_to_color (state),
|
||||
_("Networkmanager is now in the '%s' state\n"),
|
||||
nm_state_to_string (state));
|
||||
gettext (nm_state_to_string (state)));
|
||||
g_print ("%s", str);
|
||||
g_free (str);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1112,12 +1112,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2251
|
||||
size: 2249
|
||||
location: clients/tests/test-client.py:944:test_003()/36
|
||||
cmd: $NMCLI -f ALL -t dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -1131,8 +1131,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -1990,12 +1990,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2251
|
||||
size: 2249
|
||||
location: clients/tests/test-client.py:944:test_003()/59
|
||||
cmd: $NMCLI -f ALL -t dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -2009,8 +2009,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -5294,12 +5294,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2257
|
||||
size: 2255
|
||||
location: clients/tests/test-client.py:971:test_003()/109
|
||||
cmd: $NMCLI --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -5313,8 +5313,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -5914,12 +5914,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2269
|
||||
size: 2267
|
||||
location: clients/tests/test-client.py:971:test_003()/119
|
||||
cmd: $NMCLI --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -5933,8 +5933,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -7255,14 +7255,14 @@ DHCP6:dhcp-6-opt-1 = val-1 | dhcp-6-opt-5 = val-5 | dhcp-6-opt-6 = val-6 | dhcp-
|
|||
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,4}:5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1 | UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1 | UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 1387
|
||||
size: 1385
|
||||
location: clients/tests/test-client.py:971:test_003()/169
|
||||
cmd: $NMCLI --mode tabular --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 1213 bytes
|
||||
stdout: 1211 bytes
|
||||
>>>
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (nieznane):0 (nieznane):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (unknown):0 (unknown):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
CAPABILITIES:no:100 Mb/s:no:no
|
||||
WIRED-PROPERTIES:off:
|
||||
IP4:192.168.6.238/29::dst = 192.168.58.133/31, nh = 192.168.50.116, mt = 3130348792 | dst = 192.168.155.50/19, nh = 192.168.127.64:192.168.213.113:sear4.foo4.bar:192.168.156.115 | 192.168.8.33
|
||||
|
|
@ -7407,14 +7407,14 @@ DHCP6:dhcp-6-opt-1 = val-1 | dhcp-6-opt-5 = val-5 | dhcp-6-opt-6 = val-6 | dhcp-
|
|||
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,4}:5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1 | UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1 | UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 1399
|
||||
size: 1397
|
||||
location: clients/tests/test-client.py:971:test_003()/179
|
||||
cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 1213 bytes
|
||||
stdout: 1211 bytes
|
||||
>>>
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (nieznane):0 (nieznane):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (unknown):0 (unknown):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
CAPABILITIES:no:100 Mb/s:no:no
|
||||
WIRED-PROPERTIES:off:
|
||||
IP4:192.168.6.238/29::dst = 192.168.58.133/31, nh = 192.168.50.116, mt = 3130348792 | dst = 192.168.155.50/19, nh = 192.168.127.64:192.168.213.113:sear4.foo4.bar:192.168.156.115 | 192.168.8.33
|
||||
|
|
@ -11414,12 +11414,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2274
|
||||
size: 2272
|
||||
location: clients/tests/test-client.py:971:test_003()/229
|
||||
cmd: $NMCLI --mode multiline --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -11433,8 +11433,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -12182,12 +12182,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
|
||||
|
||||
<<<
|
||||
size: 2286
|
||||
size: 2284
|
||||
location: clients/tests/test-client.py:971:test_003()/239
|
||||
cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2098 bytes
|
||||
stdout: 2096 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -12201,8 +12201,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -13532,12 +13532,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:<invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 2277
|
||||
size: 2275
|
||||
location: clients/tests/test-client.py:971:test_003()/289
|
||||
cmd: $NMCLI --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2118 bytes
|
||||
stdout: 2116 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -13551,8 +13551,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -13778,12 +13778,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:<invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 2289
|
||||
size: 2287
|
||||
location: clients/tests/test-client.py:971:test_003()/299
|
||||
cmd: $NMCLI --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2118 bytes
|
||||
stdout: 2116 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -13797,8 +13797,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -14713,14 +14713,14 @@ DHCP6:dhcp-6-opt-1 = val-1 | dhcp-6-opt-5 = val-5 | dhcp-6-opt-6 = val-6 | dhcp-
|
|||
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,4}:5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1 | UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1 | <invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 1407
|
||||
size: 1405
|
||||
location: clients/tests/test-client.py:971:test_003()/349
|
||||
cmd: $NMCLI --mode tabular --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 1233 bytes
|
||||
stdout: 1231 bytes
|
||||
>>>
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (nieznane):0 (nieznane):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (unknown):0 (unknown):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
CAPABILITIES:no:100 Mb/s:no:no
|
||||
WIRED-PROPERTIES:off:
|
||||
IP4:192.168.6.238/29::dst = 192.168.58.133/31, nh = 192.168.50.116, mt = 3130348792 | dst = 192.168.155.50/19, nh = 192.168.127.64:192.168.213.113:sear4.foo4.bar:192.168.156.115 | 192.168.8.33
|
||||
|
|
@ -14839,14 +14839,14 @@ DHCP6:dhcp-6-opt-1 = val-1 | dhcp-6-opt-5 = val-5 | dhcp-6-opt-6 = val-6 | dhcp-
|
|||
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,4}:5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1 | UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1 | <invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 1419
|
||||
size: 1417
|
||||
location: clients/tests/test-client.py:971:test_003()/359
|
||||
cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 1233 bytes
|
||||
stdout: 1231 bytes
|
||||
>>>
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (nieznane):0 (nieznane):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
GENERAL:eth0:ethernet:NMDeviceEthernet:::virtual:::C0\:61\:AE\:26\:4D\:D7:0:20 (unavailable):0 (No reason given):0 (unknown):0 (unknown):/sys/devices/virtual/eth0::no:yes:yes:no:no::ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:/org/freedesktop/NetworkManager/ActiveConnection/1:unknown
|
||||
CAPABILITIES:no:100 Mb/s:no:no
|
||||
WIRED-PROPERTIES:off:
|
||||
IP4:192.168.6.238/29::dst = 192.168.58.133/31, nh = 192.168.50.116, mt = 3130348792 | dst = 192.168.155.50/19, nh = 192.168.127.64:192.168.213.113:sear4.foo4.bar:192.168.156.115 | 192.168.8.33
|
||||
|
|
@ -16878,12 +16878,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:<invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 2294
|
||||
size: 2292
|
||||
location: clients/tests/test-client.py:971:test_003()/409
|
||||
cmd: $NMCLI --mode multiline --terse -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2118 bytes
|
||||
stdout: 2116 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -16897,8 +16897,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
@ -17270,12 +17270,12 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con-
|
|||
CONNECTIONS.AVAILABLE-CONNECTIONS[3]:<invisible> | /org/freedesktop/NetworkManager/Settings/Connection/4
|
||||
|
||||
<<<
|
||||
size: 2306
|
||||
size: 2304
|
||||
location: clients/tests/test-client.py:971:test_003()/419
|
||||
cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 2118 bytes
|
||||
stdout: 2116 bytes
|
||||
>>>
|
||||
GENERAL.DEVICE:eth0
|
||||
GENERAL.TYPE:ethernet
|
||||
|
|
@ -17289,8 +17289,8 @@ GENERAL.HWADDR:C0:61:AE:26:4D:D7
|
|||
GENERAL.MTU:0
|
||||
GENERAL.STATE:20 (unavailable)
|
||||
GENERAL.REASON:0 (No reason given)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (nieznane)
|
||||
GENERAL.IP4-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.IP6-CONNECTIVITY:0 (unknown)
|
||||
GENERAL.UDI:/sys/devices/virtual/eth0
|
||||
GENERAL.IP-IFACE:
|
||||
GENERAL.IS-SOFTWARE:no
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -402,11 +402,13 @@ no-auto-default=*
|
|||
<literal>systemd-resolved</literal>. Defaults to "<literal>true</literal>".
|
||||
</para>
|
||||
<para>Note that this setting is complementary to the
|
||||
<varname>dns</varname> setting. You can keep this enable while using
|
||||
<varname>dns</varname> setting. You can keep this enabled while using
|
||||
<varname>dns</varname> set to another DNS plugin alongside
|
||||
<literal>systemd-resolved</literal>, or <varname>dns</varname> set to
|
||||
<literal>systemd-resolved</literal> to configure the system resolver to use
|
||||
<literal>systemd-resolved</literal>.</para>
|
||||
<para>If systemd-resolved is enabled, the connectivity check resolves the
|
||||
hostname per-device.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
|||
|
|
@ -1329,6 +1329,16 @@ nm_strcmp_p (gconstpointer a, gconstpointer b)
|
|||
: NM_UNIQ_T(X,xq)); \
|
||||
})
|
||||
|
||||
#define NM_MAX_WITH_CMP(cmp, a, b) \
|
||||
({ \
|
||||
typeof (a) _a = (a); \
|
||||
typeof (b) _b = (b); \
|
||||
\
|
||||
( ((cmp (_a, _b)) >= 0) \
|
||||
? _a \
|
||||
: _b); \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline guint
|
||||
|
|
|
|||
|
|
@ -76,8 +76,9 @@ static inline char
|
|||
nm_utils_addr_family_to_char (int addr_family)
|
||||
{
|
||||
switch (addr_family) {
|
||||
case AF_INET: return '4';
|
||||
case AF_INET6: return '6';
|
||||
case AF_UNSPEC: return 'X';
|
||||
case AF_INET: return '4';
|
||||
case AF_INET6: return '6';
|
||||
}
|
||||
g_return_val_if_reached ('?');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2496,7 +2496,8 @@ static void concheck_periodic_schedule_set (NMDevice *self,
|
|||
static gboolean
|
||||
_concheck_periodic_timeout_cb (NMDevice *self, int addr_family)
|
||||
{
|
||||
_LOGt (LOGD_CONCHECK, "connectivity: periodic timeout");
|
||||
_LOGt (LOGD_CONCHECK, "connectivity: [IPv%c] periodic timeout",
|
||||
nm_utils_addr_family_to_char (addr_family));
|
||||
concheck_periodic_schedule_set (self, addr_family, CONCHECK_SCHEDULE_CHECK_PERIODIC);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
|
@ -2560,7 +2561,8 @@ concheck_periodic_schedule_do (NMDevice *self, int addr_family, gint64 now_ns)
|
|||
expiry = priv->concheck_x[IS_IPv4].p_cur_basetime_ns + (priv->concheck_x[IS_IPv4].p_cur_interval * NM_UTILS_NS_PER_SECOND);
|
||||
tdiff = expiry - now_ns;
|
||||
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: periodic-check: %sscheduled in %lld milliseconds (%u seconds interval)",
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [IPv%c] periodic-check: %sscheduled in %lld milliseconds (%u seconds interval)",
|
||||
nm_utils_addr_family_to_char (addr_family),
|
||||
periodic_check_disabled ? "re-" : "",
|
||||
(long long) (tdiff / NM_UTILS_NS_PER_MSEC),
|
||||
priv->concheck_x[IS_IPv4].p_cur_interval);
|
||||
|
|
@ -2571,8 +2573,10 @@ concheck_periodic_schedule_do (NMDevice *self, int addr_family, gint64 now_ns)
|
|||
self);
|
||||
return TRUE;
|
||||
out:
|
||||
if (periodic_check_disabled)
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: periodic-check: unscheduled");
|
||||
if (periodic_check_disabled) {
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [IPv%c] periodic-check: unscheduled",
|
||||
nm_utils_addr_family_to_char (addr_family));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -2737,7 +2741,8 @@ concheck_update_interval (NMDevice *self, int addr_family, gboolean check_now)
|
|||
new_interval = NM_MIN (new_interval, 7 *24 * 3600);
|
||||
|
||||
if (new_interval != priv->concheck_x[IS_IPv4].p_max_interval) {
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: periodic-check: set interval to %u seconds", new_interval);
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [IPv%c] periodic-check: set interval to %u seconds",
|
||||
nm_utils_addr_family_to_char (addr_family), new_interval);
|
||||
priv->concheck_x[IS_IPv4].p_max_interval = new_interval;
|
||||
}
|
||||
|
||||
|
|
@ -2761,8 +2766,8 @@ concheck_update_interval (NMDevice *self, int addr_family, gboolean check_now)
|
|||
void
|
||||
nm_device_check_connectivity_update_interval (NMDevice *self)
|
||||
{
|
||||
concheck_update_interval (self, AF_INET, FALSE);
|
||||
concheck_update_interval (self, AF_INET6, FALSE);
|
||||
concheck_update_interval (self, AF_INET, TRUE);
|
||||
concheck_update_interval (self, AF_INET6, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2895,7 +2900,8 @@ concheck_cb (NMConnectivity *connectivity,
|
|||
/* the only place where we nm_connectivity_check_cancel(@c_handle), is
|
||||
* from inside concheck_handle_complete(). This is a recursive call,
|
||||
* nothing to do. */
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: complete check (seq:%llu, cancelled)",
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [IPv%c] complete check (seq:%llu, cancelled)",
|
||||
nm_utils_addr_family_to_char (handle->addr_family),
|
||||
(long long unsigned) handle->seq);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2905,7 +2911,8 @@ concheck_cb (NMConnectivity *connectivity,
|
|||
|
||||
self_keep_alive = g_object_ref (self);
|
||||
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: complete check (seq:%llu, state:%s)",
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [Ipv%c] complete check (seq:%llu, state:%s)",
|
||||
nm_utils_addr_family_to_char (handle->addr_family),
|
||||
(long long unsigned) handle->seq,
|
||||
nm_connectivity_state_to_string (state));
|
||||
|
||||
|
|
@ -3025,7 +3032,8 @@ concheck_start (NMDevice *self,
|
|||
|
||||
c_list_link_tail (&priv->concheck_lst_head, &handle->concheck_lst);
|
||||
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: start check (seq:%llu%s)",
|
||||
_LOGT (LOGD_CONCHECK, "connectivity: [IPv%c] start check (seq:%llu%s)",
|
||||
nm_utils_addr_family_to_char (addr_family),
|
||||
(long long unsigned) handle->seq,
|
||||
is_periodic ? ", periodic-check" : "");
|
||||
|
||||
|
|
@ -3072,15 +3080,26 @@ nm_device_check_connectivity_cancel (NMDeviceConnectivityHandle *handle)
|
|||
}
|
||||
|
||||
NMConnectivityState
|
||||
nm_device_get_connectivity_state (NMDevice *self)
|
||||
nm_device_get_connectivity_state (NMDevice *self, int addr_family)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
const gboolean IS_IPv4 = (addr_family == AF_INET);
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), NM_CONNECTIVITY_UNKNOWN);
|
||||
nm_assert_addr_family (addr_family);
|
||||
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
return NM_MAX (priv->concheck_x[0].state, priv->concheck_x[1].state);
|
||||
switch (addr_family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
return priv->concheck_x[IS_IPv4].state;
|
||||
default:
|
||||
nm_assert (addr_family == AF_UNSPEC);
|
||||
return NM_MAX_WITH_CMP (nm_connectivity_state_cmp,
|
||||
priv->concheck_x[0].state,
|
||||
priv->concheck_x[1].state);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ NMDeviceConnectivityHandle *nm_device_check_connectivity (NMDevice *self,
|
|||
|
||||
void nm_device_check_connectivity_cancel (NMDeviceConnectivityHandle *handle);
|
||||
|
||||
NMConnectivityState nm_device_get_connectivity_state (NMDevice *self);
|
||||
NMConnectivityState nm_device_get_connectivity_state (NMDevice *self, int addr_family);
|
||||
|
||||
typedef struct _NMBtVTableNetworkServer NMBtVTableNetworkServer;
|
||||
struct _NMBtVTableNetworkServer {
|
||||
|
|
|
|||
|
|
@ -344,6 +344,21 @@ _ip_config_lst_head (NMDnsManager *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_dns_manager_has_systemd_resolved (NMDnsManager *self)
|
||||
{
|
||||
NMDnsManagerPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE);
|
||||
|
||||
priv = NM_DNS_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
return priv->sd_resolve_plugin
|
||||
|| NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
add_string_item (GPtrArray *array, const char *str, gboolean dup)
|
||||
{
|
||||
|
|
@ -1975,8 +1990,10 @@ init_resolv_conf_mode (NMDnsManager *self, gboolean force_reload_plugin)
|
|||
NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self);
|
||||
NMDnsManagerResolvConfManager rc_manager;
|
||||
const char *mode;
|
||||
gboolean systemd_resolved = FALSE;
|
||||
gboolean param_changed = FALSE, plugin_changed = FALSE;
|
||||
gboolean systemd_resolved;
|
||||
gboolean param_changed = FALSE;
|
||||
gboolean plugin_changed = FALSE;
|
||||
gboolean systemd_resolved_changed = FALSE;
|
||||
|
||||
mode = nm_config_data_get_dns_mode (nm_config_get_data (priv->config));
|
||||
systemd_resolved = nm_config_data_get_systemd_resolved (nm_config_get_data (priv->config));
|
||||
|
|
@ -2053,16 +2070,13 @@ again:
|
|||
if (systemd_resolved) {
|
||||
if (!priv->sd_resolve_plugin) {
|
||||
priv->sd_resolve_plugin = nm_dns_systemd_resolved_new ();
|
||||
plugin_changed = TRUE;
|
||||
systemd_resolved_changed = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (priv->sd_resolve_plugin) {
|
||||
g_clear_object (&priv->sd_resolve_plugin);
|
||||
plugin_changed = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (nm_clear_g_object (&priv->sd_resolve_plugin))
|
||||
systemd_resolved_changed = TRUE;
|
||||
|
||||
if (plugin_changed && priv->plugin) {
|
||||
if ( plugin_changed
|
||||
&& priv->plugin) {
|
||||
g_signal_connect (priv->plugin, NM_DNS_PLUGIN_FAILED, G_CALLBACK (plugin_failed), self);
|
||||
g_signal_connect (priv->plugin, NM_DNS_PLUGIN_CHILD_QUIT, G_CALLBACK (plugin_child_quit), self);
|
||||
}
|
||||
|
|
@ -2082,9 +2096,10 @@ again:
|
|||
_notify (self, PROP_RC_MANAGER);
|
||||
}
|
||||
|
||||
if (param_changed || plugin_changed) {
|
||||
if (param_changed || plugin_changed || systemd_resolved_changed) {
|
||||
_LOGI ("init: dns=%s%s rc-manager=%s%s%s%s",
|
||||
mode, (systemd_resolved ? ",systemd-resolved" : ""),
|
||||
mode,
|
||||
(systemd_resolved ? ",systemd-resolved" : ""),
|
||||
_rc_manager_to_string (rc_manager),
|
||||
NM_PRINT_FMT_QUOTED (priv->plugin, ", plugin=",
|
||||
nm_dns_plugin_get_name (priv->plugin), "", ""));
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ typedef enum {
|
|||
|
||||
void nm_dns_manager_stop (NMDnsManager *self);
|
||||
|
||||
gboolean nm_dns_manager_has_systemd_resolved (NMDnsManager *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *nmtst_dns_create_resolv_conf (const char *const*searches,
|
||||
|
|
|
|||
|
|
@ -108,9 +108,10 @@ typedef struct {
|
|||
|
||||
char *dns_mode;
|
||||
char *rc_manager;
|
||||
gboolean systemd_resolved;
|
||||
|
||||
NMGlobalDnsConfig *global_dns;
|
||||
|
||||
bool systemd_resolved:1;
|
||||
} NMConfigDataPrivate;
|
||||
|
||||
struct _NMConfigData {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include "nm-default.h"
|
||||
|
||||
#include "nm-connectivity.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -32,8 +31,11 @@
|
|||
#endif
|
||||
|
||||
#include "c-list/src/c-list.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-config.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "dns/nm-dns-manager.h"
|
||||
|
||||
#define HEADER_STATUS_ONLINE "X-NetworkManager-Status: online\r\n"
|
||||
|
||||
|
|
@ -61,6 +63,14 @@ nm_connectivity_state_to_string (NMConnectivityState state)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
guint ref_count;
|
||||
char *uri;
|
||||
char *host;
|
||||
char *port;
|
||||
char *response;
|
||||
} ConConfig;
|
||||
|
||||
struct _NMConnectivityCheckHandle {
|
||||
CList handles_lst;
|
||||
NMConnectivity *self;
|
||||
|
|
@ -68,29 +78,36 @@ struct _NMConnectivityCheckHandle {
|
|||
gpointer user_data;
|
||||
|
||||
char *ifspec;
|
||||
int addr_family;
|
||||
|
||||
const char *completed_log_message;
|
||||
char *completed_log_message_free;
|
||||
|
||||
#if WITH_CONCHECK
|
||||
struct {
|
||||
char *response;
|
||||
ConConfig *con_config;
|
||||
|
||||
int ifindex;
|
||||
GCancellable *resolve_cancellable;
|
||||
CURLM *curl_mhandle;
|
||||
guint curl_timer;
|
||||
CURL *curl_ehandle;
|
||||
struct curl_slist *request_headers;
|
||||
struct curl_slist *hosts;
|
||||
|
||||
GString *recv_msg;
|
||||
|
||||
guint curl_timer;
|
||||
int ch_ifindex;
|
||||
} concheck;
|
||||
#endif
|
||||
|
||||
const char *completed_log_message;
|
||||
char *completed_log_message_free;
|
||||
NMConnectivityState completed_state;
|
||||
guint64 request_counter;
|
||||
|
||||
int addr_family;
|
||||
|
||||
guint timeout_id;
|
||||
|
||||
NMConnectivityState completed_state;
|
||||
|
||||
bool fail_reason_no_dbus_connection:1;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -104,13 +121,12 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
typedef struct {
|
||||
CList handles_lst_head;
|
||||
CList completed_handles_lst_head;
|
||||
char *uri;
|
||||
char *host;
|
||||
char *port;
|
||||
char *response;
|
||||
gboolean enabled;
|
||||
guint interval;
|
||||
NMConfig *config;
|
||||
ConConfig *con_config;
|
||||
guint interval;
|
||||
|
||||
bool enabled:1;
|
||||
bool uri_valid:1;
|
||||
} NMConnectivityPrivate;
|
||||
|
||||
struct _NMConnectivity {
|
||||
|
|
@ -142,16 +158,53 @@ NM_DEFINE_SINGLETON_GETTER (NMConnectivity, nm_connectivity_get, NM_TYPE_CONNECT
|
|||
_nm_log (__level, _NMLOG2_DOMAIN, 0, \
|
||||
(cb_data->ifspec ? &cb_data->ifspec[3] : NULL), \
|
||||
NULL, \
|
||||
"connectivity: (%s,AF_INET%s) " \
|
||||
"connectivity: (%s,IPv%c,%"G_GUINT64_FORMAT") " \
|
||||
_NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
(cb_data->ifspec ? &cb_data->ifspec[3] : ""), \
|
||||
(cb_data->addr_family == AF_INET6 ? "6" : "") \
|
||||
nm_utils_addr_family_to_char (cb_data->addr_family), \
|
||||
cb_data->request_counter \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static ConConfig *
|
||||
_con_config_ref (ConConfig *con_config)
|
||||
{
|
||||
if (con_config) {
|
||||
nm_assert (con_config->ref_count > 0);
|
||||
++con_config->ref_count;
|
||||
}
|
||||
return con_config;
|
||||
}
|
||||
|
||||
static void
|
||||
_con_config_unref (ConConfig *con_config)
|
||||
{
|
||||
if (!con_config)
|
||||
return;
|
||||
|
||||
nm_assert (con_config->ref_count > 0);
|
||||
|
||||
if (--con_config->ref_count != 0)
|
||||
return;
|
||||
|
||||
g_free (con_config->uri);
|
||||
g_free (con_config->host);
|
||||
g_free (con_config->port);
|
||||
g_free (con_config->response);
|
||||
g_slice_free (ConConfig, con_config);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_con_config_get_response (const ConConfig *con_config)
|
||||
{
|
||||
return con_config->response ?: NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
cb_data_complete (NMConnectivityCheckHandle *cb_data,
|
||||
NMConnectivityState state,
|
||||
|
|
@ -217,7 +270,7 @@ cb_data_complete (NMConnectivityCheckHandle *cb_data,
|
|||
* not use the self pointer too. */
|
||||
|
||||
#if WITH_CONCHECK
|
||||
g_free (cb_data->concheck.response);
|
||||
_con_config_unref (cb_data->concheck.con_config);
|
||||
if (cb_data->concheck.recv_msg)
|
||||
g_string_free (cb_data->concheck.recv_msg, TRUE);
|
||||
#endif
|
||||
|
|
@ -270,12 +323,6 @@ _complete_queued (NMConnectivity *self)
|
|||
nm_g_object_unref (self_keep_alive);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_check_handle_get_response (NMConnectivityCheckHandle *cb_data)
|
||||
{
|
||||
return cb_data->concheck.response ?: NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_con_curl_check_connectivity (CURLM *mhandle, int sockfd, int ev_bitmask)
|
||||
{
|
||||
|
|
@ -323,7 +370,7 @@ _con_curl_check_connectivity (CURLM *mhandle, int sockfd, int ev_bitmask)
|
|||
g_strdup_printf ("check failed: (%d) %s",
|
||||
msg->data.result,
|
||||
curl_easy_strerror (msg->data.result)));
|
||||
} else if ( !((_check_handle_get_response (cb_data))[0])
|
||||
} else if ( !((_con_config_get_response (cb_data->concheck.con_config))[0])
|
||||
&& (curl_easy_getinfo (msg->easy_handle, CURLINFO_RESPONSE_CODE, &response_code) == CURLE_OK)
|
||||
&& response_code == 204) {
|
||||
/* If we got a 204 response code (no content) and we actually
|
||||
|
|
@ -505,7 +552,7 @@ easy_write_cb (void *buffer, size_t size, size_t nmemb, void *userdata)
|
|||
|
||||
g_string_append_len (cb_data->concheck.recv_msg, buffer, len);
|
||||
|
||||
response = _check_handle_get_response (cb_data);;
|
||||
response = _con_config_get_response (cb_data->concheck.con_config);;
|
||||
if ( response
|
||||
&& cb_data->concheck.recv_msg->len >= strlen (response)) {
|
||||
/* We already have enough data -- check response */
|
||||
|
|
@ -555,6 +602,12 @@ _idle_cb (gpointer user_data)
|
|||
g_set_error (&error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
"no interface specified for connectivity check");
|
||||
cb_data_complete (cb_data, NM_CONNECTIVITY_ERROR, "missing interface");
|
||||
} else if (cb_data->fail_reason_no_dbus_connection) {
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
g_set_error (&error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
"no D-Bus connection");
|
||||
cb_data_complete (cb_data, NM_CONNECTIVITY_ERROR, "no D-Bus connection");
|
||||
} else
|
||||
cb_data_complete (cb_data, NM_CONNECTIVITY_FAKE, "fake result");
|
||||
return G_SOURCE_REMOVE;
|
||||
|
|
@ -563,7 +616,6 @@ _idle_cb (gpointer user_data)
|
|||
static void
|
||||
do_curl_request (NMConnectivityCheckHandle *cb_data)
|
||||
{
|
||||
NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (cb_data->self);
|
||||
CURLM *mhandle;
|
||||
CURL *ehandle;
|
||||
long resolve;
|
||||
|
|
@ -581,7 +633,6 @@ do_curl_request (NMConnectivityCheckHandle *cb_data)
|
|||
return;
|
||||
}
|
||||
|
||||
cb_data->concheck.response = g_strdup (priv->response);
|
||||
cb_data->concheck.curl_mhandle = mhandle;
|
||||
cb_data->concheck.curl_ehandle = ehandle;
|
||||
cb_data->concheck.request_headers = curl_slist_append (NULL, "Connection: close");
|
||||
|
|
@ -608,7 +659,7 @@ do_curl_request (NMConnectivityCheckHandle *cb_data)
|
|||
g_warn_if_reached ();
|
||||
}
|
||||
|
||||
curl_easy_setopt (ehandle, CURLOPT_URL, priv->uri);
|
||||
curl_easy_setopt (ehandle, CURLOPT_URL, cb_data->concheck.con_config->uri);
|
||||
curl_easy_setopt (ehandle, CURLOPT_WRITEFUNCTION, easy_write_cb);
|
||||
curl_easy_setopt (ehandle, CURLOPT_WRITEDATA, cb_data);
|
||||
curl_easy_setopt (ehandle, CURLOPT_HEADERFUNCTION, easy_header_cb);
|
||||
|
|
@ -625,28 +676,23 @@ do_curl_request (NMConnectivityCheckHandle *cb_data)
|
|||
static void
|
||||
resolve_cb (GObject *object, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
NMConnectivityCheckHandle *cb_data = user_data;
|
||||
NMConnectivity *self;
|
||||
NMConnectivityPrivate *priv;
|
||||
GVariant *result;
|
||||
GVariant *addresses;
|
||||
NMConnectivityCheckHandle *cb_data;
|
||||
gs_unref_variant GVariant *result = NULL;
|
||||
gs_unref_variant GVariant *addresses = NULL;
|
||||
gsize no_addresses;
|
||||
int ifindex;
|
||||
int addr_family;
|
||||
GVariant *address = NULL;
|
||||
const guchar *address_buf;
|
||||
gsize len = 0;
|
||||
char str[INET6_ADDRSTRLEN + 1] = { 0, };
|
||||
char *host;
|
||||
gsize i;
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error);
|
||||
result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), res, &error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = cb_data->self;
|
||||
priv = NM_CONNECTIVITY_GET_PRIVATE (self);
|
||||
cb_data = user_data;
|
||||
|
||||
g_clear_object (&cb_data->concheck.resolve_cancellable);
|
||||
|
||||
if (!result) {
|
||||
/* Never mind. Just let do curl do its own resolving. */
|
||||
|
|
@ -657,69 +703,36 @@ resolve_cb (GObject *object, GAsyncResult *res, gpointer user_data)
|
|||
|
||||
addresses = g_variant_get_child_value (result, 0);
|
||||
no_addresses = g_variant_n_children (addresses);
|
||||
g_variant_unref (result);
|
||||
|
||||
for (i = 0; i < no_addresses; i++) {
|
||||
gs_unref_variant GVariant *address = NULL;
|
||||
char str_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
gs_free char *host_entry = NULL;
|
||||
const guchar *address_buf;
|
||||
|
||||
g_variant_get_child (addresses, i, "(ii@ay)", &ifindex, &addr_family, &address);
|
||||
|
||||
if ( cb_data->addr_family != AF_UNSPEC
|
||||
&& cb_data->addr_family != addr_family)
|
||||
continue;
|
||||
|
||||
address_buf = g_variant_get_fixed_array (address, &len, 1);
|
||||
if ( (addr_family == AF_INET && len != sizeof (struct in_addr))
|
||||
|| (addr_family == AF_INET6 && len != sizeof (struct in6_addr)))
|
||||
continue;
|
||||
|
||||
if ( (addr_family == AF_INET && len == sizeof (struct in_addr))
|
||||
|| (addr_family == AF_INET6 && len == sizeof (struct in6_addr))) {
|
||||
inet_ntop (addr_family, address_buf, str, sizeof (str));
|
||||
host = g_strdup_printf ("%s:%s:%s", priv->host, priv->port ?: "80", str);
|
||||
cb_data->concheck.hosts = curl_slist_append (cb_data->concheck.hosts, host);
|
||||
_LOG2T ("adding '%s' to curl resolve list", host);
|
||||
g_free (host);
|
||||
}
|
||||
|
||||
g_variant_unref (address);
|
||||
host_entry = g_strdup_printf ("%s:%s:%s",
|
||||
cb_data->concheck.con_config->host,
|
||||
cb_data->concheck.con_config->port ?: "80",
|
||||
nm_utils_inet_ntop (addr_family, address_buf, str_addr));
|
||||
cb_data->concheck.hosts = curl_slist_append (cb_data->concheck.hosts, host_entry);
|
||||
_LOG2T ("adding '%s' to curl resolve list", host_entry);
|
||||
}
|
||||
|
||||
g_variant_unref (addresses);
|
||||
do_curl_request (cb_data);
|
||||
}
|
||||
|
||||
#define SD_RESOLVED_DNS 1
|
||||
|
||||
static void
|
||||
resolved_proxy_created (GObject *object, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
NMConnectivityCheckHandle *cb_data = user_data;
|
||||
NMConnectivity *self;
|
||||
NMConnectivityPrivate *priv;
|
||||
gs_free_error GError *error = NULL;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
self = cb_data->self;
|
||||
priv = NM_CONNECTIVITY_GET_PRIVATE (self);
|
||||
|
||||
if (!proxy) {
|
||||
/* Log a warning, but still proceed without systemd-resolved */
|
||||
_LOG2D ("failed to connect to resolved via DBus: %s", error->message);
|
||||
do_curl_request (cb_data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_dbus_proxy_call (proxy,
|
||||
"ResolveHostname",
|
||||
g_variant_new ("(isit)",
|
||||
cb_data->concheck.ifindex,
|
||||
priv->host,
|
||||
(gint32) cb_data->addr_family,
|
||||
(guint64) SD_RESOLVED_DNS),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cb_data->concheck.resolve_cancellable,
|
||||
resolve_cb,
|
||||
cb_data);
|
||||
g_object_unref (proxy);
|
||||
|
||||
_LOG2D ("resolving '%s' for '%s' using systemd-resolved", priv->host, priv->uri);
|
||||
}
|
||||
#define SD_RESOLVED_DNS ((guint64) (1LL << 0))
|
||||
|
||||
NMConnectivityCheckHandle *
|
||||
nm_connectivity_check_start (NMConnectivity *self,
|
||||
|
|
@ -731,41 +744,86 @@ nm_connectivity_check_start (NMConnectivity *self,
|
|||
{
|
||||
NMConnectivityPrivate *priv;
|
||||
NMConnectivityCheckHandle *cb_data;
|
||||
static guint64 request_counter = 0;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTIVITY (self), NULL);
|
||||
g_return_val_if_fail (!iface || iface[0], NULL);
|
||||
g_return_val_if_fail (callback, NULL);
|
||||
|
||||
priv = NM_CONNECTIVITY_GET_PRIVATE (self);
|
||||
|
||||
cb_data = g_slice_new0 (NMConnectivityCheckHandle);
|
||||
cb_data->self = self;
|
||||
cb_data->request_counter = ++request_counter;
|
||||
c_list_link_tail (&priv->handles_lst_head, &cb_data->handles_lst);
|
||||
cb_data->callback = callback;
|
||||
cb_data->user_data = user_data;
|
||||
cb_data->completed_state = NM_CONNECTIVITY_UNKNOWN;
|
||||
cb_data->addr_family = addr_family;
|
||||
cb_data->concheck.con_config = _con_config_ref (priv->con_config);
|
||||
|
||||
if (iface)
|
||||
cb_data->ifspec = g_strdup_printf ("if!%s", iface);
|
||||
|
||||
#if WITH_CONCHECK
|
||||
if (iface && ifindex > 0 && priv->enabled && priv->host) {
|
||||
cb_data->concheck.ifindex = ifindex;
|
||||
cb_data->concheck.resolve_cancellable = g_cancellable_new ();
|
||||
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
||||
NULL,
|
||||
"org.freedesktop.resolve1",
|
||||
"/org/freedesktop/resolve1",
|
||||
"org.freedesktop.resolve1.Manager",
|
||||
cb_data->concheck.resolve_cancellable,
|
||||
resolved_proxy_created,
|
||||
cb_data);
|
||||
if ( iface
|
||||
&& ifindex > 0
|
||||
&& priv->enabled
|
||||
&& priv->uri_valid) {
|
||||
gboolean has_systemd_resolved;
|
||||
|
||||
cb_data->concheck.ch_ifindex = ifindex;
|
||||
|
||||
/* note that we pick up support for systemd-resolved right away when we need it.
|
||||
* We don't need to remember the setting, because we can (cheaply) check anew
|
||||
* on each request.
|
||||
*
|
||||
* Yes, this makes NMConnectivity singleton dependent on NMDnsManager singleton.
|
||||
* Well, not really: it makes connectivity-check-start dependent on NMDnsManager
|
||||
* which merely means, not to start a connectivity check, late during shutdown. */
|
||||
has_systemd_resolved = nm_dns_manager_has_systemd_resolved (nm_dns_manager_get ());
|
||||
|
||||
if (has_systemd_resolved) {
|
||||
GDBusConnection *dbus_connection;
|
||||
|
||||
dbus_connection = nm_dbus_manager_get_dbus_connection (nm_dbus_manager_get ());
|
||||
if (!dbus_connection) {
|
||||
/* we have no D-Bus connection? That might happen in configure and quit mode.
|
||||
*
|
||||
* Anyway, something is very odd, just fail connectivity check. */
|
||||
_LOG2D ("start fake request (fail due to no D-Bus connection)");
|
||||
cb_data->fail_reason_no_dbus_connection = TRUE;
|
||||
cb_data->timeout_id = g_idle_add (_idle_cb, cb_data);
|
||||
return cb_data;
|
||||
}
|
||||
|
||||
cb_data->concheck.resolve_cancellable = g_cancellable_new ();
|
||||
|
||||
g_dbus_connection_call (nm_dbus_manager_get_dbus_connection (nm_dbus_manager_get ()),
|
||||
"org.freedesktop.resolve1",
|
||||
"/org/freedesktop/resolve1",
|
||||
"org.freedesktop.resolve1.Manager",
|
||||
"ResolveHostname",
|
||||
g_variant_new ("(isit)",
|
||||
(gint32) cb_data->concheck.ch_ifindex,
|
||||
cb_data->concheck.con_config->host,
|
||||
(gint32) cb_data->addr_family,
|
||||
SD_RESOLVED_DNS),
|
||||
G_VARIANT_TYPE ("(a(iiay)st)"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cb_data->concheck.resolve_cancellable,
|
||||
resolve_cb,
|
||||
cb_data);
|
||||
_LOG2D ("start request to '%s' (try resolving '%s' using systemd-resolved)",
|
||||
cb_data->concheck.con_config->uri,
|
||||
cb_data->concheck.con_config->host);
|
||||
} else {
|
||||
_LOG2D ("start request to '%s' (systemd-resolved not available)",
|
||||
cb_data->concheck.con_config->uri);
|
||||
do_curl_request (cb_data);
|
||||
}
|
||||
|
||||
_LOG2D ("start request to '%s'", priv->uri);
|
||||
return cb_data;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -840,7 +898,7 @@ host_and_port_from_uri (const char *uri, char **host, char **port)
|
|||
}
|
||||
if (host_len == 0)
|
||||
return FALSE;
|
||||
*host = strndup (host_begin, host_len);
|
||||
*host = g_strndup (host_begin, host_len);
|
||||
|
||||
/* port */
|
||||
if (*p++ == ':') {
|
||||
|
|
@ -850,7 +908,7 @@ host_and_port_from_uri (const char *uri, char **host, char **port)
|
|||
p++;
|
||||
}
|
||||
if (port_len)
|
||||
*port = strndup (port_begin, port_len);
|
||||
*port = g_strndup (port_begin, port_len);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -860,43 +918,74 @@ static void
|
|||
update_config (NMConnectivity *self, NMConfigData *config_data)
|
||||
{
|
||||
NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (self);
|
||||
const char *uri, *response;
|
||||
guint interval;
|
||||
gboolean enabled;
|
||||
gboolean changed = FALSE;
|
||||
const char *cur_uri = priv->con_config ? priv->con_config->uri : NULL;
|
||||
const char *cur_response = priv->con_config ? priv->con_config->response : NULL;
|
||||
const char *new_response;
|
||||
const char *new_uri;
|
||||
gboolean new_uri_valid = priv->uri_valid;
|
||||
gboolean new_host_port = FALSE;
|
||||
gs_free char *new_host = NULL;
|
||||
gs_free char *new_port = NULL;
|
||||
|
||||
/* Set the URI. */
|
||||
uri = nm_config_data_get_connectivity_uri (config_data);
|
||||
if (uri && !*uri)
|
||||
uri = NULL;
|
||||
changed = g_strcmp0 (uri, priv->uri) != 0;
|
||||
if (uri) {
|
||||
char *scheme = g_uri_parse_scheme (uri);
|
||||
new_uri = nm_config_data_get_connectivity_uri (config_data);
|
||||
if (!nm_streq0 (new_uri, cur_uri)) {
|
||||
|
||||
if (!scheme) {
|
||||
_LOGE ("invalid URI '%s' for connectivity check.", uri);
|
||||
uri = NULL;
|
||||
} else if (strcasecmp (scheme, "https") == 0) {
|
||||
_LOGW ("use of HTTPS for connectivity checking is not reliable and is discouraged (URI: %s)", uri);
|
||||
} else if (strcasecmp (scheme, "http") != 0) {
|
||||
_LOGE ("scheme of '%s' uri doesn't use a scheme that is allowed for connectivity check.", uri);
|
||||
uri = NULL;
|
||||
new_uri_valid = (new_uri && *new_uri);
|
||||
if (new_uri_valid) {
|
||||
gs_free char *scheme = g_uri_parse_scheme (new_uri);
|
||||
gboolean is_https = FALSE;
|
||||
|
||||
if (!scheme) {
|
||||
_LOGE ("invalid URI '%s' for connectivity check.", new_uri);
|
||||
new_uri_valid = FALSE;
|
||||
} else if (g_ascii_strcasecmp (scheme, "https") == 0) {
|
||||
_LOGW ("use of HTTPS for connectivity checking is not reliable and is discouraged (URI: %s)", new_uri);
|
||||
is_https = TRUE;
|
||||
} else if (g_ascii_strcasecmp (scheme, "http") != 0) {
|
||||
_LOGE ("scheme of '%s' uri doesn't use a scheme that is allowed for connectivity check.", new_uri);
|
||||
new_uri_valid = FALSE;
|
||||
}
|
||||
if (new_uri_valid) {
|
||||
new_host_port = TRUE;
|
||||
if (!host_and_port_from_uri (new_uri, &new_host, &new_port)) {
|
||||
_LOGE ("cannot parse host and port from '%s'", new_uri);
|
||||
new_uri_valid = FALSE;
|
||||
} else if (!new_port && is_https)
|
||||
new_port = g_strdup ("443");
|
||||
}
|
||||
}
|
||||
|
||||
if (scheme)
|
||||
g_free (scheme);
|
||||
}
|
||||
if (changed) {
|
||||
g_free (priv->uri);
|
||||
priv->uri = g_strdup (uri);
|
||||
|
||||
g_clear_pointer (&priv->host, g_free);
|
||||
g_clear_pointer (&priv->port, g_free);
|
||||
if (uri)
|
||||
host_and_port_from_uri (uri, &priv->host, &priv->port);
|
||||
if ( new_uri_valid
|
||||
|| priv->uri_valid != new_uri_valid)
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
/* Set the interval. */
|
||||
new_response = nm_config_data_get_connectivity_response (config_data);
|
||||
if (!nm_streq0 (new_response, cur_response))
|
||||
changed = TRUE;
|
||||
|
||||
if ( !priv->con_config
|
||||
|| !nm_streq0 (new_uri, priv->con_config->uri)
|
||||
|| !nm_streq0 (new_response, priv->con_config->response)) {
|
||||
if (!new_host_port) {
|
||||
new_host = priv->con_config ? g_strdup (priv->con_config->host) : NULL;
|
||||
new_port = priv->con_config ? g_strdup (priv->con_config->port) : NULL;
|
||||
}
|
||||
_con_config_unref (priv->con_config);
|
||||
priv->con_config = g_slice_new (ConConfig);
|
||||
*priv->con_config = (ConConfig) {
|
||||
.ref_count = 1,
|
||||
.uri = g_strdup (new_uri),
|
||||
.response = g_strdup (new_response),
|
||||
.host = g_steal_pointer (&new_host),
|
||||
.port = g_steal_pointer (&new_port),
|
||||
};
|
||||
}
|
||||
priv->uri_valid = new_uri_valid;
|
||||
|
||||
interval = nm_config_data_get_connectivity_interval (config_data);
|
||||
interval = MIN (interval, (7 * 24 * 3600));
|
||||
if (priv->interval != interval) {
|
||||
|
|
@ -906,7 +995,7 @@ update_config (NMConnectivity *self, NMConfigData *config_data)
|
|||
|
||||
enabled = FALSE;
|
||||
#if WITH_CONCHECK
|
||||
if ( priv->uri
|
||||
if ( priv->uri_valid
|
||||
&& priv->interval)
|
||||
enabled = nm_config_data_get_connectivity_enabled (config_data);
|
||||
#endif
|
||||
|
|
@ -916,16 +1005,6 @@ update_config (NMConnectivity *self, NMConfigData *config_data)
|
|||
changed = TRUE;
|
||||
}
|
||||
|
||||
/* Set the response. */
|
||||
response = nm_config_data_get_connectivity_response (config_data);
|
||||
if (!nm_streq0 (response, priv->response)) {
|
||||
/* a response %NULL means, NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE. Any other response
|
||||
* (including "") is accepted. */
|
||||
g_free (priv->response);
|
||||
priv->response = g_strdup (response);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
g_signal_emit (self, signals[CONFIG_CHANGED], 0);
|
||||
}
|
||||
|
|
@ -984,10 +1063,7 @@ dispose (GObject *object)
|
|||
handles_lst)))
|
||||
cb_data_complete (cb_data, NM_CONNECTIVITY_DISPOSING, "shutting down");
|
||||
|
||||
g_clear_pointer (&priv->uri, g_free);
|
||||
g_clear_pointer (&priv->host, g_free);
|
||||
g_clear_pointer (&priv->port, g_free);
|
||||
g_clear_pointer (&priv->response, g_free);
|
||||
nm_clear_pointer (&priv->con_config, _con_config_unref);
|
||||
|
||||
#if WITH_CONCHECK
|
||||
curl_global_cleanup ();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,21 @@
|
|||
|
||||
#include "nm-dbus-interface.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline int
|
||||
nm_connectivity_state_cmp (NMConnectivityState a, NMConnectivityState b)
|
||||
{
|
||||
if (a == NM_CONNECTIVITY_PORTAL && b == NM_CONNECTIVITY_LIMITED)
|
||||
return 1;
|
||||
if (b == NM_CONNECTIVITY_PORTAL && a == NM_CONNECTIVITY_LIMITED)
|
||||
return -1;
|
||||
NM_CMP_DIRECT (a, b);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_CONNECTIVITY_ERROR ((NMConnectivityState) -1)
|
||||
#define NM_CONNECTIVITY_FAKE ((NMConnectivityState) -2)
|
||||
#define NM_CONNECTIVITY_CANCELLED ((NMConnectivityState) -3)
|
||||
|
|
|
|||
|
|
@ -1470,6 +1470,14 @@ static const GDBusInterfaceInfo interface_info_objmgr = NM_DEFINE_GDBUS_INTERFAC
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
GDBusConnection *
|
||||
nm_dbus_manager_get_dbus_connection (NMDBusManager *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), NULL);
|
||||
|
||||
return NM_DBUS_MANAGER_GET_PRIVATE (self)->connection;
|
||||
}
|
||||
|
||||
void
|
||||
nm_dbus_manager_start (NMDBusManager *self,
|
||||
NMDBusManagerSetPropertyHandler set_property_handler,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ typedef void (*NMDBusManagerSetPropertyHandler) (NMDBusObject *obj,
|
|||
|
||||
gboolean nm_dbus_manager_acquire_bus (NMDBusManager *self);
|
||||
|
||||
GDBusConnection *nm_dbus_manager_get_dbus_connection (NMDBusManager *self);
|
||||
|
||||
void nm_dbus_manager_start (NMDBusManager *self,
|
||||
NMDBusManagerSetPropertyHandler set_property_handler,
|
||||
gpointer set_property_handler_data);
|
||||
|
|
|
|||
100
src/nm-manager.c
100
src/nm-manager.c
|
|
@ -2843,41 +2843,91 @@ device_realized (NMDevice *device,
|
|||
_emit_device_added_removed (self, device, nm_device_is_real (device));
|
||||
}
|
||||
|
||||
static NMConnectivityState
|
||||
_get_best_connectivity (NMManager *self, int addr_family)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
NMConnectivityState best_state;
|
||||
NMDevice *dev;
|
||||
gint64 best_metric;
|
||||
|
||||
if (addr_family == AF_UNSPEC) {
|
||||
best_state = _get_best_connectivity (self, AF_INET);
|
||||
if (nm_connectivity_state_cmp (best_state, NM_CONNECTIVITY_FULL) >= 0) {
|
||||
/* already FULL IPv4 connectivity. No need to check IPv6, it doesn't get
|
||||
* better. */
|
||||
return best_state;
|
||||
}
|
||||
return NM_MAX_WITH_CMP (nm_connectivity_state_cmp,
|
||||
best_state,
|
||||
_get_best_connectivity (self, AF_INET6));
|
||||
}
|
||||
|
||||
nm_assert_addr_family (addr_family);
|
||||
|
||||
best_state = NM_CONNECTIVITY_UNKNOWN;
|
||||
best_metric = G_MAXINT64;
|
||||
c_list_for_each_entry (dev, &priv->devices_lst_head, devices_lst) {
|
||||
const NMPObject *r;
|
||||
NMConnectivityState state;
|
||||
gint64 metric;
|
||||
|
||||
r = nm_device_get_best_default_route (dev, addr_family);
|
||||
if (r) {
|
||||
metric = nm_utils_ip_route_metric_normalize (addr_family,
|
||||
NMP_OBJECT_CAST_IP_ROUTE (r)->metric);
|
||||
} else {
|
||||
/* if all devices have no default-route, we still include the best
|
||||
* of all connectivity state of all the devices. */
|
||||
metric = G_MAXINT64;
|
||||
}
|
||||
|
||||
if (metric > best_metric) {
|
||||
/* we already have a default route with better metric. The connectivity state
|
||||
* of this device is irreleavnt. */
|
||||
continue;
|
||||
}
|
||||
|
||||
state = nm_device_get_connectivity_state (dev, addr_family);
|
||||
if (metric < best_metric) {
|
||||
/* this device has a better default route. It wins. */
|
||||
best_metric = metric;
|
||||
best_state = state;
|
||||
} else {
|
||||
best_state = NM_MAX_WITH_CMP (nm_connectivity_state_cmp,
|
||||
best_state,
|
||||
state);
|
||||
}
|
||||
|
||||
if (nm_connectivity_state_cmp (best_state, NM_CONNECTIVITY_FULL) >= 0) {
|
||||
/* it doesn't get better than FULL. We are done. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return best_state;
|
||||
}
|
||||
|
||||
static void
|
||||
device_connectivity_changed (NMDevice *device,
|
||||
GParamSpec *pspec,
|
||||
NMManager *self)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
NMConnectivityState best_state = NM_CONNECTIVITY_UNKNOWN;
|
||||
NMConnectivityState state;
|
||||
NMDevice *dev;
|
||||
NMConnectivityState best_state;
|
||||
|
||||
best_state = nm_device_get_connectivity_state (device);
|
||||
if (best_state < NM_CONNECTIVITY_FULL) {
|
||||
c_list_for_each_entry (dev, &priv->devices_lst_head, devices_lst) {
|
||||
state = nm_device_get_connectivity_state (dev);
|
||||
if (state <= best_state)
|
||||
continue;
|
||||
best_state = state;
|
||||
if (best_state >= NM_CONNECTIVITY_FULL) {
|
||||
/* it doesn't get better than this. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nm_assert (best_state <= NM_CONNECTIVITY_FULL);
|
||||
best_state = _get_best_connectivity (self, AF_UNSPEC);
|
||||
if (best_state == priv->connectivity_state)
|
||||
return;
|
||||
|
||||
if (best_state != priv->connectivity_state) {
|
||||
priv->connectivity_state = best_state;
|
||||
priv->connectivity_state = best_state;
|
||||
|
||||
_LOGD (LOGD_CORE, "connectivity checking indicates %s",
|
||||
nm_connectivity_state_to_string (priv->connectivity_state));
|
||||
_LOGD (LOGD_CORE, "connectivity checking indicates %s",
|
||||
nm_connectivity_state_to_string (priv->connectivity_state));
|
||||
|
||||
nm_manager_update_state (self);
|
||||
_notify (self, PROP_CONNECTIVITY);
|
||||
nm_dispatcher_call_connectivity (priv->connectivity_state, NULL, NULL, NULL);
|
||||
}
|
||||
nm_manager_update_state (self);
|
||||
_notify (self, PROP_CONNECTIVITY);
|
||||
nm_dispatcher_call_connectivity (priv->connectivity_state, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "systemd/nm-sd-utils.h"
|
||||
|
||||
#include "dns/nm-dns-manager.h"
|
||||
#include "nm-connectivity.h"
|
||||
|
||||
#include "nm-test-utils-core.h"
|
||||
|
||||
|
|
@ -2039,6 +2040,60 @@ test_nm_utils_dhcp_client_id_systemd_node_specific (gconstpointer test_data)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_connectivity_state_cmp (void)
|
||||
{
|
||||
NMConnectivityState a;
|
||||
|
||||
#define _cmp(a, b, cmp) \
|
||||
G_STMT_START { \
|
||||
const NMConnectivityState _a = (a); \
|
||||
const NMConnectivityState _b = (b); \
|
||||
const int _cmp = (cmp); \
|
||||
\
|
||||
g_assert (NM_IN_SET (_cmp, -1, 0, 1)); \
|
||||
g_assert_cmpint (nm_connectivity_state_cmp (_a, _b), ==, _cmp); \
|
||||
g_assert_cmpint (nm_connectivity_state_cmp (_b, _a), ==, -_cmp); \
|
||||
} G_STMT_END
|
||||
|
||||
for (a = NM_CONNECTIVITY_UNKNOWN; a <= NM_CONNECTIVITY_FULL; a++)
|
||||
_cmp (a, a, 0);
|
||||
|
||||
_cmp (NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_UNKNOWN, 0);
|
||||
_cmp (NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_NONE, -1);
|
||||
_cmp (NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_LIMITED, -1);
|
||||
_cmp (NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_PORTAL, -1);
|
||||
_cmp (NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, -1);
|
||||
|
||||
_cmp (NM_CONNECTIVITY_NONE, NM_CONNECTIVITY_UNKNOWN, 1);
|
||||
_cmp (NM_CONNECTIVITY_NONE, NM_CONNECTIVITY_NONE, 0);
|
||||
_cmp (NM_CONNECTIVITY_NONE, NM_CONNECTIVITY_LIMITED, -1);
|
||||
_cmp (NM_CONNECTIVITY_NONE, NM_CONNECTIVITY_PORTAL, -1);
|
||||
_cmp (NM_CONNECTIVITY_NONE, NM_CONNECTIVITY_FULL, -1);
|
||||
|
||||
_cmp (NM_CONNECTIVITY_LIMITED, NM_CONNECTIVITY_UNKNOWN, 1);
|
||||
_cmp (NM_CONNECTIVITY_LIMITED, NM_CONNECTIVITY_NONE, 1);
|
||||
_cmp (NM_CONNECTIVITY_LIMITED, NM_CONNECTIVITY_LIMITED, 0);
|
||||
_cmp (NM_CONNECTIVITY_LIMITED, NM_CONNECTIVITY_PORTAL, -1);
|
||||
_cmp (NM_CONNECTIVITY_LIMITED, NM_CONNECTIVITY_FULL, -1);
|
||||
|
||||
_cmp (NM_CONNECTIVITY_PORTAL, NM_CONNECTIVITY_UNKNOWN, 1);
|
||||
_cmp (NM_CONNECTIVITY_PORTAL, NM_CONNECTIVITY_NONE, 1);
|
||||
_cmp (NM_CONNECTIVITY_PORTAL, NM_CONNECTIVITY_LIMITED, 1);
|
||||
_cmp (NM_CONNECTIVITY_PORTAL, NM_CONNECTIVITY_PORTAL, 0);
|
||||
_cmp (NM_CONNECTIVITY_PORTAL, NM_CONNECTIVITY_FULL, -1);
|
||||
|
||||
_cmp (NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN, 1);
|
||||
_cmp (NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_NONE, 1);
|
||||
_cmp (NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_LIMITED, 1);
|
||||
_cmp (NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_PORTAL, 1);
|
||||
_cmp (NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_FULL, 0);
|
||||
|
||||
#undef _cmp
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
int
|
||||
|
|
@ -2094,6 +2149,8 @@ main (int argc, char **argv)
|
|||
g_test_add_data_func ("/general/nm_utils_dhcp_client_id_systemd_node_specific/0", GINT_TO_POINTER (0), test_nm_utils_dhcp_client_id_systemd_node_specific);
|
||||
g_test_add_data_func ("/general/nm_utils_dhcp_client_id_systemd_node_specific/1", GINT_TO_POINTER (1), test_nm_utils_dhcp_client_id_systemd_node_specific);
|
||||
|
||||
g_test_add_func ("/core/general/test_connectivity_state_cmp", test_connectivity_state_cmp);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue