From: Yu Watanabe Date: Tue, 29 Sep 2020 08:27:50 +0000 (+0900) Subject: network: make several functions static X-Git-Tag: v247-rc1~117^2~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4736035aaad426bfe55defd18ab6555764388cbd;p=thirdparty%2Fsystemd.git network: make several functions static --- diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index a4189e8b5a4..4436aa2a36c 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -15,7 +15,33 @@ #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; diff --git a/src/network/networkd-nexthop.h b/src/network/networkd-nexthop.h index 64d92f62be4..9d5736b3f9c 100644 --- a/src/network/networkd-nexthop.h +++ b/src/network/networkd-nexthop.h @@ -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);