Esempio n. 1
0
def mpls_push_set_two_tables_tests(parent, test_condition=0, match_exp=True):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = random.randint(16, 1048574)
    tc = random.randint(0, 6)
    ttl = 64

    # Match condition on TBL0 (match)
    label_match_tbl0 = label
    tc_match_tbl0 = tc
    dl_type_match_tbl0 = ETHERTYPE_MPLS

    # Match or Unmatch depends on match_exp parameter
    # Expect different label
    if (test_condition == 0):
        exp_label = label + 1
        exp_tc = tc
        exp_ttl = ttl
    # Expect different TC
    elif (test_condition == 1):
        exp_label = label
        exp_tc = tc + 1
        exp_ttl = ttl
    # Expect different TTL
    else:  # test_condition == 2
        exp_label = label
        exp_tc = tc
        exp_ttl = ttl + 2

    # Create action_list for TBL0
    action_list_tbl0 = []
    act = action.action_push_mpls()
    act.ethertype = ETHERTYPE_MPLS
    action_list_tbl0.append(act)
    if (match_exp):
        if (test_condition == 0):
            act = action.action_set_mpls_label()
            act.mpls_label = exp_label
            action_list_tbl0.append(act)
        elif (test_condition == 1):
            act = action.action_set_mpls_tc()
            act.mpls_tc = exp_tc
            action_list_tbl0.append(act)
        else:  #test_condition == 2
            act = action.action_set_mpls_ttl()
            act.mpls_ttl = exp_ttl
            action_list_tbl0.append(act)

    # Match condition on TBL1
    label_match_tbl1 = exp_label
    tc_match_tbl1 = exp_tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent,
                                    pa_port_map,
                                    wildcards=wildcards,
                                    mpls_label=label,
                                    mpls_tc=tc,
                                    mpls_ttl=ttl,
                                    label_match_tbl0=label_match_tbl0,
                                    tc_match_tbl0=tc_match_tbl0,
                                    dl_type_match_tbl0=dl_type_match_tbl0,
                                    action_list_tbl0=action_list_tbl0,
                                    match_exp_tbl0=True,
                                    label_match_tbl1=label_match_tbl1,
                                    tc_match_tbl1=tc_match_tbl1,
                                    dl_type_match_tbl1=dl_type_match_tbl1,
                                    match_exp_tbl1=match_exp,
                                    exp_mpls_label=exp_label,
                                    exp_mpls_tc=exp_tc,
                                    exp_mpls_ttl=exp_ttl,
                                    add_tag_exp=True,
                                    max_test=1)
Esempio n. 2
0
def mpls_set_two_tables_tests(parent, match_exp=True):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = random.randint(16, 1048574)
    tc = random.randint(0, 6)
    ttl = 64
    ip_ttl = 192

    # Match condition on TBL0 (match)
    label_match_tbl0 = label
    tc_match_tbl0 = tc
    dl_type_match_tbl0 = ETHERTYPE_MPLS

    # Set LABEL TC TTL
    exp_label = label + 1
    exp_tc = tc + 1
    exp_ttl = ttl + 2
    exp_ip_ttl = ip_ttl
    # Create action_list for TBL0
    act = action.action_set_mpls_label()
    act.mpls_label = exp_label
    act2 = action.action_set_mpls_tc()
    act2.mpls_tc = exp_tc
    act3 = action.action_set_mpls_ttl()
    act3.mpls_ttl = exp_ttl
    action_list_tbl0 = [act, act2, act3]

    # Expect modified pkt on TBL1 (match)
    if (match_exp):
        label_match_tbl1 = exp_label
        tc_match_tbl1 = exp_tc
    # Expect the same pkt on TBL1 (Unmatch)
    else:
        label_match_tbl1 = label
        tc_match_tbl1 = tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent,
                                    pa_port_map,
                                    wildcards=wildcards,
                                    mpls_label=label,
                                    mpls_tc=tc,
                                    mpls_ttl=ttl,
                                    ip_ttl=ip_ttl,
                                    label_match_tbl0=label_match_tbl0,
                                    tc_match_tbl0=tc_match_tbl0,
                                    dl_type_match_tbl0=dl_type_match_tbl0,
                                    action_list_tbl0=action_list_tbl0,
                                    match_exp_tbl0=True,
                                    label_match_tbl1=label_match_tbl1,
                                    tc_match_tbl1=tc_match_tbl1,
                                    dl_type_match_tbl1=dl_type_match_tbl1,
                                    match_exp_tbl1=match_exp,
                                    exp_mpls_label=exp_label,
                                    exp_mpls_tc=exp_tc,
                                    exp_mpls_ttl=exp_ttl,
                                    exp_ip_ttl=exp_ip_ttl,
                                    max_test=1)
