示例#1
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port2)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [
            ofp.group_desc_stats_entry(group_type=msg.group_type,
                                       group_id=msg.group_id,
                                       buckets=msg.buckets)
        ])
示例#2
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=ofp.OFPG_MAX,
                buckets=[
                    ofp.bucket(watch_port=ofp.OFPP_ANY,
                               watch_group=ofp.OFPG_ANY,
                               actions=[ofp.action.output(port1)])
                ])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=ofp.OFPG_MAX,
                buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [
            ofp.group_desc_stats_entry(group_type=msg.group_type,
                                       group_id=msg.group_id,
                                       buckets=msg.buckets)
        ])
示例#3
0
文件: groups.py 项目: wy1990/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_MODIFY,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port2)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [
            ofp.group_desc_stats_entry(
                group_type=msg.group_type,
                group_id=msg.group_id,
                buckets=msg.buckets)])
示例#4
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL, group_id=0, buckets=[ofp.bucket(actions=[ofp.action.output(port1)])]
        )

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL, group_id=1, buckets=[ofp.bucket(actions=[ofp.action.group(0)])]
        )

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL, group_id=2, buckets=[ofp.bucket(actions=[ofp.action.group(1)])]
        )

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL, group_id=0, buckets=[ofp.bucket(actions=[ofp.action.group(2)])]
        )

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_LOOP)
示例#5
0
文件: groups.py 项目: wy1990/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_DELETE,
            group_id=ofp.OFPG_ALL)

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [])
示例#6
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=10,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                    ofp.action.output(port1)
                ]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                    ofp.action.output(port2)
                ])
            ])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        request = ofp.message.group_stats_request(group_id=10)
        stats = get_stats(self, request)

        self.assertEquals(len(stats), 1)
        self.assertEquals(stats[0].group_id, 10)
        self.assertEquals(stats[0].ref_count, 0)
        self.assertEquals(stats[0].packet_count, 0)
        self.assertEquals(stats[0].byte_count, 0)
        self.assertEquals(len(stats[0].bucket_stats), 2)
示例#7
0
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[ofp.bucket(actions=[ofp.action.group(0)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=2,
            buckets=[ofp.bucket(actions=[ofp.action.group(1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.group(2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_LOOP)
示例#8
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[ofp.action.output(port1)])])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[ofp.action.output(port2)])])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(actions=[ofp.action.output(port2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_GROUP_EXISTS)
示例#9
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, port2 = openflow_ports(2)
        
        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_SELECT,
                group_id=1,
                buckets=[
                    ofp.bucket(weight=1, watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[ofp.action.output(port2)])])

        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_SELECT,
                group_id=1,
                buckets=[
                    ofp.bucket(weight=1, actions=[ofp.action.output(port2)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.flow_add(
            buffer_id=ofp.OFP_NO_BUFFER,
            instructions=[ofp.instruction.apply_actions([ofp.action.group(1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        verify_no_errors(self.controller)

        pkt = simple_tcp_packet()
        self.dataplane.send(port1, str(pkt))
        verify_packets(self, pkt, [port2])
示例#10
0
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_delete(group_id=ofp.OFPG_ALL)

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [])
示例#11
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[ofp.action.output(port1)])])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=0,
                buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(stats, [
            ofp.group_desc_stats_entry(
                group_type=msg.group_type,
                group_id=msg.group_id,
                buckets=msg.buckets)])
示例#12
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_SELECT,
                group_id=0,
                buckets=[
                    ofp.bucket(watch_port=ofp.OFPP_ANY,
                               watch_group=ofp.OFPG_ANY,
                               actions=[ofp.action.output(port1)]),
                    ofp.bucket(watch_port=ofp.OFPP_ANY,
                               watch_group=ofp.OFPG_ANY,
                               actions=[ofp.action.output(port2)])
                ])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_SELECT,
                group_id=0,
                buckets=[
                    ofp.bucket(actions=[ofp.action.output(port1)]),
                    ofp.bucket(actions=[ofp.action.output(port2)])
                ])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#13
0
文件: groups.py 项目: wy1990/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=10,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                    ofp.action.output(port1)]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                    ofp.action.output(port2)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        request = ofp.message.group_stats_request(group_id=10)
        stats = get_stats(self, request)

        self.assertEquals(len(stats), 1)
        self.assertEquals(stats[0].group_id, 10)
        self.assertEquals(stats[0].ref_count, 0)
        self.assertEquals(stats[0].packet_count, 0)
        self.assertEquals(stats[0].byte_count, 0)
        self.assertEquals(len(stats[0].bucket_stats), 2)
示例#14
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg0 = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                    ofp.action.output(port1)
                ]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                    ofp.action.output(port2)
                ])
            ])

        self.controller.message_send(msg0)
        do_barrier(self.controller)

        msg1 = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2001)),
                    ofp.action.output(port1)
                ]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3001)),
                    ofp.action.output(port2)
                ])
            ])

        self.controller.message_send(msg1)
        do_barrier(self.controller)

        request = ofp.message.group_stats_request(group_id=ofp.OFPG_ALL)
        stats = sorted(get_stats(self, request), key=lambda x: x.group_id)

        self.assertEquals(len(stats), 2)

        self.assertEquals(stats[0].group_id, 0)
        self.assertEquals(stats[0].ref_count, 0)
        self.assertEquals(stats[0].packet_count, 0)
        self.assertEquals(stats[0].byte_count, 0)
        self.assertEquals(len(stats[0].bucket_stats), 2)

        self.assertEquals(stats[1].group_id, 1)
        self.assertEquals(stats[1].ref_count, 0)
        self.assertEquals(stats[1].packet_count, 0)
        self.assertEquals(stats[1].byte_count, 0)
        self.assertEquals(len(stats[1].bucket_stats), 2)
示例#15
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_SELECT,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)]), ofp.bucket(actions=[ofp.action.output(port2)])],
        )

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#16
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)]),
                ofp.bucket(actions=[ofp.action.output(port2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#17
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_SELECT,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)]),
                ofp.bucket(actions=[ofp.action.output(port2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_GROUP_MOD_FAILED)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#18
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_SELECT,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)]),
                ofp.bucket(actions=[ofp.action.output(port2)])
            ])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_GROUP_MOD_FAILED)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#19
0
    def runTest(self):
        logging.info("Running testcase 200.130 basic OFPT_GROUP_MOD")

        in_port, out_port = openflow_ports(2)
        delete_all_flows(self.controller)
        delete_all_groups(self.controller)
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(out_port)],
                           watch_port=ofp.OFPP_ANY,
                           watch_group=ofp.OFPG_ANY)
            ])

        self.controller.message_send(request)

        reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
        if reply:
            logging.info("The device does not support group")
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST,
                             ("Error type %d was received, but we expected "
                              "OFPET_BAD_REQUEST.") % reply.err_type)
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_TYPE,
                             ("Flow mod failed code %d was received, but we "
                              "expected OFPBRC_BAD_TYPE.") % reply.code)
        else:
            logging.info("Created a group")
            group_stats = get_stats(self,
                                    ofp.message.group_desc_stats_request())
            self.assertIsNotNone(
                group_stats,
                "Can not get the information of the group created")
