+ // TODO Clean up the exception handling
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private void sendGarpOnInterface(final BigInteger dpnId, Uuid networkId, final IpAddress floatingIpAddress,
+ String floatingIpPortMacAddress) {
+ if (floatingIpAddress.getIpv4Address() == null) {
+ LOG.info("Failed to send GARP for IP. recieved IPv6.");
+ NatServiceCounters.garp_failed_ipv6.inc();
+ return;
+ }
+
+ String interfaceName = elanService.getExternalElanInterface(networkId.getValue(), dpnId);
+ if (interfaceName == null) {
+ LOG.warn("Failed to send GARP for IP. Failed to retrieve interface name from network {} and dpn id {}.",
+ networkId.getValue(), dpnId);
+ NatServiceCounters.garp_failed_missing_interface.inc();
+ }
+
+ try {
+ // find the external network interface name for dpn
+ List<InterfaceAddress> interfaceAddresses = new ArrayList<>();
+ interfaceAddresses.add(new InterfaceAddressBuilder()
+ .setInterface(interfaceName)
+ .setIpAddress(floatingIpAddress)
+ .setMacaddress(new PhysAddress(floatingIpPortMacAddress)).build());
+
+ SendArpRequestInput sendArpRequestInput = new SendArpRequestInputBuilder().setIpaddress(floatingIpAddress)
+ .setInterfaceAddress(interfaceAddresses).build();
+ arpUtilService.sendArpRequest(sendArpRequestInput);
+ NatServiceCounters.garp_sent.inc();
+ } catch (Exception e) {
+ LOG.error("Failed to send GARP request for floating ip {} from interface {}",
+ floatingIpAddress.getIpv4Address().getValue(), interfaceName, e);
+ NatServiceCounters.garp_failed_send.inc();
+ }
+ }
+
+ // TODO Clean up the exception handling
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private void removeFromFloatingIpPortInfo(Uuid floatingIpId) {
+ InstanceIdentifier id = buildfloatingIpIdToPortMappingIdentifier(floatingIpId);
+ try {
+ Optional<FloatingIpIdToPortMapping> optFloatingIpIdToPortMapping =
+ SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, id);
+ if (optFloatingIpIdToPortMapping.isPresent() && optFloatingIpIdToPortMapping.get().isFloatingIpDeleted()) {
+ LOG.debug("Deleting floating IP UUID {} to Floating IP neutron port mapping from Floating "
+ + "IP Port Info Config DS", floatingIpId.getValue());
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
+ }
+ } catch (Exception e) {
+ LOG.error("Deleting floating IP UUID {} to Floating IP neutron port mapping from Floating "
+ + "IP Port Info Config DS failed with exception {}", floatingIpId.getValue(), e);
+ }