use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleIpPackets.
private void handleIpPackets(byte[] srcIp, byte[] dstIp, String srcIpStr, String dstIpStr, String srcMac, Uint64 metadata) throws UnknownHostException, InterruptedException, ExecutionException {
Uint32 vpnId = Uint32.valueOf(MetaDataUtil.getVpnIdFromMetadata(metadata));
LOG.info("{} onPacketReceived: Processing IP Packet received with Source IP {} and Target IP {}" + " and vpnId {}", LOGGING_PREFIX, srcIpStr, dstIpStr, vpnId);
Optional<VpnIds> vpnIdsOptional = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId));
if (!vpnIdsOptional.isPresent()) {
// Donot trigger subnetroute logic for packets from
// unknown VPNs
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_drop.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.info("{} onPacketReceived: Ignoring IPv4 packet with destination Ip {} and source Ip {}" + " as it came on unknown VPN with ID {}", LOGGING_PREFIX, dstIpStr, srcIpStr, vpnId);
return;
}
String vpnIdVpnInstanceName = vpnIdsOptional.get().getVpnInstanceName();
VpnPortipToPort persistedIP = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnIdVpnInstanceName, dstIpStr);
if (persistedIP != null && !persistedIP.isLearntIp()) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_drop.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.info("{} onPacketReceived: IP Packet received with Target IP {} source IP {} vpnId {} " + "is a valid Neutron port,ignoring subnet route processing", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
if (vpnUtil.getLearntVpnVipToPort(vpnIdVpnInstanceName, dstIpStr) != null) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.info("{} onPacketReceived: IP Packet received with Target IP {} source Ip {} vpnId {}" + " is an already discovered IPAddress, ignoring subnet route processing", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
if (elanTag == 0L) {
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
LOG.error("{} onPacketReceived: elanTag value from metadata found to be 0, for IP " + " Packet received with Target IP {} src Ip {} vpnId {}", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
if (!vpnIdsOptional.get().isExternalVpn()) {
handleInternalVpnSubnetRoutePacket(metadata, dstIp, srcIpStr, dstIpStr, vpnIdVpnInstanceName, elanTag);
return;
}
handleBgpVpnSubnetRoute(srcMac, dstIp, dstIpStr, srcIpStr, elanTag);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handlePacketToInternalNetwork.
private void handlePacketToInternalNetwork(byte[] dstIp, String dstIpStr, long elanTag, String srcIpStr) throws UnknownHostException {
try {
SubnetOpDataEntry targetSubnetForPacketOut = getTargetSubnetForPacketOut(elanTag, dstIpStr);
if (targetSubnetForPacketOut == null) {
LOG.debug("Couldn't find matching subnet for elan tag {} and destination ip {}", elanTag, dstIpStr);
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
return;
}
Optional<Subnetmap> subnetMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnUtil.buildSubnetmapIdentifier(targetSubnetForPacketOut.getSubnetId()));
if (!subnetMap.isPresent()) {
LOG.debug("Couldn't find subnet map for subnet {}", targetSubnetForPacketOut.getSubnetId());
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(srcIpStr + "." + dstIpStr);
counter.increment();
return;
}
String sourceIp = subnetMap.get().getRouterInterfaceFixedIp();
if (sourceIp == null) {
LOG.debug("Subnet map {} doesn't have a router interface ip defined", subnetMap.get().getId());
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label("." + dstIpStr);
counter.increment();
return;
}
String sourceMac = subnetMap.get().getRouterIntfMacAddress();
if (sourceMac == null) {
LOG.debug("Subnet map {} doesn't have a router interface mac address defined", subnetMap.get().getId());
Counter counter = packetInCounter.label(CounterUtility.subnet_route_packet_failed.toString()).label(sourceIp + "." + dstIpStr);
counter.increment();
return;
}
transmitArpOrNsPacket(targetSubnetForPacketOut.getNhDpnId(), sourceIp, sourceMac, dstIp, dstIpStr, elanTag);
} catch (InterruptedException | ExecutionException e) {
LOG.error("handlePacketToInternalNetwork: Failed to read data store for destIp {} elanTag {}", dstIpStr, elanTag);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class NeutronSecurityRuleListener method toAceBuilder.
private AceBuilder toAceBuilder(SecurityRule securityRule, boolean isDeleted) {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
SecurityRuleAttrBuilder securityRuleAttrBuilder = new SecurityRuleAttrBuilder();
DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
boolean isDirectionIngress = false;
if (securityRule.getDirection() != null) {
securityRuleAttrBuilder.setDirection(DIRECTION_MAP.get(securityRule.getDirection()));
isDirectionIngress = securityRule.getDirection().equals(DirectionIngress.class);
}
if (securityRule.getPortRangeMax() != null) {
destinationPortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax()));
}
if (securityRule.getPortRangeMin() != null) {
destinationPortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin()));
// set destination port range if lower port is specified as it is mandatory parameter in acl model
aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
}
aceIpBuilder = handleRemoteIpPrefix(securityRule, aceIpBuilder, isDirectionIngress);
if (securityRule.getRemoteGroupId() != null) {
securityRuleAttrBuilder.setRemoteGroupId(securityRule.getRemoteGroupId());
}
if (securityRule.getProtocol() != null) {
SecurityRuleAttributes.Protocol protocol = securityRule.getProtocol();
if (protocol.getUint8() != null) {
// uint8
aceIpBuilder.setProtocol(protocol.getUint8());
} else {
// symbolic protocol name
aceIpBuilder.setProtocol(PROTOCOL_MAP.get(protocol.getIdentityref()));
}
}
securityRuleAttrBuilder.setDeleted(isDeleted);
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// set acl action as permit for the security rule
ActionsBuilder actionsBuilder = new ActionsBuilder();
actionsBuilder.setPacketHandling(new PermitBuilder().setPermit(Empty.getInstance()).build());
AceBuilder aceBuilder = new AceBuilder();
aceBuilder.withKey(new AceKey(securityRule.getUuid().getValue()));
aceBuilder.setRuleName(securityRule.getUuid().getValue());
aceBuilder.setMatches(matchesBuilder.build());
aceBuilder.setActions(actionsBuilder.build());
aceBuilder.addAugmentation(securityRuleAttrBuilder.build());
return aceBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class FibDSWriter method removeFibEntryFromDS.
public synchronized void removeFibEntryFromDS(String rd, String prefix) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
return;
}
LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {}", prefix, rd);
InstanceIdentifierBuilder<VrfEntry> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
InstanceIdentifier<VrfEntry> vrfEntryId = idBuilder.build();
bgpUtil.delete(vrfEntryId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class ElanInterfaceManager method handleExternalTunnelStateEvent.
/**
* Handle external tunnel state event.
*
* @param externalTunnel
* the external tunnel
* @param intrf
* the interface
*/
void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
return;
}
// dpId/externalNodeId will be available either in source or destination
// based on the tunnel end point
Uint64 dpId = null;
NodeId externalNodeId = null;
if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
dpId = Uint64.valueOf(externalTunnel.getSourceDevice());
externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
} else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
dpId = Uint64.valueOf(externalTunnel.getDestinationDevice());
externalNodeId = new NodeId(externalTunnel.getSourceDevice());
}
if (dpId == null || externalNodeId == null) {
LOG.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
return;
}
ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
if (dpnInterfaceLists == null) {
return;
}
Map<ElanDpnInterfacesListKey, ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.nonnullElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf.values()) {
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orElse(null);
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
if (elanInfo == null || dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
continue;
}
LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);
final Uint64 finalDpId = dpId;
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, finalDpId, confTx)), LOG, "Error setting up ELAN BGs");
// install L2gwDevices local macs in dpn.
elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
// Install dpn macs on external device
installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()), dpId, externalNodeId);
}
LOG.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}
Aggregations