Search in sources :

Example 91 with IpPrefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.

the class FlowClassifierTranslator method buildAcl.

public static Acl buildAcl(SfcFlowClassifier flowClassifier, String sfpName) {
    LOG.info("OpenStack Networking SFC pushed Flow classifier : {}", flowClassifier);
    AclBuilder aclBuilder = new AclBuilder();
    AceBuilder aceBuilder = new AceBuilder();
    ActionsBuilder actionsBuilder = new ActionsBuilder();
    RedirectToSfcBuilder redirectToSfcBuilder = new RedirectToSfcBuilder();
    NeutronPortsBuilder neutronPortsBuilder = new NeutronPortsBuilder();
    AceIpBuilder aceIpBuilder = new AceIpBuilder();
    DestinationPortRangeBuilder destinationPortRange = new DestinationPortRangeBuilder();
    SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder();
    if (flowClassifier.getUuid() != null) {
        if (flowClassifier.getName() != null) {
            aclBuilder.setAclName(flowClassifier.getUuid().getValue() + "_" + flowClassifier.getName());
        } else {
            aclBuilder.setAclName(flowClassifier.getUuid().getValue());
        }
    }
    if (flowClassifier.getEthertype() != null) {
        IpPrefix sourceIp = null;
        IpPrefix destinationIp = null;
        if (flowClassifier.getSourceIpPrefix() != null) {
            sourceIp = flowClassifier.getSourceIpPrefix();
        }
        if (flowClassifier.getDestinationIpPrefix() != null) {
            destinationIp = flowClassifier.getDestinationIpPrefix();
        }
        if (flowClassifier.getEthertype() == EthertypeV4.class) {
            AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
            if (sourceIp != null && sourceIp.getIpv4Prefix() != null) {
                aceIpv4Builder.setSourceIpv4Network(sourceIp.getIpv4Prefix());
            }
            if (destinationIp != null && destinationIp.getIpv4Prefix() != null) {
                aceIpv4Builder.setDestinationIpv4Network(destinationIp.getIpv4Prefix());
            }
            aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
            aclBuilder.setAclType(Ipv4Acl.class);
        }
        if (flowClassifier.getEthertype() == EthertypeV6.class) {
            AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
            if (sourceIp != null && sourceIp.getIpv6Prefix() != null) {
                aceIpv6Builder.setSourceIpv6Network(sourceIp.getIpv6Prefix());
            }
            if (sourceIp != null && destinationIp.getIpv6Prefix() != null) {
                aceIpv6Builder.setDestinationIpv6Network(destinationIp.getIpv6Prefix());
            }
            aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
            aclBuilder.setAclType(Ipv6Acl.class);
        }
    }
    if (flowClassifier.getProtocol() != null) {
        if (flowClassifier.getProtocol() == ProtocolTcp.class) {
            aceIpBuilder.setProtocol(PROTO_TCP);
        }
        if (flowClassifier.getProtocol() == ProtocolUdp.class) {
            aceIpBuilder.setProtocol(PROTO_UDP);
        }
    }
    if (flowClassifier.getSourcePortRangeMin() != null) {
        sourcePortRangeBuilder.setLowerPort(new PortNumber(flowClassifier.getSourcePortRangeMin()));
        // set source port range only if lower port is specified as it is a mandatory parameter in acl model
        aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
    }
    if (flowClassifier.getSourcePortRangeMax() != null) {
        sourcePortRangeBuilder.setUpperPort(new PortNumber(flowClassifier.getSourcePortRangeMax()));
    }
    if (flowClassifier.getDestinationPortRangeMin() != null) {
        destinationPortRange.setLowerPort(new PortNumber(flowClassifier.getDestinationPortRangeMin()));
        // set destination port range only if lower port is specified as it is a mandatory parameter in acl model
        aceIpBuilder.setDestinationPortRange(destinationPortRange.build());
    }
    if (flowClassifier.getDestinationPortRangeMax() != null) {
        destinationPortRange.setUpperPort(new PortNumber(flowClassifier.getDestinationPortRangeMax()));
    }
    if (flowClassifier.getLogicalSourcePort() != null) {
        neutronPortsBuilder.setSourcePortUuid(flowClassifier.getLogicalSourcePort().getValue());
    }
    if (flowClassifier.getLogicalDestinationPort() != null) {
        neutronPortsBuilder.setDestinationPortUuid(flowClassifier.getLogicalDestinationPort().getValue());
    }
    // currently not supported.
    // if (flowClassifier.getL7Parameter() != null) {
    // }
    MatchesBuilder matchesBuilder = new MatchesBuilder();
    matchesBuilder.setAceType(aceIpBuilder.build());
    matchesBuilder.addAugmentation(NeutronPorts.class, neutronPortsBuilder.build());
    // Set redirect-to-rsp action if rsp name is provided
    if (sfpName != null) {
        redirectToSfcBuilder.setSfpName(sfpName);
        actionsBuilder.addAugmentation(RedirectToSfc.class, redirectToSfcBuilder.build());
        aceBuilder.setActions(actionsBuilder.build());
    }
    aceBuilder.setMatches(matchesBuilder.build());
    // OpenStack networking-sfc don't pass action information
    // with flow classifier. It need to be determined using the
    // Port Chain data and then flow calssifier need to be updated
    // with the actions.
    aceBuilder.setRuleName(aclBuilder.getAclName() + RULE);
    aceBuilder.setKey(new AceKey(aceBuilder.getRuleName()));
    ArrayList<Ace> aceList = new ArrayList<>();
    aceList.add(aceBuilder.build());
    AccessListEntriesBuilder accessListEntriesBuilder = new AccessListEntriesBuilder();
    accessListEntriesBuilder.setAce(aceList);
    aclBuilder.setAccessListEntries(accessListEntriesBuilder.build());
    aclBuilder.setKey(new AclKey(aclBuilder.getAclName(), aclBuilder.getAclType()));
    LOG.info("Translated ACL Flow classfier : {}", aclBuilder.toString());
    return aclBuilder.build();
}
Also used : AceIpv6Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder) Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace) NeutronPortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPortsBuilder) AclKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclKey) ArrayList(java.util.ArrayList) AclBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclBuilder) MatchesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) AceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.AceKey) AccessListEntriesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntriesBuilder) ActionsBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.ActionsBuilder) AceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.AceBuilder) DestinationPortRangeBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRangeBuilder) AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) RedirectToSfcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfcBuilder) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SourcePortRangeBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRangeBuilder)

