def lacp_req_reply(self, lacp_pkt, port): """ Constructs a LACP req-reply packet. Args: lacp_pkt (PacketMeta): LACP packet received port: LACP port other_valves (list): List of other valves Returns: list packetout OpenFlow msgs. """ if port.lacp_passthrough: for peer_num in port.lacp_passthrough: lacp_peer = self.ports.get(peer_num, None) if not lacp_peer.dyn_lacp_up: self.logger.warning( 'Suppressing LACP LAG %s on %s, peer %s link is down' % (port.lacp, port, lacp_peer)) return [] actor_state_activity = 0 if port.lacp_active: actor_state_activity = 1 actor_state_sync, actor_state_col, actor_state_dist = port.get_lacp_flags( ) if lacp_pkt: pkt = valve_packet.lacp_reqreply( self.faucet_dp_mac, self.faucet_dp_mac, port.lacp, port.lacp_port_id, port.lacp_port_priority, actor_state_sync, actor_state_activity, actor_state_col, actor_state_dist, lacp_pkt.actor_system, lacp_pkt.actor_key, lacp_pkt.actor_port, lacp_pkt.actor_system_priority, lacp_pkt.actor_port_priority, lacp_pkt.actor_state_defaulted, lacp_pkt.actor_state_expired, lacp_pkt.actor_state_timeout, lacp_pkt.actor_state_collecting, lacp_pkt.actor_state_distributing, lacp_pkt.actor_state_aggregation, lacp_pkt.actor_state_synchronization, lacp_pkt.actor_state_activity) else: pkt = valve_packet.lacp_reqreply( self.faucet_dp_mac, self.faucet_dp_mac, port.lacp, port.lacp_port_id, port.lacp_port_priority, actor_state_synchronization=actor_state_sync, actor_state_activity=actor_state_activity, actor_state_collecting=actor_state_col, actor_state_distributing=actor_state_dist) self.logger.debug('Sending LACP %s on %s activity %s' % (pkt, port, actor_state_activity)) return [valve_of.packetout(port.number, pkt.data)]
def lacp_handler(self, pkt_meta): """Handle a LACP packet. We are a currently a passive, non-aggregateable LACP partner. Args: pkt_meta (PacketMeta): packet for control plane. Returns: list: OpenFlow messages, if any. """ # TODO: ensure config consistent between LAG ports. ofmsgs = [] if (pkt_meta.eth_dst == valve_packet.SLOW_PROTOCOL_MULTICAST and pkt_meta.eth_type == valve_of.ether.ETH_TYPE_SLOW and pkt_meta.port.lacp): pkt_meta.reparse_all() lacp_pkt = valve_packet.parse_lacp_pkt(pkt_meta.pkt) if lacp_pkt: last_lacp_up = pkt_meta.port.dyn_lacp_up pkt_meta.port.dyn_last_lacp_pkt = lacp_pkt pkt_meta.port.dyn_lacp_up = lacp_pkt.actor_state_synchronization pkt_meta.port.dyn_lacp_updated_time = time.time() if last_lacp_up != pkt_meta.port.dyn_lacp_up: self.logger.info( 'LACP state change from %s to %s on %s to %s LAG %u' % (last_lacp_up, pkt_meta.port.dyn_lacp_up, pkt_meta.port, lacp_pkt.actor_system, pkt_meta.port.lacp)) if pkt_meta.port.dyn_lacp_up: ofmsgs.extend(self.lacp_up(pkt_meta.port)) pkt = valve_packet.lacp_reqreply( pkt_meta.vlan.faucet_mac, pkt_meta.vlan.faucet_mac, pkt_meta.port.lacp, pkt_meta.port.number, lacp_pkt.actor_system, lacp_pkt.actor_key, lacp_pkt.actor_port, lacp_pkt.actor_system_priority, lacp_pkt.actor_port_priority, lacp_pkt.actor_state_defaulted, lacp_pkt.actor_state_expired, lacp_pkt.actor_state_timeout, lacp_pkt.actor_state_collecting, lacp_pkt.actor_state_distributing, lacp_pkt.actor_state_aggregation, lacp_pkt.actor_state_synchronization, lacp_pkt.actor_state_activity) ofmsgs.append( valve_of.packetout(pkt_meta.port.number, pkt.data)) return ofmsgs