Search in sources :

Example 1 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLogicalSwitchRef.

/**
 * Trnaform logical switch to nodepath passed .
 *
 * @param src {@link HwvtepLogicalSwitchRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return ref {@link HwvtepLogicalSwitchRef} the transforrmed result
 */
public static HwvtepLogicalSwitchRef convertLogicalSwitchRef(HwvtepLogicalSwitchRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<LogicalSwitches> srcId = (InstanceIdentifier<LogicalSwitches>) src.getValue();
    HwvtepNodeName switchName = srcId.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
    InstanceIdentifier<LogicalSwitches> iid = nodePath.augmentation(HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, new LogicalSwitchesKey(switchName));
    HwvtepLogicalSwitchRef ref = new HwvtepLogicalSwitchRef(iid);
    return ref;
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) LogicalSwitchesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey)

Example 2 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLocatorRef.

/**
 * Trnaform locator reference to nodepath passed .
 *
 * @param src {@link HwvtepPhysicalLocatorRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return physicalLocatorRef {@link HwvtepPhysicalLocatorRef} the transforrmed result
 */
public static HwvtepPhysicalLocatorRef convertLocatorRef(HwvtepPhysicalLocatorRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<TerminationPoint> srcTepPath = (InstanceIdentifier<TerminationPoint>) src.getValue();
    TpId tpId = srcTepPath.firstKeyOf(TerminationPoint.class).getTpId();
    InstanceIdentifier<TerminationPoint> tpPath = nodePath.child(TerminationPoint.class, new TerminationPointKey(tpId));
    HwvtepPhysicalLocatorRef physicalLocatorRef = new HwvtepPhysicalLocatorRef(tpPath);
    return physicalLocatorRef;
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 3 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project netvirt by opendaylight.

the class VpnInterfaceManager method handleVpnsExportingRoutes.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
void handleVpnsExportingRoutes(String vpnName, String vpnRd) {
    List<VpnInstanceOpDataEntry> vpnsToExportRoute = getVpnsExportingMyRoute(vpnName);
    for (VpnInstanceOpDataEntry vpn : vpnsToExportRoute) {
        List<VrfEntry> vrfEntries = VpnUtil.getAllVrfEntries(dataBroker, vpn.getVrfId());
        WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
        if (vrfEntries != null) {
            for (VrfEntry vrfEntry : vrfEntries) {
                try {
                    if (!FibHelper.isControllerManagedNonInterVpnLinkRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
                        LOG.info("handleVpnsExportingRoutes: vrfEntry with rd {} prefix {}" + " is not a controller managed non intervpn link route. Ignoring.", vpn.getVrfId(), vrfEntry.getDestPrefix());
                        continue;
                    }
                    String prefix = vrfEntry.getDestPrefix();
                    String gwMac = vrfEntry.getGatewayMacAddress();
                    vrfEntry.getRoutePaths().forEach(routePath -> {
                        String nh = routePath.getNexthopAddress();
                        int label = routePath.getLabel().intValue();
                        if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
                            LOG.info("handleVpnsExportingRoutesImporting: Importing fib entry rd {} prefix {}" + " nexthop {} label {} to vpn {} vpnRd {}", vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
                            fibManager.addOrUpdateFibEntry(vpnRd, null, /*macAddress*/
                            prefix, Collections.singletonList(nh), VrfEntry.EncapType.Mplsgre, label, 0, /*l3vni*/
                            gwMac, null, /*parentVpnRd*/
                            RouteOrigin.SELF_IMPORTED, writeConfigTxn);
                        } else {
                            LOG.info("handleVpnsExportingRoutes: Importing subnet route fib entry rd {} prefix {}" + " nexthop {} label {} to vpn {} vpnRd {}", vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
                            SubnetRoute route = vrfEntry.getAugmentation(SubnetRoute.class);
                            importSubnetRouteForNewVpn(vpnRd, prefix, nh, label, route, writeConfigTxn);
                        }
                    });
                } catch (RuntimeException e) {
                    LOG.error("getNextHopAddressList: Exception occurred while importing route with rd {}" + " prefix {} routePaths {} to vpn {} vpnRd {}", vpn.getVrfId(), vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), vpnName, vpnRd);
                }
            }
            writeConfigTxn.submit();
        } else {
            LOG.info("getNextHopAddressList: No vrf entries to import from vpn {} with rd {} to vpn {} with rd {}", vpn.getVpnInstanceName(), vpn.getVrfId(), vpnName, vpnRd);
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute)

Example 4 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithMultipleSubnets.

@Test
public void testonPacketReceivedRouterSolicitationWithMultipleSubnets() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getMacAddress()).thenReturn("50:7B:9D:78:54:F3");
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    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:1111::1"));
    VirtualSubnet v6Subnet1 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:1111::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_SLAAC).ipv6RAMode(Ipv6Constants.IPV6_SLAAC).build();
    VirtualRouter virtualRouter = VirtualRouter.builder().build();
    v6Subnet1.setRouter(virtualRouter);
    VirtualSubnet v6Subnet2 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:2222::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).build();
    v6Subnet2.setRouter(virtualRouter);
    VirtualSubnet v6Subnet3 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:3333::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).build();
    v6Subnet3.setRouter(virtualRouter);
    List<VirtualSubnet> subnetList = new ArrayList<>();
    subnetList.add(v6Subnet1);
    subnetList.add(v6Subnet2);
    subnetList.add(v6Subnet3);
    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
    "50 7B 9D 78 54 F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 78", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 52 7B 9D FF FE 78 54 F3", // 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)
    "59 41", // Current Hop Limit
    "40", // ICMPv6 RA Flags
    "C0", // 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
    "50 7B 9D 78 54 F3", // 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 11 11 00 00 00 00 00 00 00 00 00 00", // 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 22 22 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "80", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 33 33 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 5 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project netvirt by opendaylight.

