Ejemplo n.º 1
0
    def add_eapol_flow(self, intf_id, onu_id, logical_flow,
                       eapol_id=EAPOL_FLOW_INDEX,
                       vlan_id=DEFAULT_MGMT_VLAN):

        uplink_classifier = {}
        uplink_classifier[ETH_TYPE] = EAP_ETH_TYPE
        uplink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
        uplink_classifier[VLAN_VID] = vlan_id

        uplink_action = {}
        uplink_action[TRAP_TO_HOST] = True

        # Add Upstream EAPOL Flow.

        pon_intf_onu_id = (intf_id, onu_id)
        gemport_id = self.resource_mgr.get_gemport_id(
                          pon_intf_onu_id=pon_intf_onu_id
                     )
        alloc_id = self.resource_mgr.get_alloc_id(
                          pon_intf_onu_id=pon_intf_onu_id
                     )

        uplink_flow_id = self.platform.mk_flow_id(intf_id, onu_id, eapol_id)

        upstream_flow = openolt_pb2.Flow(
            onu_id=onu_id, flow_id=uplink_flow_id, flow_type=UPSTREAM,
            access_intf_id=intf_id, gemport_id=gemport_id,
            alloc_id=alloc_id,
            priority=logical_flow.priority,
            classifier=self.mk_classifier(uplink_classifier),
            action=self.mk_action(uplink_action))

        logical_flow = copy.deepcopy(logical_flow)
        logical_flow.match.oxm_fields.extend(fd.mk_oxm_fields([fd.vlan_vid(
            vlan_id | 0x1000)]))
        logical_flow.match.type = OFPMT_OXM

        self.add_flow_to_device(upstream_flow, logical_flow)

        if vlan_id == DEFAULT_MGMT_VLAN:

            # Add Downstream EAPOL Flow, Only for first EAP flow (BAL
            # requirement)
            special_vlan_downstream_flow = 4000 - onu_id

            downlink_classifier = {}
            downlink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
            downlink_classifier[VLAN_VID] = special_vlan_downstream_flow

            downlink_action = {}
            downlink_action[PUSH_VLAN] = True
            downlink_action[VLAN_VID] = vlan_id

            downlink_flow_id = self.platform.mk_flow_id(
                intf_id, onu_id, DOWNSTREAM_FLOW_FOR_PACKET_OUT)

            downstream_flow = openolt_pb2.Flow(
                onu_id=onu_id, flow_id=downlink_flow_id, flow_type=DOWNSTREAM,
                access_intf_id=intf_id, gemport_id=gemport_id,
                priority=logical_flow.priority,
                classifier=self.mk_classifier(downlink_classifier),
                action=self.mk_action(downlink_action))

            downstream_logical_flow = ofp_flow_stats(
                id=logical_flow.id, cookie=logical_flow.cookie,
                table_id=logical_flow.table_id, priority=logical_flow.priority,
                flags=logical_flow.flags)

            downstream_logical_flow.match.oxm_fields.extend(fd.mk_oxm_fields([
                fd.in_port(fd.get_out_port(logical_flow)),
                fd.vlan_vid((special_vlan_downstream_flow) | 0x1000)]))
            downstream_logical_flow.match.type = OFPMT_OXM

            downstream_logical_flow.instructions.extend(
                fd.mk_instructions_from_actions([fd.output(
                    self.platform.mk_uni_port_num(intf_id, onu_id))]))

            self.add_flow_to_device(downstream_flow, downstream_logical_flow)