Esempio n. 3
0
def nompls_push_set_two_tables_tests(parent):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = -1
    tc = 0
    ttl = 0
    ip_ttl = 192

    exp_label = random.randint(16, 1048574)
    exp_tc = random.randint(0, 6)
    exp_ttl = ip_ttl
    exp_ip_ttl = ip_ttl

    # Match condition on TBL0 (match)
    label_match_tbl0 = 0
    tc_match_tbl0 = 0
    dl_type_match_tbl0 = ETHERTYPE_IP

    # Create action_list for TBL0
    action_list_tbl0 = []
    act = action.action_push_mpls()
    act.ethertype = ETHERTYPE_MPLS
    action_list_tbl0.append(act)

    act = action.action_set_mpls_label()
    act.mpls_label = exp_label
    action_list_tbl0.append(act)
    act = action.action_set_mpls_tc()
    act.mpls_tc = exp_tc
    action_list_tbl0.append(act)

    # Match condition on TBL1 (match)
    label_match_tbl1 = exp_label
    tc_match_tbl1 = exp_tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent,
                                    pa_port_map,
                                    wildcards=wildcards,
                                    mpls_label=label,
                                    mpls_tc=tc,
                                    mpls_ttl=ttl,
                                    ip_ttl=ip_ttl,
                                    label_match_tbl0=label_match_tbl0,
                                    tc_match_tbl0=tc_match_tbl0,
                                    dl_type_match_tbl0=dl_type_match_tbl0,
                                    action_list_tbl0=action_list_tbl0,
                                    match_exp_tbl0=True,
                                    label_match_tbl1=label_match_tbl1,
                                    tc_match_tbl1=tc_match_tbl1,
                                    dl_type_match_tbl1=dl_type_match_tbl1,
                                    match_exp_tbl1=True,
                                    exp_mpls_label=exp_label,
                                    exp_mpls_tc=exp_tc,
                                    exp_mpls_ttl=exp_ttl,
                                    exp_ip_ttl=exp_ip_ttl,
                                    add_tag_exp=False,
                                    max_test=1)