Example 92 with IpPrefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithSingleSubnet.

@Test
public void testonPacketReceivedRouterSolicitationWithSingleSubnet() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getMacAddress()).thenReturn("fa:16:3e:4e:18:0c");
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
    IpAddress gwIpAddress = Mockito.mock(IpAddress.class);
    when(gwIpAddress.getIpv4Address()).thenReturn(null);
    when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8::1"));
    VirtualSubnet v6Subnet = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_SLAAC).ipv6RAMode(Ipv6Constants.IPV6_SLAAC).build();
    VirtualRouter virtualRouter = VirtualRouter.builder().build();
    v6Subnet.setRouter(virtualRouter);
    List<VirtualSubnet> subnetList = new ArrayList<>();
    subnetList.add(v6Subnet);
    when(intf.getSubnets()).thenReturn(subnetList);
    InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
    BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
    Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
    MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 00 00 00 02", // Source MAC
    "FA 16 3E 69 2C F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 10", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "B4 47", // ICMPv6 message body
    "00 00 00 00", // ICMPv6 Option: Source Link Layer Address
    "01", // Length
    "01", // Link Layer Address
    "FA 16 3E 69 2C F3")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
    byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
    "FA 16 3E 69 2C F3", // Source MAC
    "FA 16 3E 4E 18 0C", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 38", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 4E 18 0C", // Destination IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // ICMPv6 router advertisement.
    "86", // Code
    "00", // Checksum (valid)
    "1B B0", // Current Hop Limit
    "40", // ICMPv6 RA Flags
    "00", // Router Lifetime
    "11 94", // Reachable time
    "00 01 D4 C0", // Retransmission time.
    "00 00 00 00", // Type: Source Link-Layer Option
    "01", // Option length
    "01", // Source Link layer address
    "FA 16 3E 4E 18 0C", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 00");
    verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(ncRef).build());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 93 with IpPrefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.

the class FibRpcServiceImpl method makeLocalFibEntry.

private void makeLocalFibEntry(long vpnId, BigInteger dpnId, String ipPrefix, List<Instruction> customInstructions) {
    String[] values = ipPrefix.split("/");
    String ipAddress = values[0];
    int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
    LOG.debug("Adding route to DPN. ip {} masklen {}", ipAddress, prefixLength);
    InetAddress destPrefix = null;
    try {
        destPrefix = InetAddress.getByName(ipAddress);
    } catch (UnknownHostException e) {
        LOG.error("UnknowHostException in addRoute. Failed  to add Route for ipPrefix {} VpnId {} DPN{}", ipAddress, vpnId, dpnId, e);
        return;
    }
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    matches.add(MatchEthernetType.IPV4);
    if (prefixLength != 0) {
        matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
    }
    String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vpnId, ipAddress);
    int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, customInstructions);
    mdsalManager.installFlow(dpnId, flowEntity);
    LOG.debug("FIB entry for route {} on dpn {} installed successfully - flow {}", ipAddress, dpnId, flowEntity);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) UnknownHostException(java.net.UnknownHostException) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InetAddress(java.net.InetAddress) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 94 with IpPrefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.

