use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.
the class ArpNotificationHandler method onArpRequestReceived.
@Override
public void onArpRequestReceived(ArpRequestReceived notification) {
String srcInterface = notification.getInterface();
IpAddress srcIP = notification.getSrcIpaddress();
MacAddress srcMac = MacAddress.getDefaultInstance(notification.getSrcMac().getValue());
IpAddress targetIP = notification.getDstIpaddress();
Uint64 metadata = notification.getMetadata();
boolean isGarp = srcIP.equals(targetIP);
if (!isGarp) {
LOG.info("ArpNotification Non-Gratuitous Request Received from " + "interface {} and IP {} having MAC {} target destination {}, ignoring..", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
return;
}
LOG.info("ArpNotification Gratuitous Request Received from interface {} and IP {} having MAC {} " + "target destination {}, learning MAC", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
processIpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.
the class Ipv6NaPacketListener method onNaReceived.
@Override
public void onNaReceived(NeighborAdvertisePacket naPacket) {
PacketMetadata pktMetadata = naPacket.augmentation(PacketMetadata.class);
if (pktMetadata == null) {
return;
}
String srcInterface = pktMetadata.getInterface();
IpAddress srcIP = new IpAddress(naPacket.getSourceIpv6());
MacAddress srcMac = naPacket.getSourceMac();
IpAddress targetIP = new IpAddress(naPacket.getTargetAddress());
Uint64 metadata = pktMetadata.getMetadata();
LOG.debug("NA notification received from interface {} and IP {} having MAC {}, targetIP={}", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
validateAndProcessIpLearning(srcInterface, srcIP, srcMac, targetIP, metadata);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.
the class AbstractIpLearnNotificationHandler method processIpLearning.
protected void processIpLearning(String srcInterface, IpAddress srcIP, MacAddress srcMac, Uint64 metadata, IpAddress dstIP) {
if (!VpnUtil.isArpLearningEnabled()) {
LOG.trace("Not handling packet as ARP Based Learning is disabled");
return;
}
if (metadata == null || Objects.equals(metadata, Uint64.ZERO)) {
return;
}
Optional<List<String>> vpnList = vpnUtil.getVpnHandlingIpv4AssociatedWithInterface(srcInterface);
if (!vpnList.isPresent()) {
LOG.info("IP LEARN NO_RESOLVE: VPN not configured. Ignoring responding to ARP/NA requests from this" + " Interface {}.", srcInterface);
return;
}
String srcIpToQuery = srcIP.stringValue();
String destIpToQuery = dstIP.stringValue();
for (String vpnName : vpnList.get()) {
LOG.info("Received ARP/NA for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIpToQuery, srcInterface);
final ReentrantLock lock = lockFor(vpnName, srcIpToQuery);
lock.lock();
try {
VpnPortipToPort vpnPortipToPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnName, srcIpToQuery);
// Check if this IP belongs to external network
if (vpnPortipToPort == null) {
String extSubnetId = vpnUtil.getAssociatedExternalSubnet(srcIpToQuery);
if (extSubnetId != null) {
vpnPortipToPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(extSubnetId, srcIpToQuery);
}
}
if (vpnPortipToPort != null && !vpnPortipToPort.isLearntIp()) {
/*
* This is a well known neutron port and so should be ignored from being
* discovered...unless it is an Octavia VIP
*/
String portName = vpnPortipToPort.getPortName();
Port neutronPort = neutronVpnManager.getNeutronPort(portName);
if (neutronPort == null) {
LOG.warn("{} should have been a neutron port but could not retrieve it. Aborting processing", portName);
continue;
}
if (!"Octavia".equals(neutronPort.getDeviceOwner())) {
LOG.debug("Neutron port {} is not an Octavia port, ignoring", portName);
continue;
}
}
// after reboot, it would be ignored.
if (vpnPortipToPort != null && vpnPortipToPort.isLearntIp()) {
if (System.currentTimeMillis() < this.bootupTime + config.getBootDelayArpLearning().toJava() * 1000) {
LOG.trace("GARP/Arp Response not handled for IP {} vpnName {} for time {}s", vpnPortipToPort.getPortFixedip(), vpnName, config.getBootDelayArpLearning());
continue;
}
}
LearntVpnVipToPort learntVpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, srcIpToQuery);
if (learntVpnVipToPort != null) {
String oldPortName = learntVpnVipToPort.getPortName();
String oldMac = learntVpnVipToPort.getMacAddress();
if (!oldMac.equalsIgnoreCase(srcMac.getValue())) {
// MAC has changed for requested IP
LOG.info("ARP/NA Source IP/MAC data modified for IP {} with MAC {} and Port {}", srcIpToQuery, srcMac, srcInterface);
vpnUtil.createLearntVpnVipToPortEvent(vpnName, srcIpToQuery, destIpToQuery, oldPortName, oldMac, LearntVpnVipToPortEventAction.Delete, null);
putVpnIpToMigrateIpCache(vpnName, srcIpToQuery, srcMac);
}
} else if (!isIpInMigrateCache(vpnName, srcIpToQuery)) {
if (vpnPortipToPort != null && !vpnPortipToPort.getPortName().equals(srcInterface)) {
LOG.trace("LearntIp: {} vpnName {} is already present in VpnPortIpToPort with " + "PortName {} ", srcIpToQuery, vpnName, vpnPortipToPort.getPortName());
vpnUtil.createLearntVpnVipToPortEvent(vpnName, srcIpToQuery, destIpToQuery, vpnPortipToPort.getPortName(), vpnPortipToPort.getMacAddress(), LearntVpnVipToPortEventAction.Delete, null);
continue;
}
learnMacFromIncomingPacket(vpnName, srcInterface, srcIP, srcMac, dstIP);
}
} finally {
lock.unlock();
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.
the class ElanGroupListener method update.
@Override
public void update(InstanceIdentifier<Group> identifier, @Nullable Group original, Group update) {
LOG.trace("received group updated {}", update.key().getGroupId());
final Uint64 dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
return;
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
if (allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.key().getGroupId());
return;
}
int expectedElanFootprint = 0;
final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
if (elanInstance == null) {
LOG.trace("no elan instance is null {}", update.key().getGroupId());
return;
}
final int devicesSize = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName()).size();
if (devicesSize == 0) {
LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
return;
}
boolean updateGroup = false;
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
if (dpns.size() > 0) {
expectedElanFootprint += dpns.size();
} else {
updateGroup = true;
}
expectedElanFootprint += devicesSize;
if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
updateGroup = true;
} else {
LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
}
}
if (updateGroup) {
List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag().toJava());
// remove local bcgroup bucket
expectedElanFootprint--;
if (bucketList.size() != expectedElanFootprint) {
// no point in retrying if not able to meet expected foot print
return;
}
LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId, confTx)), LOG, "Error setting up ELAN BGs");
return null;
});
} else {
LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method updated.
/**
* Upon update checks if the tunnels Ip was null earlier and it got newly added.
* In that case simply call add.
* If not then check if Tunnel Ip has been updated from an old value to new value.
* If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
* IP then call added ().
*
* @param identifier iid
* @param phySwitchBefore ps Node before update
* @param phySwitchAfter ps Node after update
*/
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
NodeId nodeId = getNodeId(identifier);
LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
String psName = getPsName(identifier);
if (psName == null) {
LOG.error("PhysicalSwitchListener Could not find the physical switch name for node {}", nodeId.getValue());
return;
}
L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps())) {
LOG.info("PhysicalSwitchListener Received physical switch update for {} before teps {} after teps {}", nodeId.getValue(), phySwitchBefore.getTunnelIps(), phySwitchAfter.getTunnelIps());
}
InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
added(identifier, phySwitchAfter);
}
} else {
if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
final String hwvtepId = existingDevice.getHwvtepNodeId();
elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
LOG.info("PhysicalSwitchListener Deleting itm tunnels for {}", existingDevice.getDeviceName());
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
// TODO remove these sleeps
Thread.sleep(10000L);
LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
return Collections.emptyList();
});
try {
// TODO remove the sleep by using better itm api to detect finish of prev op
Thread.sleep(20000L);
} catch (InterruptedException e) {
LOG.error("Interrupted ");
}
existingDevice.setTunnelIps(new HashSet<>());
added(identifier, phySwitchAfter);
}
}
}
Aggregations