tiiuae / mesh_com

ROS node for Mesh Network configuration
BSD 3-Clause "New" or "Revised" License
16 stars 17 forks source link

MDM SLAAC integration #344

Closed DaniilTroshkovTII closed 11 months ago

DaniilTroshkovTII commented 11 months ago

I have tested this changes as follow:

root@br_hardened:~# /opt/S90mdm_agent start
-k /etc/ssl/private/csl1.local.key -c /etc/ssl/certs/csl1.local.crt -r /etc/ssl/certs/ca.crt --agent mdm
Starting comms_nats_controller.py: OK
root@br_hardened:~# cat /opt/mdm_agent.log
2023-11-16 09:16:24,574 :: comms.status 0     :: DEBUG    :: mesh_cfg_status=MESH_CONFIGURATION_NOT_STORED, is_mission_cfg=False,
2023-11-16 09:16:24,603 :: comms.status 0     :: DEBUG    :: wpa_supplicant PID: 1616
2023-11-16 09:16:24,622 :: comms.status 0     :: DEBUG    :: interface=wlp1s0
2023-11-16 09:16:24,623 :: comms.status 0     :: DEBUG    :: bssid=00:00:00:00:00:00
2023-11-16 09:16:24,623 :: comms.status 0     :: DEBUG    :: freq=5805
2023-11-16 09:16:24,623 :: comms.status 0     :: DEBUG    :: ssid=gold
2023-11-16 09:16:24,623 :: comms.status 0     :: DEBUG    :: id=0
2023-11-16 09:16:24,623 :: comms.status 0     :: DEBUG    :: mode=mesh
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: pairwise_cipher=UNKNOWN
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: group_cipher=UNKNOWN
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: key_mgmt=UNKNOWN
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: wpa_state=COMPLETED
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: address=00:30:1a:4f:c8:49
2023-11-16 09:16:24,624 :: comms.status 0     :: DEBUG    :: uuid=a27a10da-e296-54fd-b424-7160e0cb089a
2023-11-16 09:16:24,651 :: comms.status 1     :: DEBUG    :: mesh_cfg_status=MESH_CONFIGURATION_NOT_STORED, is_mission_cfg=False,
2023-11-16 09:16:24,677 :: comms.status 1     :: DEBUG    :: wpa_supplicant PID:
2023-11-16 09:16:24,705 :: comms.status 2     :: DEBUG    :: mesh_cfg_status=MESH_CONFIGURATION_NOT_STORED, is_mission_cfg=False,
2023-11-16 09:16:24,731 :: comms.status 2     :: DEBUG    :: wpa_supplicant PID:
2023-11-16 09:16:24,758 :: comms.settings     :: DEBUG    :: mesh config file /opt/0_mesh.conf not found, loading default
2023-11-16 09:16:24,760 :: comms.settings     :: DEBUG    :: index not supported for default: 1
2023-11-16 09:16:24,761 :: comms.settings     :: DEBUG    :: index not supported for default: 2
2023-11-16 09:16:24,761 :: comms.settings     :: DEBUG    :: load settings: OK, Mesh configuration loaded
2023-11-16 09:16:24,764 :: comms.controller   :: DEBUG    :: MDM: comms_nats_controller Listening for requests
2023-11-16 09:16:25,820 :: comms.controller   :: DEBUG    :: HTTP Request status: 200
2023-11-16 09:16:25,821 :: comms.controller   :: DEBUG    :: HTTP Request Response: {"version":0,"payload":{"api_version":1,"radios":[{"radio_index":"0","ssid":"test_mesh","key":"1234567890","ap_mac":"00:11:22:33:44:55","country":"FI","frequency":"5220","frequency_mcc":"2412","routing":"batman-adv","mptcp":"disable","ip":"192.168.1.2","subnet":"255.255.255.0","tx_power":"5","mode":"ap+mesh_scc","priority":"long_range","mesh_vif":"halow1","batman_iface":"bat0","bridge":"br-lan bat0 eth1 lan1 eth0 usb0","slaac":"usb0 halow1"}],"role":"sleeve"}} 200
2023-11-16 09:16:25,822 :: comms.settings     :: DEBUG    :: Mesh settings validation index: 0
2023-11-16 09:16:25,823 :: comms.settings     :: DEBUG    :: validate mesh settings
2023-11-16 09:16:25,824 :: comms.settings     :: DEBUG    :: validate mesh settings ssid ok
2023-11-16 09:16:25,825 :: comms.settings     :: DEBUG    :: validate mesh settings wpa3 ok
2023-11-16 09:16:25,825 :: comms.settings     :: DEBUG    :: validate mesh settings ip ok
2023-11-16 09:16:25,825 :: comms.settings     :: DEBUG    :: validate mesh settings mode ok
2023-11-16 09:16:25,826 :: comms.settings     :: DEBUG    :: validate mesh settings freq ok
2023-11-16 09:16:25,826 :: comms.settings     :: DEBUG    :: validate mesh settings mcc freq ok
2023-11-16 09:16:25,826 :: comms.settings     :: DEBUG    :: validate mesh settings country ok
2023-11-16 09:16:25,827 :: comms.settings     :: DEBUG    :: validate mesh settings subnet ok
2023-11-16 09:16:25,827 :: comms.settings     :: DEBUG    :: validate mesh settings tx power ok
2023-11-16 09:16:25,827 :: comms.settings     :: DEBUG    :: validate mesh settings routing ok
2023-11-16 09:16:25,827 :: comms.settings     :: DEBUG    :: validate mesh settings priority ok
2023-11-16 09:16:25,828 :: comms.settings     :: DEBUG    :: validate mesh settings role ok
2023-11-16 09:16:25,828 :: comms.settings     :: DEBUG    :: validate mesh settings mesh vif ok
2023-11-16 09:16:25,828 :: comms.settings     :: DEBUG    :: validate mesh settings mptcp ok
2023-11-16 09:16:25,828 :: comms.settings     :: DEBUG    :: validate mesh settings batman iface ok
2023-11-16 09:16:25,829 :: comms.settings     :: DEBUG    :: validate mesh settings slaac ifaces ok
2023-11-16 09:16:25,829 :: comms.settings     :: DEBUG    :: Mesh settings validation id 0: OK, Mesh settings OK
2023-11-16 09:16:25,830 :: comms.settings     :: DEBUG    :: 0_mesh_stored.conf written
2023-11-16 09:16:25,830 :: comms.settings     :: DEBUG    :: save settings index 0: OK, Mesh configuration stored
2023-11-16 09:16:25,831 :: comms.controller   :: DEBUG    :: ret: OK info: Mesh configuration stored
2023-11-16 09:16:25,831 :: comms.command      :: DEBUG    :: Command: APPLY
2023-11-16 09:16:29,159 :: comms.command      :: DEBUG    :: Mission configurations applied
2023-11-16 09:16:29,159 :: comms.controller   :: DEBUG    :: ret: OK info: Mission configurations applied
2023-11-16 09:16:29,160 :: comms.controller   :: ERROR    :: KeyError features field in config
root@br_hardened:~#

