Exemple #1
0
 def runTest(self):
     for wc in WILDCARD_VALUES:
         all_exp_one_wildcard = OFPFW_ALL ^ wc
         #print("%x"%(all_exp_one_wildcard))
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   wildcards=all_exp_one_wildcard)
Exemple #2
0
 def runTest(self):
     vid = testutils.test_param_get(self.config,
                                    'vid',
                                    default=TEST_VID_DEFAULT)
     testutils.flow_match_test(self,
                               pa_port_map,
                               wildcards=OFPFW_ALL,
                               dl_vlan=vid)
Exemple #3
0
 def runTest(self):
     # sup_acts = supported_actions_get(self)
     # if not (sup_acts & 1 << ofp.OFPXMT_OFB_TCP_DST):
         # testutils.skip_message_emit(self, "ModifyL4Dst test")
         # return
     (pkt, exp_pkt, acts) = testutils.pkt_action_setup(self, mod_fields=['tcp_dport'],
                                             check_test_params=True)
     testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                     apply_action_list=acts, max_test=2)
Exemple #4
0
    def runTest(self):
        sup_acts = supported_actions_get(self)
        if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
            testutils.skip_message_emit(self, "ModifyTOS test")
            return

        (pkt, exp_pkt, acts) = testutils.pkt_action_setup(self, mod_fields=['ip_tos'],
                                                check_test_params=True)
        testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt, 
                        apply_action_list=acts, max_test=2)
Exemple #5
0
 def runTest(self):
     vid = testutils.test_param_get(self.config,
                                    'vid',
                                    default=TEST_VID_DEFAULT)
     for wc in WILDCARD_VALUES:
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   wildcards=wc,
                                   dl_vlan=vid,
                                   max_test=10)
Exemple #6
0
 def runTest(self):
     vid = testutils.test_param_get(self.config,
                                    'vid',
                                    default=TEST_VID_DEFAULT)
     for wc in WILDCARD_VALUES:
         all_exp_one_wildcard = OFPFW_ALL ^ wc
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   wildcards=all_exp_one_wildcard,
                                   dl_vlan=vid)
Exemple #7
0
 def runTest(self):
     # sup_acts = supported_actions_get(self)
     # print(str(sup_acts).encode('hex'))
     # if not (sup_acts & 1 << ofp.OFPXMT_OFB_IP_DSCP):
         # testutils.skip_message_emit(self, "ModifyTOS test")
         # return
     (pkt, exp_pkt, acts) = testutils.pkt_action_setup(self, mod_fields=['ip_dscp'],
                                             check_test_params=True)
     testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                     apply_action_list=acts, max_test=2)
Exemple #8
0
    def runTest(self):
        rc = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
        rc = nxm_delete_all_flows()
        self.assertEqual(rc, 0, "Failed to delete all flows")

        pkt = testutils.simple_tcp_packet()
        testutils.flow_match_test(self, pa_port_map, pkt=pkt,  wildcards=ofp.OFPFW_ALL, max_test =1)

        rc = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")
Exemple #9
0
 def runTest(self):
     (pkt, exp_pkt,
      acts) = testutils.pkt_action_setup(self,
                                         mod_fields=['ip_ecn'],
                                         check_test_params=True)
     testutils.flow_match_test(self,
                               pa_port_map,
                               pkt=pkt,
                               exp_pkt=exp_pkt,
                               apply_action_list=acts,
                               max_test=2)
Exemple #10
0
    def runTest(self):
        old_vid = 2
        #sup_acts = supported_actions_get(self)
        #if not (sup_acts & 1 << ofp.OFPAT_POP_VLAN):
            #testutils.skip_message_emit(self, "Strip VLAN tag test")
            #return
        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': old_vid}])
        exp_pkt = testutils.simple_tcp_packet()
        vid_act = action.action_pop_vlan()

        testutils.flow_match_test(self, pa_port_map,pkt=pkt, exp_pkt=exp_pkt,
                        apply_action_list=[vid_act] , max_test = 10)
Exemple #11
0
    def runTest(self):
        old_vid = 2
        new_vid = 3
        # sup_acts = supported_actions_get(self)
        # if not (sup_acts & 1 << ofp.OFPXMT_OFB_VLAN_VID):
            # testutils.skip_message_emit(self, "Modify VLAN tag test")
            # return
        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': old_vid}])
        exp_pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': new_vid}])
        vid_act = action.action_set_field()
        vid_act.field = match.vlan_vid(new_vid + ofp.OFPVID_PRESENT)

        testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                        apply_action_list=[vid_act])
