use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class ArpResponderUtil method getEgressActionsForInterface.
/**
* Get List of Egress Action for the VPN interface.
*
* @param ifaceMgrRpcService
* Interface Manager RPC reference that invokes API to retrieve
* Egress Action
* @param ifName
* VPN Interface for which Egress Action to be retrieved
* @param actionCounter
* Action Key
* @return List of Egress Actions
*/
public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService, String ifName, int actionCounter) {
List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
AtomicInteger counter = new AtomicInteger(actionCounter);
return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project openflowplugin by opendaylight.
the class TransactionChainManagerTest method testEnableCounter1.
/**
* Test of {@link TransactionChainManager#enableSubmit()}: no submit - counter is not active.
*/
@Test
public void testEnableCounter1() throws Exception {
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(txChain).newReadWriteTransaction();
Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(writeTx, Mockito.never()).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleInternalVpnSubnetRoutePacket.
private void handleInternalVpnSubnetRoutePacket(Uint64 metadata, byte[] dstIp, String srcIpStr, String dstIpStr, String vpnIdVpnInstanceName, long elanTag) throws InterruptedException, ExecutionException, UnknownHostException {
String vmVpnInterfaceName = vpnUtil.getVpnInterfaceName(metadata);
if (isTunnel(vmVpnInterfaceName)) {
handlePacketFromTunnelToExternalNetwork(vpnIdVpnInstanceName, srcIpStr, dstIp, dstIpStr, elanTag);
}
VpnInterface vmVpnInterface = vpnUtil.getVpnInterface(vmVpnInterfaceName);
if (vmVpnInterface == null) {
LOG.error("Vpn interface {} doesn't exist.", vmVpnInterfaceName);
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
return;
}
if (VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnIdVpnInstanceName, new ArrayList<>(vmVpnInterface.nonnullVpnInstanceNames().values())) && !vpnUtil.isBgpVpnInternet(vpnIdVpnInstanceName)) {
LOG.trace("Unknown IP is in internal network");
handlePacketToInternalNetwork(dstIp, dstIpStr, elanTag, srcIpStr);
} else {
LOG.trace("Unknown IP is in external network");
String vpnName = vpnUtil.getInternetVpnFromVpnInstanceList(new ArrayList<>(vmVpnInterface.nonnullVpnInstanceNames().values()));
if (vpnName != null) {
handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, dstIpStr, elanTag);
} else {
vpnName = VpnHelper.getFirstVpnNameFromVpnInterface(vmVpnInterface);
LOG.trace("Unknown IP is in external network, but internet VPN not found." + " fallback to first VPN");
handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, dstIpStr, elanTag);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handlePacketToExternalNetwork.
private void handlePacketToExternalNetwork(Uuid vpnInstanceNameUuid, String routerId, byte[] dstIp, String dstIpStr, long elanTag) throws UnknownHostException {
Routers externalRouter = vpnUtil.getExternalRouter(routerId);
if (externalRouter == null) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label("." + dstIpStr);
counter.increment();
LOG.debug("{} handlePacketToExternalNetwork: Can't find external router with id {}", LOGGING_PREFIX, routerId);
return;
}
Map<ExternalIpsKey, ExternalIps> externalIpsMap = externalRouter.getExternalIps();
if (externalIpsMap == null || externalIpsMap.isEmpty()) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label("." + dstIpStr);
counter.increment();
LOG.debug("{} handlePacketToExternalNetwork: Router {} doesn't have any external ips.", LOGGING_PREFIX, externalRouter.getRouterName());
return;
}
java.util.Optional<ExternalIps> externalIp = externalRouter.getExternalIps().values().stream().filter(eip -> vpnInstanceNameUuid.equals(eip.getSubnetId())).findFirst();
if (!externalIp.isPresent()) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(externalIp.get().getIpAddress() + "." + dstIpStr);
counter.increment();
LOG.debug("{} handlePacketToExternalNetwork: Router {} doesn't have an external ip for subnet id {}.", LOGGING_PREFIX, externalRouter.getRouterName(), vpnInstanceNameUuid);
return;
}
Uint64 dpnId = centralizedSwitchProvider.getPrimarySwitchForRouter(externalRouter.getRouterName());
if (Uint64.ZERO.equals(dpnId)) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(externalIp.get().getIpAddress() + "." + dstIpStr);
counter.increment();
LOG.debug("{} handlePacketToExternalNetwork: Could not find primary switch for router {}.", LOGGING_PREFIX, externalRouter.getRouterName());
return;
}
transmitArpOrNsPacket(dpnId, externalIp.get().getIpAddress(), externalRouter.getExtGwMacAddress(), dstIp, dstIpStr, elanTag);
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_processed.toString()).label(externalIp.get().getIpAddress() + "." + dstIpStr);
counter.increment();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleBgpVpnSubnetRoute.
private void handleBgpVpnSubnetRoute(String srcMac, byte[] dstIp, String dstIpStr, String srcIpStr, long elanTag) throws UnknownHostException {
LOG.info("{} handleBgpVpnSubnetRoute: Processing IP Packet received with Source IP {} and Target IP {}" + " and elan Tag {}", LOGGING_PREFIX, srcIpStr, dstIpStr, elanTag);
SubnetOpDataEntry targetSubnetForPacketOut = getTargetSubnetForPacketOut(elanTag, dstIpStr);
if (targetSubnetForPacketOut != null) {
// Handle subnet routes ip requests
transmitArpOrNsPacket(targetSubnetForPacketOut.getNhDpnId(), srcIpStr, srcMac, dstIp, dstIpStr, elanTag);
} else {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.debug("{} handleBgpVpnSubnetRoute: Could not find target subnet for packet out {}", LOGGING_PREFIX, dstIpStr);
}
}
Aggregations