I only have doubt related to this last 2023-11-16 09:16:29,160 :: comms.controller :: ERROR :: KeyError features field in config. I will check soon if it is because of my fixes, and if does, how can I fix it. So I will do some more test but now I am creating this PR because it is basically what Mika asked and maybe there will be some more notes and ideas. Also, Mika, if you have any ideas on this ERROR :: KeyError features field in config please share.

On server side I just used this patch for testing:

(venv) daniil@daniil-ThinkPad-T14-Gen-3:~/workspace/TC_DISTRO/BUILD/MDM/mdm-server$ git diff
diff --git a/configuration/MeshConf.py b/configuration/MeshConf.py
index 19b5e3d..5ef29a4 100644
--- a/configuration/MeshConf.py
+++ b/configuration/MeshConf.py
@@ -39,6 +39,7 @@ class MeshConf(Dict):
         self['mesh_vif'] = self.mesh_vif if self.mesh_vif else 'halow1'
         self['batman_iface'] = self.batman_iface if self.batman_iface else 'bat0'
         self['bridge'] = 'br-lan bat0 eth1 lan1 eth0 usb0'
+        self['slaac'] = 'usb0 ' + self['mesh_vif']

     @staticmethod
     def from_json(json_str: str) -> MeshConf:
(venv) daniil@daniil-ThinkPad-T14-Gen-3:~/workspace/TC_DISTRO/BUILD/MDM/mdm-server$ 

I will create PR accordingly as soon as I get credentials from Seb.

DaniilTroshkovTII commented 11 months ago

FYI

root@br_hardened:~# cat /opt/0_mesh.conf
ROLE=sleeve
MSVERSION=nats
id0_MODE=ap+mesh_scc
id0_IP=192.168.1.2
id0_MASK=255.255.255.0
id0_MAC=00:11:22:33:44:55
id0_KEY=1234567890
id0_ESSID=test_mesh
id0_FREQ=5220
id0_FREQ_MCC=2412
id0_TXPOWER=5
id0_COUNTRY=FI
id0_ROUTING=batman-adv
id0_PRIORITY=long_range
id0_MESH_VIF=halow1
id0_MPTCP=disable
id0_BATMAN_IFACE=bat0
id0_BRIDGE='br-lan bat0 eth1 lan1 eth0 usb0'
id0_SLAAC='usb0 halow1'
root@br_hardened:~#
joenpera commented 11 months ago

ERROR :: KeyError features field in config

This error because MDM server is not yet delivering this field in the JSON. That Error can be ignored now.

joenpera commented 11 months ago

Also id0_SLAAC needs to be defined in mesh_start.sh which creates default config.

DaniilTroshkovTII commented 11 months ago

Is the actual usage of SLAAC parameter in some other files which are not delivered in this PR?

Here is (in this PR) MDM SLAAc integration (Merge to mdm_client branch) And here is a general SLAAC integration in develop: https://github.com/tiiuae/mesh_com/pull/346

DaniilTroshkovTII commented 11 months ago

Is the actual usage of SLAAC parameter in some other files which are not delivered in this PR?

yes it has done here: https://github.com/tiiuae/tc_distro/pull/158/files