总结
gdb gnome-control-center
nm_device_get_state 返回不正常,这个的返回值会用来刷新图标网络状态
bpftrace -e 'uretprobe:/usr/lib64/libnm.so:nm_device_get_state {printf("%d\n", retval)}'
定位到/usr/lib64/libnm.so中
gdb NetworkManager
根据下面的日志
[1704866285.5266] device[4ab3b1692f22a84b] (ens160): queue-state[unavailable, reason:carrier-changed, id:198]: queue state change
Jan 09 21:58:05 localhost.localdomain NetworkManager[6501]: <debug> [1704866285.5267] device[4ab3b1692f22a84b] (ens160): queue-state[unavailable, reason:carrier-changed, id:198]: change state
Jan 09 21:58:05 localhost.localdomain NetworkManager[6501]: <info> [1704866285.5267] device (ens160): state change: activated -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed')
定位到
/usr/src/debug/NetworkManager-1.36.0-10.0.1.cy8.x86_64/src/core/devices/nm-device.c
static gboolean
carrier_disconnected_action_cb(gpointer user_data)
{
NMDevice *self = NM_DEVICE(user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
_LOGD(LOGD_DEVICE,
"carrier: link disconnected (calling deferred action) (id=%u)",
priv->carrier_defer_id);
priv->carrier_defer_id = 0;
carrier_changed(self, FALSE);
return FALSE;
}
看到信息
$3 = {
device_link_changed_id = 0,
device_ip_link_changed_id = 0,
state = NM_DEVICE_STATE_ACTIVATED,
state_reason = NM_DEVICE_STATE_REASON_NONE,
queued_state = {
id = 0,
state = NM_DEVICE_STATE_ACTIVATED,
reason = NM_DEVICE_STATE_REASON_NONE
},
pending_actions = {
arr = 0x557685adcfd0,
len = 0,
alloc = 4
},
parent_device = {
{
obj = 0x0,
_obj = 0x0
},
_notify_target = 0x557685ad9620,
_notify_pspec = 0x557685ac7060,
_notify_signal_id = 0,
{
visible = false,
_visible = false
}
},
udi = 0x557685ad77b0 "/sys/devices/pci0000:00/0000:00:11.0/0000:02:01.0/net/ens33",
path = 0x557685ad71b0 "pci-0000:02:01.0",
{
iface = 0x557685ad5320 "ens33",
iface_ = 0x557685ad5320 "ens33"
},
{
ip_iface = 0x0,
ip_iface_ = 0x0
},
{
l3cfg = 0x557685a3b4f0,
l3cfg_ = 0x557685a3b4f0
},
{
{
l3ipdata_6 = {
ip_config = 0x557685aca0e0
},
l3ipdata_4 = {
ip_config = 0x557685aca040
}
},
l3ipdata_x = {{
ip_config = 0x557685aca0e0
}, {
ip_config = 0x557685aca040
}}
},
l3cfg_commit_type = 0x557685a680a0,
{
ifindex = 3,
ifindex_ = 3
},
{
ip_ifindex = 0,
ip_ifindex_ = 0
},
l3cds = {{
d = 0x0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x557685b2e1a0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x0
}, {
d = 0x557685b12e20
}},
parent_ifindex = 0,
auth_retries = -1,
{
{
hostname_resolver_6 = 0x0,
hostname_resolver_4 = 0x0
},
hostname_resolver_x = {0x0, 0x0}
},
{
hw_addr_len = 6 '\006',
hw_addr_len_ = 6 '\006'
},
hw_addr_type = HW_ADDR_TYPE_UNSET,
real = true,
type = NM_DEVICE_TYPE_ETHERNET,
type_desc = 0x557685ace580 "Ethernet",
link_type = NM_LINK_TYPE_ETHERNET,
capabilities = (NM_DEVICE_CAP_NM_SUPPORTED | NM_DEVICE_CAP_CARRIER_DETECT),
driver = 0x557685ad9870 "e1000",
driver_version = 0x557685ad41d0 "5.10.92-14.xc.cy8.x86_64",
firmware_version = 0x557685ad9cb0 "",
rfkill_type = RFKILL_TYPE_UNKNOWN,
firmware_missing = false,
nm_plugin_missing = false,
hw_addr_perm_fake = false,
in_state_changed = 0 '\000',
current_stable_id_type = NM_UTILS_STABLE_TYPE_UUID,
activation_state_preserve_external_ports = false,
nm_owned = false,
assume_state_guess_assume = false,
assume_state_connection_uuid = 0x0,
udi_id = 0,
available_connections = 0x557685a5cb00,
hw_addr = 0x557685ad42d0 "00:0C:29:FD:76:C5",
hw_addr_perm = 0x557685ad97d0 "00:0C:29:FD:76:C5",
hw_addr_initial = 0x557685ad9890 "00:0C:29:FD:76:C5",
physical_port_id = 0x0,
dev_id = 0,
unmanaged_mask = 121,
unmanaged_flags = NM_UNMANAGED_NONE,
delete_on_deactivate_data = 0x0,
deactivating_cancellable = 0x0,
queued_act_request = 0x0,
queued_act_request_is_waiting_for_carrier = false,
act_request = {
{
obj = 0x557685b09400,
_obj = 0x557685b09400
},
_notify_target = 0x557685ad9620,
_notify_pspec = 0x557685abb620,
_notify_signal_id = 454,
{
visible = true,
_visible = true
}
},
activation_idle_source = 0x0,
activation_func = 0x0,
recheck_assume_id = 0,
recheck_available = {
call_id = 0,
available_reason = NM_DEVICE_STATE_REASON_NONE,
unavailable_reason = NM_DEVICE_STATE_REASON_NONE
},
dispatcher = {
call_id = 0x0,
post_state = NM_DEVICE_STATE_UNKNOWN,
post_state_reason = NM_DEVICE_STATE_REASON_NONE
},
link_connected_id = 0,
link_disconnected_id = 0,
carrier_defer_id = 12356,
carrier_wait_id = 0,
config_changed_id = 186,
ifindex_changed_id = 0,
mtu = 1500,
ip6_mtu = 0,
mtu_initial = 0,
ip6_mtu_initial = 0,
mtu_source = NM_DEVICE_MTU_SOURCE_NONE,
v4_route_table = 0,
v6_route_table = 0,
carrier_wait_until_ms = 0,
{
{
l3config_merge_flags_6 = NM_L3_CONFIG_MERGE_FLAGS_NONE,
l3config_merge_flags_4 = NM_L3_CONFIG_MERGE_FLAGS_NONE
},
l3config_merge_flags_x = {NM_L3_CONFIG_MERGE_FLAGS_NONE, NM_L3_CONFIG_MERGE_FLAGS_NONE}
},
{
sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_MANAGED,
sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_MANAGED
},
carrier = false,
ignore_carrier = false,
up = true,
v4_route_table_initialized = true,
v6_route_table_initialized = true,
l3config_merge_flags_has = true,
v4_route_table_all_sync_before = false,
v6_route_table_all_sync_before = false,
autoconnect_blocked_flags = NM_DEVICE_AUTOCONNECT_BLOCKED_NONE,
is_enslaved = false,
device_link_changed_down = false,
concheck_rp_filter_checked = true,
tc_committed = true,
stage1_sriov_state = NM_DEVICE_STAGE_STATE_COMPLETED,
current_stable_id = 0x557685b27e70 "9a1f4a47-5430-4e10-b58d-7cccc858bb5b",
pacrunner_conf_id = 0x557685b00380,
ip_data = {
{
state = NM_DEVICE_IP_STATE_READY,
state_ = NM_DEVICE_IP_STATE_READY
}
},
{
{
ip_data_6 = {
check_async_source = 0x0,
req_timeout_source = 0x0,
{
state = NM_DEVICE_IP_STATE_PENDING,
state_ = NM_DEVICE_IP_STATE_PENDING
},
wait_for_carrier = false,
wait_for_ports = false,
is_disabled = false,
is_ignore = false,
do_reapply = false
},
ip_data_4 = {
check_async_source = 0x0,
req_timeout_source = 0x0,
{
state = NM_DEVICE_IP_STATE_READY,
state_ = NM_DEVICE_IP_STATE_READY
},
wait_for_carrier = false,
wait_for_ports = false,
is_disabled = false,
is_ignore = false,
do_reapply = false
}
},
ip_data_x = {{
check_async_source = 0x0,
req_timeout_source = 0x0,
{
state = NM_DEVICE_IP_STATE_PENDING,
state_ = NM_DEVICE_IP_STATE_PENDING
},
wait_for_carrier = false,
wait_for_ports = false,
is_disabled = false,
is_ignore = false,
do_reapply = false
}, {
check_async_source = 0x0,
req_timeout_source = 0x0,
{
state = NM_DEVICE_IP_STATE_READY,
state_ = NM_DEVICE_IP_STATE_READY
},
wait_for_carrier = false,
wait_for_ports = false,
is_disabled = false,
is_ignore = false,
do_reapply = false
}}
},
ipmanual_data = {
carrier_timeout = 0x0,
{
{
state_6 = NM_DEVICE_IP_STATE_READY,
state_4 = NM_DEVICE_IP_STATE_READY
},
state_x = {NM_DEVICE_IP_STATE_READY, NM_DEVICE_IP_STATE_READY}
},
carrier_timeout_expired = false
},
{
{
ipdhcp_data_6 = {
client = 0x0,
config = 0x0,
notify_sigid = 0,
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {<No data fields>},
v6 = {
needed_prefixes = 0,
mode = NM_NDISC_DHCP_LEVEL_NONE
}
}
},
ipdhcp_data_4 = {
client = 0x557685b09550,
config = 0x557685b10d90,
notify_sigid = 457,
state = NM_DEVICE_IP_STATE_READY,
{
v4 = {<No data fields>},
v6 = {
needed_prefixes = 0,
mode = NM_NDISC_DHCP_LEVEL_UNKNOWN
}
}
}
},
ipdhcp_data_x = {{
client = 0x0,
config = 0x0,
notify_sigid = 0,
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {<No data fields>},
v6 = {
needed_prefixes = 0,
mode = NM_NDISC_DHCP_LEVEL_NONE
}
}
}, {
client = 0x557685b09550,
config = 0x557685b10d90,
notify_sigid = 457,
state = NM_DEVICE_IP_STATE_READY,
{
v4 = {<No data fields>},
v6 = {
needed_prefixes = 0,
mode = NM_NDISC_DHCP_LEVEL_UNKNOWN
}
}
}}
},
ipac6_data = {
ndisc = 0x557685a5e640,
ndisc_grace_source = 0x557685aa6900,
ndisc_changed_id = 467,
ndisc_timeout_id = 468,
state = NM_DEVICE_IP_STATE_PENDING,
l3cd = 0x0
},
{
{
ipll_data_6 = {
state = NM_DEVICE_IP_STATE_READY,
{
v4 = {
ipv4ll = 0x557685b0eda0,
ipv4ll_registation = 0x0,
timeout_source = 0x80fe00000002
},
v6 = {
ipv6ll = 0x557685b0eda0,
retry_source = 0x0,
llstate = NM_L3_IPV6LL_STATE_READY,
lladdr = {
__in6_u = {
__u6_addr8 = "\376\200\000\000\000\000\000\000\317M|\225\260\031\320", <incomplete sequence \375>,
__u6_addr16 = {33022, 0, 0, 0, 19919, 38268, 6576, 64976},
__u6_addr32 = {33022, 0, 2507951567, 4258273712}
}
}
}
}
},
ipll_data_4 = {
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
ipv4ll = 0x0,
ipv4ll_registation = 0x0,
timeout_source = 0x0
},
v6 = {
ipv6ll = 0x0,
retry_source = 0x0,
llstate = NM_L3_IPV6LL_STATE_STARTING,
lladdr = {
__in6_u = {
__u6_addr8 = '\000' <repeats 15 times>,
__u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0},
__u6_addr32 = {0, 0, 0, 0}
}
}
}
}
}
},
ipll_data_x = {{
state = NM_DEVICE_IP_STATE_READY,
{
v4 = {
ipv4ll = 0x557685b0eda0,
ipv4ll_registation = 0x0,
timeout_source = 0x80fe00000002
},
v6 = {
ipv6ll = 0x557685b0eda0,
retry_source = 0x0,
llstate = NM_L3_IPV6LL_STATE_READY,
lladdr = {
__in6_u = {
__u6_addr8 = "\376\200\000\000\000\000\000\000\317M|\225\260\031\320", <incomplete sequence \375>,
__u6_addr16 = {33022, 0, 0, 0, 19919, 38268, 6576, 64976},
__u6_addr32 = {33022, 0, 2507951567, 4258273712}
}
}
}
}
}, {
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
ipv4ll = 0x0,
ipv4ll_registation = 0x0,
timeout_source = 0x0
},
v6 = {
ipv6ll = 0x0,
retry_source = 0x0,
llstate = NM_L3_IPV6LL_STATE_STARTING,
lladdr = {
__in6_u = {
__u6_addr8 = '\000' <repeats 15 times>,
__u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0},
__u6_addr32 = {0, 0, 0, 0}
}
}
}
}
}}
},
{
{
ipshared_data_6 = {
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
dnsmasq_manager = 0x0,
shared_ip_handle = 0x0,
firewall_config = 0x0,
dnsmasq_state_id = 0,
l3cd = 0x0
},
v6 = {<No data fields>}
}
},
ipshared_data_4 = {
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
dnsmasq_manager = 0x0,
shared_ip_handle = 0x0,
firewall_config = 0x0,
dnsmasq_state_id = 0,
l3cd = 0x0
},
v6 = {<No data fields>}
}
}
},
ipshared_data_x = {{
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
dnsmasq_manager = 0x0,
shared_ip_handle = 0x0,
firewall_config = 0x0,
dnsmasq_state_id = 0,
l3cd = 0x0
},
v6 = {<No data fields>}
}
}, {
state = NM_DEVICE_IP_STATE_NONE,
{
v4 = {
dnsmasq_manager = 0x0,
shared_ip_handle = 0x0,
firewall_config = 0x0,
dnsmasq_state_id = 0,
l3cd = 0x0
},
v6 = {<No data fields>}
}
}}
},
{
{
ipdev_data_6 = {
state = NM_DEVICE_IP_STATE_NONE,
failed_reason = NM_DEVICE_STATE_REASON_NONE
},
ipdev_data_4 = {
state = NM_DEVICE_IP_STATE_NONE,
failed_reason = NM_DEVICE_STATE_REASON_NONE
}
},
ipdev_data_x = {{
state = NM_DEVICE_IP_STATE_NONE,
failed_reason = NM_DEVICE_STATE_REASON_NONE
}, {
state = NM_DEVICE_IP_STATE_NONE,
failed_reason = NM_DEVICE_STATE_REASON_NONE
}}
},
ipdev_data_unspec = {
state = NM_DEVICE_IP_STATE_NONE,
failed_reason = NM_DEVICE_STATE_REASON_NONE
},
addrgenmode6_data = {
previous_mode_val = 1 '\001',
previous_mode_has = true
},
gw_ping = {
log_domain = LOGD_NONE,
timeout = 0,
watch = 0,
pid = 0,
binary = 0x0,
address = 0x0,
deadline = 0
},
fw_state = FIREWALL_STATE_INITIALIZED,
fw_mgr = 0x557685a36e30,
fw_call = 0x0,
ip6_saved_properties = 0x7f9ce40070c0,
ethtool_state = 0x0,
master = 0x0,
master_ready_id = 0,
master_ifindex = 0,
slaves = {
next = 0x557685ad9530,
prev = 0x557685ad9530
},
metered = NM_METERED_GUESS_NO,
settings = 0x557685a5e030,
manager = 0x557685a5b000,
netns = 0x7f9ce4007360,
lldp_listener = 0x0,
concheck_mgr = 0x7f9ce4006940,
concheck_lst_head = {
next = 0x557685ad9570,
prev = 0x557685ad9570
},
concheck_x = {{
p_cur_id = 12370,
p_max_interval = 300,
p_cur_interval = 8,
p_cur_basetime_ns = 298728545173,
state = NM_CONNECTIVITY_NONE
}, {
p_cur_id = 12373,
p_max_interval = 300,
p_cur_interval = 8,
p_cur_basetime_ns = 300728521250,
state = NM_CONNECTIVITY_NONE
}},
check_delete_unrealized_id = 0,
interface_flags = 1,
sriov = {
pending = 0x0,
next = 0x0
},
sriov_reset_pending = 0,
stats = {
timeout_source = 0x0,
refresh_rate_ms = 0,
tx_bytes = 5858,
rx_bytes = 3146
},
mtu_force_set_done = false,
needs_ip6_subnet = false,
promisc_reset = NM_OPTION_BOOL_DEFAULT,
ports_variant = 0x557685acf070,
prop_ip_iface = 0x557685ae8450 "ens33"
}
通过和正常的centos情况比对,priv->ignore_carrier
属性不正常,正常时此属性为false,不正常时为true,priv->carrire
属性标识是否链接,此属性正常
搜索资料
- NetworkManager does not react to link state changes in RHEL7, 8 and 9 Server
原来是安装NetworkManager-config-server
包后会默认配置忽略carrier
问题解决