Search in sources :

Example 51 with MacAddress

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

the class EvpnVrfEntryHandler method createRemoteFibEntry.

private void createRemoteFibEntry(final BigInteger remoteDpnId, final long vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, boolean isNatPrefix, WriteTransaction tx) {
    String rd = vrfTableKey.getRouteDistinguisher();
    List<SubTransaction> subTxns = new ArrayList<>();
    LOG.debug("createremotefibentry: adding route {} for rd {} with transaction {}", vrfEntry.getDestPrefix(), rd, tx);
    List<NexthopManager.AdjacencyResult> tunnelInterfaceList = resolveAdjacency(remoteDpnId, vpnId, vrfEntry, rd);
    if (tunnelInterfaceList.isEmpty()) {
        LOG.error("Could not get interface for route-paths: {} in vpn {}", vrfEntry.getRoutePaths(), rd);
        LOG.warn("Failed to add Route: {} in vpn: {}", vrfEntry.getDestPrefix(), rd);
        return;
    }
    for (NexthopManager.AdjacencyResult adjacencyResult : tunnelInterfaceList) {
        List<ActionInfo> actionInfos = new ArrayList<>();
        BigInteger tunnelId;
        String prefix = adjacencyResult.getPrefix();
        Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
        String interfaceName = prefixInfo.getVpnInterfaceName();
        if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
            tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
        } else if (elanManager.isOpenStackVniSemanticsEnforced()) {
            tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
        } else {
            Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
            tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
        }
        LOG.debug("adding set tunnel id action for label {}", tunnelId);
        String macAddress = null;
        String vpnName = getFibUtil().getVpnNameFromId(vpnId);
        if (vpnName == null) {
            LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
            return;
        }
        if (interfaceName != null) {
            macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, vpnName, prefix);
            actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
        }
        actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
        List<ActionInfo> egressActions = nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size());
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}." + " Aborting remote FIB entry creation..", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), adjacencyResult.getInterfaceName());
            return;
        }
        actionInfos.addAll(egressActions);
        List<InstructionInfo> instructions = new ArrayList<>();
        instructions.add(new InstructionApplyActions(actionInfos));
        makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
    }
    LOG.debug("Successfully added FIB entry for prefix {} in rd {}", vrfEntry.getDestPrefix(), rd);
}
Also used : SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 52 with MacAddress

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

the class TestBuilders method buildLocalMcastMacs.

public static LocalMcastMacs buildLocalMcastMacs(InstanceIdentifier<Node> iid, String mac, String logicalSwitchName, String tepIp) {
    LocalMcastMacsBuilder localMcastMacsBuilder = new LocalMcastMacsBuilder();
    if (mac.equals("unknown-dst")) {
        localMcastMacsBuilder.setMacEntryKey(new MacAddress("00:00:00:00:00:00"));
    } else {
        localMcastMacsBuilder.setMacEntryKey(new MacAddress(mac));
    }
    localMcastMacsBuilder.setMacEntryUuid(getUUid(mac));
    // mMacLocalBuilder.setIpaddr(new IpAddress(ip.toCharArray()));
    localMcastMacsBuilder.setLogicalSwitchRef(buildLogicalSwitchesRef(iid, logicalSwitchName));
    List<LocatorSet> locatorSets = new ArrayList<>();
    locatorSets.add(new LocatorSetBuilder().setLocatorRef(buildLocatorRef(iid, tepIp)).build());
    localMcastMacsBuilder.setLocatorSet(locatorSets);
    return localMcastMacsBuilder.build();
}
Also used : LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) ArrayList(java.util.ArrayList) LocalMcastMacsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacsBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) LocatorSetBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSetBuilder)

Example 53 with MacAddress

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

the class IfMgr method addHostIntf.

