Example #1
0
def _add_mpls_l3_type_php_flows(dpath, ofctl):
    # L3 VPN Forward (IPv4) based on this label (PHP)
    flow = offlow.flow_mod(
        match=ofmatch.Match().eth_type(fibcapi.ETHTYPE_MPLS).mpls_type(
            fibcapi.MPLSTYPE_PHP, True),
        actions=[
            ofaction.pop_mpls(fibcapi.ETHTYPE_IPV4),
            ofaction.goto_table(pb.FlowMod.MPLS_LABEL_TRUST),
        ],
        writes=[],
        table_id=pb.FlowMod.MPLS_L3_TYPE,
        priority=5,
    )
    ofctl.mod_flow_entry(dpath, flow, dpath.ofproto.OFPFC_ADD)
    return
Example #2
0
def _add_mpls_l3_type_l3vpn_flows(dpath, ofctl):
    # L3 VPN Route (IPv4 Unicast)
    flow = offlow.flow_mod(
        match=ofmatch.Match().eth_type(fibcapi.ETHTYPE_MPLS),
        actions=[
            ofaction.set_mpls_type(fibcapi.MPLSTYPE_UNICAST, True),
            ofaction.pop_mpls(fibcapi.ETHTYPE_IPV4),
            ofaction.goto_table(pb.FlowMod.MPLS_LABEL_TRUST),
        ],
        writes=[],
        table_id=pb.FlowMod.MPLS_L3_TYPE,
        priority=1,
    )
    ofctl.mod_flow_entry(dpath, flow, dpath.ofproto.OFPFC_ADD)
    return
Example #3
0
    def _actions():
        if not offlow.is_action_needed(dpath, cmd):
            return []

        actions = [
            ofaction.goto_table(entry.goto_table),
            ofaction.dec_mpls_ttl(),
        ]

        if entry.goto_table == pb.FlowMod.MPLS_TYPE:
            actions.append(
                ofaction.set_mpls_type(fibcapi.MPLSTYPE_PHP, use_metadata))

        for action in entry.actions:
            if action.name == pb.MPLSFlow.Action.POP_LABEL:
                actions.append(ofaction.pop_mpls(action.value))

            elif action.name == pb.MPLSFlow.Action.SET_VRF:
                actions.append(ofaction.set_vrf(action.value, use_metadata))

        return actions