Ejemplo n.º 2
0
    def add_eapol_flow(self, intf_id, onu_id, logical_flow,
                       uplink_eapol_id=EAPOL_FLOW_INDEX,
                       downlink_eapol_id=EAPOL_DOWNLINK_FLOW_INDEX,
                       vlan_id=DEFAULT_MGMT_VLAN):



        uplink_classifier = {}
        uplink_classifier['eth_type'] = EAP_ETH_TYPE
        uplink_classifier['pkt_tag_type'] = 'single_tag'
        uplink_classifier['vlan_vid'] = vlan_id

        uplink_action = {}
        uplink_action['trap_to_host'] = True

        gemport_id = self.platform.mk_gemport_id(intf_id, onu_id)

        # Add Upstream EAPOL Flow.

        uplink_flow_id = self.platform.mk_flow_id(intf_id, onu_id, uplink_eapol_id)

        upstream_flow = openolt_pb2.Flow(
            onu_id=onu_id, flow_id=uplink_flow_id, flow_type="upstream",
            access_intf_id=intf_id, gemport_id=gemport_id,
            priority=logical_flow.priority,
            classifier=self.mk_classifier(uplink_classifier),
            action=self.mk_action(uplink_action))

        logical_flow = copy.deepcopy(logical_flow)
        logical_flow.match.oxm_fields.extend(fd.mk_oxm_fields([fd.vlan_vid(
            vlan_id | 0x1000)]))
        logical_flow.match.type = OFPMT_OXM

        self.add_flow_to_device(upstream_flow, logical_flow)

        if vlan_id == DEFAULT_MGMT_VLAN:

            # Add Downstream EAPOL Flow, Only for first EAP flow

            downlink_classifier = {}
            downlink_classifier['pkt_tag_type'] = 'single_tag'
            downlink_classifier['vlan_vid'] = 4000 - onu_id



            downlink_action = {}
            downlink_action['push_vlan'] = True
            downlink_action['vlan_vid'] = vlan_id

            downlink_flow_id = self.platform.mk_flow_id(intf_id, onu_id,
                                                   downlink_eapol_id)

            downstream_flow = openolt_pb2.Flow(
                onu_id=onu_id, flow_id=downlink_flow_id, flow_type="downstream",
                access_intf_id=intf_id, gemport_id=gemport_id,
                priority=logical_flow.priority,
                classifier=self.mk_classifier(downlink_classifier),
                action=self.mk_action(downlink_action))

            downstream_logical_flow = ofp_flow_stats(id=logical_flow.id,
                 cookie=logical_flow.cookie, table_id=logical_flow.table_id,
                 priority=logical_flow.priority, flags=logical_flow.flags)

            downstream_logical_flow.match.oxm_fields.extend(fd.mk_oxm_fields([
                fd.in_port(fd.get_out_port(logical_flow)),
                fd.vlan_vid((4000 - onu_id) | 0x1000)]))
            downstream_logical_flow.match.type = OFPMT_OXM

            downstream_logical_flow.instructions.extend(
                fd.mk_instructions_from_actions([fd.output(
                self.platform.mk_uni_port_num(intf_id, onu_id))]))

            self.add_flow_to_device(downstream_flow, downstream_logical_flow)