Esempio n. 4
0
def mpls_multipush3_act_tests(parent, test_condition=0):
    """
    Test mpls push and set with out-of-range value actions for the packets
    with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags>=0) and (parent.num_tags<=2)),
        "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_push_mpls') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. PUSH not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_label') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. SET_LABEL not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. SET_TC not supported")
        return

    act = action.action_push_mpls()
    act.ethertype = 0x8847

    if test_condition == 0:
        act2 = action.action_set_mpls_label()
        act2.mpls_label = 1048576
        exp_label = act2.mpls_label
        exp_tc = 0
        exp_ttl = 0 # Not expected

    elif test_condition == 1:
        act2 = action.action_set_mpls_tc()
        act2.mpls_tc = 8
        exp_tc = act2.mpls_tc
        exp_label = 0
        exp_ttl = 0 # Not expected

    else:
        return

    match_exp = False
    exp_msg = ofp.OFPT_ERROR
    exp_msg_type = ofp.OFPET_BAD_ACTION
    exp_msg_code = ofp.OFPBAC_BAD_ARGUMENT

    action_list=[act, act2]

    testutils.flow_match_test_mpls(parent, pa_port_map,
                wildcards=0,
                mpls_label=parent.label,
                mpls_tc=parent.tc,
                mpls_label_int=parent.label_int,
                mpls_tc_int=parent.tc_int,
                label_match=parent.label_match,
                tc_match=parent.tc_match,
                dl_type_match=parent.dl_type_match,
                exp_mpls_label=exp_label,
                exp_mpls_tc=exp_tc,
                exp_mpls_ttl=exp_ttl,
                match_exp=match_exp,
                exp_msg=exp_msg,
                exp_msg_type=exp_msg_type,
                exp_msg_code=exp_msg_code,
                action_list=action_list,
                max_test=1)
Esempio n. 5
0
def mpls_set_tc_act_tests(parent, test_condition=0):
    """
    Test mpls set_tc action for the packets with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags>=0) and (parent.num_tags<=2)),
        "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(parent,
            "MPLS set_tc action test. SET_TC not supported")
        return

    act = action.action_set_mpls_tc()

    exp_label = parent.label
    exp_ttl = parent.ttl

    if test_condition == 0:
        act.mpls_tc = parent.tc + 2
        if parent.num_tags == 0:
            match_exp = False
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_MATCH_INCONSISTENT
            exp_tc = parent.tc

        else:
            match_exp = True
            exp_msg = ofp.OFPT_FLOW_REMOVED
            exp_msg_type = 0 #NOT_EXPECTED
            exp_msg_code = 0 #NOT_EXPECTED
            exp_tc = act.mpls_tc

        action_list=[act]

    elif test_condition == 1:
        act.mpls_tc = 8
        match_exp = False
        if parent.num_tags == 0:
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_MATCH_INCONSISTENT
            exp_tc = parent.tc

        else:
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_BAD_ARGUMENT
            exp_tc = act.mpls_tc

        action_list=[act]

    else:
        return

    testutils.flow_match_test_mpls(parent, pa_port_map,
            wildcards=0,
            mpls_label=parent.label,
            mpls_tc=parent.tc,
            mpls_ttl=parent.ttl,
            mpls_label_int=parent.label_int,
            mpls_tc_int=parent.tc_int,
            mpls_ttl_int=parent.ttl_int,
            ip_ttl=parent.ip_ttl,
            label_match=parent.label_match,
            tc_match=parent.tc_match,
            dl_type_match=parent.dl_type_match,
            exp_mpls_label=exp_label,
            exp_mpls_tc=exp_tc,
            exp_mpls_ttl=exp_ttl,
            match_exp=match_exp,
            exp_msg=exp_msg,
            exp_msg_type=exp_msg_type,
            exp_msg_code=exp_msg_code,
            action_list=action_list,
            max_test=1)
Esempio n. 6
0
def mpls_push_set_two_tables_tests(parent, test_condition=0, match_exp = True):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = random.randint(16, 1048574)
    tc = random.randint(0, 6)
    ttl = 64

    # Match condition on TBL0 (match)
    label_match_tbl0 = label
    tc_match_tbl0 = tc
    dl_type_match_tbl0 = ETHERTYPE_MPLS

    # Match or Unmatch depends on match_exp parameter
    # Expect different label
    if (test_condition == 0):
        exp_label = label + 1
        exp_tc = tc
        exp_ttl = ttl
    # Expect different TC
    elif (test_condition == 1):
        exp_label = label
        exp_tc = tc + 1
        exp_ttl = ttl
    # Expect different TTL
    else: # test_condition == 2
        exp_label = label
        exp_tc = tc
        exp_ttl = ttl + 2

    # Create action_list for TBL0
    action_list_tbl0 = []
    act = action.action_push_mpls()
    act.ethertype = ETHERTYPE_MPLS
    action_list_tbl0.append(act)
    if (match_exp):
        if (test_condition == 0):
            act = action.action_set_mpls_label()
            act.mpls_label = exp_label
            action_list_tbl0.append(act)
        elif (test_condition == 1):
            act = action.action_set_mpls_tc()
            act.mpls_tc = exp_tc
            action_list_tbl0.append(act)
        else: #test_condition == 2
            act = action.action_set_mpls_ttl()
            act.mpls_ttl = exp_ttl
            action_list_tbl0.append(act)

    # Match condition on TBL1
    label_match_tbl1 = exp_label
    tc_match_tbl1 = exp_tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent, pa_port_map,
                    wildcards=wildcards,
                    mpls_label=label,
                    mpls_tc=tc,
                    mpls_ttl=ttl,
                    label_match_tbl0=label_match_tbl0,
                    tc_match_tbl0=tc_match_tbl0,
                    dl_type_match_tbl0=dl_type_match_tbl0,
                    action_list_tbl0 = action_list_tbl0,
                    match_exp_tbl0 = True,
                    label_match_tbl1=label_match_tbl1,
                    tc_match_tbl1=tc_match_tbl1,
                    dl_type_match_tbl1=dl_type_match_tbl1,
                    match_exp_tbl1 = match_exp,
                    exp_mpls_label=exp_label,
                    exp_mpls_tc=exp_tc,
                    exp_mpls_ttl=exp_ttl,
                    add_tag_exp=True,
                    max_test=1)
