]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: make several functions static
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 08:27:50 +0000 (17:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:39:51 +0000 (02:39 +0900)
src/network/networkd-nexthop.c
src/network/networkd-nexthop.h

index a4189e8b5a40446eda179ea2b3e79f9583d8167f..4436aa2a36cda793bdf2cb25bebf75c7f4dff119 100644 (file)
 #include "string-util.h"
 #include "util.h"
 
-int nexthop_new(NextHop **ret) {
+void nexthop_free(NextHop *nexthop) {
+        if (!nexthop)
+                return;
+
+        if (nexthop->network) {
+                LIST_REMOVE(nexthops, nexthop->network->static_nexthops, nexthop);
+
+                assert(nexthop->network->n_static_nexthops > 0);
+                nexthop->network->n_static_nexthops--;
+
+                if (nexthop->section)
+                        hashmap_remove(nexthop->network->nexthops_by_section, nexthop->section);
+        }
+
+        network_config_section_free(nexthop->section);
+
+        if (nexthop->link) {
+                set_remove(nexthop->link->nexthops, nexthop);
+                set_remove(nexthop->link->nexthops_foreign, nexthop);
+        }
+
+        free(nexthop);
+}
+
+DEFINE_NETWORK_SECTION_FUNCTIONS(NextHop, nexthop_free);
+
+static int nexthop_new(NextHop **ret) {
         _cleanup_(nexthop_freep) NextHop *nexthop = NULL;
 
         nexthop = new(NextHop, 1);
@@ -79,30 +105,6 @@ static int nexthop_new_static(Network *network, const char *filename, unsigned s
         return 0;
 }
 
-void nexthop_free(NextHop *nexthop) {
-        if (!nexthop)
-                return;
-
-        if (nexthop->network) {
-                LIST_REMOVE(nexthops, nexthop->network->static_nexthops, nexthop);
-
-                assert(nexthop->network->n_static_nexthops > 0);
-                nexthop->network->n_static_nexthops--;
-
-                if (nexthop->section)
-                        hashmap_remove(nexthop->network->nexthops_by_section, nexthop->section);
-        }
-
-        network_config_section_free(nexthop->section);
-
-        if (nexthop->link) {
-                set_remove(nexthop->link->nexthops, nexthop);
-                set_remove(nexthop->link->nexthops_foreign, nexthop);
-        }
-
-        free(nexthop);
-}
-
 static void nexthop_hash_func(const NextHop *nexthop, struct siphash *state) {
         assert(nexthop);
 
@@ -169,7 +171,7 @@ bool nexthop_equal(NextHop *r1, NextHop *r2) {
         return nexthop_compare_func(r1, r2) == 0;
 }
 
-int nexthop_get(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_get(Link *link, NextHop *in, NextHop **ret) {
         NextHop *existing;
 
         assert(link);
@@ -225,11 +227,11 @@ static int nexthop_add_internal(Link *link, Set **nexthops, NextHop *in, NextHop
         return 0;
 }
 
-int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret) {
         return nexthop_add_internal(link, &link->nexthops_foreign, in, ret);
 }
 
-int nexthop_add(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_add(Link *link, NextHop *in, NextHop **ret) {
         NextHop *nexthop;
         int r;
 
index 64d92f62be4cdfa8d4171843dab249812c47db0b..9d5736b3f9cda24d150f18834f22fb86d42f78ea 100644 (file)
@@ -30,9 +30,6 @@ struct NextHop {
         LIST_FIELDS(NextHop, nexthops);
 };
 
-extern const struct hash_ops nexthop_hash_ops;
-
-int nexthop_new(NextHop **ret);
 void nexthop_free(NextHop *nexthop);
 int nexthop_remove(NextHop *nexthop, Link *link, link_netlink_message_handler_t callback);
 
@@ -40,14 +37,9 @@ int link_set_nexthop(Link *link);
 
 int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
 
-int nexthop_get(Link *link, NextHop *in, NextHop **ret);
-int nexthop_add(Link *link, NextHop *in, NextHop **ret);
-int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret);
 bool nexthop_equal(NextHop *r1, NextHop *r2);
 
 int nexthop_section_verify(NextHop *nexthop);
 
-DEFINE_NETWORK_SECTION_FUNCTIONS(NextHop, nexthop_free);
-
 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_id);
 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_gateway);