Launch inm-manager on boot and Disable some monitoring functions 70/322670/3 accepted/tizen_unified accepted/tizen_unified_x accepted/tizen/unified/20250428.091742 accepted/tizen/unified/x/20250429.081821
authorhyunsube-lee <hyunsube.lee@samsung.com>
Mon, 14 Apr 2025 08:25:20 +0000 (17:25 +0900)
committerhyunsube-lee <hyunsube.lee@samsung.com>
Wed, 16 Apr 2025 01:14:33 +0000 (10:14 +0900)
Change-Id: I1d3f1b8dbd7264545e79434c27ac453cb4ba0023

include/inm-util.h
packaging/inm-manager.service
packaging/inm-manager.spec
resources/var/lib/inm-manager/settings
src/inm-manager.c
src/inm-util.c

index 36b95fc2f52bc72745b9ba815ad4a06789883ea7..2fea58f1e9a0bab2ad5bbff13f4fcf8a5dc3d893 100644 (file)
@@ -201,6 +201,8 @@ void util_put_str(const char *log_str);
 void util_close_log_file(void);
 
 GKeyFile *load_keyfile(const char *pathname);
+gboolean check_monitoring_flag(const char *key);
+
 
 #ifdef __cplusplus
 }
index 31f8691329c085bd0b95483abf9506f41f635c7d..162dac58ce6e06077817d83c3120fb9430d85b32 100644 (file)
@@ -1,12 +1,18 @@
 [Unit]
 Description=Intelligent Network Monitoring service
+After=dbus.service network-pre.target systemd-sysusers.service net-config.service
+Before=network.target multi-user.target shutdown.target
 
 [Service]
 Type=dbus
 BusName=net.inm_manager
+Restart=on-failure
 SmackProcessLabel=System
 ExecStart=/usr/bin/inm-manager
 User=network_fw
 Group=network_fw
 Capabilities=cap_net_admin,cap_net_raw=i
 SecureBits=keep-caps
+
+[Install]
+WantedBy=multi-user.target
index 2ea68f58c676f68606c24b716698394e88227953..f87557daab4365263c3a0a3784a9717442a9bed3 100644 (file)
@@ -89,6 +89,9 @@ cp inm-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/inm-manager.conf
 mkdir -p %{buildroot}%{_unitdir}
 cp inm-manager.service %{buildroot}%{_unitdir}/inm-manager.service
 
+mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
+ln -s ../inm-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/inm-manager.service
+
 #log dump
 mkdir -p %{buildroot}/opt/etc/dump.d/module.d
 #udev rules for wlan module attach/detach event
@@ -114,3 +117,4 @@ mkdir -p %{buildroot}/opt/etc/dump.d/module.d
 %attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/inm-manager.conf
 %attr(644,root,root) %{_datadir}/dbus-1/system-services/net.inm_manager.service
 %attr(644,root,root) %{_unitdir}/inm-manager.service
+%attr(644,root,root) %{_unitdir}/multi-user.target.wants/inm-manager.service
index 19135ca908e69006e3b33dbeb27c800932c8cc60..7bc947ca111e01ab2d38bc9c514943959696a514 100644 (file)
@@ -2,3 +2,15 @@
 GatewayCheckInterval=1000
 DnsCheckInterval=5000
 OnlineCheckUrl=""
