faucet.valve_of module

Utility functions to parse/create OpenFlow messages.

class faucet.valve_of.NullRyuDatapath[source]

Bases: object

Placeholder Ryu Datapath.

ofproto = <module 'os_ken.ofproto.ofproto_v1_3' from '/home/user/documentation/docs/faucet/venv/lib/python3.10/site-packages/os_ken/ofproto/ofproto_v1_3.py'>
faucet.valve_of.apply_actions(actions)[source]

Return instruction that applies action list.

Parameters:

actions (list) – list of OpenFlow actions.

Returns:

instruction of actions.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPInstruction

faucet.valve_of.apply_meter(meter_id)[source]

Return instruction to apply a meter.

faucet.valve_of.barrier()[source]

Return OpenFlow barrier request.

Returns:

barrier request.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPBarrierRequest

faucet.valve_of.bucket(weight=0, watch_port=4294967295, watch_group=4294967295, actions=None)[source]

Return a group action bucket with provided actions.

faucet.valve_of.build_group_flood_buckets(vlan_flood_acts)[source]

Return a list of group buckets to implement flooding on a VLAN.

faucet.valve_of.build_match_dict(in_port=None, vlan=None, eth_type=None, eth_src=None, eth_dst=None, eth_dst_mask=None, icmpv6_type=None, nw_proto=None, nw_dst=None, metadata=None, metadata_mask=None, vlan_pcp=None, udp_src=None, udp_dst=None)[source]
faucet.valve_of.controller_pps_meteradd(datapath=None, pps=0)[source]

Add a PPS meter towards controller.

faucet.valve_of.controller_pps_meterdel(datapath=None)[source]

Delete a PPS meter towards controller.

faucet.valve_of.ct(**kwds)[source]

Return connection tracker action.

Parameters:

kwds (dict) – exactly one connection tracker action.

Returns:

connection tracker action.

Return type:

ryu.ofproto.nx_actions.NXActionCT

faucet.valve_of.ct_clear()[source]

Return clear connection tracker state action.

Parameters:

kwds (dict) – exactly one clear connection tracker state action.

Returns:

clear connection tracker state action.

Return type:

ryu.ofproto.nx_actions.NXActionCTClear

faucet.valve_of.ct_nat(**kwds)[source]

Return network address translation connection tracker action.

Parameters:

kwds (dict) – exactly one network address translation connection tracker action.

Returns:

network address translation connection tracker action.

Return type:

ryu.ofproto.nx_actions.NXActionNAT

faucet.valve_of.dec_ip_ttl()[source]

Return OpenFlow action to decrement IP TTL.

Returns:

decrement IP TTL.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionDecNwTtl

faucet.valve_of.dedupe_ofmsgs(input_ofmsgs, random_order, flowkey)[source]

Return deduplicated ofmsg list.

faucet.valve_of.dedupe_output_port_acts(output_port_acts)[source]

Deduplicate parser.OFPActionOutputs (because Ryu doesn’t define __eq__).

Parameters:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput (list of) – output to port actions.

Returns:

output to port actions.

Return type:

list of ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput

faucet.valve_of.dedupe_overlaps_ofmsgs(input_ofmsgs, random_order, flowkey)[source]
faucet.valve_of.desc_stats_request(datapath=None)[source]

Query switch description.

faucet.valve_of.devid_present(vid)[source]

Return VLAN VID without VID_PRESENT flag set.

Parameters:

vid (int) – VLAN VID with VID_PRESENT.

Returns:

VLAN VID.

Return type:

int

faucet.valve_of.faucet_async(datapath=None, notify_flow_removed=False, packet_in=True, port_status=True)[source]

Return async message config for FAUCET/Gauge

faucet.valve_of.faucet_config(datapath=None)[source]

Return switch config for FAUCET.

faucet.valve_of.flood_port_outputs(tagged_ports, untagged_ports, in_port=None, exclude_ports=None)[source]

Return actions for both tagged and untagged ports.

faucet.valve_of.flood_tagged_port_outputs(ports, in_port=None, exclude_ports=None)[source]

Return list of actions necessary to flood to list of tagged ports.

faucet.valve_of.flood_untagged_port_outputs(ports, in_port=None, exclude_ports=None)[source]

