Skip to content

Commit 383eb58

Browse files
committed
ubus: do not overwrite ipset name attribute
When importing ipset definitions from published ubus data, do not overwrite the name attribute with an autogenerated string like it is being done for rules or redirects. Ref: https://forum.openwrt.org/t/fw3-ipset-procd-objects/44044 Signed-off-by: Jo-Philipp Wich <[email protected]>
1 parent c26f890 commit 383eb58

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

ubus.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,34 @@ static void fw3_ubus_rules_add(struct blob_buf *b, const char *service,
257257
void *k = blobmsg_open_table(b, "");
258258
struct blob_attr *ropt;
259259
unsigned orem;
260-
char *type = NULL;
260+
char *type = NULL, *name = NULL;
261261
char comment[256];
262262

263263
blobmsg_for_each_attr(ropt, rule, orem) {
264264
if (!strcmp(blobmsg_name(ropt), "type"))
265265
type = blobmsg_data(ropt);
266+
else if (!strcmp(blobmsg_name(ropt), "name"))
267+
name = blobmsg_data(ropt);
268+
266269
if (device && !strcmp(blobmsg_name(ropt), "device"))
267270
device = blobmsg_get_string(ropt);
268271
else if (strcmp(blobmsg_name(ropt), "name"))
269272
blobmsg_add_blob(b, ropt);
270273
}
271274

272-
if (instance)
273-
snprintf(comment, sizeof(comment), "ubus:%s[%s] %s %d",
274-
service, instance, type ? type : "rule", n);
275-
else
276-
snprintf(comment, sizeof(comment), "ubus:%s %s %d",
277-
service, type ? type : "rule", n);
275+
if (!type || strcmp(type, "ipset")) {
276+
if (instance)
277+
snprintf(comment, sizeof(comment), "ubus:%s[%s] %s %d",
278+
service, instance, type ? type : "rule", n);
279+
else
280+
snprintf(comment, sizeof(comment), "ubus:%s %s %d",
281+
service, type ? type : "rule", n);
278282

279-
blobmsg_add_string(b, "name", comment);
283+
blobmsg_add_string(b, "name", comment);
284+
}
285+
else if (name) {
286+
blobmsg_add_string(b, "name", name);
287+
}
280288

281289
if (device)
282290
blobmsg_add_string(b, "device", device);

0 commit comments

Comments
 (0)