Esempio n. 1
0
def mpls_interface_group(dpath, mod, ofctl):
    """
    MPLS Interface group
    """
    _LOG.debug("MPLS Interface Group: %d %s", dpath.id, mod)

    entry = mod.mpls_iface
    cmd = fibcapi.group_mod_cmd(mod.cmd, dpath.ofproto)
    gid = fibcapi.mpls_interface_group_id(entry.ne_id)

    def _buckets():
        if not ofgroup.is_bucket_needed(dpath, cmd):
            return []

        next_gid = fibcapi.l2_interface_group_id(entry.port_id, entry.vlan_vid)
        vlan_vid = fibcapi.adjust_vlan_vid(
            entry.vlan_vid) | fibcapi.OFPVID_PRESENT
        actions = [
            ofaction.set_field("eth_src", entry.eth_src),
            ofaction.set_field("eth_dst", entry.eth_dst),
            ofaction.set_field("vlan_vid", vlan_vid),
            ofaction.group(next_gid),
        ]
        return [dict(actions=actions)]

    group = ofgroup.group_mod(gid, "INDIRECT", _buckets)
    ofctl.mod_group_entry(dpath, group, cmd)
Esempio n. 2
0
    def _buckets():
        if not ofgroup.is_bucket_needed(dpath, cmd):
            return []

        next_gid = fibcapi.mpls_interface_group_id(entry.ne_id)
        actions = [
            ofaction.set_field("mpls_label", entry.new_label),
            ofaction.group(next_gid),
        ]
        return [dict(actions=actions)]
Esempio n. 3
0
    def get_next_gid(entry):
        """
        Get Next Group Id
        """
        if entry.ne_id != 0:
            return fibcapi.mpls_interface_group_id(entry.ne_id)
        elif entry.new_dst_id != 0:
            return fibcapi.mpls_label_group_id(3, entry.new_dst_id)

        return None
Esempio n. 4
0
 def _writes():
     if not offlow.is_action_needed(dpath, cmd):
         return []
     if entry.g_type == pb.GroupMod.MPLS_INTERFACE:
         return [
             ofaction.group(fibcapi.mpls_interface_group_id(entry.g_id))
         ]
     if entry.g_type == pb.GroupMod.MPLS_SWAP:
         return [ofaction.group(fibcapi.mpls_label_group_id(5, entry.g_id))]
     if entry.g_type == pb.GroupMod.MPLS_FF:
         return [ofaction.group(fibcapi.mpls_ff_group_id(entry.g_id))]
     if entry.g_type == pb.GroupMod.MPLS_ECMP:
         return [ofaction.group(fibcapi.mpls_ecmp_group_id(entry.g_id))]
     return []