Exemple #12
0
 def runTest(self):
     # sup_acts = supported_actions_get(self)
     # if not (sup_acts & 1 << ofp.OFPXMT_OFB_TCP_DST):
     # testutils.skip_message_emit(self, "ModifyL4Dst test")
     # return
     (pkt, exp_pkt,
      acts) = testutils.pkt_action_setup(self,
                                         mod_fields=['tcp_dport'],
                                         check_test_params=True)
     testutils.flow_match_test(self,
                               pa_port_map,
                               pkt=pkt,
                               exp_pkt=exp_pkt,
                               apply_action_list=acts,
                               max_test=2)
Exemple #13
0
    def runTest(self):
        old_vid = 2
        new_vid = 3
        sup_acts = supported_actions_get(self)
        if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
            testutils.skip_message_emit(self, "Modify VLAN tag test")
            return

        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': old_vid}])
        exp_pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': new_vid}])
        vid_act = action.action_set_vlan_vid()
        vid_act.vlan_vid = new_vid

        testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                        apply_action_list=[vid_act])
Exemple #14
0
    def runTest(self):
        old_vid = 2
        #sup_acts = supported_actions_get(self)
        #if not (sup_acts & 1 << ofp.OFPAT_POP_VLAN):
        #testutils.skip_message_emit(self, "Strip VLAN tag test")
        #return
        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': old_vid}])
        exp_pkt = testutils.simple_tcp_packet()
        vid_act = action.action_pop_vlan()

        testutils.flow_match_test(self,
                                  pa_port_map,
                                  pkt=pkt,
                                  exp_pkt=exp_pkt,
                                  apply_action_list=[vid_act],
                                  max_test=10)
Exemple #15
0
 def runTest(self):
     # sup_acts = supported_actions_get(self)
     # print(str(sup_acts).encode('hex'))
     # if not (sup_acts & 1 << ofp.OFPXMT_OFB_IP_DSCP):
     # testutils.skip_message_emit(self, "ModifyTOS test")
     # return
     (pkt, exp_pkt,
      acts) = testutils.pkt_action_setup(self,
                                         mod_fields=['ip_dscp'],
                                         check_test_params=True)
     testutils.flow_match_test(self,
                               pa_port_map,
                               pkt=pkt,
                               exp_pkt=exp_pkt,
                               apply_action_list=acts,
                               max_test=2)
Exemple #16
0
    def runTest(self):
        old_vid = 2
        sup_acts = supported_actions_get(self)
        if not (sup_acts & 1 << ofp.OFPAT_POP_VLAN):
            testutils.skip_message_emit(self, "Strip VLAN tag test")
            return

        len_w_vid = 104
        len = 100
        pkt = testutils.simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True, 
                                dl_vlan=old_vid)
        exp_pkt = testutils.simple_tcp_packet(pktlen=len)
        vid_act = action.action_pop_vlan()

        testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                        apply_action_list=[vid_act])
Exemple #17
0
def bitmask_test(parent,
                 port_map,
                 wildcards=0,
                 mask=None,
                 dl_vlan=-1,
                 pkt=None,
                 exp_pkt=None,
                 action_list=None,
                 check_expire=False,
                 max_test=0):
    """
    Run flow_match_test with DL/NW bitmasks

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    @param pkt If not None, use this packet for ingress
    @param wildcards For flow match entry
    @param mask DL/NW address bit masks as a dictionary. If set, it is tested
    against the corresponding match fields with the opposite values
    @param dl_vlan If not -1, and pkt is None, create a pkt w/ VLAN tag
    @param exp_pkt If not None, use this as the expected output pkt; els use pkt
    @param action_list Additional actions to add to flow mod
    @param check_expire Check for flow expiration message
    @param max_test If > 0 no more than this number of tests are executed.
    """
    pkt = testutils.simple_tcp_packet(dl_vlan_enable=(dl_vlan >= 0),
                                      dl_vlan=dl_vlan)
    match = parse.packet_to_flow_match(pkt)
    parent.assertTrue(match is not None, "Flow match from pkt failed")
    if mask is not None:
        match.dl_src_mask = mask['dl_src']
        match.dl_dst_mask = mask['dl_dst']
        match.nw_src_mask = mask['nw_src']
        match.nw_dst_mask = mask['nw_dst']
        #Set unmatching values on corresponding match fields
        for i in range(ofp.OFP_ETH_ALEN):
            match.dl_src[i] = match.dl_src[i] ^ match.dl_src_mask[i]
            match.dl_dst[i] = match.dl_dst[i] ^ match.dl_dst_mask[i]
        match.nw_src = match.nw_src ^ match.nw_src_mask
        match.nw_dst = match.nw_dst ^ match.nw_dst_mask

    testutils.flow_match_test(parent,
                              pa_port_map,
                              pkt=pkt,
                              match=match,
                              wildcards=wildcards,
                              max_test=1)
