Exemplo n.º 1
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running FlowModFailed Unsupported action list Grp100No250 test")

        msg = message.flow_mod()
        act1 = action.action_output()
        act2 = action.action_set_dl_src()
        act1.port = 99
        act2.dl_addr = [11, 11, 11, 11, 11, 11]

        self.assertTrue(msg.actions.add(act1), "Could not add action")
        self.assertTrue(msg.actions.add(act2), "Could not add action")

        packed = msg.pack()

        rv = self.controller.message_send(packed)
        self.assertTrue(rv == 0, "Unable to send the message")

        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, timeout=10)
        self.assertTrue(response is not None, "Did not receive an error")
        self.assertTrue(
            response.type == ofp.OFPET_FLOW_MOD_FAILED,
            "Unexpected Error type. Expected OFPET_FLOW_MOD_FAILED error type",
        )
        self.assertTrue(
            response.code == ofp.OFPFMFC_UNSUPPORTED or response.code == ofp.OFPFMFC_EPERM,
            " Unexpected error code, Expected ofp.OFPFMFC_UNSUPPORTED or ofp.OFPFMFC_EPERM error code got{0}".format(
                response.code
            ),
        )
Exemplo n.º 2
0
    def runTest(self):
        logging.info("Running FlowModFailed Unsupported action list Grp100No250 test")

        msg = message.flow_mod()
        act1 = action.action_output()
        act2 = action.action_set_dl_src()
        act1.port = 99
        act2.dl_addr = [11, 11, 11, 11, 11, 11]

        self.assertTrue(msg.actions.add(act1), "Could not add action")
        self.assertTrue(msg.actions.add(act2), "Could not add action")

        packed = msg.pack()

        rv = self.controller.message_send(packed)
        self.assertTrue(rv == 0, "Unable to send the message")
        (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR)

        count = 0
        while True:
            (response, raw) = self.controller.poll(ofp.OFPT_ERROR)
            if not response:  # Timeout
                break
            if not response.type == ofp.OFPET_FLOW_MOD_FAILED:
                logging.info("Error Type is not as expected")
                break
            if response.code == ofp.OFPFMFC_UNSUPPORTED | ofp.OFPFMFC_EPERM:
                logging.info("Error Code is not as expected")
                break
            if not config["relax"]:  # Only one attempt to match
                break
            count += 1
            if count > 10:  # Too many tries
                break
Exemplo n.º 3
0
    def runTest(self):
        logging = get_logger()
        logging.info(
            "Running FlowModFailed Unsupported action list Grp100No250 test")

        msg = message.flow_mod()
        act1 = action.action_output()
        act2 = action.action_set_dl_src()
        act1.port = 99
        act2.dl_addr = [11, 11, 11, 11, 11, 11]

        self.assertTrue(msg.actions.add(act1), "Could not add action")
        self.assertTrue(msg.actions.add(act2), "Could not add action")

        packed = msg.pack()

        rv = self.controller.message_send(packed)
        self.assertTrue(rv == 0, "Unable to send the message")

        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, timeout=10)
        self.assertTrue(response is not None, "Did not receive an error")
        self.assertTrue(
            response.type == ofp.OFPET_FLOW_MOD_FAILED,
            "Unexpected Error type. Expected OFPET_FLOW_MOD_FAILED error type")
        self.assertTrue(
            response.code == ofp.OFPFMFC_UNSUPPORTED
            or response.code == ofp.OFPFMFC_EPERM,
            " Unexpected error code, Expected ofp.OFPFMFC_UNSUPPORTED or ofp.OFPFMFC_EPERM error code got{0}"
            .format(response.code))