示例#20
0
    def runTest(self):
        port1, port2 = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_SELECT,
            group_id=1,
            buckets=[ofp.bucket(weight=1, actions=[ofp.action.output(port2)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.flow_add(buffer_id=ofp.OFP_NO_BUFFER,
                                   instructions=[
                                       ofp.instruction.apply_actions(
                                           [ofp.action.group(1)])
                                   ])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        verify_no_errors(self.controller)

        pkt = simple_tcp_packet()
        self.dataplane.send(port1, str(pkt))
        verify_packets(self, pkt, [port2])
示例#21
0
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg0 = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                    ofp.action.output(port1)]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                    ofp.action.output(port2)])])

        self.controller.message_send(msg0)
        do_barrier(self.controller)

        msg1 = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2001)),
                    ofp.action.output(port1)]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3001)),
                    ofp.action.output(port2)])])

        self.controller.message_send(msg1)
        do_barrier(self.controller)

        request = ofp.message.group_stats_request(group_id=ofp.OFPG_ALL)
        stats = sorted(get_stats(self, request), key=lambda x: x.group_id)

        self.assertEquals(len(stats), 2)

        self.assertEquals(stats[0].group_id, 0)
        self.assertEquals(stats[0].ref_count, 0)
        self.assertEquals(stats[0].packet_count, 0)
        self.assertEquals(stats[0].byte_count, 0)
        self.assertEquals(len(stats[0].bucket_stats), 2)

        self.assertEquals(stats[1].group_id, 1)
        self.assertEquals(stats[1].ref_count, 0)
        self.assertEquals(stats[1].packet_count, 0)
        self.assertEquals(stats[1].byte_count, 0)
        self.assertEquals(len(stats[1].bucket_stats), 2)
示例#22
0
    def runTest(self):
        num_out_ports = 3
        num_pkts = 1000

        port1, port2, port3, port4 = openflow_ports(num_out_ports + 1)
        out_ports = [port2, port3, port4]

        msg = ofp.message.group_add(group_type=ofp.OFPGT_SELECT,
                                    group_id=1,
                                    buckets=[
                                        ofp.bucket(
                                            weight=1,
                                            actions=[ofp.action.output(port)])
                                        for port in out_ports
                                    ])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.flow_add(buffer_id=ofp.OFP_NO_BUFFER,
                                   instructions=[
                                       ofp.instruction.apply_actions(
                                           [ofp.action.group(1)])
                                   ])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        verify_no_errors(self.controller)

        counters = {x: 0 for x in out_ports}

        for i in xrange(0, num_pkts):
            pkt = simple_tcp_packet(tcp_sport=i,
                                    tcp_dport=random.randint(0, 65535))
            self.dataplane.send(port1, str(pkt))
            (rcv_port, rcv_pkt,
             pkt_time) = self.dataplane.poll(exp_pkt=str(pkt))
            self.assertIsNotNone(rcv_pkt)
            if rcv_port not in counters:
                raise AssertionError("unexpected packet on port %d" % rcv_port)
            counters[rcv_port] += 1

            # Verify the same flow is mapped to the same output port
            self.dataplane.send(port1, str(pkt))
            (rcv_port2, rcv_pkt,
             pkt_time) = self.dataplane.poll(exp_pkt=str(pkt))
            self.assertIsNotNone(rcv_pkt)
            self.assertEquals(rcv_port, rcv_port2)

        logging.debug("Distribution: %r", counters)

        self.assertEquals(sum(counters.values()), num_pkts)
        expected = num_pkts / num_out_ports
        for port, count in counters.iteritems():
            # Check that count is within 20% of expected
            self.assertTrue(
                expected * 0.8 < count < expected * 1.2,
                "port %d count was %d, expected %d" % (port, count, expected))
示例#23
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL, group_id=0, buckets=[ofp.bucket(actions=[ofp.action.output(ofp.OFPP_ANY)])]
        )

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.bad_action_error_msg)
        self.assertEquals(response.code, ofp.OFPBAC_BAD_OUT_PORT)
示例#24
0
文件: groups.py 项目: zhengqin/oftest
def create_bucket(actions,
                  weight=0,
                  watch_port=4294967295,
                  watch_group=4294967295):
    return ofp.bucket(actions=actions,
                      weight=weight,
                      watch_port=watch_port,
                      watch_group=watch_group)
示例#25
0
    def runTest(self):
        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(ofp.OFPP_ANY)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.bad_action_error_msg)
        self.assertEquals(response.code, ofp.OFPBAC_BAD_OUT_PORT)
示例#26
0
def create_bucket(weight = 0, watch_port = 0, watch_group = 0, actions=[]):
    b = ofp.bucket()
    b.weight = weight
    b.watch_port = watch_port
    b.watch_group = watch_group
    for a in actions:
        b.actions.append(a)

    return b
