xaptum / xaprc

Drivers and firmware for the Xaptum ENF router cards
0 stars 0 forks source link

captived: connman does not restart properly on PUT to /wifi/config #117

Closed glfejer closed 4 years ago

glfejer commented 4 years ago

To reproduce: router is connected to MakeOffices wifi:

$ curl http://[2607:8f80:8100:0:e78d:c0c0:20cf:92dc]:4000/wifi/status
{
  "connected": true,
  "IPv4_addresses": [
    "192.168.2.222"
  ],
  "IPv6_addresses": [
    "fdc3:c108:dc6a:0:b2a6:f5ff:fe00:fbe",
    "fe80::b2a6:f5ff:fe00:fbe"
  ],
  "SSID": "MakeOffices"
}

New, broken.json configuration is:

{
    "contents": "[broken-wifi]\nType = wifi\nName = NonExistent\nPassphrase = NotValid123\nIPv4 = dhcp\nIPv6 = auto\n",
    "sha256": "29d8ecf5cefeae235981d525dc525c53cb3f4fd83904a5957740369521a224a3"
}

Update configuration:

curl -i -X PUT -H "Content-Type: application/json" -d "@broken.json" http://[2607:8f80:8100:0:e78d:c0c0:20cf:92dc]:4000/wifi/config/secure

Router card acknowledges the change. Repeated calls to status shows no change in connected network.

Router card shows that connman has exited:

# systemctl status connman
â● connman.service - Connection service
   Loaded: loaded (/usr/lib/systemd/system/connman.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Thu 2019-02-14 18:36:19 UTC; 2min 6s ago
  Process: 218 ExecStart=/usr/sbin/connmand -n (code=killed, signal=HUP)
 Main PID: 218 (code=killed, signal=HUP)

Feb 14 10:12:15 buildroot connmand[218]: enf1 {update} flags 69841 <UP,RUNNING,LOWER_UP>
Feb 14 10:12:15 buildroot connmand[218]: enf1 {newlink} index 4 address 00:00:00:00:00:00 mtu 1280
Feb 14 10:12:15 buildroot connmand[218]: enf1 {newlink} index 4 operstate 6 <UP>
Feb 14 10:12:15 buildroot connmand[218]: enf1 {add} route 2607:8f80:8100:0:e78d:c0c0:20cf:92dc gw :: scope 0 <UNIVERSE>
Feb 14 10:12:15 buildroot connmand[218]: enf1 {add} address 2607:8f80:8100:0:e78d:c0c0:20cf:92dc/128 label (null) family
 10
Feb 14 10:12:16 buildroot connmand[218]: wlan0 {add} route fdc3:c108:dc6a:: gw :: scope 0 <UNIVERSE>
Feb 14 10:12:17 buildroot connmand[218]: wlan0 {add} address fdc3:c108:dc6a:0:b2a6:f5ff:fe00:fbe/64 label (null) family 
10
Feb 14 10:12:17 buildroot connmand[218]: Failed to find URL:http://ipv6.connman.net/online/status.html
Feb 14 18:36:19 buildroot systemd[1]: connman.service: Main process exited, code=killed, status=1/HUP
Feb 14 18:36:19 buildroot systemd[1]: connman.service: Succeeded.

Restarting connman with systemctl start connman causes router to disconnect from previous network, but doesn't connect to recovery network. Recovery network is visible when issuing connmanctl services

When a reboot issued via curl prior to restarting connman, the reboot succeeds and router card connects to recovery network. After connman is restarted, a reboot must be issued on the board.

drbild commented 4 years ago

Does captived issue a SIGHUP to connmand after updating the wifi config files?

EDIT: Yes it does, via this command.

drbild commented 4 years ago

The connmand service should not be killed by the SIGHUP. I'd added code to just reload the configs in response to that signal. Perhaps that code got lost in the switch to the latest Buildroot?

EDIT: Yep, those patches will install for connman 1.36: https://github.com/xaptum/xaptum-buildroot/tree/master/buildroot-external-xaptum/patches/connman/1.36

But we're now on 1.37. Need to migrate those patches to 1.37.

drbild commented 4 years ago

I'll prep an updated patch for xaptum-buildroot. @glfejer Then you can give a test.