]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-fdb.c
tree-wide: use in_addr_is_set() or friends
[thirdparty/systemd.git] / src / network / networkd-fdb.c
index c5e591d50b1b11ced6270c8a19784184f04420c9..e4e727038f5a628fb899fdadcc8ff91635fc99e4 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
 /***
   Copyright © 2014 Intel Corporation. All rights reserved.
 ***/
@@ -8,14 +8,13 @@
 
 #include "alloc-util.h"
 #include "bridge.h"
-#include "conf-parser.h"
 #include "netlink-util.h"
 #include "networkd-fdb.h"
+#include "networkd-link.h"
 #include "networkd-manager.h"
+#include "networkd-network.h"
 #include "parse-util.h"
-#include "string-util.h"
 #include "string-table.h"
-#include "util.h"
 #include "vlan-util.h"
 #include "vxlan.h"
 
@@ -80,11 +79,7 @@ static int fdb_entry_new_static(
                 .fdb_ntf_flags = NEIGHBOR_CACHE_ENTRY_FLAGS_SELF,
         };
 
-        r = hashmap_ensure_allocated(&network->fdb_entries_by_section, &network_config_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = hashmap_put(network->fdb_entries_by_section, fdb_entry->section, fdb_entry);
+        r = hashmap_ensure_put(&network->fdb_entries_by_section, &network_config_hash_ops, fdb_entry->section, fdb_entry);
         if (r < 0)
                 return r;
 
@@ -147,7 +142,7 @@ static int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
                         return log_link_error_errno(link, r, "Could not append NDA_VLAN attribute: %m");
         }
 
-        if (!in_addr_is_null(fdb_entry->family, &fdb_entry->destination_addr)) {
+        if (in_addr_is_set(fdb_entry->family, &fdb_entry->destination_addr)) {
                 r = netlink_message_append_in_addr_union(req, NDA_DST, fdb_entry->family, &fdb_entry->destination_addr);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m");
@@ -186,7 +181,7 @@ int link_set_bridge_fdb(Link *link) {
         return 0;
 }
 
-void network_verify_fdb_entries(Network *network) {
+void network_drop_invalid_fdb_entries(Network *network) {
         FdbEntry *fdb_entry;
 
         assert(network);
@@ -382,7 +377,6 @@ int config_parse_fdb_ntf_flags(
 
         _cleanup_(fdb_entry_free_or_set_invalidp) FdbEntry *fdb_entry = NULL;
         Network *network = userdata;
-        NeighborCacheEntryFlags f;
         int r;
 
         assert(filename);
@@ -395,9 +389,9 @@ int config_parse_fdb_ntf_flags(
         if (r < 0)
                 return log_oom();
 
-        f = fdb_ntf_flags_from_string(rvalue);
+        NeighborCacheEntryFlags f = fdb_ntf_flags_from_string(rvalue);
         if (f < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
+                log_syntax(unit, LOG_WARNING, filename, line, f,
                            "FDB failed to parse AssociatedWith=, ignoring assignment: %s",
                            rvalue);
                 return 0;