Ejemplo n.º 3
0
    def add_eapol_flow(self, intf_id, onu_id, uni_id, port_no, logical_flow,
                       alloc_id, gemport_id, vlan_id=DEFAULT_MGMT_VLAN):

        uplink_classifier = dict()
        uplink_classifier[ETH_TYPE] = EAP_ETH_TYPE
        uplink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
        uplink_classifier[VLAN_VID] = vlan_id

        uplink_action = dict()
        uplink_action[TRAP_TO_HOST] = True

        flow_store_cookie = self._get_flow_store_cookie(uplink_classifier,
                                                        gemport_id)

        if self.resource_mgr.is_flow_cookie_on_kv_store(intf_id, onu_id,
                                                        uni_id,
                                                        flow_store_cookie):
            self.log.debug('flow-exists--not-re-adding')
        else:
            # Add Upstream EAPOL Flow.
            uplink_flow_id = self.resource_mgr.get_flow_id(
                intf_id, onu_id, uni_id, flow_store_cookie
            )

            upstream_flow = openolt_pb2.Flow(
                access_intf_id=intf_id, onu_id=onu_id, uni_id=uni_id,
                flow_id=uplink_flow_id, flow_type=UPSTREAM, alloc_id=alloc_id,
                network_intf_id=self.data_model.olt_nni_intf_id(),
                gemport_id=gemport_id,
                classifier=self.mk_classifier(uplink_classifier),
                action=self.mk_action(uplink_action),
                priority=logical_flow.priority,
                port_no=port_no,
                cookie=logical_flow.cookie)

            logical_flow = copy.deepcopy(logical_flow)
            logical_flow.match.oxm_fields.extend(fd.mk_oxm_fields([fd.vlan_vid(
                vlan_id | 0x1000)]))
            logical_flow.match.type = OFPMT_OXM

            if self.add_flow_to_device(upstream_flow, logical_flow):
                flow_info = self._get_flow_info_as_json_blob(upstream_flow,
                                                             flow_store_cookie)
                self.update_flow_info_to_kv_store(upstream_flow.access_intf_id,
                                                  upstream_flow.onu_id,
                                                  upstream_flow.uni_id,
                                                  upstream_flow.flow_id,
                                                  flow_info)

        if vlan_id == DEFAULT_MGMT_VLAN:
            # Add Downstream EAPOL Flow, Only for first EAP flow (BAL
            # requirement)
            # On one of the platforms (Broadcom BAL), when same DL classifier
            # vlan was used across multiple ONUs, eapol flow re-adds after
            # flow delete (cases of onu reboot/disable) fails.
            # In order to generate unique vlan, a combination of intf_id
            # onu_id and uni_id is used.
            # uni_id defaults to 0, so add 1 to it.
            special_vlan_downstream_flow = 4090 - intf_id * onu_id * (uni_id+1)
            # Assert that we do not generate invalid vlans under no condition
            assert special_vlan_downstream_flow >= 2

            downlink_classifier = dict()
            downlink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
            downlink_classifier[VLAN_VID] = special_vlan_downstream_flow

            downlink_action = dict()
            downlink_action[PUSH_VLAN] = True
            downlink_action[VLAN_VID] = vlan_id

            flow_store_cookie = self._get_flow_store_cookie(
                downlink_classifier, gemport_id)
            if self.resource_mgr.is_flow_cookie_on_kv_store(
                    intf_id, onu_id, uni_id, flow_store_cookie):
                self.log.debug('flow-exists--not-re-adding')
            else:

                downlink_flow_id = self.resource_mgr.get_flow_id(
                    intf_id, onu_id, uni_id, flow_store_cookie
                )

                downstream_flow = openolt_pb2.Flow(
                    access_intf_id=intf_id, onu_id=onu_id, uni_id=uni_id,
                    flow_id=downlink_flow_id, flow_type=DOWNSTREAM,
                    alloc_id=alloc_id,
                    network_intf_id=self.data_model.olt_nni_intf_id(),
                    gemport_id=gemport_id,
                    classifier=self.mk_classifier(downlink_classifier),
                    action=self.mk_action(downlink_action),
                    priority=logical_flow.priority,
                    port_no=port_no,
                    cookie=logical_flow.cookie)

                downstream_logical_flow = ofp_flow_stats(
                    id=logical_flow.id, cookie=logical_flow.cookie,
                    table_id=logical_flow.table_id,
                    priority=logical_flow.priority, flags=logical_flow.flags)

                downstream_logical_flow.match.oxm_fields.extend(
                    fd.mk_oxm_fields(
                        [fd.in_port(fd.get_out_port(logical_flow)),
                         fd.vlan_vid(special_vlan_downstream_flow | 0x1000)]))
                downstream_logical_flow.match.type = OFPMT_OXM

                downstream_logical_flow.instructions.extend(
                    fd.mk_instructions_from_actions([fd.output(
                        self.platform.mk_uni_port_num(intf_id, onu_id,
                                                      uni_id))]))

                if self.add_flow_to_device(downstream_flow,
                                           downstream_logical_flow):
                    flow_info = self._get_flow_info_as_json_blob(
                        downstream_flow, flow_store_cookie)
                    self.update_flow_info_to_kv_store(
                        downstream_flow.access_intf_id, downstream_flow.onu_id,
                        downstream_flow.uni_id, downstream_flow.flow_id,
                        flow_info)
