faucet.valve module

Implementation of Valve learning layer 2/3 switch.

class faucet.valve.AlliedTelesis(dp, logname, metrics, notifier)[source]

Bases: faucet.valve.OVSValve

Valve implementation for AT.

DEC_TTL = False
class faucet.valve.ArubaValve(dp, logname, metrics, notifier)[source]

Bases: faucet.valve.TfmValve

Valve implementation that uses OpenFlow send table features messages.

DEC_TTL = False
PIPELINE_CONF = 'aruba_pipeline.json'
class faucet.valve.CiscoC9KValve(dp, logname, metrics, notifier)[source]

Bases: faucet.valve.TfmValve

Valve implementation that uses OpenFlow send table features messages.

PIPELINE_CONF = 'cisco_c9k_pipeline.json'
class faucet.valve.OVSValve(dp, logname, metrics, notifier)[source]

Bases: faucet.valve.Valve

Valve implementation for OVS.

USE_BARRIERS = True
class faucet.valve.TfmValve(dp, logname, metrics, notifier)[source]

Bases: faucet.valve.Valve

Valve implementation that uses OpenFlow send table features messages.

PIPELINE_CONF = 'tfm_pipeline.json'
class faucet.valve.Valve(dp, logname, metrics, notifier)[source]

Bases: object

Generates the messages to configure a datapath as a l2 learning switch.

Vendor specific implementations may require sending configuration flows. This can be achieved by inheriting from this class and overwriting the function switch_features.

DEC_TTL = True
USE_BARRIERS = True
add_authed_mac(port_num, mac)[source]

Add authed mac address

add_route(vlan, ip_gw, ip_dst)[source]

Add route to VLAN routing table.

advertise(now)[source]

Called periodically to advertise services (eg. IPv6 RAs).

base_prom_labels = None
close_logs()[source]

Explicitly close any active loggers.

datapath_connect(now, discovered_up_ports)[source]

Handle Ryu datapath connection event and provision pipeline.

Parameters:
  • now (float) – current epoch time.
  • discovered_up_ports (list) – datapath port numbers that are up.
Returns:

OpenFlow messages to send to datapath.

Return type:

list

datapath_disconnect()[source]

Handle Ryu datapath disconnection event.

del_route(vlan, ip_dst)[source]

Delete route from VLAN routing table.

dp_init()[source]

Initialize datapath state at connection/re/config time.

flood_manager = None
flow_timeout(now, table_id, match)[source]

Call flow timeout message handler:

Parameters:
  • now (float) – current epoch time.
  • table_id (int) – ID of table where flow was installed.
  • match (dict) – match conditions for expired flow.
Returns:

OpenFlow messages, if any.

Return type:

list

get_config_dict()[source]

Return datapath config as a dict for experimental API.

host_manager = None
lacp_down(port)[source]

Return OpenFlow messages when LACP is down on a port.

lacp_handler(now, pkt_meta)[source]

Handle a LACP packet.

We are a currently a passive, non-aggregateable LACP partner.

Parameters:
  • now (float) – current epoch time.
  • pkt_meta (PacketMeta) – packet for control plane.
Returns:

OpenFlow messages, if any.

Return type:

list

lacp_up(port)[source]

Return OpenFlow messages when LACP is up on a port.

lldp_handler(now, pkt_meta)[source]

Handle an LLDP packet.

Parameters:pkt_meta (PacketMeta) – packet for control plane.
logger = None
ofchannel_log(ofmsgs)[source]

Log OpenFlow messages in text format to debugging log.

ofchannel_logger = None
ofdescstats_handler(body)[source]

Handle OF DP description.

oferror(msg)[source]

Correlate OFError message with flow we sent, if any.

Parameters:msg (ryu.controller.ofp_event.EventOFPMsgBase) – message from datapath.
parse_pkt_meta(msg)[source]

Parse OF packet-in message to PacketMeta.

parse_rcv_packet(in_port, vlan_vid, eth_type, data, orig_len, pkt, eth_pkt)[source]

Parse a received packet into a PacketMeta instance.