示例#27
0
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[
                ofp.bucket(actions=[ofp.action.group(0)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=2,
            buckets=[
                ofp.bucket(actions=[ofp.action.group(1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_MODIFY,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.group(2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_GROUP_MOD_FAILED)
        self.assertEquals(response.code, ofp.OFPGMFC_LOOP)
示例#28
0
def create_bucket(actions, weight = 0, watch_port = 4294967295,
                  watch_group = 4294967295):
    b = ofp.bucket()
    b.weight = weight
    b.watch_port = watch_port
    b.watch_group = watch_group
    for a in actions:
        b.actions.append(a)

    return b
示例#29
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL, group_id=0, buckets=[ofp.bucket(actions=[ofp.action.output(port1)])]
        )

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_UNKNOWN_GROUP)
示例#30
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_INDIRECT,
                group_id=0,
                buckets=[
                        ofp.bucket(weight=1, watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[ofp.action.output(port1)])])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_INDIRECT,
                group_id=0,
                buckets=[
                    ofp.bucket(weight=1, actions=[ofp.action.output(port1)])])


        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#31
0
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_modify(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_UNKNOWN_GROUP)
示例#32
0
    def runTest(self):
        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(ofp.OFPP_ANY)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_BAD_ACTION)
        self.assertEquals(response.code, ofp.OFPBAC_BAD_OUT_PORT)
示例#33
0
文件: groups.py 项目: lparkes/oftest
    def runTest(self):
        num_out_ports = 3
        num_pkts = 1000

        port1, port2, port3, port4 = openflow_ports(num_out_ports + 1)
        out_ports = [port2, port3, port4]

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_SELECT,
            group_id=1,
            buckets=[
                ofp.bucket(weight=1, actions=[ofp.action.output(port)])
                for port in out_ports])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.flow_add(
            buffer_id=ofp.OFP_NO_BUFFER,
            instructions=[ofp.instruction.apply_actions([ofp.action.group(1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        verify_no_errors(self.controller)

        counters = {x: 0 for x in out_ports}

        for i in xrange(0, num_pkts):
            pkt = simple_tcp_packet(tcp_sport=i, tcp_dport=random.randint(0, 65535))
            self.dataplane.send(port1, str(pkt))
            (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(exp_pkt=str(pkt))
            self.assertIsNotNone(rcv_pkt)
            if rcv_port not in counters:
                raise AssertionError("unexpected packet on port %d" % rcv_port)
            counters[rcv_port] += 1

            # TODO the same packet cannot be mapped to the same output port in CPQD 1.3
            # Verify the same flow is mapped to the same output port
            # self.dataplane.send(port1, str(pkt))
            # (rcv_port2, rcv_pkt, pkt_time) = self.dataplane.poll(exp_pkt=str(pkt))
            # self.assertIsNotNone(rcv_pkt)
            # print(str(rcv_port)+" "+str(rcv_port2))
            # self.assertEquals(rcv_port, rcv_port2)

        logging.debug("Distribution: %r", counters)

        self.assertEquals(sum(counters.values()), num_pkts)
        expected = num_pkts / num_out_ports
        for port, count in counters.iteritems():
            # Check that count is within 20% of expected
            self.assertTrue(expected * 0.8 < count < expected * 1.2,
                            "port %d count was %d, expected %d" % (port, count, expected))
示例#34
0
    def runTest(self):
        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(ofp.OFPP_ANY)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_BAD_ACTION)
        self.assertEquals(response.code, ofp.OFPBAC_BAD_OUT_PORT)
示例#35
0
文件: groups.py 项目: pred/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        if (config["correction"]):
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=10,
                buckets=[
                    ofp.bucket(watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[
                        ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                        ofp.action.output(port1)]),
                    ofp.bucket(watch_port=ofp.OFPP_ANY,watch_group=ofp.OFPG_ANY,actions=[
                        ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                        ofp.action.output(port2)])])
        else:
            msg = ofp.message.group_add(
                group_type=ofp.OFPGT_ALL,
                group_id=10,
                buckets=[
                    ofp.bucket(actions=[
                        ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                        ofp.action.output(port1)]),
                    ofp.bucket(actions=[
                        ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                        ofp.action.output(port2)])])

        

        self.controller.message_send(msg)
        do_barrier(self.controller)

        request = ofp.message.group_stats_request(group_id=10)
        stats = get_stats(self, request)

        self.assertEquals(len(stats), 1)
        self.assertEquals(stats[0].group_id, 10)
        self.assertEquals(stats[0].ref_count, 0)
        self.assertEquals(stats[0].packet_count, 0)
        self.assertEquals(stats[0].byte_count, 0)
        self.assertEquals(len(stats[0].bucket_stats), 2)
示例#36
0
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[ofp.bucket(actions=[ofp.action.group(0)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=2,
            buckets=[ofp.bucket(actions=[ofp.action.group(1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_MODIFY,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[ofp.bucket(actions=[ofp.action.group(2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.error_msg)
        self.assertEquals(response.err_type, ofp.OFPET_GROUP_MOD_FAILED)
        self.assertEquals(response.code, ofp.OFPGMFC_LOOP)
示例#37
0
def test_group(testcase, table_id, ports, property_type):
    """ Verify that packets can be placed in the correct queue.
    """
    msg = "Checking if table {0} supports OFPAT_SET_QUEUE."
    logging.info(msg.format(table_id))

    # Check if table_id supports OFPAT_SET_QUEUE.
    supporting_tables = tables_supporting_action(testcase,
                                                 ofp.const.OFPAT_SET_QUEUE,
                                                 property_type)
    logging.info("Tables {0} support the OFPAT_SET_QUEUE.".format(supporting_tables))
    if table_id not in supporting_tables:
        logging.info("Table does not support OFPAT_SET_QUEUE type. Skipping check.")
        return False

    # If a property is not a *_MISS property set the priority to one.
    priority = 0
    if property_type == ofp.const.OFPTFPT_WRITE_ACTIONS:
        priority = 1
    if property_type == ofp.const.OFPTFPT_APPLY_ACTIONS:
        priority = 1
    group_id = 1

    req = ofp.message.group_add(
        group_type=ofp.OFPGT_ALL,
        group_id=group_id,
        buckets=[
            ofp.bucket(actions=[ofp.action.output(ports[1])])
            ])
    testcase.controller.message_send(req)
    err, _ = testcase.controller.poll(exp_msg=ofp.const.OFPT_ERROR)
    testcase.assertIsNone(err, "Unexpected ofp_error_msg received: %s." % err)

    actions = [ofp.action.group(group_id=group_id)]
    instructions = []
    if property_type == ofp.const.OFPTFPT_WRITE_ACTIONS:
        instructions.append(ofp.instruction.write_actions(actions=actions))
    elif property_type == ofp.const.OFPTFPT_WRITE_ACTIONS_MISS:
        instructions.append(ofp.instruction.write_actions(actions=actions))
    else:
        instructions.append(ofp.instruction.apply_actions(actions=actions))

    req = ofp.message.flow_add(table_id=table_id, instructions=instructions,
                               buffer_id=ofp.const.OFP_NO_BUFFER, priority=priority)
    testcase.controller.message_send(req)
    err, _ = testcase.controller.poll(exp_msg=ofp.const.OFPT_ERROR)
    testcase.assertIsNone(err, "Unexpected ofp_error_msg received: %s." % err)

    packet = simple_tcp_packet()
    testcase.dataplane.send(ports[0], str(packet))
    verify_packet(testcase, str(packet), ports[1])
    return True
示例#38
0
文件: groups.py 项目: wy1990/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_INDIRECT,
            group_id=0,
            buckets=[
                ofp.bucket(weight=1, actions=[ofp.action.output(port1)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_INVALID_GROUP)
示例#39
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        port1, = openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL, group_id=ofp.OFPG_MAX, buckets=[ofp.bucket(actions=[ofp.action.output(port1)])]
        )

        self.controller.message_send(msg)
        do_barrier(self.controller)

        stats = get_stats(self, ofp.message.group_desc_stats_request())
        self.assertEquals(
            stats, [ofp.group_desc_stats_entry(group_type=msg.group_type, group_id=msg.group_id, buckets=msg.buckets)]
        )
示例#40
0
文件: groups.py 项目: wy1990/oftest
    def runTest(self):
        port1, port2, = openflow_ports(2)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])

        self.controller.message_send(msg)
        do_barrier(self.controller)

        msg = ofp.message.group_mod(
            command=ofp.OFPGC_ADD,
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port2)])])

        response, _ = self.controller.transact(msg)
        self.assertIsInstance(response, ofp.message.group_mod_failed_error_msg)
        self.assertEquals(response.code, ofp.OFPGMFC_GROUP_EXISTS)
示例#41
0
    def runTest(self):
        logging.info("Running testcase 390.100 packet out actions")
        in_port, out_port1, out_port2 = openflow_ports(3)

        pkt = simple_tcp_packet()
        verify_pkt = simple_tcp_packet(ip_src = '192.168.0.5') #0xc0a80105

        delete_all_flows(self.controller)
        delete_all_groups(self.controller)
        msg = ofp.message.group_add(
        group_type=ofp.OFPGT_ALL,
        group_id=1,
        buckets=[
            ofp.bucket(actions=[ofp.action.output(out_port2)])])
        self.controller.message_send(msg)
        reply, _ = self.controller.poll(exp_msg = ofp.OFPT_ERROR, timeout = 3)
        self.assertIsNone(reply, "Received an error")
        
        request = ofp.message.group_features_stats_request()
        reply, _= self.controller.transact(request)
        self.assertIsNotNone(reply, "Did not receive group features reply")
        if reply.type == ofp.const.OFPT_ERROR:
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST, "Error type is not OFPET_BAD_REQUEST")
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_STAT, "Error code is not OFPBRC_BAD_STAT")
            logging.info("DUT does not support group features and returned error msg as expected")
            out_port = out_port1
            no_port = out_port2
            actions = [ofp.action.set_field(ofp.oxm.ipv4_src(0xc0a80105)),ofp.action.output(out_port1)]
            request = ofp.message.packet_out(in_port = in_port, data = str(pkt), buffer_id = ofp.OFP_NO_BUFFER, actions = actions)
            self.controller.message_send(request)
            verify_packet(self, str(simple_tcp_packet(ip_src = '192.168.1.5')), out_port)
            verify_no_packet(self, str(simple_tcp_packet(ip_src = '192.168.1.5')), no_port)
            reply, _ = self.controller.poll(exp_msg = ofp.OFPT_ERROR, timeout = 3)
            self.assertIsNone(reply, "Received an error")


        else:
            self.assertEqual(reply.stats_type,ofp.const.OFPST_GROUP_FEATURES,"Received msg is not group features")
            self.assertNotEqual(reply.max_groups_all,0,"Group is not supported by DUT")
            out_port = [out_port1,out_port2]
            #no_port = out_port1
            actions = [ofp.action.set_field(ofp.oxm.ipv4_src(0xc0a80105)), ofp.action.group(group_id = 1), ofp.action.output(out_port1)]
            request = ofp.message.packet_out(in_port = in_port, data = str(pkt), buffer_id = ofp.OFP_NO_BUFFER, actions = actions)
            self.controller.message_send(request)
            verify_packets(self, str(simple_tcp_packet(ip_src = '192.168.1.5')), out_port)
            #verify_packet(self, str(simple_tcp_packet(ip_src = '192.168.1.5')), out_port1)
            reply, _ = self.controller.poll(exp_msg = ofp.OFPT_ERROR, timeout = 3)
            self.assertIsNone(reply, "Received an error")
示例#42
0
    def runTest(self):
        port1, = testutils.openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=ofp.OFPG_ANY,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])
        logging.info("Sending group add request")
        reply, pkt = self.controller.transact(msg)
        self.assertTrue(reply is not None, "No response to group add request")
        self.assertTrue(reply.type == ofp.OFPT_ERROR,
                        "reply not an error message")
        self.assertTrue(reply.err_type == ofp.OFPET_GROUP_MOD_FAILED,
                        "reply error type is not bad group mod request")
        self.assertTrue(reply.code == ofp.OFPGMFC_INVALID_GROUP,
                        "reply code is not invalid group")
示例#43
0
    def runTest(self):
        logging.info(
            "Running 300.190 - Multipart type group counter statistics test")
        rv = delete_all_flows(self.controller)
        delete_all_groups(self.controller)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        in_port, port_a, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[ofp.bucket(actions=[ofp.action.output(port_a)])])
        #self.controller.message_send(msg)
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, "Failed to add group")

        table_id = 0
        priority = 100
        actions = [ofp.action.group(group_id=1)]
        instructions = [ofp.instruction.apply_actions(actions=actions)]
        match = ofp.match([ofp.oxm.in_port(in_port)])
        request = ofp.message.flow_add(table_id=table_id,
                                       match=match,
                                       buffer_id=ofp.OFP_NO_BUFFER,
                                       instructions=instructions,
                                       priority=priority)
        logging.info("Insert flow")
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert flow")

        request = ofp.message.group_stats_request(group_id=ofp.OFPG_ALL)
        reply, _ = self.controller.transact(request)
        self.assertIsNotNone(reply, "Did not receive group stats reply")
        if reply.type == ofp.const.OFPT_ERROR:
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST,
                             "Error type is not OFPET_BAD_REQUEST")
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_STAT,
                             "Error code is not OFPBRC_BAD_STAT")
            logging.info(
                "DUT does not support group stats and returned error msg as expected"
            )
        else:
            self.assertEqual(reply.stats_type, ofp.const.OFPST_GROUP,
                             "Received group stats reply as expected")
示例#44
0
    def runTest(self):
        port1, = testutils.openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=ofp.OFPG_ANY,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])
        logging.info("Sending group add request")
        reply, pkt = self.controller.transact(msg)
        self.assertTrue(reply is not None,
                        "No response to group add request")
        self.assertTrue(reply.type == ofp.OFPT_ERROR,
                        "reply not an error message")
        self.assertTrue(reply.err_type == ofp.OFPET_GROUP_MOD_FAILED,
                        "reply error type is not bad group mod request")
        self.assertTrue(reply.code == ofp.OFPGMFC_INVALID_GROUP,
                        "reply code is not invalid group")