Return list of actions necessary to flood to list of untagged ports.

faucet.valve_of.flowmod(cookie, command, table_id, priority, out_port, out_group, match_fields, inst, hard_timeout, idle_timeout, flags=0)[source]
faucet.valve_of.goto_table(table)[source]

Return instruction to goto table.

Parameters:

table (ValveTable) – table to goto.

Returns:

goto instruction.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPInstruction

faucet.valve_of.goto_table_id(table_id)[source]

Return instruction to goto table by table ID.

Parameters:

table (int) – table by ID to goto.

Returns:

goto instruction.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPInstruction

faucet.valve_of.group_act(group_id)[source]

Return an action to run a group.

faucet.valve_of.groupadd(datapath=None, type_=0, group_id=0, buckets=None)[source]

Add a group.

faucet.valve_of.groupadd_ff(datapath=None, group_id=0, buckets=None)[source]

Add a fast failover group.

faucet.valve_of.groupdel(datapath=None, group_id=4294967292)[source]

Delete a group (default all groups).

faucet.valve_of.ignore_port(port_num)[source]

Return True if FAUCET should ignore this port.

Parameters:

port_num (int) – switch port.

Returns:

True if FAUCET should ignore this port.

Return type:

bool

faucet.valve_of.is_apply_actions(instruction)[source]

Return True if an apply action.

Parameters:

instruction – OpenFlow instruction.

Returns:

True if an apply action.

Return type:

bool

faucet.valve_of.is_ct(action)[source]
faucet.valve_of.is_flowaddmod(ofmsg)[source]

Return True if flow message is a FlowMod, add or modify.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a FlowMod, add or modify.

Return type:

bool

faucet.valve_of.is_flowdel(ofmsg)[source]

Return True if flow message is a FlowMod and a delete.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a FlowMod delete/strict.

Return type:

bool

faucet.valve_of.is_flowmod(ofmsg)[source]

Return True if flow message is a FlowMod.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a FlowMod

Return type:

bool

faucet.valve_of.is_global_flowdel(ofmsg)[source]

Is a delete of all flows in all tables.

faucet.valve_of.is_global_groupdel(ofmsg)[source]

Is a delete of all groups.

faucet.valve_of.is_global_meterdel(ofmsg)[source]

Is a delete of all meters.

faucet.valve_of.is_groupadd(ofmsg)[source]

Return True if OF message is a GroupMod and command is add.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a GroupMod add

Return type:

bool

faucet.valve_of.is_groupdel(ofmsg)[source]

Return True if OF message is a GroupMod and command is delete.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a GroupMod delete

Return type:

bool

faucet.valve_of.is_groupmod(ofmsg)[source]

Return True if OF message is a GroupMod.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a GroupMod

Return type:

bool

faucet.valve_of.is_meter(instruction)[source]

Return True if a meter.

Parameters:

instruction – OpenFlow instruction.

Returns:

True if a meter.

Return type:

bool

faucet.valve_of.is_meteradd(ofmsg)[source]

Return True if OF message is a MeterMod and command is add.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a MeterMod add

Return type:

bool

faucet.valve_of.is_meterdel(ofmsg)[source]

Return True if OF message is a MeterMod and command is delete.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a MeterMod delete

Return type:

bool

faucet.valve_of.is_metermod(ofmsg)[source]

Return True if OF message is a MeterMod.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a MeterMod

Return type:

bool

faucet.valve_of.is_output(ofmsg)[source]

Return True if flow message is an action output message.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a OFPActionOutput.

Return type:

bool

faucet.valve_of.is_packetout(ofmsg)[source]

Return True if OF message is a PacketOut

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a PacketOut

Return type:

bool

faucet.valve_of.is_set_field(action)[source]
faucet.valve_of.is_table_features_req(ofmsg)[source]

Return True if flow message is a TFM req.

Parameters:

ofmsg – ryu.ofproto.ofproto_v1_3_parser message.

Returns:

True if is a TFM req.

Return type:

bool

faucet.valve_of.match(match_fields)[source]

Return OpenFlow matches from dict.

Parameters:

match_fields (dict) – match fields and values.

Returns:

matches.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPMatch

faucet.valve_of.match_from_dict(match_dict)[source]

