faucet.valve module

Implementation of Valve learning layer 2/3 switch.

class faucet.valve.ArubaValve(dp, logname, 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.TfmValve(dp, logname, notifier)[source]

Bases: faucet.valve.Valve

Valve implementation that uses OpenFlow send table features messages.

PIPELINE_CONF = 'tfm_pipeline.json'
SKIP_VALIDATION_TABLES = ()
switch_features(msg)[source]
class faucet.valve.Valve(dp, logname, 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
L3 = False
add_route(vlan, ip_gw, ip_dst)[source]

Add route to VLAN routing table.

advertise()[source]

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

base_prom_labels = None
control_plane_handler(pkt_meta)[source]

Handle a packet probably destined to FAUCET’s route managers.

For example, next hop resolution or ICMP echo requests.

Parameters:pkt_meta (PacketMeta) – packet for control plane.
Returns:OpenFlow messages, if any.
Return type:list
datapath_connect(discovered_up_port_nums)[source]

Handle Ryu datapath connection event and provision pipeline.

Parameters:discovered_up_port_nums (list) – datapath ports that are up as ints.
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.

flow_timeout(table_id, match)[source]
get_config_dict()[source]
lacp_down(port)[source]
lacp_handler(pkt_meta)[source]

Handle a LACP packet.

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

Parameters:pkt_meta (PacketMeta) – packet for control plane.
Returns:OpenFlow messages, if any.
Return type:list
lacp_up(port)[source]
ofchannel_log(ofmsgs)[source]

Log OpenFlow messages in text format to debugging log.

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]
port_status_handler(port_no, reason, port_status)[source]
ports_add(port_nums, cold_start=False)[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)[source]

Handle the deletion of ports.

Parameters:port_nums (list) – list of port numbers.
Returns:OpenFlow messages, if any.
Return type:list
rcv_packet(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 = <queue.Queue object>
reload_config(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:new_dp (DP) – new dataplane configuration.
Returns:cold_start (bool): whether cold starting. ofmsgs (list): OpenFlow messages.
Return type:tuple of
resolve_gateways()[source]

Call route managers to re/resolve gateways.

Returns:OpenFlow messages, if any.
Return type:list
state_expire()[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(metrics)[source]

Update gauge/metrics for configuration.

Parameters:metrics (FaucetMetrics) – container of Prometheus metrics.
update_metrics(metrics)[source]

Update Gauge/metrics.

Parameters:metrics (FaucetMetrics or None) – container of Prometheus metrics.
class faucet.valve.ValveLogger(logger, dp_id)[source]

Bases: object

debug(log_msg)[source]
error(log_msg)[source]
info(log_msg)[source]
warning(log_msg)[source]
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.