示例#45
0
    def runTest(self):
        logging.info("Running 300.190 - Multipart type group counter statistics test")
        rv = delete_all_flows(self.controller)
	delete_all_groups(self.controller)
        self.assertEqual(rv, 0, "Failed to delete all flows")

        in_port,port_a, = openflow_ports(2)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port_a)])])
        #self.controller.message_send(msg)
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, "Failed to add group")

        table_id = 0
        priority = 100
        actions=[ofp.action.group(group_id = 1)]
        instructions=[ofp.instruction.apply_actions(actions=actions)]
        match = ofp.match([ofp.oxm.in_port(in_port)])
        request = ofp.message.flow_add(table_id=table_id,
                                   match=match,
                                   buffer_id=ofp.OFP_NO_BUFFER,
                                   instructions=instructions,
                                   priority=priority)
        logging.info("Insert flow")
        rv = self.controller.message_send(request)
        self.assertTrue(rv != -1, "Failed to insert flow") 

        request = ofp.message.group_stats_request(group_id = ofp.OFPG_ALL)
        reply, _= self.controller.transact(request)
        self.assertIsNotNone(reply, "Did not receive group stats reply")
        if reply.type == ofp.const.OFPT_ERROR:
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST, "Error type is not OFPET_BAD_REQUEST")
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_STAT, "Error code is not OFPBRC_BAD_STAT")
            logging.info("DUT does not support group stats and returned error msg as expected")
        else:
            self.assertEqual(reply.stats_type,ofp.const.OFPST_GROUP,"Received group stats reply as expected")