Exemplo n.º 4
0
def action_generate(parent, field_to_mod, mod_field_vals):
    """
    Create an action to modify the field indicated in field_to_mod

    @param parent Must implement, assertTrue
    @param field_to_mod The field to modify as a string name
    @param mod_field_vals Hash of values to use for modified values
    """

    act = None

    if field_to_mod in ['pktlen']:
        return None

    if field_to_mod == 'dl_dst':
        act = action.action_set_dl_dst()
        act.dl_addr = parse.parse_mac(mod_field_vals['dl_dst'])
    elif field_to_mod == 'dl_src':
        act = action.action_set_dl_src()
        act.dl_addr = parse.parse_mac(mod_field_vals['dl_src'])
    elif field_to_mod == 'dl_vlan_enable':
        if not mod_field_vals['dl_vlan_enable']: # Strip VLAN tag
            act = action.action_strip_vlan()
        # Add VLAN tag is handled by dl_vlan field
        # Will return None in this case
    elif field_to_mod == 'dl_vlan':
        act = action.action_set_vlan_vid()
        act.vlan_vid = mod_field_vals['dl_vlan']
    elif field_to_mod == 'dl_vlan_pcp':
        act = action.action_set_vlan_pcp()
        act.vlan_pcp = mod_field_vals['dl_vlan_pcp']
    elif field_to_mod == 'ip_src':
        act = action.action_set_nw_src()
        act.nw_addr = parse.parse_ip(mod_field_vals['ip_src'])
    elif field_to_mod == 'ip_dst':
        act = action.action_set_nw_dst()
        act.nw_addr = parse.parse_ip(mod_field_vals['ip_dst'])
    elif field_to_mod == 'ip_tos':
        act = action.action_set_nw_tos()
        act.nw_tos = mod_field_vals['ip_tos']
    elif field_to_mod == 'tcp_sport':
        act = action.action_set_tp_src()
        act.tp_port = mod_field_vals['tcp_sport']
    elif field_to_mod == 'tcp_dport':
        act = action.action_set_tp_dst()
        act.tp_port = mod_field_vals['tcp_dport']
    elif field_to_mod == 'udp_sport':
        act = action.action_set_tp_src()
        act.tp_port = mod_field_vals['udp_sport']
    elif field_to_mod == 'udp_dport':
        act = action.action_set_tp_dst()
        act.tp_port = mod_field_vals['udp_dport']
    else:
        parent.assertTrue(0, "Unknown field to modify: " + str(field_to_mod))

    return act
Exemplo n.º 5
0
def action_generate(parent, field_to_mod, mod_field_vals):
    """
    Create an action to modify the field indicated in field_to_mod

    @param parent Must implement, assertTrue
    @param field_to_mod The field to modify as a string name
    @param mod_field_vals Hash of values to use for modified values
    """

    act = None

    if field_to_mod in ['pktlen']:
        return None

    if field_to_mod == 'dl_dst':
        act = action.action_set_dl_dst()
        act.dl_addr = parse.parse_mac(mod_field_vals['dl_dst'])
    elif field_to_mod == 'dl_src':
        act = action.action_set_dl_src()
        act.dl_addr = parse.parse_mac(mod_field_vals['dl_src'])
    elif field_to_mod == 'dl_vlan_enable':
        if not mod_field_vals['dl_vlan_enable']:  # Strip VLAN tag
            act = action.action_strip_vlan()
        # Add VLAN tag is handled by dl_vlan field
        # Will return None in this case
    elif field_to_mod == 'dl_vlan':
        act = action.action_set_vlan_vid()
        act.vlan_vid = mod_field_vals['dl_vlan']
    elif field_to_mod == 'dl_vlan_pcp':
        act = action.action_set_vlan_pcp()
        act.vlan_pcp = mod_field_vals['dl_vlan_pcp']
    elif field_to_mod == 'ip_src':
        act = action.action_set_nw_src()
        act.nw_addr = parse.parse_ip(mod_field_vals['ip_src'])
    elif field_to_mod == 'ip_dst':
        act = action.action_set_nw_dst()
        act.nw_addr = parse.parse_ip(mod_field_vals['ip_dst'])
    elif field_to_mod == 'ip_tos':
        act = action.action_set_nw_tos()
        act.nw_tos = mod_field_vals['ip_tos']
    elif field_to_mod == 'tcp_sport':
        act = action.action_set_tp_src()
        act.tp_port = mod_field_vals['tcp_sport']
    elif field_to_mod == 'tcp_dport':
        act = action.action_set_tp_dst()
        act.tp_port = mod_field_vals['tcp_dport']
    else:
        parent.assertTrue(0, "Unknown field to modify: " + str(field_to_mod))

    return act