Exemple #18
0
    def runTest(self):
        old_vid = 2
        new_vid = 3
        # sup_acts = supported_actions_get(self)
        # if not (sup_acts & 1 << ofp.OFPXMT_OFB_VLAN_VID):
        # testutils.skip_message_emit(self, "Modify VLAN tag test")
        # return
        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': old_vid}])
        exp_pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': new_vid}])
        vid_act = action.action_set_field()
        vid_act.field = match.vlan_vid(new_vid + ofp.OFPVID_PRESENT)

        testutils.flow_match_test(self,
                                  pa_port_map,
                                  pkt=pkt,
                                  exp_pkt=exp_pkt,
                                  apply_action_list=[vid_act])
Exemple #19
0
 def runTest(self):
     new_vid = 4002
     # sup_acts = supported_actions_get(self)
     # if not(sup_acts & 1<<ofp.OFPXMT_OFB_VLAN_VID):
         # testutils.skip_message_emit(self, "Add VLAN tag test")
         # return
     pkt = testutils.simple_tcp_packet()
     exp_pkt = testutils.simple_tcp_packet(
                                 vlan_tags=[{'vid': new_vid}])
     push_act = action.action_push_vlan()
     push_act.ethertype = 0x8100
     vid_act = action.action_set_field()
     vid_act.field=match.vlan_vid(new_vid + ofp.OFPVID_PRESENT)
     #vid_act = action.action_set_vlan_vid()
     #vid_act.vlan_vid = new_vid
     testutils.flow_match_test(self, pa_port_map, pkt=pkt,
                     exp_pkt=exp_pkt, apply_action_list=[push_act, vid_act])
Exemple #20
0
 def runTest(self):
     new_vid = 4002
     # sup_acts = supported_actions_get(self)
     # if not(sup_acts & 1<<ofp.OFPXMT_OFB_VLAN_VID):
     # testutils.skip_message_emit(self, "Add VLAN tag test")
     # return
     pkt = testutils.simple_tcp_packet()
     exp_pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': new_vid}])
     push_act = action.action_push_vlan()
     push_act.ethertype = 0x8100
     vid_act = action.action_set_field()
     vid_act.field = match.vlan_vid(new_vid + ofp.OFPVID_PRESENT)
     #vid_act = action.action_set_vlan_vid()
     #vid_act.vlan_vid = new_vid
     testutils.flow_match_test(self,
                               pa_port_map,
                               pkt=pkt,
                               exp_pkt=exp_pkt,
                               apply_action_list=[push_act, vid_act])
Exemple #21
0
    def runTest(self):
        new_vid = 4002
        sup_acts = supported_actions_get(self)
        if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
            testutils.skip_message_emit(self, "Add VLAN tag test")
            return

        pkt = testutils.simple_tcp_packet()
        exp_pkt = testutils.simple_tcp_packet(
                                    vlan_tags=[{'vid': new_vid}])
        push_act = action.action_push_vlan()
        push_act.ethertype = 0x8100
        

        vid_act = action.action_set_vlan_vid()
        vid_act.vlan_vid = new_vid

        testutils.flow_match_test(self, pa_port_map, pkt=pkt, 
                        exp_pkt=exp_pkt, apply_action_list=[push_act, vid_act])
