use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleBgpVpnSubnetRoute.
private void handleBgpVpnSubnetRoute(String srcMac, byte[] dstIp, String dstIpStr, String srcIpStr, long elanTag) throws UnknownHostException {
LOG.info("{} handleBgpVpnSubnetRoute: Processing IP Packet received with Source IP {} and Target IP {}" + " and elan Tag {}", LOGGING_PREFIX, srcIpStr, dstIpStr, elanTag);
SubnetOpDataEntry targetSubnetForPacketOut = getTargetSubnetForPacketOut(elanTag, dstIpStr);
if (targetSubnetForPacketOut != null) {
// Handle subnet routes ip requests
transmitArpOrNsPacket(targetSubnetForPacketOut.getNhDpnId(), srcIpStr, srcMac, dstIp, dstIpStr, elanTag);
} else {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.debug("{} handleBgpVpnSubnetRoute: Could not find target subnet for packet out {}", LOGGING_PREFIX, dstIpStr);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests 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.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testDelegatedLspsCountWithDelegation.
@Test
public void testDelegatedLspsCountWithDelegation() throws Exception {
this.listener.onSessionUp(this.session);
this.topologyRpcs.addLsp(createAddLspInput());
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
// delegate set to true
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).setDelegate(true).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
checkEquals(() -> assertEquals(1, this.listener.listenerState.getDelegatedLspsCount().intValue()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnSessionTermination.
@Test
public void testOnSessionTermination() throws Exception {
this.listener.onSessionUp(this.session);
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().size());
return topology;
});
assertFalse(this.session.isClosed());
// node should be removed after termination
this.listener.onSessionTerminated(this.session, new PCEPCloseTermination(TerminationReason.UNKNOWN));
assertTrue(this.session.isClosed());
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testDelegatedLspsCountWithoutDelegation.
@Test
public void testDelegatedLspsCountWithoutDelegation() throws Exception {
this.listener.onSessionUp(this.session);
this.topologyRpcs.addLsp(createAddLspInput());
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
// delegate set to false
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).setDelegate(false).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
checkEquals(() -> assertEquals(0, this.listener.listenerState.getDelegatedLspsCount().intValue()));
}
Aggregations