private void deleteTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap dataBefore, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore); final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().tapDelete(getTapDeleteRequest(index)); TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore); // Remove deleted interface from interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); }
private void deleteVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage = getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext()))); TranslateUtils.getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser); // Remove interface from our interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); }
@Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing nsh entry: iid={} dataBefore={}", id, dataBefore); final String entryName = dataBefore.getName(); checkState(nshEntryContext.containsIndex(entryName, writeContext.getMappingContext()), "Removing nsh entry {}, but index could not be found in the nsh entry context", entryName); final int entryIndex = nshEntryContext.getIndex(entryName, writeContext.getMappingContext()); try { nshAddDelEntry(false, id, dataBefore, entryIndex, writeContext.getMappingContext()); // Remove deleted interface from interface context: nshEntryContext.removeName(dataBefore.getName(), writeContext.getMappingContext()); LOG.debug("Successfully removed nsh entry(id={]): iid={} dataAfter={}", entryIndex, id, dataBefore); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(id, e); } }
@Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id, @Nonnull final NshMap dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing nsh map: iid={} dataBefore={}", id, dataBefore); final String mapName = dataBefore.getName(); checkState(nshMapContext.containsIndex(mapName, writeContext.getMappingContext()), "Removing nsh map {}, but index could not be found in the nsh map context", mapName); final int mapIndex = nshMapContext.getIndex(mapName, writeContext.getMappingContext()); try { nshAddDelMap(false, id, dataBefore, mapIndex, writeContext.getMappingContext()); // Remove deleted interface from interface context: nshMapContext.removeName(dataBefore.getName(), writeContext.getMappingContext()); LOG.debug("Successfully removed nsh map(id={]): iid={} dataAfter={}", mapIndex, id, dataBefore); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(id, e); } }
private void deleteGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0); final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc())); final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst())); int outerFibId = gre.getOuterFibId().intValue(); LOG.debug("Deleting gre tunnel for interface: {}. Gre: {}", swIfName, gre); final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage = getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(), dstAddress.getAddress(), outerFibId, isIpv6)); TranslateUtils.getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Gre tunnel deleted successfully for: {}, gre: {}", swIfName, gre); // Remove interface from our interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); }
private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0); final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc())); final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst())); int encapVrfId = vxlan.getEncapVrfId().intValue(); int vni = vxlan.getVni().getValue().intValue(); LOG.debug("Deleting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan); final CompletionStage<VxlanAddDelTunnelReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(), dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6)); TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan); final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext()); // Mark this interface as disabled to not include it in operational reads // because VPP will keep the interface there LOG.debug("Marking vxlan tunnel as disabled, id: {}, name: {}", index, swIfName); interfaceDisableContext.disableInterface(index, writeContext.getMappingContext()); // Remove interface from our interface naming context interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext()); }
private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName, final VxlanGpe vxlanGpe, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final byte isIpv6 = (byte) (isIpv6(vxlanGpe) ? 1 : 0); final InetAddress local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal())); final InetAddress remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote())); int vni = vxlanGpe.getVni().getValue().intValue(); byte protocol = (byte) vxlanGpe.getNextProtocol().getIntValue(); int encapVrfId = vxlanGpe.getEncapVrfId().intValue(); int decapVrfId = vxlanGpe.getDecapVrfId().intValue(); LOG.debug("Deleting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe); final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage = getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(), remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6)); TranslateUtils.getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext()); // Mark this interface as disabled to not include it in operational reads // because VPP will keep the interface there LOG.debug("Marking vxlan tunnel as disabled, id: {}, name: {}", index, swIfName); interfaceDisableContext.disableInterface(index, writeContext.getMappingContext()); // Remove interface from our interface naming context interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext()); }
private void createGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0); final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc())); final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst())); int outerFibId = gre.getOuterFibId().intValue(); LOG.debug("Setting gre tunnel for interface: {}. Gre: {}", swIfName, gre); final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage = getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 1 /* is add */, srcAddress.getAddress(), dstAddress.getAddress(), outerFibId, isIpv6)); final GreAddDelTunnelReply reply = TranslateUtils.getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Gre tunnel set successfully for: {}, gre: {}", swIfName, gre); if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) { // VPP keeps gre tunnels present even after they are delete(reserving ID for next tunnel) // This may cause inconsistencies in mapping context when configuring tunnels like this: // 1. Add tunnel 2. Delete tunnel 3. Read interfaces (reserved mapping e.g. gre_tunnel0 -> 6 // will get into mapping context) 4. Add tunnel (this will add another mapping with the same // reserved ID and context is invalid) // That's why a check has to be performed here removing mapping gre_tunnel0 -> 6 mapping and storing // new name for that ID final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext()); LOG.debug("Removing updated mapping of a gre tunnel, id: {}, former name: {}, new name: {}", reply.swIfIndex, formerName, swIfName); interfaceContext.removeName(formerName, writeContext.getMappingContext()); } // Add new interface to our interface context interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext()); }
LOG.debug("Removing updated mapping of a vxlan tunnel, id: {}, former name: {}, new name: {}", reply.swIfIndex, formerName, swIfName); interfaceNamingContext.removeName(formerName, writeContext.getMappingContext());
LOG.debug("Removing updated mapping of a vxlan-gpe tunnel, id: {}, former name: {}, new name: {}", reply.swIfIndex, formerName, swIfName); interfaceNamingContext.removeName(formerName, writeContext.getMappingContext());