Parse a match dict into a OFPMatch object

faucet.valve_of.metadata_goto_table(metadata, mask, table)[source]

Return instructions to write metadata and goto table.

Parameters:
  • metadata (int) – metadata to write to packet

  • maks (int) – mask to apply to metadata

  • table (ValveTable) – table to goto.

Returns:

list of OFPInstructions

faucet.valve_of.meteradd(meter_conf, command=0)[source]

Add a meter based on YAML configuration.

faucet.valve_of.meterdel(datapath=None, meter_id=4294967295)[source]

Delete a meter (default all meters).

faucet.valve_of.output_controller(max_len=194)[source]

Return OpenFlow action to packet in to the controller.

Parameters:

max_len (int) – max number of bytes from packet to output.

Returns:

packet in action.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput

faucet.valve_of.output_in_port()[source]

Return OpenFlow action to output out input port.

Returns:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput.

faucet.valve_of.output_non_output_actions(flood_acts)[source]

Split output actions into deduped actions, output ports, and non-output port actions.

Parameters:

ryu.ofproto.ofproto_v1_3_parser.OFPActions (list of) – flood actions.

Returns:

set of deduped actions, output ports, and non-output actions.

faucet.valve_of.output_port(port_num, max_len=0)[source]

Return OpenFlow action to output to a port.

Parameters:
  • port_num (int) – port to output to.

  • max_len (int) – maximum length of packet to output (default no maximum).

Returns:

output to port action.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput

faucet.valve_of.packetout(port_num, data)[source]

Return OpenFlow action to packet out to dataplane from controller.

Parameters:
  • port_num (int) – port to output to.

  • data (str) – raw packet to output.

Returns:

packet out action.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput

faucet.valve_of.packetouts(port_nums, data)[source]

Return OpenFlow action to multiply packet out to dataplane from controller.

Parameters:
  • port_num (list) – ints, ports to output to.

  • data (str) – raw packet to output.

Returns:

packet out action.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput

faucet.valve_of.pop_vlan()[source]

Return OpenFlow action to pop outermost Ethernet 802.1Q VLAN header.

Returns:

Pop VLAN.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionPopVlan

faucet.valve_of.port_status_from_state(state)[source]

Return True if OFPPS_LINK_DOWN is not set.

faucet.valve_of.ports_from_output_port_acts(output_port_acts)[source]

Return unique port numbers from OFPActionOutput actions.

Parameters:

ryu.ofproto.ofproto_v1_3_parser.OFPActionOutput (list of) – output to port actions.

Returns:

set of port number ints.

faucet.valve_of.push_vlan_act(table, vlan_vid, eth_type=33024)[source]

Return OpenFlow action list to push Ethernet 802.1Q header with VLAN VID.

Parameters:

vid (int) – VLAN VID

Returns:

actions to push 802.1Q header with VLAN VID set.

Return type:

list

faucet.valve_of.remove_overlap_ofmsgs(input_ofmsgs, overlap_input_ofmsgs)[source]
faucet.valve_of.set_field(**kwds)[source]

Return action to set any field.

Parameters:

kwds (dict) – exactly one field to set

Returns:

set field action.

Return type:

ryu.ofproto.ofproto_v1_3_parser.OFPActionSetField

faucet.valve_of.slowpath_pps_meteradd(datapath=None, pps=0)[source]

Add a PPS meter towards controller.

faucet.valve_of.slowpath_pps_meterdel(datapath=None)[source]

Delete a PPS meter towards controller.

faucet.valve_of.sort_flows(input_ofmsgs)[source]

Sort flows in canonical order, descending table and priority.

faucet.valve_of.table_features(body)[source]
faucet.valve_of.valve_flowreorder(input_ofmsgs, use_barriers=True)[source]

Reorder flows for better OFA performance.

faucet.valve_of.valve_match_vid(value)[source]
faucet.valve_of.verify_flowmod(flowmod_msg)[source]

Verify flowmod can be serialized.

faucet.valve_of.vid_present(vid)[source]

Return VLAN VID with VID_PRESENT flag set.

Parameters:

vid (int) – VLAN VID

Returns:

VLAN VID with VID_PRESENT.

Return type:

int