the class FibRpcServiceImpl method removeLocalFibEntry.

private void removeLocalFibEntry(BigInteger dpnId, long vpnId, String ipPrefix) {
    String[] values = ipPrefix.split("/");
    String ipAddress = values[0];
    int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
    LOG.debug("Removing route from DPN. ip {} masklen {}", ipAddress, prefixLength);
    InetAddress destPrefix = null;
    try {
        destPrefix = InetAddress.getByName(ipAddress);
    } catch (UnknownHostException e) {
        LOG.error("UnknowHostException in removeRoute. Failed  to remove Route for ipPrefix {} DPN {} Vpn {}", ipAddress, dpnId, vpnId, e);
        return;
    }
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    matches.add(MatchEthernetType.IPV4);
    if (prefixLength != 0) {
        matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
    }
    String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vpnId, ipAddress);
    int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, null);
    mdsalManager.removeFlow(dpnId, flowEntity);
    LOG.info("FIB entry for prefix {} on dpn {} vpn {} removed successfully", ipAddress, dpnId, vpnId);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) UnknownHostException(java.net.UnknownHostException) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InetAddress(java.net.InetAddress) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 95 with IpPrefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.

the class VrfEntryListener method createLocalFibEntry.

private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
    List<BigInteger> returnLocalDpnId = new ArrayList<>();
    String localNextHopIP = vrfEntry.getDestPrefix();
    Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
    String vpnName = fibUtil.getVpnNameFromId(vpnId);
    if (localNextHopInfo == null) {
        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
        List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, vpnName, usedRds, localNextHopIP);
        boolean localNextHopSeen = false;
        // Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
        for (Routes vpnExtraRoute : vpnExtraRoutes) {
            String ipPrefix;
            if (isIpv4Address(vpnExtraRoute.getNexthopIpList().get(0))) {
                ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
            } else {
                ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
            }
            Prefixes localNextHopInfoLocal = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
            if (localNextHopInfoLocal != null) {
                localNextHopSeen = true;
                BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfoLocal, localNextHopInfoLocal.getIpAddress(), vpnId, rd, vrfEntry, vpnId, vpnExtraRoute, vpnExtraRoutes);
                returnLocalDpnId.add(dpnId);
            }
        }
        if (!localNextHopSeen && RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
            java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
            if (optionalLabel.isPresent()) {
                Long label = optionalLabel.get();
                List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
                synchronized (label.toString().intern()) {
                    LabelRouteInfo lri = getLabelRouteInfo(label);
                    if (isPrefixAndNextHopPresentInLri(localNextHopIP, nextHopAddressList, lri)) {
                        Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = fibUtil.getVpnInstanceOpData(rd);
                        if (vpnInstanceOpDataEntryOptional.isPresent()) {
                            String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
                            if (lri.getVpnInstanceList().contains(vpnInstanceName)) {
                                localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, true);
                                localNextHopIP = lri.getPrefix();
                            } else {
                                localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, false);
                                localNextHopIP = lri.getPrefix();
                            }
                        }
                        if (localNextHopInfo != null) {
                            LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, localNextHopInfo.getVpnInterfaceName(), lri.getDpnId());
                            if (vpnExtraRoutes.isEmpty()) {
                                BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, lri.getParentVpnid(), null, vpnExtraRoutes);
                                returnLocalDpnId.add(dpnId);
                            } else {
                                for (Routes extraRoutes : vpnExtraRoutes) {
                                    BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, lri.getParentVpnid(), extraRoutes, vpnExtraRoutes);
                                    returnLocalDpnId.add(dpnId);
                                }
                            }
                        }
                    }
                }
            }
        }
        if (returnLocalDpnId.isEmpty()) {
            LOG.error("Local DPNID is empty for rd {}, vpnId {}, vrfEntry {}", rd, vpnId, vrfEntry);
        }
    } else {
        BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, vpnId, /*routes*/
        null, /*vpnExtraRoutes*/
        null);
        if (dpnId != null) {
            returnLocalDpnId.add(dpnId);
        }
    }
    return returnLocalDpnId;
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) BigInteger(java.math.BigInteger)

Aggregations

IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)96 Test (org.junit.Test)38 ByteBuf (io.netty.buffer.ByteBuf)33 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)28 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)27 ArrayList (java.util.ArrayList)23 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)23 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)23 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)17 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)13 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)12 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)12 BigInteger (java.math.BigInteger)11 InetAddress (java.net.InetAddress)11 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)8 BitArray (org.opendaylight.protocol.util.BitArray)8 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)8 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)8