summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-02 03:16:25 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-06 19:44:43 +0200
commit74154c2e28bf0b397baa4cb33840d5945c2c2ae0 (patch)
treec194eeb2bb025e0eaf06f67a57a7a86055a7075f
parentnetwork: introduce network_verify_routes() (diff)
downloadsystemd-74154c2e28bf0b397baa4cb33840d5945c2c2ae0.tar.xz
systemd-74154c2e28bf0b397baa4cb33840d5945c2c2ae0.zip
network: make several functions static
-rw-r--r--src/network/networkd-route.c227
-rw-r--r--src/network/networkd-route.h23
2 files changed, 117 insertions, 133 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 65ab7f46c1..460f3623a7 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -25,6 +25,116 @@
#define ROUTES_DEFAULT_MAX_PER_FAMILY 4096U
+static const char * const route_type_table[__RTN_MAX] = {
+ [RTN_UNICAST] = "unicast",
+ [RTN_LOCAL] = "local",
+ [RTN_BROADCAST] = "broadcast",
+ [RTN_ANYCAST] = "anycast",
+ [RTN_MULTICAST] = "multicast",
+ [RTN_BLACKHOLE] = "blackhole",
+ [RTN_UNREACHABLE] = "unreachable",
+ [RTN_PROHIBIT] = "prohibit",
+ [RTN_THROW] = "throw",
+ [RTN_NAT] = "nat",
+ [RTN_XRESOLVE] = "xresolve",
+};
+
+assert_cc(__RTN_MAX <= UCHAR_MAX);
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_type, int);
+
+static const char * const route_scope_table[] = {
+ [RT_SCOPE_UNIVERSE] = "global",
+ [RT_SCOPE_SITE] = "site",
+ [RT_SCOPE_LINK] = "link",
+ [RT_SCOPE_HOST] = "host",
+ [RT_SCOPE_NOWHERE] = "nowhere",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_scope, int);
+
+#define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
+static const char *format_route_scope(int scope, char *buf, size_t size) {
+ const char *s;
+ char *p = buf;
+
+ s = route_scope_to_string(scope);
+ if (s)
+ strpcpy(&p, size, s);
+ else
+ strpcpyf(&p, size, "%d", scope);
+
+ return buf;
+}
+
+static const char * const route_table_table[] = {
+ [RT_TABLE_DEFAULT] = "default",
+ [RT_TABLE_MAIN] = "main",
+ [RT_TABLE_LOCAL] = "local",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_table, int);
+
+#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
+static const char *format_route_table(int table, char *buf, size_t size) {
+ const char *s;
+ char *p = buf;
+
+ s = route_table_to_string(table);
+ if (s)
+ strpcpy(&p, size, s);
+ else
+ strpcpyf(&p, size, "%d", table);
+
+ return buf;
+}
+
+static const char * const route_protocol_table[] = {
+ [RTPROT_KERNEL] = "kernel",
+ [RTPROT_BOOT] = "boot",
+ [RTPROT_STATIC] = "static",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
+
+static const char * const route_protocol_full_table[] = {
+ [RTPROT_REDIRECT] = "redirect",
+ [RTPROT_KERNEL] = "kernel",
+ [RTPROT_BOOT] = "boot",
+ [RTPROT_STATIC] = "static",
+ [RTPROT_GATED] = "gated",
+ [RTPROT_RA] = "ra",
+ [RTPROT_MRT] = "mrt",
+ [RTPROT_ZEBRA] = "zebra",
+ [RTPROT_BIRD] = "bird",
+ [RTPROT_DNROUTED] = "dnrouted",
+ [RTPROT_XORP] = "xorp",
+ [RTPROT_NTK] = "ntk",
+ [RTPROT_DHCP] = "dhcp",
+ [RTPROT_MROUTED] = "mrouted",
+ [RTPROT_BABEL] = "babel",
+ [RTPROT_BGP] = "bgp",
+ [RTPROT_ISIS] = "isis",
+ [RTPROT_OSPF] = "ospf",
+ [RTPROT_RIP] = "rip",
+ [RTPROT_EIGRP] = "eigrp",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(route_protocol_full, int);
+
+#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
+static const char *format_route_protocol(int protocol, char *buf, size_t size) {
+ const char *s;
+ char *p = buf;
+
+ s = route_protocol_full_to_string(protocol);
+ if (s)
+ strpcpy(&p, size, s);
+ else
+ strpcpyf(&p, size, "%d", protocol);
+
+ return buf;
+}
+
static unsigned routes_max(void) {
static thread_local unsigned cached = 0;
@@ -282,7 +392,7 @@ DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
route_compare_func,
route_free);
-bool route_equal(Route *r1, Route *r2) {
+static bool route_equal(Route *r1, Route *r2) {
if (r1 == r2)
return true;
@@ -292,7 +402,7 @@ bool route_equal(Route *r1, Route *r2) {
return route_compare_func(r1, r2) == 0;
}
-int route_get(Link *link, Route *in, Route **ret) {
+static int route_get(Link *link, Route *in, Route **ret) {
Route *existing;
@@ -362,11 +472,11 @@ static int route_add_internal(Link *link, Set **routes, Route *in, Route **ret)
return 0;
}
-int route_add_foreign(Link *link, Route *in, Route **ret) {
+static int route_add_foreign(Link *link, Route *in, Route **ret) {
return route_add_internal(link, &link->routes_foreign, in, ret);
}
-int route_add(Link *link, Route *in, Route **ret) {
+static int route_add(Link *link, Route *in, Route **ret) {
Route *route;
int r;
@@ -585,7 +695,7 @@ int link_drop_routes(Link *link) {
return r;
}
-int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
+static int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
Route *route = userdata;
int r;
@@ -1378,113 +1488,6 @@ int network_add_default_route_on_device(Network *network) {
return 0;
}
-static const char * const route_type_table[__RTN_MAX] = {
- [RTN_UNICAST] = "unicast",
- [RTN_LOCAL] = "local",
- [RTN_BROADCAST] = "broadcast",
- [RTN_ANYCAST] = "anycast",
- [RTN_MULTICAST] = "multicast",
- [RTN_BLACKHOLE] = "blackhole",
- [RTN_UNREACHABLE] = "unreachable",
- [RTN_PROHIBIT] = "prohibit",
- [RTN_THROW] = "throw",
- [RTN_NAT] = "nat",
- [RTN_XRESOLVE] = "xresolve",
-};
-
-assert_cc(__RTN_MAX <= UCHAR_MAX);
-DEFINE_STRING_TABLE_LOOKUP(route_type, int);
-
-static const char * const route_scope_table[] = {
- [RT_SCOPE_UNIVERSE] = "global",
- [RT_SCOPE_SITE] = "site",
- [RT_SCOPE_LINK] = "link",
- [RT_SCOPE_HOST] = "host",
- [RT_SCOPE_NOWHERE] = "nowhere",
-};
-
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_scope, int);
-
-const char *format_route_scope(int scope, char *buf, size_t size) {
- const char *s;
- char *p = buf;
-
- s = route_scope_to_string(scope);
- if (s)
- strpcpy(&p, size, s);
- else
- strpcpyf(&p, size, "%d", scope);
-
- return buf;
-}
-
-static const char * const route_table_table[] = {
- [RT_TABLE_DEFAULT] = "default",
- [RT_TABLE_MAIN] = "main",
- [RT_TABLE_LOCAL] = "local",
-};
-
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_table, int);
-
-const char *format_route_table(int table, char *buf, size_t size) {
- const char *s;
- char *p = buf;
-
- s = route_table_to_string(table);
- if (s)
- strpcpy(&p, size, s);
- else
- strpcpyf(&p, size, "%d", table);
-
- return buf;
-}
-
-static const char * const route_protocol_table[] = {
- [RTPROT_KERNEL] = "kernel",
- [RTPROT_BOOT] = "boot",
- [RTPROT_STATIC] = "static",
-};
-
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
-
-static const char * const route_protocol_full_table[] = {
- [RTPROT_REDIRECT] = "redirect",
- [RTPROT_KERNEL] = "kernel",
- [RTPROT_BOOT] = "boot",
- [RTPROT_STATIC] = "static",
- [RTPROT_GATED] = "gated",
- [RTPROT_RA] = "ra",
- [RTPROT_MRT] = "mrt",
- [RTPROT_ZEBRA] = "zebra",
- [RTPROT_BIRD] = "bird",
- [RTPROT_DNROUTED] = "dnrouted",
- [RTPROT_XORP] = "xorp",
- [RTPROT_NTK] = "ntk",
- [RTPROT_DHCP] = "dhcp",
- [RTPROT_MROUTED] = "mrouted",
- [RTPROT_BABEL] = "babel",
- [RTPROT_BGP] = "bgp",
- [RTPROT_ISIS] = "isis",
- [RTPROT_OSPF] = "ospf",
- [RTPROT_RIP] = "rip",
- [RTPROT_EIGRP] = "eigrp",
-};
-
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(route_protocol_full, int);
-
-const char *format_route_protocol(int protocol, char *buf, size_t size) {
- const char *s;
- char *p = buf;
-
- s = route_protocol_full_to_string(protocol);
- if (s)
- strpcpy(&p, size, s);
- else
- strpcpyf(&p, size, "%d", protocol);
-
- return buf;
-}
-
int config_parse_gateway(
const char *unit,
const char *filename,
diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h
index 42eda8e762..7bbe16e7e0 100644
--- a/src/network/networkd-route.h
+++ b/src/network/networkd-route.h
@@ -68,6 +68,8 @@ extern const struct hash_ops route_hash_ops;
int route_new(Route **ret);
Route *route_free(Route *route);
+DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
+
int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret);
int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
@@ -79,31 +81,10 @@ int link_deserialize_routes(Link *link, const char *routes);
int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
-int route_get(Link *link, Route *in, Route **ret);
-int route_add(Link *link, Route *in, Route **ret);
-int route_add_foreign(Link *link, Route *in, Route **ret);
-bool route_equal(Route *r1, Route *r2);
-
-int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
-
-DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
-
int network_add_ipv4ll_route(Network *network);
int network_add_default_route_on_device(Network *network);
void network_verify_routes(Network *network);
-const char* route_type_to_string(int t) _const_;
-int route_type_from_string(const char *s) _pure_;
-
-#define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
-const char *format_route_scope(int scope, char *buf, size_t size);
-
-#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
-const char *format_route_table(int table, char *buf, size_t size);
-
-#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
-const char *format_route_protocol(int protocol, char *buf, size_t size);
-
CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
CONFIG_PARSER_PROTOTYPE(config_parse_destination);