use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class ArpMonitoringHandler method add.
@Override
protected void add(InstanceIdentifier<LearntVpnVipToPort> identifier, LearntVpnVipToPort value) {
runOnlyInOwnerNode("ArpMonitoringHandler: add event", () -> {
try {
InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
if (value.getMacAddress() == null) {
LOG.warn("The mac address received is null for VpnPortipToPort {}, ignoring the DTCN", value);
return;
}
MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
String vpnName = value.getVpnName();
MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, value.getPortName(), value.getCreationTime());
jobCoordinator.enqueueJob(buildJobKey(srcInetAddr.toString(), vpnName), new ArpMonitorStartTask(macEntry, arpMonitorProfileId, dataBroker, alivenessManager, neutronVpnService, interfaceManager));
} catch (UnknownHostException e) {
LOG.error("Error in deserializing packet {} with exception", value, e);
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.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();
PhysAddress srcMac = notification.getSrcMac();
IpAddress targetIP = notification.getDstIpaddress();
BigInteger 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.getIpv4Address().getValue(), srcMac.getValue(), targetIP.getIpv4Address().getValue());
return;
}
LOG.info("ArpNotification Gratuitous Request Received from " + "interface {} and IP {} having MAC {} target destination {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue(), targetIP.getIpv4Address().getValue());
processArpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class ArpNotificationHandler method onArpResponseReceived.
@Override
public void onArpResponseReceived(ArpResponseReceived notification) {
String srcInterface = notification.getInterface();
IpAddress srcIP = notification.getSrcIpaddress();
PhysAddress srcMac = notification.getSrcMac();
LOG.info("ArpNotification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue());
List<Adjacency> adjacencies = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, srcInterface);
if (adjacencies != null) {
for (Adjacency adj : adjacencies) {
String ipAddress = adj.getIpAddress();
try {
if (NWUtil.isIpInSubnet(NWUtil.ipAddressToInt(srcIP.getIpv4Address().getValue()), ipAddress)) {
return;
}
} catch (UnknownHostException e) {
LOG.error("Subnet string {} not convertible to InetAdddress", srcIP, e);
}
}
}
BigInteger metadata = notification.getMetadata();
IpAddress targetIP = notification.getDstIpaddress();
LOG.trace("ArpNotification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue());
processArpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class ArpNotificationHandler method processArpLearning.
private void processArpLearning(String srcInterface, IpAddress srcIP, PhysAddress srcMac, BigInteger metadata, IpAddress dstIP) {
if (metadata != null && !Objects.equals(metadata, BigInteger.ZERO)) {
Optional<List<String>> vpnList = VpnUtil.getVpnHandlingIpv4AssociatedWithInterface(dataBroker, srcInterface);
if (vpnList.isPresent()) {
for (String vpnName : vpnList.get()) {
LOG.info("Received ARP for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIP.getIpv4Address().getValue(), srcInterface);
String ipToQuery = srcIP.getIpv4Address().getValue();
LOG.info("ARP being processed for Source IP {}", ipToQuery);
VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ipToQuery);
if (vpnPortipToPort != null) {
/* This is a well known neutron port and so should be ignored
* from being discovered
*/
continue;
}
LearntVpnVipToPort learntVpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
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 Source IP/MAC data modified for IP {} with MAC {} and Port {}", ipToQuery, srcMac, srcInterface);
synchronized ((vpnName + ipToQuery).intern()) {
removeMipAdjacency(vpnName, oldPortName, srcIP);
VpnUtil.removeLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
putVpnIpToMigrateArpCache(vpnName, ipToQuery, srcMac);
}
}
} else if (!isIpInArpMigrateCache(vpnName, ipToQuery)) {
learnMacFromArpPackets(vpnName, srcInterface, srcIP, srcMac, dstIP);
}
}
} else {
LOG.info("ARP NO_RESOLVE: VPN not configured. Ignoring responding to ARP requests from this" + " Interface {}.", srcInterface);
return;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class BgpConfigurationManager method replayNbrConfig.
private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
if (neighbors == null || neighbors.isEmpty()) {
LOG.error("Replaying nbr configuration, received NULL list ");
return true;
}
List<ReplayNbr> replayNbrList = new ArrayList<>();
for (Neighbors nbr : neighbors) {
if (nbr != null) {
replayNbrList.add(new ReplayNbr(nbr, true));
}
}
final int numberOfNbrRetries = 3;
RetryOnException nbrRetry = new RetryOnException(numberOfNbrRetries);
do {
for (ReplayNbr replayNbr : replayNbrList) {
if (!replayNbr.isShouldRetry()) {
continue;
}
boolean replayDone = false;
LOG.debug("Replaying addNbr {}", replayNbr.getNbr().getAddress().getValue());
replayDone = false;
try {
final String md5password = extractMd5Secret(replayNbr.getNbr());
br.addNeighbor(replayNbr.getNbr().getAddress().getValue(), replayNbr.getNbr().getRemoteAs().longValue(), md5password);
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (us != null) {
LOG.debug("Replaying updatesource along with nbr: {} US-ip: {} to peer {}", replayNbr.getNbr().getAddress().getValue(), us.getSourceIp().getValue(), us.getPeerIp().getValue());
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
}
replayDone = true;
} catch (TException | BgpRouterException eNbr) {
LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
}
boolean replaySuccess = true;
replaySuccess = replaySuccess && replayDone;
LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
// Update Source handling
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (replayDone == false && us != null) {
LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
replayDone = false;
try {
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
replayDone = true;
} catch (TException | BgpRouterException eUs) {
LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
}
LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
replaySuccess = replaySuccess && replayDone;
}
// Ebgp Multihope
EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
if (en != null) {
replayDone = false;
try {
br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
replayDone = true;
} catch (TException | BgpRouterException eEbgpMhop) {
LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
}
replaySuccess = replaySuccess && replayDone;
}
// afs
List<AddressFamilies> afs = replayNbr.getNbr().getAddressFamilies();
if (afs != null) {
for (AddressFamilies af : afs) {
af_afi afi = af_afi.findByValue(af.getAfi().intValue());
af_safi safi = af_safi.findByValue(af.getSafi().intValue());
replayDone = false;
try {
br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
replayDone = true;
} catch (TException | BgpRouterException eAFs) {
LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
}
replaySuccess = replaySuccess && replayDone;
}
}
// replay is success --> no need to replay this nbr in next iteration.
replayNbr.setShouldRetry(replaySuccess ? false : true);
}
} while (nbrRetry.decrementAndRetry());
boolean replaySuccess = true;
for (ReplayNbr replayNbr : replayNbrList) {
replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
}
return replaySuccess;
}
Aggregations