Esempio n. 7
0
def mpls_multipush2_act_tests(parent, test_condition=0):
    """
    Test mpls push and set actions for the packets with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags>=0) and (parent.num_tags<=2)),
        "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_push_mpls') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. PUSH not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_label') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. SET_LABEL not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. SET_TC not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_ttl') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. SET_TTL not supported")
        return
    if sup_mpls_act.has_key('sup_dec_mpls_ttl') == False:
        testutils.skip_message_emit(parent,
            "MPLS multipush action test. DEC_TTL not supported")
        return

    act = action.action_push_mpls()
    act.ethertype = 0x8847

    if test_condition == 0:
        act2 = action.action_set_mpls_label()
        act2.mpls_label = parent.label + 2
        exp_label = act2.mpls_label
        if parent.num_tags == 0:
            exp_tc = 0
            exp_ttl = parent.ip_ttl
        else:
            exp_tc = parent.tc
            exp_ttl = parent.ttl

    elif test_condition == 1:
        act2 = action.action_set_mpls_tc()
        act2.mpls_tc = parent.tc + 2
        exp_tc = act2.mpls_tc
        if parent.num_tags == 0:
            exp_label = 0
            exp_ttl = parent.ip_ttl
        else:
            exp_label = parent.label
            exp_ttl = parent.ttl

    elif test_condition == 2:
        act2 = action.action_set_mpls_ttl()
        act2.mpls_ttl = parent.ttl + 2
        exp_ttl = act2.mpls_ttl
        if parent.num_tags == 0:
            exp_label = 0
            exp_tc = 0
        else:
            exp_label = parent.label
            exp_tc = parent.tc

    elif test_condition == 3:
        act2 = action.action_dec_mpls_ttl()
        if parent.num_tags == 0:
            exp_ttl = parent.ip_ttl - 1
            exp_label = 0
            exp_tc = 0
        else:
            exp_ttl = parent.ttl - 1
            exp_label = parent.label
            exp_tc = parent.tc

    else:
        return

    match_exp = True
    add_tag_exp = parent.num_tags > 0
    exp_msg = ofp.OFPT_FLOW_REMOVED
    exp_msg_type = 0 #NOT_EXPECTED
    exp_msg_code = 0 #NOT_EXPECTED

    action_list=[act, act2]

    testutils.flow_match_test_mpls(parent, pa_port_map,
                wildcards=0,
                mpls_label=parent.label,
                mpls_tc=parent.tc,
                mpls_label_int=parent.label_int,
                mpls_tc_int=parent.tc_int,
                label_match=parent.label_match,
                tc_match=parent.tc_match,
                dl_type_match=parent.dl_type_match,
                exp_mpls_label=exp_label,
                exp_mpls_tc=exp_tc,
                exp_mpls_ttl=exp_ttl,
                match_exp=match_exp,
                add_tag_exp=add_tag_exp,
                exp_msg=exp_msg,
                exp_msg_type=exp_msg_type,
                exp_msg_code=exp_msg_code,
                action_list=action_list,
                max_test=1)
Esempio n. 8
0
def nompls_push_set_two_tables_tests(parent):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = -1
    tc = 0
    ttl = 0
    ip_ttl = 192

    exp_label = random.randint(16, 1048574)
    exp_tc = random.randint(0, 6)
    exp_ttl = ip_ttl
    exp_ip_ttl = ip_ttl

    # Match condition on TBL0 (match)
    label_match_tbl0 = 0
    tc_match_tbl0 = 0
    dl_type_match_tbl0 = ETHERTYPE_IP

    # Create action_list for TBL0
    action_list_tbl0 = []
    act = action.action_push_mpls()
    act.ethertype = ETHERTYPE_MPLS
    action_list_tbl0.append(act)

    act = action.action_set_mpls_label()
    act.mpls_label = exp_label
    action_list_tbl0.append(act)
    act = action.action_set_mpls_tc()
    act.mpls_tc = exp_tc
    action_list_tbl0.append(act)

    # Match condition on TBL1 (match)
    label_match_tbl1 = exp_label
    tc_match_tbl1 = exp_tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent, pa_port_map,
                    wildcards=wildcards,
                    mpls_label=label,
                    mpls_tc=tc,
                    mpls_ttl=ttl,
                    ip_ttl=ip_ttl,
                    label_match_tbl0=label_match_tbl0,
                    tc_match_tbl0=tc_match_tbl0,
                    dl_type_match_tbl0=dl_type_match_tbl0,
                    action_list_tbl0 = action_list_tbl0,
                    match_exp_tbl0 = True,
                    label_match_tbl1=label_match_tbl1,
                    tc_match_tbl1=tc_match_tbl1,
                    dl_type_match_tbl1=dl_type_match_tbl1,
                    match_exp_tbl1 = True,
                    exp_mpls_label=exp_label,
                    exp_mpls_tc=exp_tc,
                    exp_mpls_ttl=exp_ttl,
                    exp_ip_ttl=exp_ip_ttl,
                    add_tag_exp=False,
                    max_test=1)
Esempio n. 9
0
def mpls_set_two_tables_tests(parent, match_exp=True):
    """
    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    wildcards = 0
    label = random.randint(16, 1048574)
    tc = random.randint(0, 6)
    ttl = 64
    ip_ttl = 192

    # Match condition on TBL0 (match)
    label_match_tbl0 = label
    tc_match_tbl0 = tc
    dl_type_match_tbl0 = ETHERTYPE_MPLS

    # Set LABEL TC TTL
    exp_label = label + 1
    exp_tc = tc + 1
    exp_ttl = ttl + 2
    exp_ip_ttl = ip_ttl
    # Create action_list for TBL0
    act = action.action_set_mpls_label()
    act.mpls_label = exp_label
    act2 = action.action_set_mpls_tc()
    act2.mpls_tc = exp_tc
    act3 = action.action_set_mpls_ttl()
    act3.mpls_ttl = exp_ttl
    action_list_tbl0 = [act, act2, act3]

    # Expect modified pkt on TBL1 (match)
    if (match_exp) :
        label_match_tbl1 = exp_label
        tc_match_tbl1 = exp_tc
    # Expect the same pkt on TBL1 (Unmatch)
    else:
        label_match_tbl1 = label
        tc_match_tbl1 = tc
    dl_type_match_tbl1 = ETHERTYPE_MPLS

    # Output action for table1 will be set in the framework

    flow_match_test_mpls_two_tables(parent, pa_port_map,
                    wildcards=wildcards,
                    mpls_label=label,
                    mpls_tc=tc,
                    mpls_ttl=ttl,
                    ip_ttl=ip_ttl,
                    label_match_tbl0=label_match_tbl0,
                    tc_match_tbl0=tc_match_tbl0,
                    dl_type_match_tbl0=dl_type_match_tbl0,
                    action_list_tbl0 = action_list_tbl0,
                    match_exp_tbl0=True,
                    label_match_tbl1=label_match_tbl1,
                    tc_match_tbl1=tc_match_tbl1,
                    dl_type_match_tbl1=dl_type_match_tbl1,
                    match_exp_tbl1=match_exp,
                    exp_mpls_label=exp_label,
                    exp_mpls_tc=exp_tc,
                    exp_mpls_ttl=exp_ttl,
                    exp_ip_ttl=exp_ip_ttl,
                    max_test=1)