示例#46
0
    def runTest(self):
        INFO = " 1.1.30 - Group Identifier Violation"
        port1, = testutils.openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=ofp.OFPG_ANY,
            buckets=[ofp.bucket(actions=[ofp.action.output(port1)])])
        logging.info("Sending group add request")
        reply, pkt = self.controller.transact(msg)
        try:
            self.assertTrue(reply is not None,
                            "No response to group add request")
            self.assertTrue(reply.type == ofp.OFPT_ERROR,
                            "Reply not an error message")
            self.assertTrue(reply.err_type == ofp.OFPET_GROUP_MOD_FAILED,
                            "Reply error type is not bad group mod request")
            self.assertTrue(reply.code == ofp.OFPGMFC_INVALID_GROUP,
                            "Reply code is not invalid group")
            log.info(PASS + INFO)
        except AssertionError, Err:
            log.info(FAIL + INFO)
            log.info(REASON + " -> " + str(Err))
示例#47
0
    def runTest(self):
        INFO = " 1.1.30 - Group Identifier Violation"
        port1, = testutils.openflow_ports(1)

        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=ofp.OFPG_ANY,
            buckets=[
                ofp.bucket(actions=[ofp.action.output(port1)])])
        logging.info("Sending group add request")
        reply, pkt = self.controller.transact(msg)
        try:
            self.assertTrue(reply is not None,
                            "No response to group add request")
            self.assertTrue(reply.type == ofp.OFPT_ERROR,
                            "Reply not an error message")
            self.assertTrue(reply.err_type == ofp.OFPET_GROUP_MOD_FAILED,
                            "Reply error type is not bad group mod request")
            self.assertTrue(reply.code == ofp.OFPGMFC_INVALID_GROUP,
                           "Reply code is not invalid group")
            log.info(PASS + INFO)
        except AssertionError, Err:
            log.info(FAIL + INFO)
            log.info(REASON + " -> "+ str(Err))
示例#48
0
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        delete_all_flows(self.controller)
        delete_all_groups(self.controller)    

        #l2-interface-grup_port1_vlann100_untag
        grouptype = 0
        vlanid = 100
        of_port=1
        group_id = of_port + (vlanid << 16) + (grouptype << 28)
        actions = [
            ofp.action.pop_vlan(),
            ofp.action.output(of_port),
        ]
        buckets = [
            ofp.bucket(actions=actions),
        ]
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=group_id,
            buckets=buckets
        )
        self.controller.message_send(request) 
        #l2-interface-grup_port2_vlann100_untag
        grouptype = 0
        vlanid = 100
        of_port=2
        group_id = of_port + (vlanid << 16) + (grouptype << 28)
        actions = [
            ofp.action.pop_vlan(),
            ofp.action.output(of_port),
        ]
        buckets = [
            ofp.bucket(actions=actions),
        ]
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=group_id,
            buckets=buckets
        )
        self.controller.message_send(request)     

        #10_add_port1_allow_rx_tag_vid_100
        match = ofp.match()
        of_port=1
        vlanid=100
        match.oxm_list.append(ofp.oxm.in_port(of_port))
        match.oxm_list.append(ofp.oxm.vlan_vid(0x1000|vlanid))
        request = ofp.message.flow_add(
            table_id=10,
            cookie=42,
            match=match,
            instructions=[
              ofp.instruction.goto_table(20)
            ],
            priority=0)
        logging.info("Set vlan-1 tagged on port %d, and goto table 20" % of_port)
        self.controller.message_send(request)
        """        
        #50_mac_0000000010_vlan_100
        grouptype = 0
        vlanid = 100
        out_port=2
        group_id = out_port + (vlanid << 16) + (grouptype << 28)
        match = ofp.match()
        match.oxm_list.append(ofp.oxm.eth_dst([0x00, 0x00, 0x00, 0x00, 0x00, 0x10]))
        match.oxm_list.append(ofp.oxm.vlan_vid(vlanid))
        request = ofp.message.flow_add(
                table_id=50,
                cookie=42,
                match=match,
                instructions=[
                    ofp.instruction.write_actions(
                        actions=[
                            ofp.action.group(group_id)]),
                        ofp.instruction.goto_table(60)
                    ],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)

        logging.info("Inserting Bridge flow sending matching packets to port %d", out_port)
        self.controller.message_send(request)
        do_barrier(self.controller)        
        """
        #60_acl

        grouptype = 0
        vlanid = 100
        out_port=2
        group_id = out_port + (vlanid << 16) + (grouptype << 28)
        match = ofp.match()
        match.oxm_list.append(ofp.oxm.eth_dst([0x00, 0x00, 0x00, 0x00, 0x00, 0x10]))
        match.oxm_list.append(ofp.oxm.vlan_vid(vlanid))
        match.oxm_list.append(ofp.oxm.eth_type(0x0800))        
        match.oxm_list.append(ofp.oxm.ipv4_dst_masked(0xc0010164, 32))        
        request = ofp.message.flow_add(
                table_id=60,
                cookie=42,
                match=match,
                instructions=[
                    ofp.instruction.apply_actions(
                        actions=[
                            ofp.action.group(group_id)])
                    ],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)

        logging.info("Inserting ACL flow sending matching packets to port %d", out_port)
        self.controller.message_send(request)
        do_barrier(self.controller)        

        #send packet on port 1
        in_port=1
        out_port=2
        parsed_pkt = simple_tcp_packet(pktlen=104, 
                                       eth_dst='00:00:00:00:00:10', 
                                       dl_vlan_enable=True,
                                       vlan_vid=100,
                                       ip_dst='192.168.1.100')
        pkt = str(parsed_pkt)
        logging.info("Send packet on port %d, out port %d", in_port, out_port)
        self.dataplane.send(in_port, pkt)
        #construct verify packet content
        parsed_pkt = simple_tcp_packet(pktlen=100, 
                                       eth_dst='00:00:00:00:00:10', 
                                       ip_dst='192.168.1.100')
        verify_packet(self, parsed_pkt, out_port)
        
        verify_no_other_packets(self)   

        #send packet on port 1, again but diff DST IP
        in_port=1
        out_port=2
        parsed_pkt = simple_tcp_packet(pktlen=104, 
                                       eth_dst='00:00:00:00:00:10', 
                                       dl_vlan_enable=True,
                                       vlan_vid=100,
                                       ip_dst='192.168.1.200')
        pkt = str(parsed_pkt)
        logging.info("Send packet on port %d, out port %d", in_port, out_port)
        self.dataplane.send(in_port, pkt)
        #construct verify packet content
        parsed_pkt = simple_tcp_packet(pktlen=100, 
                                       eth_dst='00:00:00:00:00:10', 
                                       ip_dst='192.168.1.200')
        verify_no_packet(self, parsed_pkt, out_port)
        
        verify_no_other_packets(self)  
