mirror of
https://github.com/openvswitch/ovs
synced 2025-10-17 14:28:02 +00:00
mac-learning: Change mac_learning_set_flood_vlans() to not take ownership.
These new semantics are less efficient in the case where the flood_vlans actually changed, but that should be very rare. There are no advantages to this change on its own, but upcoming commits will add multiple layers between the code supplying the flood_vlans and actually calling mac_learning_set_flood_vlans(). Consistency in this multilayered interface seems valuable, and the rest of it does not transfer ownership from the caller to the callee.
This commit is contained in:
@@ -139,17 +139,19 @@ mac_learning_destroy(struct mac_learning *ml)
|
||||
}
|
||||
|
||||
/* Provides a bitmap of VLANs which have learning disabled, that is, VLANs on
|
||||
* which all packets are flooded. It takes ownership of the bitmap. Returns
|
||||
* true if the set has changed from the previous value. */
|
||||
* which all packets are flooded. Returns true if the set has changed from the
|
||||
* previous value. */
|
||||
bool
|
||||
mac_learning_set_flood_vlans(struct mac_learning *ml, unsigned long *bitmap)
|
||||
mac_learning_set_flood_vlans(struct mac_learning *ml,
|
||||
const unsigned long *bitmap)
|
||||
{
|
||||
bool ret = vlan_bitmap_equal(ml->flood_vlans, bitmap);
|
||||
|
||||
bitmap_free(ml->flood_vlans);
|
||||
ml->flood_vlans = bitmap;
|
||||
|
||||
return ret;
|
||||
if (vlan_bitmap_equal(ml->flood_vlans, bitmap)) {
|
||||
return false;
|
||||
} else {
|
||||
bitmap_free(ml->flood_vlans);
|
||||
ml->flood_vlans = vlan_bitmap_clone(bitmap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Reference in New Issue
Block a user