+
+[Monitoring]
+SupportIpConflictMonitoring=false
+SupportChannelInterferenceMonitoring=false
+SupportCongestionMonitoring=false
+SupportCommnanMonitoring=True
+SupportWpsMonitoring=True
+SupportDnsMonitoring=True
+SupportGatewayMonitoring=True
+SupportRtnlMonitoring=True
+SupportArpMonitoring=True
+SupportIfaceMonitoring=True
\ No newline at end of file
index 69724929e580d516b8651eb43332a356fc7e832c..48195512eb8ecb1531a0aaea5f223d8d5b9518ea 100644 (file)
@@ -832,6 +832,12 @@ static void __ip_conflict_cb(int state, gchar *if_name, guchar *ip, gpointer use
 static inline void __init_ip_conflict_detect()
 {
        __INM_FUNC_ENTER__;
+
+       if (!check_monitoring_flag("SupportIpConflictMonitoring")) {
+               INM_LOGI("ip conflict monitoring not supported");
+               return;
+       }
+
        if (ip_conflict_detection_init() != 0) {
                INM_LOGW("ip conflict detection init failed");
                __INM_FUNC_EXIT__;
@@ -842,6 +848,8 @@ static inline void __init_ip_conflict_detect()
 
        ip_conflict_set_callback(IF_NAME_ETH, __ip_conflict_cb, NULL);
        ip_conflict_set_callback(IF_NAME_WLAN, __ip_conflict_cb, NULL);
+
+
        __INM_FUNC_EXIT__;
 }
 
@@ -879,6 +887,11 @@ static void __arping_cb(gboolean found,
 static inline void __init_arping()
 {
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportArpMonitoring")) {
+               INM_LOGI("Airping monitoring not supported");
+               return;
+       }
+
        if (inm_arping_init() != 0) {
                INM_LOGW("arping init failed");
                __INM_FUNC_EXIT__;
@@ -927,6 +940,11 @@ static inline void __deinit_reacher()
 static inline void __init_dns_lookup()
 {
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportDnsMonitoring")) {
+               INM_LOGI("Dns monitoring not supported");
+               return;
+       }
+
        if (inm_dns_lookup_init() != 0) {
                INM_LOGW("dns lookup init failed");
                __INM_FUNC_EXIT__;
@@ -1003,6 +1021,11 @@ static void __wifi_module_state_changed_cb(char *iface_name, int state, void *us
 static inline void __init_iface_monitor()
 {
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportIfaceMonitoring")) {
+               INM_LOGI("Interface monitoring not supported");
+               return;
+       }
+
        if (inm_iface_mon_init() != 0) {
                INM_LOGW("inm_iface_mon_init failed");
                __INM_FUNC_EXIT__;
@@ -1084,9 +1107,14 @@ void __channel_interference_cb(int freq, double channel_interference, gpointer u
 
 static inline void __init_channel_interference_monitor()
 {
+       __INM_FUNC_ENTER__;
+
        int ret = 0;
+       if (!check_monitoring_flag("SupportChannelInterferenceMonitoring")) {
+               INM_LOGI("Channel interference monitoring not supported");
+               return;
+       }
 
-       __INM_FUNC_ENTER__;
        ret = inm_channel_interference_monitor_start(__channel_interference_cb, NULL);
        if (ret != INM_MANAGER_ERROR_NONE)
                INM_LOGW("inm_channel_interference_monitor_start failed");
@@ -1117,9 +1145,14 @@ void __congestion_mon_cb(int congestion_level, gpointer user_data)
 
 static inline void __init_congestion_mon()
 {
+       __INM_FUNC_ENTER__;
+
        int ret = 0;
+       if (!check_monitoring_flag("SupportCongestionMonitoring")) {
+               INM_LOGI("Congestion monitoring not supported");
+               return;
+       }
 
-       __INM_FUNC_ENTER__;
        ret = inm_congestion_mon_init();
        if (ret != INM_MANAGER_ERROR_NONE) {
                INM_LOGW("inm_congestion_mon_init failed");
@@ -1156,6 +1189,10 @@ static inline void __init_rtnl_mon()
        int ret = 0;
 
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportRtnlMonitoring")) {
+               INM_LOGI("Rtnl not supported");
+               return;
+       }
 
        ret = inm_rtnl_mon_init();
        if (ret != INM_RTNL_ERROR_NONE) {
@@ -1233,10 +1270,15 @@ static inline void __init_connman()
        int ret = 0;
 
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportCommnanMonitoring")) {
+               INM_LOGI("Connman monitoring not supported");
+               return;
+       }
+
        ret = inm_connman_init();
        if (ret != 0) {
                INM_LOGW("Init connman failed");
-       __INM_FUNC_EXIT__;
+               __INM_FUNC_EXIT__;
                return;
        }
 
@@ -1313,6 +1355,11 @@ static inline void __init_supplicant()
        int ret = 0;
 
        __INM_FUNC_ENTER__;
+       if (!check_monitoring_flag("SupportWpsMonitoring")) {
+               INM_LOGI("Wps supplicant monitoring not supported");
+               return;
+       }
+
        ret = inm_supplicant_init();
        if (ret != 0) {
                INM_LOGW("Init supplicant failed");
index eebcf726b926dbc59d752c1b59b02bd7c38b5e6c..c564e27475a9cc216b3ab38bbfea37cc8103f9c6 100644 (file)
@@ -1353,3 +1353,22 @@ GKeyFile *load_keyfile(const char *pathname)
 
        return keyfile;
 }
+
+gboolean check_monitoring_flag(const char *key)
+{
+       GKeyFile *keyfile = NULL;
+       gboolean is_supporting = TRUE;
+       keyfile = load_keyfile(INM_MANAGER_CONF);
+
+       if (keyfile != NULL) {
+               GError *error = NULL;
+               is_supporting = g_key_file_get_boolean(keyfile, "Monitoring", key, &error);
+               if (!error && is_supporting == FALSE) {
+                       g_key_file_free(keyfile);
+                       return FALSE;
+               }
+               g_clear_error(&error);
+               g_key_file_free(keyfile);
+       }
+       return TRUE;
+}