public void addHostIntf(Uuid portId, Uuid snetId, Uuid networkId, IpAddress fixedIp, String macAddress, String deviceOwner) {
    LOG.debug("addHostIntf portId {}, snetId {}, networkId {}, ip {}, mac {}", portId, snetId, networkId, fixedIp, macAddress);
    // Save the interface ipv6 address in its fully expanded format
    Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
    fixedIp = new IpAddress(addr);
    VirtualPort intf = VirtualPort.builder().intfUUID(portId).networkID(networkId).macAddress(macAddress).routerIntfFlag(false).deviceOwner(deviceOwner).build();
    intf.setSubnetInfo(snetId, fixedIp);
    VirtualPort prevIntf = vintfs.putIfAbsent(portId, intf);
    if (prevIntf == null) {
        Long elanTag = getNetworkElanTag(networkId);
        // Do service binding for the port and set the serviceBindingStatus to true.
        ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
        intf.setServiceBindingStatus(true);
        /* Update the intf dpnId/ofPort from the Operational Store */
        updateInterfaceDpidOfPortInfo(portId);
    } else {
        intf = prevIntf;
        intf.setSubnetInfo(snetId, fixedIp);
    }
    VirtualSubnet snet = getSubnet(snetId);
    if (snet != null) {
        intf.setSubnet(snetId, snet);
    } else {
        addUnprocessed(unprocessedSubnetIntfs, snetId, intf);
    }
}
Also used : IVirtualPort(org.opendaylight.netvirt.ipv6service.api.IVirtualPort) IVirtualSubnet(org.opendaylight.netvirt.ipv6service.api.IVirtualSubnet) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Example 54 with MacAddress

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

the class Ipv6NeighborSolicitation method frameNeighborSolicitationRequest.

private byte[] frameNeighborSolicitationRequest(MacAddress srcMacAddress, Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address) {
    MacAddress macAddress = Ipv6ServiceUtils.getIpv6MulticastMacAddress(targetIpv6Address);
    Ipv6Address snMcastAddr = Ipv6ServiceUtils.getIpv6SolicitedNodeMcastAddress(targetIpv6Address);
    NeighborSolicitationPacketBuilder nsPacket = new NeighborSolicitationPacketBuilder();
    nsPacket.setSourceMac(srcMacAddress);
    nsPacket.setDestinationMac(macAddress);
    nsPacket.setEthertype(NwConstants.ETHTYPE_IPV6);
    nsPacket.setVersion(Ipv6Constants.IP_VERSION_6);
    nsPacket.setFlowLabel((long) 0);
    nsPacket.setIpv6Length(32);
    nsPacket.setNextHeader(Ipv6Constants.ICMP_V6_TYPE);
    nsPacket.setHopLimit(Ipv6Constants.ICMP_V6_MAX_HOP_LIMIT);
    nsPacket.setSourceIpv6(srcIpv6Address);
    nsPacket.setDestinationIpv6(snMcastAddr);
    nsPacket.setIcmp6Type(Ipv6Constants.ICMP_V6_NS_CODE);
    nsPacket.setIcmp6Code((short) 0);
    nsPacket.setIcmp6Chksum(0);
    nsPacket.setReserved((long) 0);
    nsPacket.setTargetIpAddress(targetIpv6Address);
    nsPacket.setOptionType(Ipv6Constants.ICMP_V6_OPTION_SOURCE_LLA);
    nsPacket.setSourceAddrLength((short) 1);
    nsPacket.setSourceLlAddress(srcMacAddress);
    return fillNeighborSolicitationPacket(nsPacket.build());
}
Also used : NeighborSolicitationPacketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.ipv6service.nd.packet.rev160620.NeighborSolicitationPacketBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Example 55 with MacAddress

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

the class Ipv6NeighborSolicitation method transmitNeighborSolicitation.

public boolean transmitNeighborSolicitation(BigInteger dpnId, NodeConnectorRef nodeRef, MacAddress srcMacAddress, Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address) {
    byte[] txPayload = frameNeighborSolicitationRequest(srcMacAddress, srcIpv6Address, targetIpv6Address);
    NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd");
    TransmitPacketInput input = new TransmitPacketInputBuilder().setPayload(txPayload).setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).setEgress(nodeRef).setIngress(nodeConnectorRef).build();
    // Tx the packet out of the controller.
    LOG.debug("Transmitting the Neighbor Solicitation packet out on {}", dpnId);
    JdkFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket");
    return true;
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Aggregations

MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)213 ArrayList (java.util.ArrayList)84 Test (org.junit.Test)79 BigInteger (java.math.BigInteger)52 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)37 ByteBuf (io.netty.buffer.ByteBuf)33 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)33 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)33 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)26 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)23 List (java.util.List)22 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)21 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)20 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)20 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)20 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)20 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)19 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)19 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)18 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)17