service: add default group @ to match all nodes
authorFelix Fietkau <nbd@nbd.name>
Sun, 22 Dec 2024 18:19:25 +0000 (19:19 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 22 Dec 2024 18:20:12 +0000 (19:20 +0100)
Simplifies handling services that should be enabled globally

Signed-off-by: Felix Fietkau <nbd@nbd.name>
service.c

index 73cf5b8146ff5c289f86cffd671aaa4ce18918fd..5237915b0fbede942d2012720186a9591167e8e8 100644 (file)
--- a/service.c
+++ b/service.c
@@ -54,6 +54,7 @@ __service_parse_members(struct network *net, struct network_service *s,
 {
        struct network_group *group;
        struct network_host *host;
+       unsigned int count = 0;
 
        if (name[0] != '@') {
                host = avl_find_element(&net->hosts, name, host, node);
@@ -68,6 +69,15 @@ __service_parse_members(struct network *net, struct network_service *s,
        }
 
        name++;
+       if (!name[0]) {
+               avl_for_each_element(&net->hosts, host, node) {
+                       if (s)
+                               __service_add_member(s->members, &s->n_members, host);
+                       count++;
+               }
+               return count;
+       }
+
        group = avl_find_element(&net->groups, name, group, node);
        if (!group)
                return 0;