diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-09-29 18:53:16 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-06 19:44:42 +0200 |
commit | df3a18f87f2995b7e2f9c8a1043679f7ec64c45c (patch) | |
tree | db24bc1072a56d92bd45b6fc601d37e2967d9677 /src | |
parent | network: cleanup networkd-address-label.h (diff) | |
download | systemd-df3a18f87f2995b7e2f9c8a1043679f7ec64c45c.tar.xz systemd-df3a18f87f2995b7e2f9c8a1043679f7ec64c45c.zip |
network: make fdb_entry_free() return NULL
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-fdb.c | 38 | ||||
-rw-r--r-- | src/network/networkd-fdb.h | 4 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index 628c3988ac..43aaebb285 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -30,6 +30,26 @@ static const char* const fdb_ntf_flags_table[_NEIGHBOR_CACHE_ENTRY_FLAGS_MAX] = DEFINE_STRING_TABLE_LOOKUP(fdb_ntf_flags, NeighborCacheEntryFlags); +/* remove and FDB entry. */ +FdbEntry *fdb_entry_free(FdbEntry *fdb_entry) { + if (!fdb_entry) + return NULL; + + if (fdb_entry->network) { + LIST_REMOVE(static_fdb_entries, fdb_entry->network->static_fdb_entries, fdb_entry); + assert(fdb_entry->network->n_static_fdb_entries > 0); + fdb_entry->network->n_static_fdb_entries--; + + if (fdb_entry->section) + hashmap_remove(fdb_entry->network->fdb_entries_by_section, fdb_entry->section); + } + + network_config_section_free(fdb_entry->section); + return mfree(fdb_entry); +} + +DEFINE_NETWORK_SECTION_FUNCTIONS(FdbEntry, fdb_entry_free); + /* create a new FDB entry or get an existing one. */ static int fdb_entry_new_static( Network *network, @@ -171,24 +191,6 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) { return 1; } -/* remove and FDB entry. */ -void fdb_entry_free(FdbEntry *fdb_entry) { - if (!fdb_entry) - return; - - if (fdb_entry->network) { - LIST_REMOVE(static_fdb_entries, fdb_entry->network->static_fdb_entries, fdb_entry); - assert(fdb_entry->network->n_static_fdb_entries > 0); - fdb_entry->network->n_static_fdb_entries--; - - if (fdb_entry->section) - hashmap_remove(fdb_entry->network->fdb_entries_by_section, fdb_entry->section); - } - - network_config_section_free(fdb_entry->section); - free(fdb_entry); -} - /* parse the HW address from config files. */ int config_parse_fdb_hwaddr( const char *unit, diff --git a/src/network/networkd-fdb.h b/src/network/networkd-fdb.h index f607dfc70f..521376cb86 100644 --- a/src/network/networkd-fdb.h +++ b/src/network/networkd-fdb.h @@ -43,11 +43,9 @@ struct FdbEntry { LIST_FIELDS(FdbEntry, static_fdb_entries); }; -void fdb_entry_free(FdbEntry *fdb_entry); +FdbEntry *fdb_entry_free(FdbEntry *fdb_entry); int fdb_entry_configure(Link *link, FdbEntry *fdb_entry); -DEFINE_NETWORK_SECTION_FUNCTIONS(FdbEntry, fdb_entry_free); - const char* fdb_ntf_flags_to_string(NeighborCacheEntryFlags i) _const_; NeighborCacheEntryFlags fdb_ntf_flags_from_string(const char *s) _pure_; |