示例#49
0
文件: groups.py 项目: harshsin/oftest
    def runTest(self):
        port1, port2, port3, = openflow_ports(3)

        msg0 = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[ofp.action.set_field(ofp.oxm.tcp_src(2000)), ofp.action.output(port1)]),
                ofp.bucket(actions=[ofp.action.set_field(ofp.oxm.tcp_src(3000)), ofp.action.output(port2)]),
                ofp.bucket(actions=[ofp.action.set_field(ofp.oxm.tcp_src(4000)), ofp.action.output(port3)]),
            ],
        )

        self.controller.message_send(msg0)
        do_barrier(self.controller)

        msg1 = ofp.message.group_add(
            group_type=ofp.OFPGT_SELECT,
            group_id=1,
            buckets=[
                ofp.bucket(weight=1, actions=[ofp.action.set_field(ofp.oxm.tcp_src(2001)), ofp.action.output(port1)]),
                ofp.bucket(weight=2, actions=[ofp.action.set_field(ofp.oxm.tcp_src(3001)), ofp.action.output(port2)]),
                ofp.bucket(weight=3, actions=[ofp.action.set_field(ofp.oxm.tcp_src(4001)), ofp.action.output(port3)]),
            ],
        )

        self.controller.message_send(msg1)
        do_barrier(self.controller)

        msg2 = ofp.message.group_add(
            group_type=ofp.OFPGT_FF,
            group_id=2,
            buckets=[
                ofp.bucket(
                    watch_port=port1, actions=[ofp.action.set_field(ofp.oxm.tcp_src(2002)), ofp.action.output(port1)]
                ),
                ofp.bucket(
                    watch_port=port2, actions=[ofp.action.set_field(ofp.oxm.tcp_src(3002)), ofp.action.output(port2)]
                ),
                ofp.bucket(
                    watch_port=port3, actions=[ofp.action.set_field(ofp.oxm.tcp_src(4002)), ofp.action.output(port3)]
                ),
            ],
        )

        self.controller.message_send(msg2)
        do_barrier(self.controller)

        request = ofp.message.group_desc_stats_request()
        stats = sorted(get_stats(self, request), key=lambda x: x.group_id)

        self.assertEquals(len(stats), 3)

        self.assertEquals(stats[0].group_id, msg0.group_id)
        self.assertEquals(stats[0].type, msg0.group_type)
        self.assertEquals(stats[0].buckets, msg0.buckets)

        self.assertEquals(stats[1].group_id, msg1.group_id)
        self.assertEquals(stats[1].type, msg1.group_type)
        self.assertEquals(stats[1].buckets, msg1.buckets)

        self.assertEquals(stats[2].group_id, msg2.group_id)
        self.assertEquals(stats[2].type, msg2.group_type)
        self.assertEquals(stats[2].buckets, msg2.buckets)
示例#50
0
def get_group_mod(gid, action_sets):
    buckets = []
    for b in action_sets:
        buckets.append(ofp.bucket(actions=[get_action(a, arg) for a, arg in b.items()]))
    return group_mod(group_type=ofp.OFPGT_ALL, group_id=gid, buckets=buckets)
示例#51
0
    def runTest(self):
        logging.info("Running testcase 390.100 packet out actions")
        in_port, out_port1, out_port2 = openflow_ports(3)

        pkt = simple_tcp_packet()
        verify_pkt = simple_tcp_packet(ip_src='192.168.0.5')  #0xc0a80105

        delete_all_flows(self.controller)
        delete_all_groups(self.controller)
        msg = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=1,
            buckets=[ofp.bucket(actions=[ofp.action.output(out_port2)])])
        self.controller.message_send(msg)
        reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
        self.assertIsNone(reply, "Received an error")

        request = ofp.message.group_features_stats_request()
        reply, _ = self.controller.transact(request)
        self.assertIsNotNone(reply, "Did not receive group features reply")
        if reply.type == ofp.const.OFPT_ERROR:
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST,
                             "Error type is not OFPET_BAD_REQUEST")
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_STAT,
                             "Error code is not OFPBRC_BAD_STAT")
            logging.info(
                "DUT does not support group features and returned error msg as expected"
            )
            out_port = out_port1
            no_port = out_port2
            actions = [
                ofp.action.set_field(ofp.oxm.ipv4_src(0xc0a80105)),
                ofp.action.output(out_port1)
            ]
            request = ofp.message.packet_out(in_port=in_port,
                                             data=str(pkt),
                                             buffer_id=ofp.OFP_NO_BUFFER,
                                             actions=actions)
            self.controller.message_send(request)
            verify_packet(self, str(simple_tcp_packet(ip_src='192.168.1.5')),
                          out_port)
            verify_no_packet(self,
                             str(simple_tcp_packet(ip_src='192.168.1.5')),
                             no_port)
            reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
            self.assertIsNone(reply, "Received an error")

        else:
            self.assertEqual(reply.stats_type, ofp.const.OFPST_GROUP_FEATURES,
                             "Received msg is not group features")
            self.assertNotEqual(reply.max_groups_all, 0,
                                "Group is not supported by DUT")
            out_port = [out_port1, out_port2]
            #no_port = out_port1
            actions = [
                ofp.action.set_field(ofp.oxm.ipv4_src(0xc0a80105)),
                ofp.action.group(group_id=1),
                ofp.action.output(out_port1)
            ]
            request = ofp.message.packet_out(in_port=in_port,
                                             data=str(pkt),
                                             buffer_id=ofp.OFP_NO_BUFFER,
                                             actions=actions)
            self.controller.message_send(request)
            verify_packets(self, str(simple_tcp_packet(ip_src='192.168.1.5')),
                           out_port)
            #verify_packet(self, str(simple_tcp_packet(ip_src = '192.168.1.5')), out_port1)
            reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
            self.assertIsNone(reply, "Received an error")
