使用 SynCE 时 Debian PDA / HandHeld 之间的 PPP 连接丢失

使用 SynCE 时 Debian  PDA / HandHeld 之间的 PPP 连接丢失

我目前能够将手持设备连接到运行 Linux 的 PC,该 PC 安装了非常老的 Ubuntu 14.04,并将 SynCE 的存储库 PPA 添加到源列表中。现在,目标是更新操作系统,我选择了 Debian Buster,我已成功安装了来自同一存储库的 DEB 软件包,该软件包是针对 Ubuntu Xenial 的版本。

在 Debian 中,USB 串行设备被识别并连接到 ttyUSB 总线,获取 IP 地址并在几秒钟后断开连接(两秒,最多三秒)。我进行了 PPP 调试(选项调试转储和 kdebug),一切似乎正常:

pppd options in effect:
debug       # (from /etc/ppp/options)
kdebug 7        # (from /etc/ppp/options)
logfile /tmp/pppd.log       # (from /etc/ppp/options)
linkname synce-device0      # (from command line)
dump        # (from /etc/ppp/options)
noauth      # (from command line)
/dev/ttyUSB0        # (from command line)
115200      # (from command line)
lock        # (from /etc/ppp/options)
connect /usr/lib/synce-core/synce-serial-chat       # (from command line)
record /tmp/pppd.pcap       # (from /etc/ppp/options)
crtscts     # (from command line)
local       # (from command line)
asyncmap 0      # (from /etc/ppp/options)
lcp-echo-failure 4      # (from /etc/ppp/options)
lcp-echo-interval 30        # (from /etc/ppp/options)
hide-password       # (from /etc/ppp/options)
ms-dns xxx # [don't know how to print value]        # (from command line)
nodefaultroute      # (from command line)
192.168.131.1:192.168.131.129       # (from command line)
noipx       # (from /etc/ppp/options)
Removed stale lock on ttyUSB0 (pid 4366)
Script /usr/lib/synce-core/synce-serial-chat finished (pid 4435), status = 0x0
Serial connection established.
using channel 14
Using interface ppp0
Connect: ppp0 <--> /dev/pts/3
rcvd [LCP ConfReq id=0x0 <mru 1500> <asyncmap 0x0> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xf230f2eb> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <mru 1500> <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xf230f2eb> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0xf230f2eb]
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 192.168.131.1>]
rcvd [CCP ConfReq id=0x0 <mppe -H -M -S -L -D +C>]
sent [CCP ConfRej id=0x0 <mppe -H -M -S -L -D +C>]
rcvd [IPCP ConfReq id=0x2 <compress VJ 0f 00> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-wins 0.0.0.0> <ms-dns2 0.0.0.0> <ms-wins 0.0.0.0>]
sent [IPCP ConfRej id=0x2 <ms-wins 0.0.0.0> <ms-wins 0.0.0.0>]
rcvd [IPV6CP ConfReq id=0x0 <addr fe80::4283:deff:feae:dec9>]
Unsupported protocol 'IPv6 Control Protocol' (0x8057) received
sent [LCP ProtRej id=0x2 80 57 01 00 00 0e 01 0a 42 83 de ff fe ae de c9]
rcvd [LCP EchoRep id=0x0 magic=0x0]
rcvd [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [CCP ConfReq id=0x2]
rcvd [IPCP ConfAck id=0x1 <compress VJ 0f 01> <addr 192.168.131.1>]
rcvd [CCP ConfReq id=0x1]
sent [CCP ConfAck id=0x1]
rcvd [IPCP ConfReq id=0x3 <compress VJ 0f 00> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
sent [IPCP ConfNak id=0x3 <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
rcvd [CCP ConfNak id=0x2 <mppe -H -M -S -L -D +C>]
sent [CCP ConfReq id=0x3]
rcvd [IPCP ConfReq id=0x4 <compress VJ 0f 00> <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
sent [IPCP ConfAck id=0x4 <compress VJ 0f 00> <addr 192.168.131.129> <ms-dns1 192.168.131.1> <ms-dns2 192.168.131.1>]
local  IP address 192.168.131.1
remote IP address 192.168.131.129
Script /etc/ppp/ip-up started (pid 4444)
rcvd [CCP ConfAck id=0x3]
Script /etc/ppp/ip-up finished (pid 4444), status = 0x0

在 UDEV 中,我看到在“添加”事件之后,内核会触发“删除”,而无需断开设备连接。令人惊讶的是,该事件仅与 ppp0 网络设备相关联。

KERNEL[13133.932298] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
KERNEL[13133.941859] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
KERNEL[13133.946512] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
KERNEL[13133.946847] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0 (tty)
KERNEL[13133.946887] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
KERNEL[13133.946930] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
KERNEL[13133.947016] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
UDEV  [13133.951550] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
UDEV  [13133.967665] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
UDEV  [13133.969926] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
UDEV  [13133.993251] add      /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV  [13134.002291] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0 (usb-serial)
UDEV  [13134.003803] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0 (usb)
UDEV  [13134.004620] bind     /devices/pci0000:00/0000:00:06.0/usb2/2-2 (usb)
KERNEL[13134.445488] add      /devices/virtual/net/ppp0 (net)
KERNEL[13134.445509] add      /devices/virtual/net/ppp0/queues/rx-0 (queues)
KERNEL[13134.445519] add      /devices/virtual/net/ppp0/queues/tx-0 (queues)
UDEV  [13134.498959] add      /devices/virtual/net/ppp0 (net)
UDEV  [13134.510588] add      /devices/virtual/net/ppp0/queues/rx-0 (queues)
UDEV  [13134.514145] add      /devices/virtual/net/ppp0/queues/tx-0 (queues)
<< a little few seconds later >>
KERNEL[13137.624110] remove   /devices/virtual/net/ppp0/queues/rx-0 (queues)
KERNEL[13137.624144] remove   /devices/virtual/net/ppp0/queues/tx-0 (queues)
KERNEL[13137.624169] remove   /devices/virtual/net/ppp0 (net)
UDEV  [13137.644633] remove   /devices/virtual/net/ppp0/queues/tx-0 (queues)
UDEV  [13137.644791] remove   /devices/virtual/net/ppp0/queues/rx-0 (queues)
UDEV  [13137.659488] remove   /devices/virtual/net/ppp0 (net)

该事件与网络接口或网络协议有关,但我没有发现导致该事件的任何原因。使用 Whireshark 查看了网络流量(记录到 pcap 文件),我没有发现任何线索。我将其与 Ubuntu 中的连接进行了比较,但没有发现任何异常。在 Ubuntu 中,尽管有 RST,但连接从未丢失(见下图)

https://i.stack.imgur.com/c0RKA.png

在 Debian 上,它突然消失了。

https://i.stack.imgur.com/43vtk.png

目标是在 USB 串行设备和 Linux PC 之间建立稳定的 TCP/IP 连接: ppp0 <--> /dev/ttyUSB0 目前,使用 Debian,连接会在几秒钟(两三秒)内丢失...

Jan 18 20:26:56 debian10 pppd[1590]: local  IP address 192.168.131.1
Jan 18 20:26:56 debian10 pppd[1590]: remote IP address 192.168.131.129
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_check_interface_cb: address ready
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: found device interface for /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: listening for device /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:56 debian10 dccm[1505]: DEBUG: synce_device_manager_create_device: NOT triggering connection
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_client_connected_cb: have a connection to port 5679
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_client_connected_cb: creating device object for /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_set_property: running for device /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/ttyUSB0/tty/ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_initable_init: connecting to udev
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: info buffer length = 138
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 0: unknown: guint32 ?: 40
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 4: os_major: guint8: 6
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 5: os_minor: guint8: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 6: unknown, build number ?: guint16 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 8: cpu_type: guint16: 2577
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 10: unknown: guint16 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 12: unknown: guint32 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 16: cur_partner_id: guint32: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 20: second partner id ?: guint32 ?: 0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 24: offset to device name: guint32: 40
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 28: offset to platform name: guint32: 74
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: offset 32: offset to model name: guint32: 104
Jan 18 20:26:57 debian10 dccm[1505]: Message: synce_device_dbus_init: registering object path '/org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0'
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_manager_device_obj_path_changed_cb: sending connected signal for /org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_dbus_init: obj_path set to /org/synce/dccm/Device/_devices_pci0000_00_0000_00_06_0_usb2_2_2_2_2_1_0_ttyUSB0_tty_ttyUSB0
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: get_password_flag_text: setting password flags unset
Jan 18 20:26:57 debian10 dccm[1505]: DEBUG: synce_device_legacy_info_received: setting CTRL_STATE_CONNECTED
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0/queues/tx-0
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0/queues/rx-0
Jan 18 20:26:58 debian10 dccm[1505]: DEBUG: gudev_uevent_callback: received uevent **remove** for device /sys/devices/virtual/net/ppp0

我如何才能检测到发生了什么?内核删除 ppp0 设备的原因是什么?任何有助于解决此问题的答案都将不胜感激,即使还有其他方法可以连接 USB 串行设备,我也不知道是否有。

答案1

udev 手册请回复我:

不允许启动守护进程或其他长时间运行的进程;分叉进程(无论是否分离)将在事件处理完成后无条件终止。为了从 udev 规则激活长时间运行的进程,请提供服务单元并使用 SYSTEMD_WANTS 设备属性将其从 udev 设备中拉入。

较新的 udev 版本(来自 Ubuntu 16 和 Debian 8)通过对 udev 事务及其产生的进程设置严格的时间限制,阻止您在 RUN 或 PROGRAM 脚本中启动长期存在的后台进程。至于对 udev 产生的脚本的长期运行进程限制,如果您在后台启动某些东西,只要 udev 启动的实际脚本快速终止即可。Udev 使用 cgroup 来查找并销毁产生的任务。

systemd 路线是正确的方法,因为不建议从 udev 启动长时间运行的进程。

相关内容