Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. Re: [PATCH] test: Add support for Python3 (Daniel Wagner)
2. Re: [PATCH] coding-style: Update M8 about g_malloc use
(Daniel Wagner)
3. [RFC] service: Add support to set MTU via D-Bus interface
(Daniel Wagner)
----------------------------------------------------------------------
Date: Mon, 10 Feb 2020 09:13:47 +0100
From: Daniel Wagner <[email protected]>
Subject: Re: [PATCH] test: Add support for Python3
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Tue, Nov 19, 2019 at 08:13:18AM +0100, Daniel Wagner wrote:
> Python2 is EOL, it's time to update our test script to run with
> Python3. The conversion was done using 2to3 and most of the scripts
> will run with both versions. Since most of the transformation is about
> updating the print commands. Only a quick smoke test was done.
Patch regenerated and then applied.
------------------------------
Date: Mon, 10 Feb 2020 09:14:44 +0100
From: Daniel Wagner <[email protected]>
Subject: Re: [PATCH] coding-style: Update M8 about g_malloc use
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Patch applied
------------------------------
Date: Mon, 10 Feb 2020 10:23:30 +0100
From: Daniel Wagner <[email protected]>
Subject: [RFC] service: Add support to set MTU via D-Bus interface
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
---
Well this could be a way to set the MTU via D-Bus. Not sure if this is
a good idea to do this way.
doc/service-api.txt | 6 +++
src/service.c | 103 ++++++++++++++++++++++++++++++++++++++++--
test/get-services | 3 +-
test/list-services | 4 +-
test/monitor-services | 4 +-
test/set-ethernet | 31 +++++++++++++
test/test-manager | 5 +-
7 files changed, 146 insertions(+), 10 deletions(-)
create mode 100755 test/set-ethernet
diff --git a/doc/service-api.txt b/doc/service-api.txt
index c0d5adbb2b57..da514160dd61 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -508,6 +508,12 @@ Properties string State [readonly]
This information is not available.
+ dict Ethernet.Configuration [readwrite]
+
+ uint16 MTU [readwrite]
+
+ The Ethernet MTU (default is 1500).
+
bool mDNS [readonly]
Whether or not mDNS support is enabled. Note
diff --git a/src/service.c b/src/service.c
index 2f497d10cef1..6c9a75a28738 100644
--- a/src/service.c
+++ b/src/service.c
@@ -93,6 +93,7 @@ struct connman_service {
bool roaming;
struct connman_ipconfig *ipconfig_ipv4;
struct connman_ipconfig *ipconfig_ipv6;
+ unsigned short mtu;
struct connman_network *network;
struct connman_provider *provider;
char **nameservers;
@@ -557,6 +558,9 @@ static int service_load(struct connman_service *service)
__connman_ipconfig_load(service->ipconfig_ipv6, keyfile,
service->identifier, "IPv6.");
+ service->mtu = g_key_file_get_integer(keyfile,
+ service->identifier, "MTU", 0);
+
service->nameservers_config = g_key_file_get_string_list(keyfile,
service->identifier, "Nameservers", &length, NULL);
if (service->nameservers_config && length == 0) {
@@ -721,6 +725,10 @@ static int service_save(struct connman_service *service)
__connman_ipconfig_save(service->ipconfig_ipv6, keyfile,
service->identifier, "IPv6.");
+ if (service->mtu)
+ g_key_file_set_integer(keyfile, service->identifier,
+ "MTU", service->mtu);
+
if (service->nameservers_config) {
guint len = g_strv_length(service->nameservers_config);
@@ -1760,6 +1768,15 @@ static void append_ethernet(DBusMessageIter *iter, void
*user_data)
iter);
}
+static void append_ethernetconfig(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+
+ if (service->mtu)
+ connman_dbus_dict_append_basic(iter, "MTU",
+ DBUS_TYPE_UINT16, &service->mtu);
+}
+
static void append_ipv4(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
@@ -2210,6 +2227,27 @@ static int set_mdns(struct connman_service *service,
return result;
}
+
+static void mtu_configuration_changed(struct connman_service *service)
+{
+ if (!allow_property_changed(service))
+ return;
+
+ connman_dbus_property_changed_dict(service->path,
+ CONNMAN_SERVICE_INTERFACE,
+ "Ethernet.Configuration",
+ append_ethernetconfig,
+ service);
+}
+
+static int set_mtu(struct connman_service *service,
+ unsigned short mtu)
+{
+ int index = __connman_service_get_index(service);
+
+ return connman_inet_set_mtu(index, mtu);
+}
+
static void timeservers_configuration_changed(struct connman_service *service)
{
if (!allow_property_changed(service))
@@ -2532,16 +2570,16 @@ static void append_properties(DBusMessageIter *dict,
dbus_bool_t limited,
val = service->roaming;
connman_dbus_dict_append_basic(dict, "Roaming",
DBUS_TYPE_BOOLEAN, &val);
-
- connman_dbus_dict_append_dict(dict, "Ethernet",
- append_ethernet, service);
- break;
+ /* fall through */
case CONNMAN_SERVICE_TYPE_WIFI:
case CONNMAN_SERVICE_TYPE_ETHERNET:
case CONNMAN_SERVICE_TYPE_BLUETOOTH:
case CONNMAN_SERVICE_TYPE_GADGET:
connman_dbus_dict_append_dict(dict, "Ethernet",
append_ethernet, service);
+
+ connman_dbus_dict_append_dict(dict, "Ethernet.Configuration",
+ append_ethernetconfig, service);
break;
}
@@ -3860,6 +3898,57 @@ static DBusMessage *set_property(DBusConnection *conn,
}
service_save(service);
+ } else if (g_str_equal(name, "Ethernet.Configuration")) {
+ DBusMessageIter dict;
+
+ if (service->immutable)
+ return __connman_error_not_supported(msg);
+
+ if (type != DBUS_TYPE_ARRAY)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_recurse(&value, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) ==
+ DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, variant;
+ const char *key;
+ int type;
+
+ dbus_message_iter_recurse(&dict, &entry);
+ if (dbus_message_iter_get_arg_type(&entry) !=
DBUS_TYPE_STRING)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&entry, &key);
+ dbus_message_iter_next(&entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) !=
DBUS_TYPE_VARIANT)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_recurse(&entry, &variant);
+ type = dbus_message_iter_get_arg_type(&variant);
+
+ if (!strcmp(key, "MTU")) {
+ dbus_uint16_t val;
+
+ if (type != DBUS_TYPE_UINT16)
+ return
__connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&variant, &val);
+ if (val >= 64) {
+ service->mtu = val;
+ set_mtu(service, service->mtu);
+ } else {
+ service->mtu = 0;
+ set_mtu(service, 1500);
+ }
+
+ mtu_configuration_changed(service);
+
+ service_save(service);
+ }
+ dbus_message_iter_next(&dict);
+ }
} else
return __connman_error_invalid_property(msg);
@@ -6567,6 +6656,12 @@ int __connman_service_connect(struct connman_service
*service,
__connman_service_clear_error(service);
+ if (service->mtu) {
+ err = set_mtu(service, service->mtu);
+ if (err)
+ connman_warn("Failed to set MTU size %d", service->mtu);
+ }
+
err = service_connect(service);
DBG("service %p err %d", service, err);
diff --git a/test/get-services b/test/get-services
index 2fa8b5b75da8..4d0e1b656bc2 100755
--- a/test/get-services
+++ b/test/get-services
@@ -37,7 +37,8 @@ services = manager.GetServices()
if key in ["IPv4", "IPv4.Configuration",
"IPv6", "IPv6.Configuration",
"Proxy", "Proxy.Configuration",
- "Ethernet", "Provider"]:
+ "Ethernet", "Ethernet.Configuration",
+ "Provider"]:
val = extract_values(properties[key])
elif key in ["Nameservers", "Nameservers.Configuration",
"Domains", "Domains.Configuration",
diff --git a/test/list-services b/test/list-services
index 4accf773022c..786c9e976039 100755
--- a/test/list-services
+++ b/test/list-services
@@ -40,8 +40,8 @@ manager = dbus.Interface(bus.get_object("net.connman", "/"),
if key in ["IPv4", "IPv4.Configuration",
"IPv6", "IPv6.Configuration",
"Proxy", "Proxy.Configuration",
- "Ethernet", "Provider",
- "LastAddressConflict"]:
+ "Ethernet", "Ethernet.Configuration",
+ "Provider", "LastAddressConflict"]:
val = extract_values(properties[key])
elif key in ["Nameservers", "Nameservers.Configuration",
"Domains", "Domains.Configuration",
diff --git a/test/monitor-services b/test/monitor-services
index d570e5f57d9c..414b4d69f297 100755
--- a/test/monitor-services
+++ b/test/monitor-services
@@ -32,7 +32,9 @@ import dbus.mainloop.glib
val = val + " ]"
elif name in ["IPv4", "IPv4.Configuration",
"IPv6", "IPv6.Configuration",
- "Proxy", "Proxy.Configuration", "Ethernet", "Provider"]:
+ "Proxy", "Proxy.Configuration",
+ "Ethernet", "Ethernet.Configuration",
+ "Provider"]:
val = extract_values(value)
elif name in ["Nameservers", "Nameservers.Configuration",
"Domains", "Domains.Configuration",
diff --git a/test/set-ethernet b/test/set-ethernet
new file mode 100755
index 000000000000..fc1ef7770ab0
--- /dev/null
+++ b/test/set-ethernet
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def make_variant(string):
+ return dbus.UInt16(string, variant_level=1)
+
+def print_usage():
+ print("Usage: %s <service> [mtu <size>]" % (sys.argv[0]))
+
+
+if (len(sys.argv) < 3):
+ print_usage()
+ sys.exit(1)
+
+bus = dbus.SystemBus()
+path = "/net/connman/service/" + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+ 'net.connman.Service')
+
+properties = service.GetProperties()
+
+print("Setting method %s for %s" % (sys.argv[2], sys.argv[1]))
+
+eth_configuration = { "MTU": make_variant(sys.argv[3]) }
+
+service.SetProperty("Ethernet.Configuration", eth_configuration)
+print("New Ethernet.Configuration: ", eth_configuration)
+
+print()
diff --git a/test/test-manager b/test/test-manager
index 2bc53acc3c77..aaba98b985fa 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -58,8 +58,9 @@ services = manager.GetServices()
elif key in ["IPv4", "IPv4.Configuration",
"IPv6", "IPv6.Configuration",
- "Proxy", "Proxy.Configuration",
- "Ethernet", "Provider"]:
+ "Proxy", "Proxy.Configuration",
+ "Ethernet", "Ethernet.Configuration",
+ "Provider"]:
val = extract_values(properties[key])
elif key in ["Nameservers", "Nameservers.Configuration",
--
2.25.0
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]
------------------------------
End of connman Digest, Vol 52, Issue 12
***************************************