示例#52
0
    def runTest(self):
        port1, port2, port3, = openflow_ports(3)

        msg0 = ofp.message.group_add(
            group_type=ofp.OFPGT_ALL,
            group_id=0,
            buckets=[
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(2000)),
                    ofp.action.output(port1)
                ]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(3000)),
                    ofp.action.output(port2)
                ]),
                ofp.bucket(actions=[
                    ofp.action.set_field(ofp.oxm.tcp_src(4000)),
                    ofp.action.output(port3)
                ])
            ])

        self.controller.message_send(msg0)
        do_barrier(self.controller)

        msg1 = ofp.message.group_add(
            group_type=ofp.OFPGT_SELECT,
            group_id=1,
            buckets=[
                ofp.bucket(weight=1,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(2001)),
                               ofp.action.output(port1)
                           ]),
                ofp.bucket(weight=2,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(3001)),
                               ofp.action.output(port2)
                           ]),
                ofp.bucket(weight=3,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(4001)),
                               ofp.action.output(port3)
                           ])
            ])

        self.controller.message_send(msg1)
        do_barrier(self.controller)

        msg2 = ofp.message.group_add(
            group_type=ofp.OFPGT_FF,
            group_id=2,
            buckets=[
                ofp.bucket(watch_port=port1,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(2002)),
                               ofp.action.output(port1)
                           ]),
                ofp.bucket(watch_port=port2,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(3002)),
                               ofp.action.output(port2, )
                           ]),
                ofp.bucket(watch_port=port3,
                           actions=[
                               ofp.action.set_field(ofp.oxm.tcp_src(4002)),
                               ofp.action.output(port3, )
                           ])
            ])

        self.controller.message_send(msg2)
        do_barrier(self.controller)

        request = ofp.message.group_desc_stats_request()
        stats = sorted(get_stats(self, request), key=lambda x: x.group_id)

        self.assertEquals(len(stats), 3)

        self.assertEquals(stats[0].group_id, msg0.group_id)
        self.assertEquals(stats[0].group_type, msg0.group_type)
        self.assertEquals(stats[0].buckets, msg0.buckets)

        self.assertEquals(stats[1].group_id, msg1.group_id)
        self.assertEquals(stats[1].group_type, msg1.group_type)
        self.assertEquals(stats[1].buckets, msg1.buckets)

        self.assertEquals(stats[2].group_id, msg2.group_id)
        self.assertEquals(stats[2].group_type, msg2.group_type)
        self.assertEquals(stats[2].buckets, msg2.buckets)
示例#53
0
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        delete_all_flows(self.controller)
        delete_all_groups(self.controller)    

        #l2-interface-grup_port1_vlann200_untag
        grouptype = 0
        vlanid = 200
        of_port=1
        group_id = of_port + (vlanid << 16) + (grouptype << 28)
        actions = [
            ofp.action.pop_vlan(),
            ofp.action.output(of_port),
        ]
        buckets = [
            ofp.bucket(actions=actions),
        ]
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=group_id,
            buckets=buckets
        )
        self.controller.message_send(request) 
        #l2-interface-grup_port2_vlann300
        grouptype = 0
        vlanid = 300
        of_port=2
        group_id = of_port + (vlanid << 16) + (grouptype << 28)
        actions = [
            ofp.action.output(of_port),
        ]
        buckets = [
            ofp.bucket(actions=actions),
        ]
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=group_id,
            buckets=buckets
        )
        self.controller.message_send(request)     

        #rewrite_group_vlan_200_to_300, use l2-interface-grup_port2_vlann300 group_id
        grouptype = 1
        vlanid = 300
        rw_group_id = 2 + (grouptype << 28)
        
        action=[]
        action.append(ofp.action.set_field(ofp.oxm.vlan_vid(vlanid)))
        action.append(ofp.action.group(group_id))        
        buckets = [ofp.bucket(actions=action)]   
        request = ofp.message.group_add(
            group_type=ofp.OFPGT_INDIRECT,
            group_id=rw_group_id,
            buckets=buckets
        )
        self.controller.message_send(request)     
                
        #10_add_port1_allow_rx_tag_vid_200
        match = ofp.match()
        of_port=1
        vlanid=200
        match.oxm_list.append(ofp.oxm.in_port(of_port))
        match.oxm_list.append(ofp.oxm.vlan_vid(0x1000|vlanid))
        request = ofp.message.flow_add(
            table_id=10,
            cookie=42,
            match=match,
            instructions=[
              ofp.instruction.goto_table(20)
            ],
            priority=0)
        logging.info("Set vlan-1 tagged on port %d, and goto table 20" % of_port)
        self.controller.message_send(request)
        
       
        #60_acl
        grouptype = 1
        vlanid = 200
        rw_group_id = 2 + (grouptype << 28)
        match = ofp.match()
        match.oxm_list.append(ofp.oxm.in_port(1))
        match.oxm_list.append(ofp.oxm.eth_src([0x00, 0x00, 0x00, 0x00, 0x00, 0x20]))
        match.oxm_list.append(ofp.oxm.vlan_vid(vlanid))
        match.oxm_list.append(ofp.oxm.eth_type(0x0800))        
        match.oxm_list.append(ofp.oxm.ipv4_src(0xc0a80164))
        match.oxm_list.append(ofp.oxm.ip_proto(6))
        
        request = ofp.message.flow_add(
                table_id=60,
                cookie=42,
                match=match,
                instructions=[
                    ofp.instruction.apply_actions(
                        actions=[
                            ofp.action.group(rw_group_id)])
                    ],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)

        self.controller.message_send(request)
        do_barrier(self.controller)        

        #send packet on port 1
        in_port=1
        out_port=2
        parsed_pkt = simple_tcp_packet(pktlen=104, 
                                       eth_src='00:00:00:00:00:20', 
                                       dl_vlan_enable=True,
                                       vlan_vid=200,
                                       ip_src='192.168.1.100')
        pkt = str(parsed_pkt)
        logging.info("Send packet on port %d, out port %d", in_port, out_port)
        self.dataplane.send(in_port, pkt)
        #construct verify packet content
        parsed_pkt = simple_tcp_packet(pktlen=104, 
                                       eth_src='00:00:00:00:00:20', 
                                       dl_vlan_enable=True,
                                       vlan_vid=300,                                       
                                       ip_src='192.168.1.100')
        verify_packet(self, parsed_pkt, out_port)
        
        verify_no_other_packets(self)   

        #send packet on port 1, again but diff SRC IP
        in_port=1
        out_port=2
        parsed_pkt = simple_tcp_packet(pktlen=104, 
                                       eth_src='00:00:00:00:00:20', 
                                       dl_vlan_enable=True,
                                       vlan_vid=100,
                                       ip_src='192.168.1.200')
        pkt = str(parsed_pkt)
        logging.info("Send packet on port %d, out port %d", in_port, out_port)
        self.dataplane.send(in_port, pkt)
        verify_no_packet(self, pkt, out_port)
        
        verify_no_other_packets(self)         