Exemple #22
0
def bitmask_test(parent, port_map, wildcards=0,
                 mask=None, dl_vlan=-1, pkt=None,
                 exp_pkt=None, action_list=None, check_expire=False,
                 max_test=0):
    """
    Run flow_match_test with DL/NW bitmasks

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    @param pkt If not None, use this packet for ingress
    @param wildcards For flow match entry
    @param mask DL/NW address bit masks as a dictionary. If set, it is tested
    against the corresponding match fields with the opposite values
    @param dl_vlan If not -1, and pkt is None, create a pkt w/ VLAN tag
    @param exp_pkt If not None, use this as the expected output pkt; els use pkt
    @param action_list Additional actions to add to flow mod
    @param check_expire Check for flow expiration message
    @param max_test If > 0 no more than this number of tests are executed.
    """
    if dl_vlan >= 0:
        pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': dl_vlan}])
    else:
        pkt = testutils.simple_tcp_packet()
    match = parse.packet_to_flow_match(pkt)
    parent.assertTrue(match is not None, "Flow match from pkt failed")
    if mask is not None:
        match.dl_src_mask = mask['dl_src']
        match.dl_dst_mask = mask['dl_dst']
        match.nw_src_mask = mask['nw_src']
        match.nw_dst_mask = mask['nw_dst']
        #Set unmatching values on corresponding match fields
        for i in range(ofp.OFP_ETH_ALEN):
            match.dl_src[i] = match.dl_src[i] ^ match.dl_src_mask[i]
            match.dl_dst[i] = match.dl_dst[i] ^ match.dl_dst_mask[i]
        match.nw_src = match.nw_src ^ match.nw_src_mask
        match.nw_dst = match.nw_dst ^ match.nw_dst_mask

    testutils.flow_match_test(parent, pa_port_map,
                              pkt=pkt, match=match,
                              wildcards=wildcards, max_test=1)
Exemple #23
0
 def runTest(self):
     for vid in range(2, 100, 20):
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   dl_vlan=vid,
                                   max_test=5)
     for vid in range(100, 4000, 500):
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   dl_vlan=vid,
                                   max_test=5)
     testutils.flow_match_test(self, pa_port_map, dl_vlan=4094, max_test=5)
Exemple #24
0
 def runTest(self):
     vid = testutils.test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
     for wc in WILDCARD_VALUES:
         all_exp_one_wildcard = ofp.OFPFW_ALL ^ wc
         testutils.flow_match_test(self, pa_port_map, wildcards=all_exp_one_wildcard,
                         dl_vlan=vid)
Exemple #25
0
 def runTest(self):
     for wc in WILDCARD_VALUES:
         testutils.flow_match_test(self,
                                   pa_port_map,
                                   wildcards=wc,
                                   max_test=10)
Exemple #26
0
 def runTest(self):
     (pkt, exp_pkt, acts) = testutils.pkt_action_setup(self, mod_fields=['ip_ecn'],
                                             check_test_params=True)
     testutils.flow_match_test(self, pa_port_map, pkt=pkt, exp_pkt=exp_pkt,
                     apply_action_list=acts, max_test=2)
Exemple #27
0
 def runTest(self):
     for wc in WILDCARD_VALUES:
         all_exp_one_wildcard = ofp.OFPFW_ALL ^ wc
         testutils.flow_match_test(self, pa_port_map, wildcards=all_exp_one_wildcard)
Exemple #28
0
 def runTest(self):
     testutils.flow_match_test(self, pa_port_map)
Exemple #29
0
 def runTest(self):
     testutils.flow_match_test(self, pa_port_map, wildcards=OFPFW_ALL)
Exemple #30
0
 def runTest(self):
     vid = testutils.test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
     testutils.flow_match_test(self, pa_port_map, wildcards=ofp.OFPFW_ALL, 
                     dl_vlan=vid)
Exemple #31
0
 def runTest(self):
     for vid in range(2,100,10):
         testutils.flow_match_test(self, pa_port_map, dl_vlan=vid, max_test=5)
     for vid in range(100,4000,389):
         testutils.flow_match_test(self, pa_port_map, dl_vlan=vid, max_test=5)
     testutils.flow_match_test(self, pa_port_map, dl_vlan=4094, max_test=5)
Exemple #32
0
 def runTest(self):
     vid = testutils.test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
     for wc in WILDCARD_VALUES:
         testutils.flow_match_test(self, pa_port_map, wildcards=wc, dl_vlan=vid,
                         max_test=10)
Exemple #33
0
 def runTest(self):
     for wc in WILDCARD_VALUES:
         all_exp_one_wildcard = OFPFW_ALL ^ wc
         #print("%x"%(all_exp_one_wildcard))
         testutils.flow_match_test(self, pa_port_map, wildcards=all_exp_one_wildcard)
Exemple #34
0
 def runTest(self):
     vid = testutils.test_param_get(self.config,
                                    'vid',
                                    default=TEST_VID_DEFAULT)
     testutils.flow_match_test(self, pa_port_map, dl_vlan=vid, max_test=2)
