mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 02:21:44 +03:00
network: drop list of bridge FDB entries
[BridgeFDB] sections are managed by both LIST and Hashmap, and they contains the completely same information. Let's drop the list.
This commit is contained in:
parent
df3a18f87f
commit
62ed9442bf
@ -36,11 +36,7 @@ FdbEntry *fdb_entry_free(FdbEntry *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)
|
||||
assert(fdb_entry->section);
|
||||
hashmap_remove(fdb_entry->network->fdb_entries_by_section, fdb_entry->section);
|
||||
}
|
||||
|
||||
@ -63,23 +59,21 @@ static int fdb_entry_new_static(
|
||||
|
||||
assert(network);
|
||||
assert(ret);
|
||||
assert(!!filename == (section_line > 0));
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
/* search entry in hashmap first. */
|
||||
if (filename) {
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* search entry in hashmap first. */
|
||||
fdb_entry = hashmap_get(network->fdb_entries_by_section, n);
|
||||
if (fdb_entry) {
|
||||
*ret = TAKE_PTR(fdb_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (network->n_static_fdb_entries >= STATIC_FDB_ENTRIES_PER_NETWORK_MAX)
|
||||
if (hashmap_size(network->fdb_entries_by_section) >= STATIC_FDB_ENTRIES_PER_NETWORK_MAX)
|
||||
return -E2BIG;
|
||||
|
||||
/* allocate space for and FDB entry. */
|
||||
@ -90,16 +84,11 @@ static int fdb_entry_new_static(
|
||||
/* init FDB structure. */
|
||||
*fdb_entry = (FdbEntry) {
|
||||
.network = network,
|
||||
.section = TAKE_PTR(n),
|
||||
.vni = VXLAN_VID_MAX + 1,
|
||||
.fdb_ntf_flags = NEIGHBOR_CACHE_ENTRY_FLAGS_SELF,
|
||||
};
|
||||
|
||||
LIST_PREPEND(static_fdb_entries, network->static_fdb_entries, fdb_entry);
|
||||
network->n_static_fdb_entries++;
|
||||
|
||||
if (filename) {
|
||||
fdb_entry->section = TAKE_PTR(n);
|
||||
|
||||
r = hashmap_ensure_allocated(&network->fdb_entries_by_section, &network_config_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -107,7 +96,6 @@ static int fdb_entry_new_static(
|
||||
r = hashmap_put(network->fdb_entries_by_section, fdb_entry->section, fdb_entry);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* return allocated FDB structure. */
|
||||
*ret = TAKE_PTR(fdb_entry);
|
||||
|
@ -39,8 +39,6 @@ struct FdbEntry {
|
||||
struct ether_addr mac_addr;
|
||||
union in_addr_union destination_addr;
|
||||
NeighborCacheEntryFlags fdb_ntf_flags;
|
||||
|
||||
LIST_FIELDS(FdbEntry, static_fdb_entries);
|
||||
};
|
||||
|
||||
FdbEntry *fdb_entry_free(FdbEntry *fdb_entry);
|
||||
|
@ -1136,7 +1136,7 @@ static int link_set_bridge_fdb(Link *link) {
|
||||
FdbEntry *fdb_entry;
|
||||
int r;
|
||||
|
||||
LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
|
||||
HASHMAP_FOREACH(fdb_entry, link->network->fdb_entries_by_section) {
|
||||
r = fdb_entry_configure(link, fdb_entry);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to add MAC entry to static MAC table: %m");
|
||||
|
@ -156,7 +156,7 @@ int network_verify(Network *network) {
|
||||
Address *address, *address_next;
|
||||
Prefix *prefix, *prefix_next;
|
||||
Route *route, *route_next;
|
||||
FdbEntry *fdb, *fdb_next;
|
||||
FdbEntry *fdb;
|
||||
MdbEntry *mdb, *mdb_next;
|
||||
TrafficControl *tc;
|
||||
SRIOV *sr_iov;
|
||||
@ -300,7 +300,7 @@ int network_verify(Network *network) {
|
||||
|
||||
network_verify_nexthops(network);
|
||||
|
||||
LIST_FOREACH_SAFE(static_fdb_entries, fdb, fdb_next, network->static_fdb_entries)
|
||||
HASHMAP_FOREACH(fdb, network->fdb_entries_by_section)
|
||||
if (section_is_invalid(fdb->section))
|
||||
fdb_entry_free(fdb);
|
||||
|
||||
@ -637,7 +637,6 @@ failure:
|
||||
static Network *network_free(Network *network) {
|
||||
IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
|
||||
RoutePrefix *route_prefix;
|
||||
FdbEntry *fdb_entry;
|
||||
MdbEntry *mdb_entry;
|
||||
Address *address;
|
||||
Prefix *prefix;
|
||||
@ -704,9 +703,6 @@ static Network *network_free(Network *network) {
|
||||
while ((address = network->static_addresses))
|
||||
address_free(address);
|
||||
|
||||
while ((fdb_entry = network->static_fdb_entries))
|
||||
fdb_entry_free(fdb_entry);
|
||||
|
||||
while ((mdb_entry = network->static_mdb_entries))
|
||||
mdb_entry_free(mdb_entry);
|
||||
|
||||
@ -722,7 +718,7 @@ static Network *network_free(Network *network) {
|
||||
hashmap_free(network->addresses_by_section);
|
||||
hashmap_free(network->routes_by_section);
|
||||
hashmap_free_with_destructor(network->nexthops_by_section, nexthop_free);
|
||||
hashmap_free(network->fdb_entries_by_section);
|
||||
hashmap_free_with_destructor(network->fdb_entries_by_section, fdb_entry_free);
|
||||
hashmap_free(network->mdb_entries_by_section);
|
||||
hashmap_free_with_destructor(network->neighbors_by_section, neighbor_free);
|
||||
hashmap_free_with_destructor(network->address_labels_by_section, address_label_free);
|
||||
@ -849,7 +845,7 @@ bool network_has_static_ipv6_configurations(Network *network) {
|
||||
if (route->family == AF_INET6)
|
||||
return true;
|
||||
|
||||
LIST_FOREACH(static_fdb_entries, fdb, network->static_fdb_entries)
|
||||
HASHMAP_FOREACH(fdb, network->fdb_entries_by_section)
|
||||
if (fdb->family == AF_INET6)
|
||||
return true;
|
||||
|
||||
|
@ -283,7 +283,6 @@ struct Network {
|
||||
|
||||
LIST_HEAD(Address, static_addresses);
|
||||
LIST_HEAD(Route, static_routes);
|
||||
LIST_HEAD(FdbEntry, static_fdb_entries);
|
||||
LIST_HEAD(MdbEntry, static_mdb_entries);
|
||||
LIST_HEAD(IPv6ProxyNDPAddress, ipv6_proxy_ndp_addresses);
|
||||
LIST_HEAD(Prefix, static_prefixes);
|
||||
@ -291,7 +290,6 @@ struct Network {
|
||||
|
||||
unsigned n_static_addresses;
|
||||
unsigned n_static_routes;
|
||||
unsigned n_static_fdb_entries;
|
||||
unsigned n_static_mdb_entries;
|
||||
unsigned n_ipv6_proxy_ndp_addresses;
|
||||
unsigned n_static_prefixes;
|
||||
|
Loading…
Reference in New Issue
Block a user