diff --git a/faucet/valve_flood.py b/faucet/valve_flood.py index 07b5425ff3..340db911ad 100644 --- a/faucet/valve_flood.py +++ b/faucet/valve_flood.py @@ -17,6 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import functools from collections import defaultdict from faucet import valve_of @@ -85,6 +86,7 @@ def floods_to_root(self, _dp_obj): """Return True if the given dp floods (only) to root switch""" return False + @functools.lru_cache(maxsize=1024) def _mask_flood_priority(self, eth_dst_mask): return self.flood_priority + valve_packet.mac_mask_bits(eth_dst_mask) @@ -127,6 +129,7 @@ def _build_flood_rule(self, match, command, flood_acts, flood_priority): inst=[valve_of.apply_actions(flood_acts)], priority=flood_priority) + @functools.lru_cache(maxsize=1024) def _vlan_flood_priority(self, eth_type, eth_dst_mask): priority = self._mask_flood_priority(eth_dst_mask) if eth_type: diff --git a/faucet/valve_packet.py b/faucet/valve_packet.py index b22b509aba..f328876d29 100644 --- a/faucet/valve_packet.py +++ b/faucet/valve_packet.py @@ -72,6 +72,7 @@ MAC_MASK_BITMAP = {(2**EUI_BITS - 2**i): (EUI_BITS - i) for i in range(0, EUI_BITS + 1)} +@functools.lru_cache(maxsize=1024) def mac_mask_bits(mac_mask): """Return number of bits in MAC mask or 0.""" if mac_mask is not None: @@ -377,6 +378,7 @@ def lacp_actor_up(lacp_pkt): return 0 +@functools.lru_cache(maxsize=1024) def lacp_reqreply(eth_src, actor_system, actor_key, actor_port, actor_state_synchronization=0,