Exemple #35
0
 def runTest(self):
     testutils.flow_match_test(self, pa_port_map, max_test=2)
Exemple #36
0
def bitmask_test(parent,
                 port_map,
                 wildcards=0,
                 mask=None,
                 dl_vlan=-1,
                 pkt=None,
                 exp_pkt=None,
                 action_list=None,
                 check_expire=False,
                 max_test=0):
    """
    Run flow_match_test with DL/NW bitmasks

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    @param pkt If not None, use this packet for ingress
    @param wildcards For flow match entry
    @param mask DL/NW address bit masks as a dictionary. If set, it is tested
    against the corresponding match fields with the opposite values
    @param dl_vlan If not -1, and pkt is None, create a pkt w/ VLAN tag
    @param exp_pkt If not None, use this as the expected output pkt; els use pkt
    @param action_list Additional actions to add to flow mod
    @param check_expire Check for flow expiration message
    @param max_test If > 0 no more than this number of tests are executed.
    """
    '''
    if pkt == None:
        if dl_vlan >= 0:
            pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': dl_vlan}])
        else:
            pkt = testutils.simple_tcp_packet()
    if mask is not None:
        match_ls = parse.packet_to_flow_match(pkt)
        parent.assertTrue(match_ls is not None, "Flow match from pkt failed")

        """
        if mask is not None:
            match.dl_src_mask = mask['dl_src']
            match.dl_dst_mask = mask['dl_dst']
            match.nw_src_mask = mask['ipv4_src']
            match.nw_dst_mask = mask['nw_dst']
            #Set unmatching values on corresponding match fields
            for i in range(ofp.OFP_ETH_ALEN):
                match.dl_src[i] = match.dl_src[i] ^ match.dl_src_mask[i]
                match.dl_dst[i] = match.dl_dst[i] ^ match.dl_dst_mask[i]
            match.nw_src = match.nw_src ^ match.nw_src_mask
            match.nw_dst = match.nw_dst ^ match.nw_dst_mask
        """
        idx = 0
        eth_src_index = 0
        eth_dst_index = 0
        ipv4_src_index = 0
        ipv4_dst_index = 0

        for obj in match_ls.items:
            if obj.field == ofp.OFPXMT_OFB_ETH_SRC:
                eth_src_index = idx
            if obj.field == ofp.OFPXMT_OFB_ETH_DST:
                eth_dst_index = idx
            if obj.field == ofp.OFPXMT_OFB_IPV4_SRC:
                ipv4_src_index = idx
            if obj.field == ofp.OFPXMT_OFB_IPV4_DST:
                ipv4_dst_index = idx
            idx = idx + 1

        match_ls.items[eth_src_index] = match.eth_src(match_ls.items[eth_src_index].value,mask = mask['eth_src'])
        match_ls.items[eth_dst_index] = match.eth_dst(match_ls.items[eth_dst_index].value,mask = mask['eth_dst'])
        match_ls.items[ipv4_src_index] = match.ipv4_src(match_ls.items[ipv4_src_index].value,mask = mask['ipv4_src'])
        match_ls.items[ipv4_dst_index] = match.ipv4_dst(match_ls.items[ipv4_dst_index].value,mask = mask['ipv4_dst'])
        for i in range(ofp.OFP_ETH_ALEN):
            match_ls.items[eth_src_index].value[i] = match_ls.items[eth_src_index].value[i] ^ (~(mask['eth_src'][i]) & 0xFF)
            match_ls.items[eth_dst_index].value[i] = match_ls.items[eth_dst_index].value[i] ^ (~(mask['eth_dst'][i]) & 0xFF)
        match_ls.items[ipv4_src_index].value = match_ls.items[ipv4_src_index].value ^ (~mask['ipv4_src'] & 0xFFFFFFFF)
        match_ls.items[ipv4_dst_index].value = match_ls.items[ipv4_dst_index].value ^ (~mask['ipv4_dst'] & 0xFFFFFFFF)

    #print(match_ls.show())
    '''
    testutils.flow_match_test(
        parent,
        pa_port_map,
        pkt=pkt,
        table_id=testutils.WC_ALL_TABLE,  #match=match_ls,
        wildcards=wildcards,
        mask=mask,
        max_test=1)
Exemple #37
0
 def runTest(self):
     vid = testutils.test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
     testutils.flow_match_test(self, pa_port_map, dl_vlan=vid, max_test=2)
