Skip to content

Commit

Permalink
ConnMan: disable interface stats and history files
Browse files Browse the repository at this point in the history
ConnMan writes stats and history files for each configured interface to
/storage/.cache/connman/*/{data,history}. These files remain open while
ConnMan is running, and prevent the system from halting or rebooting
when /storage is an NFS mount (because ConnMan brings down the interface
through which the NFS mount is accessed and then tries to update the
stats and/or history file for that interface, but the file descriptors
are no longer valid, so the system hangs).

The stats and history files are superfluous, especially since the means
of viewing them isn't included in LibreELEC (the stats tool is missing
because ConnMan is compiled with --disable-tools), so there's no harm in
not generating them on systems that don't mount /storage over NFS
either; in fact, it benefits LibreELEC installations where /storage is
mounted on a flash device by reducing unnecessary flash writes.
  • Loading branch information
chrisnovakovic committed May 3, 2018
1 parent dac5caa commit 0235a22
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/network/connman/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ PKG_CONFIGURE_OPTS_TARGET="WPASUPPLICANT=/usr/bin/wpa_supplicant \
--disable-neard \
--disable-wispr \
--disable-tools \
--disable-stats \
--enable-client \
--enable-datafiles \
--with-dbusconfdir=/etc \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
From 5ca75ed2cfcc93fb63651965ec146dca3a394a9d Mon Sep 17 00:00:00 2001
From: Chris Novakovic <chris@chrisn.me.uk>
Date: Thu, 19 Apr 2018 01:29:43 +0100
Subject: [PATCH] build: Add --disable-stats option

Generation of interface statistics files can now be controlled at
compile-time using the --{enable,disable}-stats configure options.
Statistics files remain enabled by default.

Based on an idea by Feng Wang <wangfe@nestlabs.com>.

This is based on upstream commit 1946bbe0, which doesn't apply cleanly
against the latest stable release of ConnMan (1.35).
---
Makefile.am | 14 ++++++++++----
configure.ac | 5 +++++
src/nostats.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 4 deletions(-)
create mode 100644 src/nostats.c

diff --git a/Makefile.am b/Makefile.am
index e67a7a5..9c3b871 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,12 @@ else
gweb_sources += gweb/giognutls.h gweb/gionotls.c
endif

+if STATS
+stats_sources = src/stats.c
+else
+stats_sources = src/nostats.c
+endif
+
if BACKTRACE
backtrace_sources = src/backtrace.c
endif
@@ -106,9 +112,9 @@ MANUAL_PAGES =

sbin_PROGRAMS = src/connmand src/connmand-wait-online

-src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) $(backtrace_sources) \
- $(builtin_sources) $(shared_sources) src/connman.ver \
- src/main.c src/connman.h src/log.c \
+src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) $(stats_sources) \
+ $(backtrace_sources) $(builtin_sources) $(shared_sources) \
+ src/connman.ver src/main.c src/connman.h src/log.c \
src/error.c src/plugin.c src/task.c \
src/device.c src/network.c src/connection.c \
src/manager.c src/service.c \
@@ -120,7 +126,7 @@ src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) $(backtrace_sources) \
src/storage.c src/dbus.c src/config.c \
src/technology.c src/counter.c src/ntp.c \
src/session.c src/tethering.c src/wpad.c src/wispr.c \
- src/stats.c src/dnsproxy.c src/6to4.c \
+ src/dnsproxy.c src/6to4.c \
src/ippool.c src/bridge.c src/nat.c src/ipaddress.c \
src/inotify.c src/ipv6pd.c src/peer.c \
src/peer_service.c src/machine.c src/util.c
diff --git a/configure.ac b/configure.ac
index 4baa685..56d4b50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -380,6 +380,11 @@ AC_ARG_ENABLE(tools, AC_HELP_STRING([--disable-tools],
[enable_tools=${enableval}])
AM_CONDITIONAL(TOOLS, test "${enable_tools}" != "no")

+AC_ARG_ENABLE(stats, AC_HELP_STRING([--disable-stats],
+ [disable statistics round robin file generation]),
+ [enable_stats=${enableval}])
+AM_CONDITIONAL(STATS, test "${enable_stats}" != "no")
+
if (test "${enable_tools}" != "no"); then
AC_PATH_PROGS(IPTABLES_SAVE, [iptables-save], [],
$PATH:/sbin:/usr/sbin)
diff --git a/src/nostats.c b/src/nostats.c
new file mode 100644
index 0000000..3d0dc79
--- /dev/null
+++ b/src/nostats.c
@@ -0,0 +1,57 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2018 Chris Novakovic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+
+#include "connman.h"
+
+int __connman_stats_service_register(struct connman_service *service)
+{
+ return -ENOTSUP;
+}
+
+void __connman_stats_service_unregister(struct connman_service *service)
+{
+}
+
+int __connman_stats_update(struct connman_service *service,
+ bool roaming,
+ struct connman_stats_data *data)
+{
+ return 0;
+}
+
+int __connman_stats_get(struct connman_service *service,
+ bool roaming,
+ struct connman_stats_data *data)
+{
+ return 0;
+}
+
+int __connman_stats_init(void)
+{
+ return 0;
+}
+
+void __connman_stats_cleanup(void)
+{
+}
--
2.7.4

0 comments on commit 0235a22

Please sign in to comment.