]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: move config_parse_bridge_port_priority()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Oct 2020 14:49:05 +0000 (23:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 29 Oct 2020 05:23:49 +0000 (14:23 +0900)
src/libsystemd-network/network-internal.c
src/libsystemd-network/network-internal.h
src/network/netdev/bridge.c
src/network/netdev/bridge.h

index 3b0e6b276d91cba88ad89f4c416a0076855a6a1f..f6e836e3997a39788affda0da907859d1ecc6044 100644 (file)
@@ -627,45 +627,6 @@ int config_parse_hwaddrs(const char *unit,
         }
 }
 
-int config_parse_bridge_port_priority(
-                const char *unit,
-                const char *filename,
-                unsigned line,
-                const char *section,
-                unsigned section_line,
-                const char *lvalue,
-                int ltype,
-                const char *rvalue,
-                void *data,
-                void *userdata) {
-
-        uint16_t i;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        r = safe_atou16(rvalue, &i);
-        if (r < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, r,
-                           "Failed to parse bridge port priority, ignoring: %s", rvalue);
-                return 0;
-        }
-
-        if (i > LINK_BRIDGE_PORT_PRIORITY_MAX) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Bridge port priority is larger than maximum %u, ignoring: %s",
-                           LINK_BRIDGE_PORT_PRIORITY_MAX, rvalue);
-                return 0;
-        }
-
-        *((uint16_t *)data) = i;
-
-        return 0;
-}
-
 size_t serialize_in_addrs(FILE *f,
                           const struct in_addr *addresses,
                           size_t size,
index e4c11235b62f2f4f85ae189cb20f52f988fc80bb..170117e9007a18f9ca20c2543b67b6a3de4a5927 100644 (file)
@@ -11,9 +11,6 @@
 #include "set.h"
 #include "strv.h"
 
-#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
-#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
-
 char *link_get_type_string(unsigned short iftype, sd_device *device);
 bool net_match_config(Set *match_mac,
                       Set *match_permanent_mac,
@@ -43,7 +40,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_match_strv);
 CONFIG_PARSER_PROTOTYPE(config_parse_match_ifnames);
 CONFIG_PARSER_PROTOTYPE(config_parse_match_property);
 CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
-CONFIG_PARSER_PROTOTYPE(config_parse_bridge_port_priority);
 
 int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *result);
 const char *net_get_name_persistent(sd_device *device);
index 45d97ac15eeb55b53b48e5f097b3a915ad758a03..8d822839b43e8614b87ae02ed2922bb2954ba5b7 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "bridge.h"
 #include "netlink-util.h"
-#include "network-internal.h"
 #include "networkd-manager.h"
 #include "string-table.h"
 #include "vlan-util.h"
@@ -342,6 +341,47 @@ int config_parse_bridge_igmp_version(
         return 0;
 }
 
+int config_parse_bridge_port_priority(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        uint16_t i;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        /* This is used in networkd-network-gperf.gperf. */
+
+        r = safe_atou16(rvalue, &i);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Failed to parse bridge port priority, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        if (i > LINK_BRIDGE_PORT_PRIORITY_MAX) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Bridge port priority is larger than maximum %u, ignoring: %s",
+                           LINK_BRIDGE_PORT_PRIORITY_MAX, rvalue);
+                return 0;
+        }
+
+        *((uint16_t *)data) = i;
+
+        return 0;
+}
+
 static void bridge_init(NetDev *n) {
         Bridge *b;
 
index ed4f484c946457966dc010fc862e1543bfb18e84..0316880b12008cbede536c7a0d97c48df8cf0c8d 100644 (file)
@@ -7,6 +7,9 @@
 #include "conf-parser.h"
 #include "netdev.h"
 
+#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
+#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
+
 typedef struct Bridge {
         NetDev meta;
 
@@ -45,3 +48,4 @@ MulticastRouter multicast_router_from_string(const char *s) _pure_;
 
 CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
 CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version);
+CONFIG_PARSER_PROTOTYPE(config_parse_bridge_port_priority);