the class IVpnLinkServiceImpl method handleStaticRoute.

/*
     * Takes care of an static route to see if flows related to interVpnLink
     * must be installed in tables 20 and 17
     *
     * @param vpnId Vpn to which the route belongs
     * @param route Route to handle. Will only be considered if its nexthop is the VPN's endpoint IpAddress
     *              at the other side of the InterVpnLink
     * @param iVpnLink
     */
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleStaticRoute(String vpnId, Routes route, InterVpnLinkDataComposite ivpnLink) {
    IpAddress nhIpAddr = route.getNexthop();
    String routeNextHop = nhIpAddr.getIpv4Address() != null ? nhIpAddr.getIpv4Address().getValue() : nhIpAddr.getIpv6Address().getValue();
    String destination = String.valueOf(route.getDestination().getValue());
    // is nexthop the other endpoint's IP
    String otherEndpoint = ivpnLink.getOtherEndpoint(vpnId);
    if (!routeNextHop.equals(otherEndpoint)) {
        LOG.debug("VPN {}: Route to {} nexthop={} points to an InterVpnLink endpoint, but its not " + "the other endpoint. Other endpoint is {}", vpnId, destination, routeNextHop, otherEndpoint);
        return;
    }
    // Lets work: 1) write Fibentry, 2) advertise to BGP and 3) check if it must be leaked
    String vpnRd = VpnUtil.getVpnRd(dataBroker, vpnId);
    if (vpnRd == null) {
        LOG.warn("Could not find Route-Distinguisher for VpnName {}", vpnId);
        return;
    }
    int label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(vpnId, destination));
    try {
        InterVpnLinkUtil.handleStaticRoute(ivpnLink, vpnId, destination, routeNextHop, label, dataBroker, fibManager, bgpManager);
    } catch (Exception e) {
        LOG.error("Exception while advertising prefix for intervpn link, {}", e);
    }
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

Test (org.junit.Test)454 ByteBuf (io.netty.buffer.ByteBuf)138 ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)58 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)54 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)45 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)38 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)35 InetAddress (java.net.InetAddress)33 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)33 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)32 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)28 Inet4Address (java.net.Inet4Address)27 Inet6Address (java.net.Inet6Address)27 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)27 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)26 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)26