Ejemplo n.º 4
0
    def add_eapol_flow(self,
                       intf_id,
                       onu_id,
                       logical_flow,
                       alloc_id,
                       gemport_id,
                       eapol_flow_category=EAPOL_PRIMARY_FLOW,
                       vlan_id=DEFAULT_MGMT_VLAN):

        uplink_classifier = dict()
        uplink_classifier[ETH_TYPE] = EAP_ETH_TYPE
        uplink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
        uplink_classifier[VLAN_VID] = vlan_id

        uplink_action = dict()
        uplink_action[TRAP_TO_HOST] = True

        pon_intf_onu_id = (intf_id, onu_id)
        # Add Upstream EAPOL Flow.
        if eapol_flow_category == EAPOL_PRIMARY_FLOW:
            uplink_flow_id = self.resource_mgr.get_flow_id(pon_intf_onu_id)
        else:
            uplink_flow_id = self.resource_mgr.get_flow_id(pon_intf_onu_id)

        upstream_flow = openolt_pb2.Flow(
            access_intf_id=intf_id,
            onu_id=onu_id,
            flow_id=uplink_flow_id,
            flow_type=UPSTREAM,
            alloc_id=alloc_id,
            network_intf_id=0,
            gemport_id=gemport_id,
            classifier=self.mk_classifier(uplink_classifier),
            action=self.mk_action(uplink_action),
            priority=logical_flow.priority)

        logical_flow = copy.deepcopy(logical_flow)
        logical_flow.match.oxm_fields.extend(
            fd.mk_oxm_fields([fd.vlan_vid(vlan_id | 0x1000)]))
        logical_flow.match.type = OFPMT_OXM

        if self.add_flow_to_device(upstream_flow, logical_flow):
            if eapol_flow_category == EAPOL_PRIMARY_FLOW:
                flow_info = self._get_flow_info_as_json_blob(
                    upstream_flow, EAPOL_PRIMARY_FLOW)
                self.update_flow_info_to_kv_store(upstream_flow.access_intf_id,
                                                  upstream_flow.onu_id,
                                                  upstream_flow.flow_id,
                                                  flow_info)
            else:
                flow_info = self._get_flow_info_as_json_blob(
                    upstream_flow, EAPOL_SECONDARY_FLOW)
                self.update_flow_info_to_kv_store(upstream_flow.access_intf_id,
                                                  upstream_flow.onu_id,
                                                  upstream_flow.flow_id,
                                                  flow_info)

        if vlan_id == DEFAULT_MGMT_VLAN:
            # Add Downstream EAPOL Flow, Only for first EAP flow (BAL
            # requirement)
            special_vlan_downstream_flow = 4000 - onu_id

            downlink_classifier = dict()
            downlink_classifier[PACKET_TAG_TYPE] = SINGLE_TAG
            downlink_classifier[VLAN_VID] = special_vlan_downstream_flow

            downlink_action = dict()
            downlink_action[PUSH_VLAN] = True
            downlink_action[VLAN_VID] = vlan_id

            pon_intf_onu_id = (intf_id, onu_id)
            downlink_flow_id = self.resource_mgr.get_flow_id(pon_intf_onu_id)

            downstream_flow = openolt_pb2.Flow(
                access_intf_id=intf_id,
                onu_id=onu_id,
                flow_id=downlink_flow_id,
                flow_type=DOWNSTREAM,
                alloc_id=alloc_id,
                network_intf_id=0,
                gemport_id=gemport_id,
                classifier=self.mk_classifier(downlink_classifier),
                action=self.mk_action(downlink_action),
                priority=logical_flow.priority)

            downstream_logical_flow = ofp_flow_stats(
                id=logical_flow.id,
                cookie=logical_flow.cookie,
                table_id=logical_flow.table_id,
                priority=logical_flow.priority,
                flags=logical_flow.flags)

            downstream_logical_flow.match.oxm_fields.extend(
                fd.mk_oxm_fields([
                    fd.in_port(fd.get_out_port(logical_flow)),
                    fd.vlan_vid(special_vlan_downstream_flow | 0x1000)
                ]))
            downstream_logical_flow.match.type = OFPMT_OXM

            downstream_logical_flow.instructions.extend(
                fd.mk_instructions_from_actions([
                    fd.output(self.platform.mk_uni_port_num(intf_id, onu_id))
                ]))

            if self.add_flow_to_device(downstream_flow,
                                       downstream_logical_flow):
                flow_info = self._get_flow_info_as_json_blob(
                    downstream_flow, EAPOL_PRIMARY_FLOW)
                self.update_flow_info_to_kv_store(
                    downstream_flow.access_intf_id, downstream_flow.onu_id,
                    downstream_flow.flow_id, flow_info)