Exemple #38
0
 def runTest(self):
     for wc in WILDCARD_VALUES:
         testutils.flow_match_test(self, pa_port_map, wildcards=wc, max_test=10)
Exemple #39
0
def bitmask_test(parent, port_map, wildcards=0,
                 mask=None, dl_vlan=-1, pkt=None,
                 exp_pkt=None, action_list=None, check_expire=False,
                 max_test=0):
    """
    Run flow_match_test with DL/NW bitmasks

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    @param pkt If not None, use this packet for ingress
    @param wildcards For flow match entry
    @param mask DL/NW address bit masks as a dictionary. If set, it is tested
    against the corresponding match fields with the opposite values
    @param dl_vlan If not -1, and pkt is None, create a pkt w/ VLAN tag
    @param exp_pkt If not None, use this as the expected output pkt; els use pkt
    @param action_list Additional actions to add to flow mod
    @param check_expire Check for flow expiration message
    @param max_test If > 0 no more than this number of tests are executed.
    """
    '''
    if pkt == None:
        if dl_vlan >= 0:
            pkt = testutils.simple_tcp_packet(vlan_tags=[{'vid': dl_vlan}])
        else:
            pkt = testutils.simple_tcp_packet()
    if mask is not None:
        match_ls = parse.packet_to_flow_match(pkt)
        parent.assertTrue(match_ls is not None, "Flow match from pkt failed")

        """
        if mask is not None:
            match.dl_src_mask = mask['dl_src']
            match.dl_dst_mask = mask['dl_dst']
            match.nw_src_mask = mask['ipv4_src']
            match.nw_dst_mask = mask['nw_dst']
            #Set unmatching values on corresponding match fields
            for i in range(ofp.OFP_ETH_ALEN):
                match.dl_src[i] = match.dl_src[i] ^ match.dl_src_mask[i]
                match.dl_dst[i] = match.dl_dst[i] ^ match.dl_dst_mask[i]
            match.nw_src = match.nw_src ^ match.nw_src_mask
            match.nw_dst = match.nw_dst ^ match.nw_dst_mask
        """
        idx = 0
        eth_src_index = 0
        eth_dst_index = 0
        ipv4_src_index = 0
        ipv4_dst_index = 0

        for obj in match_ls.items:
            if obj.field == ofp.OFPXMT_OFB_ETH_SRC:
                eth_src_index = idx
            if obj.field == ofp.OFPXMT_OFB_ETH_DST:
                eth_dst_index = idx
            if obj.field == ofp.OFPXMT_OFB_IPV4_SRC:
                ipv4_src_index = idx
            if obj.field == ofp.OFPXMT_OFB_IPV4_DST:
                ipv4_dst_index = idx
            idx = idx + 1

        match_ls.items[eth_src_index] = match.eth_src(match_ls.items[eth_src_index].value,mask = mask['eth_src'])
        match_ls.items[eth_dst_index] = match.eth_dst(match_ls.items[eth_dst_index].value,mask = mask['eth_dst'])
        match_ls.items[ipv4_src_index] = match.ipv4_src(match_ls.items[ipv4_src_index].value,mask = mask['ipv4_src'])
        match_ls.items[ipv4_dst_index] = match.ipv4_dst(match_ls.items[ipv4_dst_index].value,mask = mask['ipv4_dst'])
        for i in range(ofp.OFP_ETH_ALEN):
            match_ls.items[eth_src_index].value[i] = match_ls.items[eth_src_index].value[i] ^ (~(mask['eth_src'][i]) & 0xFF)
            match_ls.items[eth_dst_index].value[i] = match_ls.items[eth_dst_index].value[i] ^ (~(mask['eth_dst'][i]) & 0xFF)
        match_ls.items[ipv4_src_index].value = match_ls.items[ipv4_src_index].value ^ (~mask['ipv4_src'] & 0xFFFFFFFF)
        match_ls.items[ipv4_dst_index].value = match_ls.items[ipv4_dst_index].value ^ (~mask['ipv4_dst'] & 0xFFFFFFFF)

    #print(match_ls.show())
    '''
    testutils.flow_match_test(parent, pa_port_map,
                              pkt=pkt, table_id=testutils.WC_ALL_TABLE, #match=match_ls,
                              wildcards=wildcards, mask = mask, max_test=1)
Exemple #40
0
 def runTest(self):
     testutils.flow_match_test(self, pa_port_map, wildcards=ofp.OFPFW_ALL)