Parameters:
  • in_port (int) – port packet was received on.
  • vlan_vid (int) – VLAN VID of port packet was received on.
  • eth_type (int) – Ethernet type of packet.
  • data (bytes) – Raw packet data.
  • orig_len (int) – Original length of packet.
  • pkt (ryu.lib.packet.packet) – parsed packet received.
  • ekt_pkt (ryu.lib.packet.ethernet) – parsed Ethernet header.
Returns:

PacketMeta instance.

port_add(port_num)[source]

Handle addition of a single port.

Parameters:port_num (list) – list of port numbers.
Returns:OpenFlow messages, if any.
Return type:list
port_delete(port_num)[source]

Return flow messages that delete port from pipeline.

port_no_valid(port_no)[source]

Return True if supplied port number valid on this datapath.

port_status_handler(port_no, reason, state)[source]

Return OpenFlow messages responding to port operational status change.

ports_add(port_nums, cold_start=False, log_msg='up')[source]

Handle the addition of ports.

Parameters:
  • port_num (list) – list of port numbers.
  • cold_start (bool) – True if configuring datapath from scratch.
Returns:

OpenFlow messages, if any.

Return type:

list

ports_delete(port_nums, log_msg='down')[source]

Handle the deletion of ports.

Parameters:port_nums (list) – list of port numbers.
Returns:OpenFlow messages, if any.
Return type:list
prepare_send_flows(flow_msgs)[source]

Prepare to send flows to datapath.

Parameters:flow_msgs (list) – OpenFlow messages to send.
rate_limit_packet_ins(now)[source]

Return True if too many packet ins this second.

rcv_packet(now, other_valves, pkt_meta)[source]

Handle a packet from the dataplane (eg to re/learn a host).

The packet may be sent to us also in response to FAUCET initiating IPv6 neighbor discovery, or ARP, to resolve a nexthop.

Parameters:
  • other_valves (list) – all Valves other than this one.
  • pkt_meta (PacketMeta) – packet for control plane.
Returns:

OpenFlow messages, if any.

Return type:

list

recent_ofmsgs = deque([], maxlen=32)
reload_config(now, new_dp)[source]

Reload configuration new_dp.

Following config changes are currently supported:
  • Port config: support all available configs
    (e.g. native_vlan, acl_in) & change operations (add, delete, modify) a port
  • ACL config:support any modification, currently reload all
    rules belonging to an ACL
  • VLAN config: enable, disable routing, etc…
Parameters:
  • now (float) – current epoch time.
  • new_dp (DP) – new dataplane configuration.
Returns:

OpenFlow messages.

Return type:

ofmsgs (list)

resolve_gateways(now)[source]

Call route managers to re/resolve gateways.

Returns:OpenFlow messages, if any.
Return type:list
send_flows(ryu_dp, flow_msgs)[source]

Send flows to datapath.

Parameters:
  • ryu_dp (ryu.controller.controller.Datapath) – datapath.
  • flow_msgs (list) – OpenFlow messages to send.
send_lldp_beacons(now)[source]

Called periodically to send LLDP beacon packets.

state_expire(now)[source]

Expire controller caches/state (e.g. hosts learned).

Expire state from the host manager only; the switch does its own flow expiry.

Returns:OpenFlow messages, if any.
Return type:list
switch_features(_msg)[source]

Send configuration flows necessary for the switch implementation.

Parameters:msg (OFPSwitchFeatures) – msg sent from switch.

Vendor specific configuration should be implemented here.

update_config_metrics()[source]

Update gauge/metrics for configuration.

update_metrics(now, updated_port=None, rate_limited=False)[source]

Update Gauge/metrics.

Called periodically to verify the state of stack ports.

class faucet.valve.ValveLogger(logger, dp_id, dp_name)[source]

Bases: object

Logger for a Valve that adds DP ID.

debug(log_msg)[source]

Log debug level message.

error(log_msg)[source]

Log error level message.

info(log_msg)[source]

Log info level message.

warning(log_msg)[source]

Log warning level message.

faucet.valve.valve_factory(dp)[source]

Return a Valve object based dp’s hardware configuration field.

Parameters:dp (DP) – DP instance with the configuration for this Valve.