示例#54
0
    def runTest(self):
        logging.info("Running testcase 200.130 basic OFPT_GROUP_MOD")

        in_port, out_port = openflow_ports(2)
        delete_all_flows(self.controller)
        request = ofp.message.group_add(group_type = ofp.OFPGT_ALL, group_id = 0, buckets = [ofp.bucket(actions = [ofp.action.output(out_port)],
                                                                                                watch_port = ofp.OFPP_ANY,
                                                                                                watch_group = ofp.OFPG_ANY)])

        self.controller.message_send(request)

        reply,_= self.controller.poll(exp_msg = ofp.OFPT_ERROR, timeout = 3)
        if reply:
            logging.info("The device does not support group")
            self.assertEqual(reply.err_type, ofp.const.OFPET_BAD_REQUEST,
                              ("Error type %d was received, but we expected "
                               "OFPET_BAD_REQUEST.") % reply.err_type)
            self.assertEqual(reply.code, ofp.const.OFPBRC_BAD_TYPE,
                              ("Flow mod failed code %d was received, but we "
                               "expected OFPBRC_BAD_TYPE.") % reply.code)
        else:
            logging.info("Created a group")
            group_stats = get_stats(self, ofp.message.group_desc_stats_request())
            self.assertIsNotNone(group_stats, "Can not get the information of the group created")
示例#55
0
    def create_new_vpws(self):

        ####################################################################################
        #
        # Create VPWS
        #
        ####################################################################################
        '''
        set up L2 Interface groups on physical ports  1
        '''
        id_1 = 0
        id_1 = ofdb_group_type_set(id_1,
                                   ofdpa.OFDPA_GROUP_ENTRY_TYPE_L2_INTERFACE)
        id_1 = ofdb_group_vlanid_set(id_1, self.vlanid)
        id_1 = ofdb_group_portid_set(id_1, self.firstPhysicalPort)
        action_list = [ofp.action.output(self.firstPhysicalPort)
                       ]  #, ofp.action.pop_vlan()]
        bucket_list = [ofp.bucket(actions=action_list)]

        msg = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT,
                                    group_id=id_1,
                                    buckets=bucket_list)
        self.pe.message_send(msg)
        '''
        set up L2 Interface groups on physical ports  2
        '''
        id_2 = 0
        id_2 = ofdb_group_type_set(id_2,
                                   ofdpa.OFDPA_GROUP_ENTRY_TYPE_L2_INTERFACE)
        id_2 = ofdb_group_vlanid_set(id_2, self.vlanid)
        id_2 = ofdb_group_portid_set(id_2, self.secondPhysicalPort)
        action_list = [ofp.action.output(self.secondPhysicalPort)
                       ]  #, ofp.action.pop_vlan()]
        bucket_list = [ofp.bucket(actions=action_list)]

        msg = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT,
                                    group_id=id_2,
                                    buckets=bucket_list)
        self.pe.message_send(msg)
        '''
        Add vlan table entry 1
        '''
        table_id = ofdpa.OFDPA_FLOW_TABLE_ID_VLAN
        match = ofp.match([
            ofp.oxm.in_port(self.firstPhysicalPort),
            ofp.oxm.vlan_vid_masked(
                value=ofdpa.OFDPA_VID_PRESENT | self.vlanid,
                value_mask=ofdpa.OFDPA_VID_PRESENT | 0xfff),
        ])
        instructions = [
            ofp.instruction.goto_table(
                ofdpa.OFDPA_FLOW_TABLE_ID_TERMINATION_MAC),
        ]

        logging.info("Inserting vlan flow")
        request = ofp.message.flow_add(
            table_id=table_id,
            match=match,
            instructions=instructions,
        )

        self.pe.message_send(request)

        do_barrier(self.pe)
        '''
        Add vlan table entry  2
        '''
        table_id = ofdpa.OFDPA_FLOW_TABLE_ID_VLAN
        match = ofp.match([
            ofp.oxm.in_port(self.secondPhysicalPort),
            ofp.oxm.vlan_vid_masked(
                value=ofdpa.OFDPA_VID_PRESENT | self.vlanid,
                value_mask=ofdpa.OFDPA_VID_PRESENT | 0xfff),
        ])
        instructions = [
            ofp.instruction.goto_table(
                ofdpa.OFDPA_FLOW_TABLE_ID_TERMINATION_MAC),
        ]

        logging.info("Inserting vlan flow")
        request = ofp.message.flow_add(
            table_id=table_id,
            match=match,
            instructions=instructions,
        )

        self.pe.message_send(request)

        do_barrier(self.pe)
        '''
       set up first Bridging flow entry 1
        '''
        table_id = ofdpa.OFDPA_FLOW_TABLE_ID_BRIDGING
        match = ofp.match([
            ofp.oxm.eth_dst_masked(
                value=self.firstMacAddress,
                value_mask=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]),
            ofp.oxm.vlan_vid_masked(
                value=ofdpa.OFDPA_VID_PRESENT | self.vlanid,
                value_mask=ofdpa.OFDPA_VID_PRESENT | 0xfff),
        ])
        instructions = [
            ofp.instruction.goto_table(ofdpa.OFDPA_FLOW_TABLE_ID_ACL_POLICY),
            ofp.instruction.write_actions(
                actions=[ofp.action.group(group_id=id_1)]),
        ]

        logging.info("Inserting vlan flow")
        request = ofp.message.flow_add(
            table_id=table_id,
            match=match,
            instructions=instructions,
        )

        self.pe.message_send(request)

        do_barrier(self.pe)
        '''
       set up first Bridging flow entry 2
        '''
        table_id = ofdpa.OFDPA_FLOW_TABLE_ID_BRIDGING
        match = ofp.match([
            ofp.oxm.eth_dst_masked(
                value=self.secondMacAddress,
                value_mask=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]),
            ofp.oxm.vlan_vid_masked(
                value=ofdpa.OFDPA_VID_PRESENT | self.vlanid,
                value_mask=ofdpa.OFDPA_VID_PRESENT | 0xfff),
        ])
        instructions = [
            ofp.instruction.goto_table(ofdpa.OFDPA_FLOW_TABLE_ID_ACL_POLICY),
            ofp.instruction.write_actions(
                actions=[ofp.action.group(group_id=id_2)]),
        ]

        logging.info("Inserting vlan flow")
        request = ofp.message.flow_add(
            table_id=table_id,
            match=match,
            instructions=instructions,
        )

        self.pe.message_send(request)

        do_barrier(self.pe)
示例#56
0
def get_group_mod(gid, action_sets):
    buckets = []
    for b in action_sets:
        buckets.append(
            ofp.bucket(actions=[get_action(a, arg) for a, arg in b.items()]))
    return group_mod(group_type=ofp.OFPGT_ALL, group_id=gid, buckets=buckets)