def _switch_features_handler(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser match = parser.OFPMatch() reg = oxm_fields.NiciraExtended1('reg0', 0, type_desc.Int4), actions_x = [ parser.NXActionMultipath( fields=nicira_ext.NX_HASH_FIELDS_SYMMETRIC_L4, basis=1024, algorithm=nicira_ext.NX_MP_ALG_HRW, max_link=1, arg=0, ofs_nbits=nicira_ext.ofs_nbits(0, 31), dst="reg0") ] actions_x.append( parser.NXActionResubmitTable(in_port=8080, table_id=10)) self.add_flow(datapath, 999, match, actions_x, table=0) actions = [ parser.NXActionOutputReg(ofs_nbits=nicira_ext.ofs_nbits(0, 31), src="reg0", max_len=2048) ] learn_action = parser.NXActionLearn( table_id=15, specs=[ # Match parser.NXFlowSpecMatch( src=('eth_type_nxm', 16), dst=('eth_type', 0), n_bits=16, ), parser.NXFlowSpecMatch( src=("ip_proto_nxm", 8), dst=('ip_proto', 0), n_bits=8, ), # Actions parser.NXFlowSpecLoad( src=('reg6', 0), dst=('reg7', 0), n_bits=32, ), ], fin_idle_timeout=1, fin_hard_timeout=1, ) actions.append(learn_action) self.add_flow(datapath, 999, match, actions, table=10)
oxm_fields.OpenFlowBasic('arp_sha', 24, type_desc.MacAddr), oxm_fields.OpenFlowBasic('arp_tha', 25, type_desc.MacAddr), oxm_fields.OpenFlowBasic('ipv6_src', 26, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_dst', 27, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_flabel', 28, type_desc.Int4), oxm_fields.OpenFlowBasic('icmpv6_type', 29, type_desc.Int1), oxm_fields.OpenFlowBasic('icmpv6_code', 30, type_desc.Int1), oxm_fields.OpenFlowBasic('ipv6_nd_target', 31, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_nd_sll', 32, type_desc.MacAddr), oxm_fields.OpenFlowBasic('ipv6_nd_tll', 33, type_desc.MacAddr), oxm_fields.OpenFlowBasic('mpls_label', 34, type_desc.Int4), oxm_fields.OpenFlowBasic('mpls_tc', 35, type_desc.Int1), oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1), oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3), oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8), oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8), oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2), oxm_fields.OldONFExperimenter('pbb_uca', 2560, type_desc.Int1), # EXT-109 TCP flags match field Extension oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2), # EXT-233 Output match Extension # NOTE(yamamoto): The spec says uint64_t but I assume it's an error. oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), # The following definition is merely for testing 64-bit experimenter OXMs. # Following Open vSwitch, we use dp_hash for this purpose. # Prefix the name with '_' to indicate this is not intended to be used # in wild. oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4),
oxm_fields.OpenFlowBasic('ipv6_nd_target', 31, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_nd_sll', 32, type_desc.MacAddr), oxm_fields.OpenFlowBasic('ipv6_nd_tll', 33, type_desc.MacAddr), oxm_fields.OpenFlowBasic('mpls_label', 34, type_desc.Int4), oxm_fields.OpenFlowBasic('mpls_tc', 35, type_desc.Int1), oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1), oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3), oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8), oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2), oxm_fields.OldONFExperimenter('pbb_uca', 2560, type_desc.Int1), # EXT-109 TCP flags match field Extension oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2), # EXT-233 Output match Extension # NOTE(yamamoto): The spec says uint64_t but I assume it's an error. oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), # The following definition is merely for testing 64-bit experimenter OXMs. # Following Open vSwitch, we use dp_hash for this purpose. # Prefix the name with '_' to indicate this is not intended to be used # in wild. oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4), ] oxm_fields.generate(__name__) # define constants OFP_VERSION = 0x04 OFP_TCP_PORT = 6633 MAX_XID = 0xffffffff
oxm_fields.OpenFlowBasic('arp_sha', 24, type_desc.MacAddr), oxm_fields.OpenFlowBasic('arp_tha', 25, type_desc.MacAddr), oxm_fields.OpenFlowBasic('ipv6_src', 26, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_dst', 27, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_flabel', 28, type_desc.Int4), oxm_fields.OpenFlowBasic('icmpv6_type', 29, type_desc.Int1), oxm_fields.OpenFlowBasic('icmpv6_code', 30, type_desc.Int1), oxm_fields.OpenFlowBasic('ipv6_nd_target', 31, type_desc.IPv6Addr), oxm_fields.OpenFlowBasic('ipv6_nd_sll', 32, type_desc.MacAddr), oxm_fields.OpenFlowBasic('ipv6_nd_tll', 33, type_desc.MacAddr), oxm_fields.OpenFlowBasic('mpls_label', 34, type_desc.Int4), oxm_fields.OpenFlowBasic('mpls_tc', 35, type_desc.Int1), oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1), oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3), oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8), oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8), oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2), oxm_fields.OldONFExperimenter('pbb_uca', 2560, type_desc.Int1), # EXT-109 TCP flags match field Extension oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2), # EXT-233 Output match Extension # NOTE(yamamoto): The spec says uint64_t but I assume it's an error. oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4), oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4), # The following definition is merely for testing 64-bit experimenter OXMs. # Following Open vSwitch, we use dp_hash for this purpose. # Prefix the name with '_' to indicate this is not intended to be used
oxm_fields.NiciraExtended0('nw_tos', 5, type_desc.Int1), oxm_fields.NiciraExtended0('ip_proto_nxm', 6, type_desc.Int1), oxm_fields.NiciraExtended0('ipv4_src_nxm', 7, type_desc.IPv4Addr), oxm_fields.NiciraExtended0('ipv4_dst_nxm', 8, type_desc.IPv4Addr), oxm_fields.NiciraExtended0('tcp_src_nxm', 9, type_desc.Int2), oxm_fields.NiciraExtended0('tcp_dst_nxm', 10, type_desc.Int2), oxm_fields.NiciraExtended0('udp_src_nxm', 11, type_desc.Int2), oxm_fields.NiciraExtended0('udp_dst_nxm', 12, type_desc.Int2), oxm_fields.NiciraExtended0('icmpv4_type_nxm', 13, type_desc.Int1), oxm_fields.NiciraExtended0('icmpv4_code_nxm', 14, type_desc.Int1), oxm_fields.NiciraExtended0('arp_op_nxm', 15, type_desc.Int2), oxm_fields.NiciraExtended0('arp_spa_nxm', 16, type_desc.IPv4Addr), oxm_fields.NiciraExtended0('arp_tpa_nxm', 17, type_desc.IPv4Addr), # OFPXMC_NXM_1 oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8), oxm_fields.NiciraExtended1('arp_sha_nxm', 17, type_desc.MacAddr), oxm_fields.NiciraExtended1('arp_tha_nxm', 18, type_desc.MacAddr), oxm_fields.NiciraExtended1('ipv6_src_nxm', 19, type_desc.IPv6Addr), oxm_fields.NiciraExtended1('ipv6_dst_nxm', 20, type_desc.IPv6Addr), oxm_fields.NiciraExtended1('icmpv6_type_nxm', 21, type_desc.Int1), oxm_fields.NiciraExtended1('icmpv6_code_nxm', 22, type_desc.Int1), oxm_fields.NiciraExtended1('nd_target', 23, type_desc.IPv6Addr), oxm_fields.NiciraExtended1('nd_sll', 24, type_desc.MacAddr), oxm_fields.NiciraExtended1('nd_tll', 25, type_desc.MacAddr), oxm_fields.NiciraExtended1('ip_frag', 26, type_desc.Int1), oxm_fields.NiciraExtended1('ipv6_label', 27, type_desc.Int4), oxm_fields.NiciraExtended1('ip_ecn_nxm', 28, type_desc.Int1), oxm_fields.NiciraExtended1('nw_ttl', 29, type_desc.Int1), oxm_fields.NiciraExtended1('mpls_ttl', 30, type_desc.Int1), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
eth_type=eth_type) # Works flag = tcp.TCP_ACK match = parser.OFPMatch( tcp_flags_nxm=(flag, flag), ip_proto_nxm=inet.IPPROTO_TCP, eth_type_nxm=eth_type) """ oxm_types = [ oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr), oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr), oxm_fields.NiciraExtended0('eth_type_nxm', 3, type_desc.Int2), oxm_fields.NiciraExtended0('ip_proto_nxm', 6, type_desc.Int1), oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4), oxm_fields.NiciraExtended1('tcp_flags_nxm', 34, type_desc.Int2), oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4), oxm_fields.NiciraExtended1('ct_state', 105, type_desc.Int4), oxm_fields.NiciraExtended1('ct_zone', 106, type_desc.Int2), oxm_fields.NiciraExtended1('ct_mark', 107, type_desc.Int4), oxm_fields.NiciraExtended1('ct_label', 108, type_desc.Int16), oxm_fields.NiciraExtended1('tun_ipv6_src', 109, type_desc.IPv6Addr), oxm_fields.NiciraExtended1('tun_ipv6_dst', 110, type_desc.IPv6Addr), # The following definition is merely for testing 64-bit experimenter OXMs. # Following Open vSwitch, we use dp_hash for this purpose. # Prefix the name with '_' to indicate this is not intended to be used