Esempio n. 10
0
def mpls_set_tc_act_tests(parent, test_condition=0):
    """
    Test mpls set_tc action for the packets with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags >= 0) and (parent.num_tags <= 2)),
                      "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(
            parent, "MPLS set_tc action test. SET_TC not supported")
        return

    act = action.action_set_mpls_tc()

    exp_label = parent.label
    exp_ttl = parent.ttl

    if test_condition == 0:
        act.mpls_tc = parent.tc + 2
        if parent.num_tags == 0:
            match_exp = False
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_MATCH_INCONSISTENT
            exp_tc = parent.tc

        else:
            match_exp = True
            exp_msg = ofp.OFPT_FLOW_REMOVED
            exp_msg_type = 0  #NOT_EXPECTED
            exp_msg_code = 0  #NOT_EXPECTED
            exp_tc = act.mpls_tc

        action_list = [act]

    elif test_condition == 1:
        act.mpls_tc = 8
        match_exp = False
        if parent.num_tags == 0:
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_MATCH_INCONSISTENT
            exp_tc = parent.tc

        else:
            exp_msg = ofp.OFPT_ERROR
            exp_msg_type = ofp.OFPET_BAD_ACTION
            exp_msg_code = ofp.OFPBAC_BAD_ARGUMENT
            exp_tc = act.mpls_tc

        action_list = [act]

    else:
        return

    testutils.flow_match_test_mpls(parent,
                                   pa_port_map,
                                   wildcards=0,
                                   mpls_label=parent.label,
                                   mpls_tc=parent.tc,
                                   mpls_ttl=parent.ttl,
                                   mpls_label_int=parent.label_int,
                                   mpls_tc_int=parent.tc_int,
                                   mpls_ttl_int=parent.ttl_int,
                                   ip_ttl=parent.ip_ttl,
                                   label_match=parent.label_match,
                                   tc_match=parent.tc_match,
                                   dl_type_match=parent.dl_type_match,
                                   exp_mpls_label=exp_label,
                                   exp_mpls_tc=exp_tc,
                                   exp_mpls_ttl=exp_ttl,
                                   match_exp=match_exp,
                                   exp_msg=exp_msg,
                                   exp_msg_type=exp_msg_type,
                                   exp_msg_code=exp_msg_code,
                                   action_list=action_list,
                                   max_test=1)
Esempio n. 11
0
def mpls_multipush3_act_tests(parent, test_condition=0):
    """
    Test mpls push and set with out-of-range value actions for the packets
    with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags >= 0) and (parent.num_tags <= 2)),
                      "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_push_mpls') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. PUSH not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_label') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. SET_LABEL not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. SET_TC not supported")
        return

    act = action.action_push_mpls()
    act.ethertype = 0x8847

    if test_condition == 0:
        act2 = action.action_set_mpls_label()
        act2.mpls_label = 1048576
        exp_label = act2.mpls_label
        exp_tc = 0
        exp_ttl = 0  # Not expected

    elif test_condition == 1:
        act2 = action.action_set_mpls_tc()
        act2.mpls_tc = 8
        exp_tc = act2.mpls_tc
        exp_label = 0
        exp_ttl = 0  # Not expected

    else:
        return

    match_exp = False
    exp_msg = ofp.OFPT_ERROR
    exp_msg_type = ofp.OFPET_BAD_ACTION
    exp_msg_code = ofp.OFPBAC_BAD_ARGUMENT

    action_list = [act, act2]

    testutils.flow_match_test_mpls(parent,
                                   pa_port_map,
                                   wildcards=0,
                                   mpls_label=parent.label,
                                   mpls_tc=parent.tc,
                                   mpls_label_int=parent.label_int,
                                   mpls_tc_int=parent.tc_int,
                                   label_match=parent.label_match,
                                   tc_match=parent.tc_match,
                                   dl_type_match=parent.dl_type_match,
                                   exp_mpls_label=exp_label,
                                   exp_mpls_tc=exp_tc,
                                   exp_mpls_ttl=exp_ttl,
                                   match_exp=match_exp,
                                   exp_msg=exp_msg,
                                   exp_msg_type=exp_msg_type,
                                   exp_msg_code=exp_msg_code,
                                   action_list=action_list,
                                   max_test=1)
