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;
}
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);
}
}
}
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);
}
}
}
}
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;
}
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);
}
}
}
Aggregations