Search in sources :

Example 11 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method getBucketInfoForPrimaryNaptSwitch.

List<BucketInfo> getBucketInfoForPrimaryNaptSwitch() {
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
    listActionInfoPrimary.add(new ActionNxResubmit(NwConstants.INTERNAL_TUNNEL_TABLE));
    BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
    listBucketInfo.add(0, bucketPrimary);
    return listBucketInfo;
}
Also used : ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 12 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method removeFlowsFromNonActiveSwitches.

public void removeFlowsFromNonActiveSwitches(long routerId, String routerName, BigInteger naptSwitchDpnId, WriteTransaction removeFlowInvTx) {
    LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
    // Remove the flows from the other switches which points to the primary and secondary switches
    // for the flows related the router ID.
    List<BigInteger> allSwitchList = naptSwitchSelector.getDpnsForVpn(routerName);
    if (allSwitchList.isEmpty()) {
        LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
        return;
    }
    for (BigInteger dpnId : allSwitchList) {
        if (!naptSwitchDpnId.equals(dpnId)) {
            LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
            // Remove the PSNAT entry which forwards the packet to Terminating Service table
            String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
            FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
            LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch " + "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
            mdsalManager.removeFlowToTx(preSnatFlowEntity, removeFlowInvTx);
            // Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
            long groupId = createGroupId(getGroupIdKey(routerName));
            List<BucketInfo> listBucketInfo = new ArrayList<>();
            GroupEntity preSnatGroupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
            LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with " + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
            mdsalManager.removeGroup(preSnatGroupEntity);
        }
    }
}
Also used : GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 13 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method installFlowsWithUpdatedVpnId.

public void installFlowsWithUpdatedVpnId(BigInteger primarySwitchId, String routerName, long bgpVpnId, long routerId, boolean isSnatCfgd, WriteTransaction writeFlowInvTx, ProviderTypes extNwProvType) {
    long changedVpnId = bgpVpnId;
    String idType = "BGP VPN";
    if (bgpVpnId == NatConstants.INVALID_ID) {
        changedVpnId = routerId;
        idType = "router";
    }
    List<BigInteger> switches = NatUtil.getDpnsForRouter(dataBroker, routerName);
    if (switches.isEmpty()) {
        LOG.error("installFlowsWithUpdatedVpnId : No switches found for router {}", routerName);
        return;
    }
    for (BigInteger dpnId : switches) {
        // Update the BGP VPN ID in the SNAT miss entry to group
        if (!dpnId.equals(primarySwitchId)) {
            LOG.debug("installFlowsWithUpdatedVpnId : Install group in non NAPT switch {}", dpnId);
            List<BucketInfo> bucketInfoForNonNaptSwitches = getBucketInfoForNonNaptSwitches(dpnId, primarySwitchId, routerName, routerId);
            long groupId = createGroupId(getGroupIdKey(routerName));
            if (!isSnatCfgd) {
                groupId = installGroup(dpnId, routerName, bucketInfoForNonNaptSwitches);
            }
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the SNAT miss entry pointing to group " + "{} in the non NAPT switch {}", idType, changedVpnId, groupId, dpnId);
            FlowEntity flowEntity = buildSnatFlowEntityWithUpdatedVpnId(dpnId, routerName, groupId, changedVpnId);
            mdsalManager.addFlowToTx(flowEntity, writeFlowInvTx);
        } else {
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the SNAT miss entry pointing to group " + "in the primary switch {}", idType, changedVpnId, primarySwitchId);
            FlowEntity flowEntity = buildSnatFlowEntityWithUpdatedVpnIdForPrimrySwtch(primarySwitchId, routerName, changedVpnId);
            mdsalManager.addFlowToTx(flowEntity, writeFlowInvTx);
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the Terminating Service table (table " + "ID 36) which forwards the packet to the table 46 in the Primary switch {}", idType, changedVpnId, primarySwitchId);
            installTerminatingServiceTblEntryWithUpdatedVpnId(primarySwitchId, routerName, routerId, changedVpnId, writeFlowInvTx, extNwProvType);
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the Outbound NAPT table (table ID 46) " + "which punts the packet to the controller in the Primary switch {}", idType, changedVpnId, primarySwitchId);
            createOutboundTblEntryWithBgpVpn(primarySwitchId, routerId, changedVpnId, writeFlowInvTx);
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the NAPT PFIB TABLE which forwards the" + " outgoing packet to FIB Table in the Primary switch {}", idType, changedVpnId, primarySwitchId);
            installNaptPfibEntryWithBgpVpn(primarySwitchId, routerId, changedVpnId, writeFlowInvTx);
            LOG.debug("installFlowsWithUpdatedVpnId : Update the {} ID {} in the NAPT flows for the Outbound NAPT " + "table (table ID 46) and the INBOUND NAPT table (table ID 44) in the Primary switch" + " {}", idType, changedVpnId, primarySwitchId);
            updateNaptFlowsWithVpnId(primarySwitchId, routerName, routerId, bgpVpnId);
            LOG.debug("installFlowsWithUpdatedVpnId : Installing SNAT PFIB flow in the primary switch {}", primarySwitchId);
            Long vpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
            // Install the NAPT PFIB TABLE which forwards the outgoing packet to FIB Table matching on the VPN ID.
            if (vpnId != NatConstants.INVALID_ID) {
                installNaptPfibEntry(primarySwitchId, vpnId, writeFlowInvTx);
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 14 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo in project netvirt by opendaylight.

the class NaptSwitchHA method handleGroupInPrimarySwitch.

public List<BucketInfo> handleGroupInPrimarySwitch() {
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
    listActionInfoPrimary.add(new ActionNxResubmit(NwConstants.INTERNAL_TUNNEL_TABLE));
    BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
    listBucketInfo.add(bucketPrimary);
    return listBucketInfo;
}
Also used : ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 15 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo in project netvirt by opendaylight.

the class NaptSwitchHA method updateNaptSwitchBucketStatus.

public void updateNaptSwitchBucketStatus(String routerName, long routerId, BigInteger naptSwitch) {
    LOG.debug("updateNaptSwitchBucketStatus : called");
    List<BigInteger> dpnList = naptSwitchSelector.getDpnsForVpn(routerName);
    // List<BigInteger> dpnList = getDpnListForRouter(routerName);
    if (dpnList.isEmpty()) {
        LOG.warn("updateNaptSwitchBucketStatus : No switches found for router {}", routerName);
        return;
    }
    for (BigInteger dpn : dpnList) {
        if (!dpn.equals(naptSwitch)) {
            LOG.debug("updateNaptSwitchBucketStatus : Updating SNAT_TABLE missentry for DpnId {} " + "which is not naptSwitch for router {}", dpn, routerName);
            List<BucketInfo> bucketInfoList = handleGroupInNeighborSwitches(dpn, routerName, routerId, naptSwitch);
            modifySnatGroupEntry(dpn, bucketInfoList, routerName);
        }
    }
}
Also used : BigInteger(java.math.BigInteger) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Aggregations

BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)19 ArrayList (java.util.ArrayList)14 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)13 BigInteger (java.math.BigInteger)7 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)5 GroupEntity (org.opendaylight.genius.mdsalutil.GroupEntity)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)3 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)3 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)3 ActionOutput (org.opendaylight.genius.mdsalutil.actions.ActionOutput)3 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)3 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)3 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)3 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)2 ActionPushVlan (org.opendaylight.genius.mdsalutil.actions.ActionPushVlan)2 ActionSetFieldEthernetSource (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource)2 ActionSetFieldVlanVid (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid)2 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)2