Esempio n. 12
0
def mpls_multipush2_act_tests(parent, test_condition=0):
    """
    Test mpls push and set actions for the packets with/without tags

    @param parent Must implement controller, dataplane, assertTrue, assertEqual
    and logger
    """
    parent.assertTrue(((parent.num_tags >= 0) and (parent.num_tags <= 2)),
                      "Parameter num_tags not within an acceptable range")

    sup_mpls_act = mpls_action_support_check(parent)

    if sup_mpls_act.has_key('sup_push_mpls') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. PUSH not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_label') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. SET_LABEL not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_tc') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. SET_TC not supported")
        return
    if sup_mpls_act.has_key('sup_set_mpls_ttl') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. SET_TTL not supported")
        return
    if sup_mpls_act.has_key('sup_dec_mpls_ttl') == False:
        testutils.skip_message_emit(
            parent, "MPLS multipush action test. DEC_TTL not supported")
        return

    act = action.action_push_mpls()
    act.ethertype = 0x8847

    if test_condition == 0:
        act2 = action.action_set_mpls_label()
        act2.mpls_label = parent.label + 2
        exp_label = act2.mpls_label
        if parent.num_tags == 0:
            exp_tc = 0
            exp_ttl = parent.ip_ttl
        else:
            exp_tc = parent.tc
            exp_ttl = parent.ttl

    elif test_condition == 1:
        act2 = action.action_set_mpls_tc()
        act2.mpls_tc = parent.tc + 2
        exp_tc = act2.mpls_tc
        if parent.num_tags == 0:
            exp_label = 0
            exp_ttl = parent.ip_ttl
        else:
            exp_label = parent.label
            exp_ttl = parent.ttl

    elif test_condition == 2:
        act2 = action.action_set_mpls_ttl()
        act2.mpls_ttl = parent.ttl + 2
        exp_ttl = act2.mpls_ttl
        if parent.num_tags == 0:
            exp_label = 0
            exp_tc = 0
        else:
            exp_label = parent.label
            exp_tc = parent.tc

    elif test_condition == 3:
        act2 = action.action_dec_mpls_ttl()
        if parent.num_tags == 0:
            exp_ttl = parent.ip_ttl - 1
            exp_label = 0
            exp_tc = 0
        else:
            exp_ttl = parent.ttl - 1
            exp_label = parent.label
            exp_tc = parent.tc

    else:
        return

    match_exp = True
    add_tag_exp = parent.num_tags > 0
    exp_msg = ofp.OFPT_FLOW_REMOVED
    exp_msg_type = 0  #NOT_EXPECTED
    exp_msg_code = 0  #NOT_EXPECTED

    action_list = [act, act2]

    testutils.flow_match_test_mpls(parent,
                                   pa_port_map,
                                   wildcards=0,
                                   mpls_label=parent.label,
                                   mpls_tc=parent.tc,
                                   mpls_label_int=parent.label_int,
                                   mpls_tc_int=parent.tc_int,
                                   label_match=parent.label_match,
                                   tc_match=parent.tc_match,
                                   dl_type_match=parent.dl_type_match,
                                   exp_mpls_label=exp_label,
                                   exp_mpls_tc=exp_tc,
                                   exp_mpls_ttl=exp_ttl,
                                   match_exp=match_exp,
                                   add_tag_exp=add_tag_exp,
                                   exp_msg=exp_msg,
                                   exp_msg_type=exp_msg_type,
                                   exp_msg_code=exp_msg_code,
                                   action_list=action_list,
                                   max_test=1)