Skip to content

Commit 0297543

Browse files
author
Josh Bailey
committed
Move LACP active to fast_advertise().
1 parent 3b07228 commit 0297543

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

faucet/valve.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Valve:
8787
'ofchannel_logger',
8888
'recent_ofmsgs',
8989
'_last_advertise_sec',
90+
'_last_fast_advertise_sec',
9091
'_last_packet_in_sec',
9192
'_last_pipeline_flows',
9293
'_packet_in_count_sec',
@@ -149,6 +150,7 @@ def dp_init(self):
149150
self._packet_in_count_sec = 0
150151
self._last_packet_in_sec = 0
151152
self._last_advertise_sec = 0
153+
self._last_fast_advertise_sec = 0
152154
self._route_manager_by_ipv = {}
153155
self._route_manager_by_eth_type = {}
154156
self._port_highwater = {}
@@ -513,16 +515,15 @@ def _decode_port_status(reason):
513515
def advertise(self, now, _other_values):
514516
"""Called periodically to advertise services (eg. IPv6 RAs)."""
515517
ofmsgs = []
516-
if (self.dp.advertise_interval and
517-
now - self._last_advertise_sec > self.dp.advertise_interval):
518-
for route_manager in list(self._route_manager_by_ipv.values()):
519-
for vlan in list(self.dp.vlans.values()):
520-
ofmsgs.extend(route_manager.advertise(vlan))
521-
for port in list(self.dp.lacp_active_ports):
522-
if port.running():
523-
pkt = self._lacp_pkt(port.dyn_last_lacp_pkt, port)
524-
ofmsgs.append(valve_of.packetout(port.number, pkt.data))
525-
self._last_advertise_sec = now
518+
if (not self.dp.advertise_interval or
519+
now - self._last_advertise_sec < self.dp.advertise_interval):
520+
return ofmsgs
521+
self._last_advertise_sec = now
522+
523+
for route_manager in list(self._route_manager_by_ipv.values()):
524+
for vlan in list(self.dp.vlans.values()):
525+
ofmsgs.extend(route_manager.advertise(vlan))
526+
526527
return ofmsgs
527528

528529
def _send_lldp_beacon_on_port(self, port, now):
@@ -546,18 +547,27 @@ def _send_lldp_beacon_on_port(self, port, now):
546547
return valve_of.packetout(port.number, lldp_beacon_pkt.data)
547548

548549
def fast_advertise(self, now, _other_valves):
549-
"""Called periodically to send LLDP beacon packets."""
550+
"""Called periodically to send LLDP/LACP packets."""
550551
# TODO: the beacon service is specifically NOT to support conventional R/STP.
551552
# It is intended to facilitate physical troubleshooting (e.g.
552553
# a standard cable tester can display OF port information).
553554
# It is used also by stacking to verify stacking links.
554555
# TODO: in the stacking case, provide an authentication scheme for the probes
555556
# so they cannot be forged.
556557
ofmsgs = []
558+
if (not self.dp.fast_advertise_interval or
559+
now - self._last_fast_advertise_sec < self.dp.fast_advertise_interval):
560+
return ofmsgs
561+
self._last_fast_advertise_sec = now
562+
563+
for port in list(self.dp.lacp_active_ports):
564+
if port.running():
565+
pkt = self._lacp_pkt(port.dyn_last_lacp_pkt, port)
566+
ofmsgs.append(valve_of.packetout(port.number, pkt.data))
567+
557568
ports = self.dp.lldp_beacon_send_ports(now)
558-
if ports:
559-
self.logger.debug('sending LLDP beacons on %s' % ports)
560-
ofmsgs = [self._send_lldp_beacon_on_port(port, now) for port in ports]
569+
ofmsgs.extend([self._send_lldp_beacon_on_port(port, now) for port in ports])
570+
561571
return ofmsgs
562572

563573
def _next_stack_link_state(self, port, now):

0 commit comments

Comments
 (0)