use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.neutron.vip.states.VipState in project netvirt by opendaylight.
the class NatArpNotificationHandler method onArpRequestReceived.
@Override
public void onArpRequestReceived(ArpRequestReceived notification) {
LOG.debug("NatArpNotificationHandler received {}", notification);
IpAddress srcIp = notification.getSrcIpaddress();
if (srcIp == null || !Objects.equals(srcIp, notification.getDstIpaddress())) {
LOG.debug("NatArpNotificationHandler: ignoring ARP packet, not gratuitous {}", notification);
return;
}
// Since the point of all this is to learn VIPs those are by definition
// not the IP addresses assigned to a port by neutron configuration.
ElanInterface arpSenderIfc = elanService.getElanInterfaceByElanInterfaceName(notification.getInterface());
if (ipBelongsToElanInterface(arpSenderIfc, srcIp)) {
LOG.debug("NatArpNotificationHandler: ignoring GARP packet. No need to NAT a port's static IP. {}", notification);
return;
}
ElanInterface targetIfc = null;
for (String ifcName : elanService.getElanInterfaces(arpSenderIfc.getElanInstanceName())) {
ElanInterface elanInterface = elanService.getElanInterfaceByElanInterfaceName(ifcName);
if (ipBelongsToElanInterface(elanInterface, srcIp)) {
targetIfc = elanInterface;
break;
}
}
if (null == targetIfc) {
LOG.warn("NatArpNotificationHandler: GARP does not correspond to an interface in this elan {}", notification);
return;
}
RouterInterface routerInterface = NatUtil.getConfiguredRouterInterface(dataBroker, targetIfc.getName());
if (null == routerInterface) {
LOG.warn("NatArpNotificationHandler: Could not retrieve router ifc for {}", targetIfc);
return;
}
VipState newVipState = this.vipStateTracker.buildVipState(srcIp.getIpv4Address().getValue(), notification.getDpnId(), targetIfc.getName());
VipState cachedState = null;
try {
cachedState = this.vipStateTracker.get(newVipState.getIp()).orElse(null);
} catch (ReadFailedException e) {
LOG.warn("NatArpNotificationHandler failed to read vip state {}", notification, e);
}
if (null == cachedState) {
this.southboundEventHandlers.handleAdd(targetIfc.getName(), notification.getDpnId(), routerInterface, newVipState);
} else if (!cachedState.getDpnId().equals(newVipState.getDpnId())) {
this.southboundEventHandlers.handleRemove(cachedState.getIfcName(), cachedState.getDpnId(), routerInterface);
this.southboundEventHandlers.handleAdd(targetIfc.getName(), notification.getDpnId(), routerInterface, newVipState);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.neutron.vip.states.VipState in project netvirt by opendaylight.
the class NatSouthboundEventHandlers method processInterfaceAdded.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void processInterfaceAdded(String portName, String routerId, Uint64 dpnId, VipState vipState) {
LOG.trace("processInterfaceAdded : Processing Interface Add Event for interface {}", portName);
List<InternalToExternalPortMap> intExtPortMapList = getIntExtPortMapListForPortName(portName, routerId);
if (intExtPortMapList.isEmpty()) {
LOG.debug("processInterfaceAdded : Ip Mapping list is empty/null for portname {}", portName);
return;
}
InstanceIdentifier<RouterPorts> portIid = NatUtil.buildRouterPortsIdentifier(routerId);
FluentFuture<?> future = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
floatingIPListener.createNATFlowEntries(portName, intExtPortMap, portIid, routerId, dpnId, tx);
}
});
future.transform((ignored) -> {
if (vipState != null) {
return this.vipStateTracker.writeVipState(vipState);
}
return null;
}, MoreExecutors.directExecutor());
}
Aggregations