ubus: allow proto handlers to override device in announced rules
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 21 May 2015 13:04:11 +0000 (15:04 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 21 May 2015 13:06:50 +0000 (15:06 +0200)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
ubus.c

diff --git a/ubus.c b/ubus.c
index ef2c53027dfb88f0b941a965b9321695ad02f84b..9e034c8b8745a0240e2320266f4f69046bf5cae8 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -281,10 +281,12 @@ fw3_ubus_rules(struct blob_buf *b)
                                snprintf(comment, sizeof(comment), "ubus:%s[%s] rule %d",
                                         iface_name, iface_proto, n++);
 
-                               blobmsg_for_each_attr(ropt, rule, orem)
-                                       if (strcmp(blobmsg_name(ropt), "name") &&
-                                           strcmp(blobmsg_name(ropt), "device"))
+                               blobmsg_for_each_attr(ropt, rule, orem) {
+                                       if (!strcmp(blobmsg_name(ropt), "device"))
+                                               l3_device = blobmsg_get_string(ropt);
+                                       else if (strcmp(blobmsg_name(ropt), "name"))
                                                blobmsg_add_blob(b, ropt);
+                               }
 
                                blobmsg_add_string(b, "name", comment);
                                blobmsg_add_string(b, "device", l3_device);