blob: 48944604326a743413b34b4a6eb00b0b333447f8 [file] [log] [blame]
From javier.martinez@collabora.co.uk Thu Jun 6 03:26:33 2013
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Date: Thu, 6 Jun 2013 12:25:53 +0200
Subject: [PATCH 5/6] netfilter: nfdbus: add 'path' key to match rule parse function
To: Greg KH <gregkh@linuxfoundation.org>
Cc: ltsi-dev@lists.linuxfoundation.org, Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Message-ID: <1370514354-19114-6-git-send-email-javier.martinez@collabora.co.uk>
Match rules are added using the AddMatch bus method and are
specified as a string of comma separated key/value pairs.
One of these keys is 'path' that specifies to match messages
sent from or to the given object. Support to parse this key
was not present on the match rule parse function and this
lead to the following error:
Unknown key "path" in match rule
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
net/bus/nfdbus/matchrule.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
--- a/net/bus/nfdbus/matchrule.c
+++ b/net/bus/nfdbus/matchrule.c
@@ -188,6 +188,26 @@ bus_match_rule_set_member(struct bus_mat
}
static int
+bus_match_rule_set_path(struct bus_match_rule *rule,
+ const char *path,
+ gfp_t gfp_flags)
+{
+ char *new;
+
+ WARN_ON(!path);
+
+ new = kstrdup(path, gfp_flags);
+ if (new == NULL)
+ return 0;
+
+ rule->flags |= BUS_MATCH_PATH;
+ kfree(rule->path);
+ rule->path = new;
+
+ return 1;
+}
+
+static int
bus_match_rule_set_sender(struct bus_match_rule *rule,
const char *sender,
gfp_t gfp_flags)
@@ -526,6 +546,18 @@ struct bus_match_rule *bus_match_rule_pa
pr_err("Out of memeory");
goto failed;
}
+ } else if (strcmp(key, "path") == 0) {
+ if (rule->flags & BUS_MATCH_PATH) {
+ pr_warn("Key %s specified twice in match rule\n",
+ key);
+ goto failed;
+ }
+
+ if (!bus_match_rule_set_path(rule, value,
+ gfp_flags)) {
+ pr_err("Out of memory");
+ goto failed;
+ }
} else if (strcmp(key, "destination") == 0) {
if (rule->flags & BUS_MATCH_DESTINATION) {
pr_warn("Key %s specified twice in match rule\n",