[systemd-commits] 6 commits - man/sd_bus_path_encode.xml man/systemd.link.xml man/systemd.network.xml src/libsystemd-network src/network src/udev TODO
Tom Gundersen
tomegun at kemper.freedesktop.org
Tue Feb 10 13:30:58 PST 2015
TODO | 2
man/sd_bus_path_encode.xml | 2
man/systemd.link.xml | 20 +++---
man/systemd.network.xml | 18 +++--
src/libsystemd-network/network-internal.c | 97 ++++++++++++++++++++++++++----
src/libsystemd-network/network-internal.h | 12 ++-
src/network/networkd-fdb.c | 26 ++++----
src/network/networkd-link.c | 2
src/network/networkd-network-bus.c | 68 +++++++++++++++------
src/network/networkd-network-gperf.gperf | 8 +-
src/network/networkd-network.c | 8 +-
src/network/networkd.h | 10 +--
src/udev/net/link-config-gperf.gperf | 8 +-
src/udev/net/link-config.h | 8 +-
14 files changed, 202 insertions(+), 87 deletions(-)
New commits:
commit dafd8112349f645016b4be71444c23d07ad8dcaa
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 22:30:50 2015 +0100
TODO
diff --git a/TODO b/TODO
index 0daddbf..fba051d 100644
--- a/TODO
+++ b/TODO
@@ -36,8 +36,6 @@ Before 219:
* revert Kay's revert orgies
-* networkd's match bus properties should be "as" instead of "s"
-
Features:
* coredump: make the handler check /proc/$PID/rlimits for RLIMIT_CORE,
commit 5256e00e8b9015dd1a976d647fc71dc7efbd8cf8
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 18:30:16 2015 +0100
net: support globbing and disjunction in Match logic
Match{Name,OrginalName,Type,Driver,Path} can now take a space-separated glob of matches.
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
index afc0ad8..d0e9f8e 100644
--- a/man/systemd.link.xml
+++ b/man/systemd.link.xml
@@ -103,10 +103,10 @@
<varlistentry>
<term><varname>OriginalName=</varname></term>
<listitem>
- <para>The device name, as exposed by the udev property
- "INTERFACE". May contain shell style globs. This can not be
- used to match on names that have already been changed from
- userspace. Caution is advised when matching on
+ <para>A whitespace-separated list of shell-style globs matching
+ the device name, as exposed by the udev property
+ "INTERFACE". This can not be used to match on names that have
+ already been changed from userspace. Caution is advised when matching on
kernel-assigned names, as they are known to be unstable
between reboots.</para>
</listitem>
@@ -114,15 +114,16 @@
<varlistentry>
<term><varname>Path=</varname></term>
<listitem>
- <para>The persistent path, as exposed by the
- udev property <literal>ID_PATH</literal>. May
- contain shell style globs.</para>
+ <para>A whitespace-separated list of shell-style globs matching
+ the persistent path, as exposed by the udev property
+ <literal>ID_PATH</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Driver=</varname></term>
<listitem>
- <para>The driver currently bound to the device,
+ <para>A whitespace-separated list of shell-style globs matching
+ the driver currently bound to the device,
as exposed by the udev property <literal>DRIVER</literal>
of its parent device, or if that is not set, the
driver as exposed by <literal>ethtool -i</literal>
@@ -132,7 +133,8 @@
<varlistentry>
<term><varname>Type=</varname></term>
<listitem>
- <para>The device type, as exposed by the udev
+ <para>A whitespace-separated list of shell-style globs matching
+ the device type, as exposed by the udev
property <literal>DEVTYPE</literal>.</para>
</listitem>
</varlistentry>
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 9b3a92d..069b605 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -107,15 +107,16 @@
<varlistentry>
<term><varname>Path=</varname></term>
<listitem>
- <para>The persistent path, as exposed by the udev
- property <literal>ID_PATH</literal>. May contain shell
- style globs.</para>
+ <para>A whitespace-separated list of shell-style globs
+ matching the persistent path, as exposed by the udev
+ property <literal>ID_PATH</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Driver=</varname></term>
<listitem>
- <para>The driver currently bound to the device, as
+ <para>A whitespace-separated list of shell-style globs
+ matching the driver currently bound to the device, as
exposed by the udev property <literal>DRIVER</literal>
of its parent device, or if that is not set the driver
as exposed by <literal>ethtool -i</literal> of the
@@ -125,16 +126,17 @@
<varlistentry>
<term><varname>Type=</varname></term>
<listitem>
- <para>The device type, as exposed by the udev property
+ <para>A whitespace-separated list of shell-style globs
+ matching the device type, as exposed by the udev property
<literal>DEVTYPE</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Name=</varname></term>
<listitem>
- <para>The device name, as exposed by the udev property
- <literal>INTERFACE</literal>. May contain shell style
- globs.</para>
+ <para>A whitespace-separated list of shell-style globs
+ matching the device name, as exposed by the udev property
+ <literal>INTERFACE</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index e4a15d0..870858c 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -83,10 +83,10 @@ int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8
}
bool net_match_config(const struct ether_addr *match_mac,
- const char *match_path,
- const char *match_driver,
- const char *match_type,
- const char *match_name,
+ char * const *match_paths,
+ char * const *match_drivers,
+ char * const *match_types,
+ char * const *match_names,
Condition *match_host,
Condition *match_virt,
Condition *match_kernel,
@@ -97,6 +97,10 @@ bool net_match_config(const struct ether_addr *match_mac,
const char *dev_driver,
const char *dev_type,
const char *dev_name) {
+ char * const *match_path;
+ char * const *match_driver;
+ char * const *match_type;
+ char * const *match_name;
if (match_host && !condition_test(match_host))
return false;
@@ -113,22 +117,50 @@ bool net_match_config(const struct ether_addr *match_mac,
if (match_mac && (!dev_mac || memcmp(match_mac, dev_mac, ETH_ALEN)))
return false;
- if (match_path && (!dev_path || fnmatch(match_path, dev_path, 0)))
+ if (!strv_isempty(match_paths)) {
+ if (!dev_path)
+ return false;
+
+ STRV_FOREACH(match_path, match_paths)
+ if (fnmatch(*match_path, dev_path, 0) != 0)
+ return true;
+
return false;
+ }
- if (match_driver) {
- if (dev_parent_driver && !streq(match_driver, dev_parent_driver))
- return false;
- else if (!streq_ptr(match_driver, dev_driver))
+ if (!strv_isempty(match_drivers)) {
+ if (!dev_driver)
return false;
+
+ STRV_FOREACH(match_driver, match_drivers)
+ if (fnmatch(*match_driver, dev_driver, 0) != 0)
+ return true;
+
+ return false;
}
- if (match_type && !streq_ptr(match_type, dev_type))
+ if (!strv_isempty(match_types)) {
+ if (!dev_type)
+ return false;
+
+ STRV_FOREACH(match_type, match_types)
+ if (fnmatch(*match_type, dev_type, 0) != 0)
+ return true;
+
return false;
+ }
- if (match_name && (!dev_name || fnmatch(match_name, dev_name, 0)))
+ if (!strv_isempty(match_names)) {
+ if (!dev_name)
return false;
+ STRV_FOREACH(match_name, match_names)
+ if (fnmatch(*match_name, dev_name, 0) != 0)
+ return true;
+
+ return false;
+ }
+
return true;
}
@@ -212,6 +244,49 @@ int config_parse_ifname(const char *unit,
return 0;
}
+int config_parse_ifnames(const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ char ***sv = data;
+ const char *word, *state;
+ size_t l;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ FOREACH_WORD(word, l, rvalue, state) {
+ char *n;
+
+ n = strndup(word, l);
+ if (!n)
+ return log_oom();
+
+ if (!ascii_is_valid(n) || strlen(n) >= IFNAMSIZ) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Interface name is not ASCII clean or is too long, ignoring assignment: %s", rvalue);
+ free(n);
+ return 0;
+ }
+
+ r = strv_consume(sv, n);
+ if (r < 0)
+ return log_oom();
+ }
+
+ return 0;
+}
+
int config_parse_ifalias(const char *unit,
const char *filename,
unsigned line,
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
index c64db2e..e51717e 100644
--- a/src/libsystemd-network/network-internal.h
+++ b/src/libsystemd-network/network-internal.h
@@ -29,10 +29,10 @@
#include "condition.h"
bool net_match_config(const struct ether_addr *match_mac,
- const char *match_path,
- const char *match_driver,
- const char *match_type,
- const char *match_name,
+ char * const *match_path,
+ char * const *match_driver,
+ char * const *match_type,
+ char * const *match_name,
Condition *match_host,
Condition *match_virt,
Condition *match_kernel,
@@ -56,6 +56,10 @@ int config_parse_ifname(const char *unit, const char *filename, unsigned line,
const char *section, unsigned section_line, const char *lvalue,
int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_ifnames(const char *unit, const char *filename, unsigned line,
+ const char *section, unsigned section_line, const char *lvalue,
+ int ltype, const char *rvalue, void *data, void *userdata);
+
int config_parse_ifalias(const char *unit, const char *filename, unsigned line,
const char *section, unsigned section_line, const char *lvalue,
int ltype, const char *rvalue, void *data, void *userdata);
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index f1b58b3..36b40d3 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -68,10 +68,10 @@ const sd_bus_vtable network_vtable[] = {
SD_BUS_PROPERTY("Description", "s", NULL, offsetof(Network, description), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SourcePath", "s", NULL, offsetof(Network, filename), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("MatchMAC", "as", property_get_ether_addrs, offsetof(Network, match_mac), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("MatchPath", "s", NULL, offsetof(Network, match_path), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("MatchDriver", "s", NULL, offsetof(Network, match_driver), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("MatchType", "s", NULL, offsetof(Network, match_type), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("MatchName", "s", NULL, offsetof(Network, match_name), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("MatchPath", "as", NULL, offsetof(Network, match_path), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("MatchDriver", "as", NULL, offsetof(Network, match_driver), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("MatchType", "as", NULL, offsetof(Network, match_type), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("MatchName", "as", NULL, offsetof(Network, match_name), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_VTABLE_END
};
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 1731e04..9f6e65f 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -16,10 +16,10 @@ struct ConfigPerfItem;
%includes
%%
Match.MACAddress, config_parse_hwaddr, 0, offsetof(Network, match_mac)
-Match.Path, config_parse_string, 0, offsetof(Network, match_path)
-Match.Driver, config_parse_string, 0, offsetof(Network, match_driver)
-Match.Type, config_parse_string, 0, offsetof(Network, match_type)
-Match.Name, config_parse_ifname, 0, offsetof(Network, match_name)
+Match.Path, config_parse_strv, 0, offsetof(Network, match_path)
+Match.Driver, config_parse_strv, 0, offsetof(Network, match_driver)
+Match.Type, config_parse_strv, 0, offsetof(Network, match_type)
+Match.Name, config_parse_ifnames, 0, offsetof(Network, match_name)
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(Network, match_host)
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(Network, match_virt)
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(Network, match_kernel)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 3ebd4d7..c90f730 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -196,10 +196,10 @@ void network_free(Network *network) {
free(network->filename);
free(network->match_mac);
- free(network->match_path);
- free(network->match_driver);
- free(network->match_type);
- free(network->match_name);
+ strv_free(network->match_path);
+ strv_free(network->match_driver);
+ strv_free(network->match_type);
+ strv_free(network->match_name);
free(network->description);
free(network->dhcp_vendor_class_identifier);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 691d603..fdd0684 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -100,10 +100,10 @@ struct Network {
char *name;
struct ether_addr *match_mac;
- char *match_path;
- char *match_driver;
- char *match_type;
- char *match_name;
+ char **match_path;
+ char **match_driver;
+ char **match_type;
+ char **match_name;
Condition *match_host;
Condition *match_virt;
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
index 191ab68..b25e4b3 100644
--- a/src/udev/net/link-config-gperf.gperf
+++ b/src/udev/net/link-config-gperf.gperf
@@ -17,10 +17,10 @@ struct ConfigPerfItem;
%includes
%%
Match.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, match_mac)
-Match.OriginalName, config_parse_ifname, 0, offsetof(link_config, match_name)
-Match.Path, config_parse_string, 0, offsetof(link_config, match_path)
-Match.Driver, config_parse_string, 0, offsetof(link_config, match_driver)
-Match.Type, config_parse_string, 0, offsetof(link_config, match_type)
+Match.OriginalName, config_parse_ifnames, 0, offsetof(link_config, match_name)
+Match.Path, config_parse_strv, 0, offsetof(link_config, match_path)
+Match.Driver, config_parse_strv, 0, offsetof(link_config, match_driver)
+Match.Type, config_parse_strv, 0, offsetof(link_config, match_type)
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(link_config, match_host)
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(link_config, match_virt)
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(link_config, match_kernel)
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
index 688f836..cb434d1 100644
--- a/src/udev/net/link-config.h
+++ b/src/udev/net/link-config.h
@@ -52,10 +52,10 @@ struct link_config {
char *filename;
struct ether_addr *match_mac;
- char *match_path;
- char *match_driver;
- char *match_type;
- char *match_name;
+ char **match_path;
+ char **match_driver;
+ char **match_type;
+ char **match_name;
Condition *match_host;
Condition *match_virt;
Condition *match_kernel;
commit ea6ec096db5f9f3562b9bbf438da7fe21411c74d
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 20:40:41 2015 +0100
networkd: fdb - refactor a bit
Pass around Link objcets rather than FdbEntry objects. The link objects have an up-to-date
ifname we can use for logging. match_name sholud _never_ be used for anything except
matching. Firstly, it may be unset (usually is), and secondly it may not be up-to-date.
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index 9bb45e3..78488c9 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -86,31 +86,33 @@ int fdb_entry_new_static(Network *const network,
}
static int set_fdb_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
- _cleanup_fdbentry_free_ FdbEntry *fdb_entry = userdata;
+ Link *link = userdata;
int r;
- assert(fdb_entry);
+ assert(link);
r = sd_rtnl_message_get_errno(m);
- if ((r < 0) && (r != (-EEXIST)))
- log_error("Could not add FDB entry for interface: %s error: %s",
- fdb_entry->network->match_name, strerror(-r));
+ if (r < 0 && r != -EEXIST)
+ log_link_error(link, "Could not add FDB entry: %s", strerror(-r));
return 1;
}
/* send a request to the kernel to add a FDB entry in its static MAC table. */
-int fdb_entry_configure(sd_rtnl *const rtnl,
- FdbEntry *const fdb_entry,
- const int ifindex) {
+int fdb_entry_configure(Link *link,
+ FdbEntry *const fdb_entry) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL;
+ sd_rtnl *rtnl;
int r;
+ assert(link);
+ assert(link->manager);
assert(fdb_entry);
- assert(rtnl);
+
+ rtnl = link->manager->rtnl;
/* create new RTM message */
- r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, ifindex, PF_BRIDGE);
+ r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, link->ifindex, PF_BRIDGE);
if (r < 0)
return rtnl_log_create_error(r);
@@ -136,9 +138,9 @@ int fdb_entry_configure(sd_rtnl *const rtnl,
}
/* send message to the kernel to update its internal static MAC table. */
- r = sd_rtnl_call_async(rtnl, req, set_fdb_handler, fdb_entry, 0, NULL);
+ r = sd_rtnl_call_async(rtnl, req, set_fdb_handler, link, 0, NULL);
if (r < 0) {
- log_error("Could not send rtnetlink message: %s", strerror(-r));
+ log_link_error(link, "Could not send rtnetlink message: %s", strerror(-r));
return r;
}
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 0b1cac1..3f15394 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -733,7 +733,7 @@ static int link_set_bridge_fdb(const Link *const link) {
int r = 0;
LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
- r = fdb_entry_configure(link->manager->rtnl, fdb_entry, link->ifindex);
+ r = fdb_entry_configure(link, fdb_entry);
if(r < 0) {
log_link_error(link, "Failed to add MAC entry to static MAC table: %s", strerror(-r));
break;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 22cc51d..691d603 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -383,7 +383,7 @@ int config_parse_label(const char *unit, const char *filename, unsigned line,
int ltype, const char *rvalue, void *data, void *userdata);
/* Forwarding database table. */
-int fdb_entry_configure(sd_rtnl *const rtnl, FdbEntry *const fdb_entry, const int ifindex);
+int fdb_entry_configure(Link *link, FdbEntry *const fdb_entry);
void fdb_entry_free(FdbEntry *fdb_entry);
int fdb_entry_new_static(Network *const network, const unsigned section, FdbEntry **ret);
commit 9198e12ca32db7812b2a79b5922233ec80890306
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 17:29:40 2015 +0100
networkd: bus - expose MatchMAC
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index 6e7cbc5..f1b58b3 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -25,12 +25,49 @@
#include "networkd.h"
+static int property_get_ether_addrs(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ Network *n = userdata;
+ const char *ether = NULL;
+ int r;
+
+ assert(bus);
+ assert(reply);
+ assert(n);
+
+ if (n->match_mac)
+ ether = ether_ntoa(n->match_mac);
+
+ r = sd_bus_message_open_container(reply, 'a', "s");
+ if (r < 0)
+ return r;
+
+ if (ether) {
+ r = sd_bus_message_append(reply, "s", strempty(ether));
+ if (r < 0)
+ return r;
+ }
+
+ r = sd_bus_message_close_container(reply);
+ if (r < 0)
+ return r;
+
+ return 1;
+}
+
const sd_bus_vtable network_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Description", "s", NULL, offsetof(Network, description), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SourcePath", "s", NULL, offsetof(Network, filename), SD_BUS_VTABLE_PROPERTY_CONST),
-/* SD_BUS_PROPERTY("MatchMAC", "s", NULL TODO, offsetof(Network, match_mac), SD_BUS_VTABLE_PROPERTY_CONST), */
+ SD_BUS_PROPERTY("MatchMAC", "as", property_get_ether_addrs, offsetof(Network, match_mac), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("MatchPath", "s", NULL, offsetof(Network, match_path), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("MatchDriver", "s", NULL, offsetof(Network, match_driver), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("MatchType", "s", NULL, offsetof(Network, match_type), SD_BUS_VTABLE_PROPERTY_CONST),
commit 53d6837510478e1275b294654663635466cbafc7
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 17:28:34 2015 +0100
man: sd_bus_path_encode - fix order of arguments
diff --git a/man/sd_bus_path_encode.xml b/man/sd_bus_path_encode.xml
index 55a6fd0..3197054 100644
--- a/man/sd_bus_path_encode.xml
+++ b/man/sd_bus_path_encode.xml
@@ -62,8 +62,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<funcprototype>
<funcdef>int <function>sd_bus_path_decode</function></funcdef>
- <paramdef>const char *<parameter>prefix</parameter></paramdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
+ <paramdef>const char *<parameter>prefix</parameter></paramdef>
<paramdef>char **<parameter>ret_external_id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
commit f6f8d466bd6ce5f737d66a076c1f9e40d8ec9d7f
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 10 16:36:58 2015 +0100
networkd: network-bus - use sd_bus_path_{en,de}code
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index a167857..6e7cbc5 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -40,10 +40,9 @@ const sd_bus_vtable network_vtable[] = {
};
static char *network_bus_path(Network *network) {
- _cleanup_free_ char *e = NULL;
_cleanup_free_ char *name = NULL;
- char *networkname;
- char *d;
+ char *networkname, *d, *path;
+ int r;
assert(network);
assert(network->filename);
@@ -62,11 +61,11 @@ static char *network_bus_path(Network *network) {
*d = '\0';
- e = bus_label_escape(networkname);
- if (!e)
+ r = sd_bus_path_encode("/org/freedesktop/network1/network", networkname, &path);
+ if (r < 0)
return NULL;
- return strappend("/org/freedesktop/network1/network/", e);
+ return path;
}
int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
@@ -102,7 +101,6 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
Manager *m = userdata;
Network *network;
_cleanup_free_ char *name = NULL;
- _cleanup_free_ char *e = NULL;
int r;
assert(bus);
@@ -111,14 +109,11 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
assert(m);
assert(found);
- if (sscanf(path, "/org/freedesktop/network1/network/%ms", &name) != 1)
+ r = sd_bus_path_decode(path, "/org/freedesktop/network1/network", &name);
+ if (r < 0)
return 0;
- e = bus_label_unescape(name);
- if (!e)
- return -ENOMEM;
-
- r = network_get_by_name(m, e, &network);
+ r = network_get_by_name(m, name, &network);
if (r < 0)
return 0;
More information about the systemd-commits
mailing list