Skip to content

Commit

Permalink
Merge pull request #3123 from anarkiwi/stackby
Browse files Browse the repository at this point in the history
Don't calculate flows for DPs that are down when considering stack ch…
  • Loading branch information
anarkiwi authored Jul 31, 2019
2 parents 31ce058 + 73072c6 commit 56a3542
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
12 changes: 8 additions & 4 deletions faucet/tfm_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def init_table(table_id, name, max_entries, metadata_match, metadata_write):
return valve_of.parser.OFPTableFeaturesStats(**table_attr)


def load_tables(dp, valve_cl, max_table_id, min_max_flows, use_oxm_ids): # pylint: disable=invalid-name
# pylint: disable=invalid-name
# pylint: disable=too-many-arguments
# pylint: disable=too-many-locals
def load_tables(dp, valve_cl, max_table_id, min_max_flows, use_oxm_ids, fill_req):
"""Configure switch tables with TFM messages."""
table_array = []
active_table_ids = sorted([valve_table.table_id for valve_table in dp.tables.values()])
Expand Down Expand Up @@ -123,15 +126,16 @@ def load_tables(dp, valve_cl, max_table_id, min_max_flows, use_oxm_ids): # pylin
new_table.properties.append(
valve_of.parser.OFPTableFeaturePropInstructions(
type_=valve_of.ofp.OFPTFPT_INSTRUCTIONS_MISS, instruction_ids=inst_ids))

fill_required_properties(new_table)
if fill_req:
fill_required_properties(new_table)
table_array.append(new_table)

tfm_table_ids = {table.table_id for table in table_array}
for missing_table_id in set(range(max_table_id+1)) - tfm_table_ids:
new_table = init_table(
missing_table_id, str(missing_table_id), min_max_flows, 0, 0)
fill_required_properties(new_table)
if fill_req:
fill_required_properties(new_table)
table_array.append(new_table)

return table_array
30 changes: 17 additions & 13 deletions faucet/valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,8 @@ def _next_stack_link_state(self, port, now):
return next_state

def _update_stack_link_state(self, ports, now, other_valves):
stack_change = False
all_valves = [self] + other_valves
ofmsgs_by_valve = {valve: [] for valve in all_valves}
stack_changes = 0
ofmsgs_by_valve = defaultdict(list)

for port in ports:
next_state = self._next_stack_link_state(port, now)
Expand All @@ -580,16 +579,16 @@ def _update_stack_link_state(self, ports, now, other_valves):
port.dyn_stack_current_state,
labels=self.dp.port_labels(port.number))
if port.is_stack_up() or port.is_stack_down():
stack_change = True
stack_changes += 1
port_stack_up = port.is_stack_up()
for valve in all_valves:
for valve in [self] + other_valves:
valve.flood_manager.update_stack_topo(port_stack_up, self.dp, port)
valve.update_tunnel_flowrules()
if stack_change:
for valve in all_valves:
ofmsgs_by_valve[valve].extend(valve.get_tunnel_flowmods())
for vlan in self.dp.vlans.values():
ofmsgs_by_valve[self].extend(self.flood_manager.add_vlan(vlan))
if stack_changes:
self.logger.info('%u stack ports changed state' % stack_changes)
self.update_tunnel_flowrules()
ofmsgs_by_valve[self].extend(self.get_tunnel_flowmods())
for vlan in self.dp.vlans.values():
ofmsgs_by_valve[self].extend(self.flood_manager.add_vlan(vlan))
return ofmsgs_by_valve

def update_tunnel_flowrules(self):
Expand Down Expand Up @@ -974,7 +973,8 @@ def lacp_handler(self, now, pkt_meta):
ofmsgs_by_valve[self].extend(self.lacp_up(pkt_meta.port))
else:
ofmsgs_by_valve[self].extend(self.lacp_down(pkt_meta.port))
if lacp_pkt_change or (age is not None and age > self.dp.ports[pkt_meta.port.number].lacp_resp_interval):
lacp_resp_interval = pkt_meta.port.lacp_resp_interval
if lacp_pkt_change or (age is not None and age > lacp_resp_interval):
ofmsgs_by_valve[self].extend(self._lacp_actions(lacp_pkt, pkt_meta.port))
pkt_meta.port.dyn_lacp_last_resp_time = now
pkt_meta.port.dyn_last_lacp_pkt = lacp_pkt
Expand Down Expand Up @@ -1678,11 +1678,13 @@ class TfmValve(Valve):
USE_OXM_IDS = True
MAX_TABLE_ID = 0
MIN_MAX_FLOWS = 0
FILL_REQ = True

def _pipeline_flows(self):
return [valve_of.table_features(
tfm_pipeline.load_tables(
self.dp, self, self.MAX_TABLE_ID, self.MIN_MAX_FLOWS, self.USE_OXM_IDS))]
self.dp, self, self.MAX_TABLE_ID, self.MIN_MAX_FLOWS,
self.USE_OXM_IDS, self.FILL_REQ))]

def _add_default_flows(self):
ofmsgs = self._pipeline_flows()
Expand Down Expand Up @@ -1712,6 +1714,8 @@ class ArubaValve(TfmValve):
"""Valve implementation for Aruba."""

DEC_TTL = False
# Aruba does not like empty miss instructions even if not used.
FILL_REQ = False

def _delete_all_valve_flows(self):
ofmsgs = super(ArubaValve, self)._delete_all_valve_flows()
Expand Down

0 comments on commit 56a3542

Please sign in to comment.