Search in sources :

Example 26 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class ElanL2GatewayUtils method getElanMacTableEntriesMacs.

/**
 * Gets the elan mac table entries as remote ucast macs. <br>
 * Note: ELAN MAC table only contains internal switches MAC's. It doesn't
 * contain external device MAC's.
 *
 * @param elanName
 *            the elan name
 * @param hwVtepNodeId
 *            the hw vtep node id
 * @param logicalSwitchName
 *            the logical switch name
 * @return the elan mac table entries as remote ucast macs
 */
public List<RemoteUcastMacs> getElanMacTableEntriesMacs(String elanName, NodeId hwVtepNodeId, String logicalSwitchName) {
    List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>();
    MacTable macTable = ElanUtils.getElanMacTable(broker, elanName);
    if (macTable == null || macTable.getMacEntry() == null || macTable.getMacEntry().isEmpty()) {
        LOG.trace("MacTable is empty for elan: {}", elanName);
        return lstRemoteUcastMacs;
    }
    for (MacEntry macEntry : macTable.getMacEntry()) {
        BigInteger dpnId = getDpidFromInterface(macEntry.getInterface());
        if (dpnId == null) {
            LOG.error("DPN ID not found for interface {}", macEntry.getInterface());
            continue;
        }
        IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, hwVtepNodeId);
        LOG.trace("Dpn Tep IP: {} for dpnId: {} and nodeId: {}", dpnTepIp, dpnId, hwVtepNodeId.getValue());
        if (dpnTepIp == null) {
            LOG.error("TEP IP not found for dpnId {} and nodeId {}", dpnId, hwVtepNodeId.getValue());
            continue;
        }
        HwvtepPhysicalLocatorAugmentation physLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dpnTepIp.getValue()));
        // TODO: Query ARP cache to get IP address corresponding to the
        // MAC
        RemoteUcastMacs remoteUcastMac = HwvtepSouthboundUtils.createRemoteUcastMac(hwVtepNodeId, macEntry.getMacAddress().getValue().toLowerCase(Locale.getDefault()), null, /*IpAddress*/
        logicalSwitchName, physLocatorAug);
        lstRemoteUcastMacs.add(remoteUcastMac);
    }
    return lstRemoteUcastMacs;
}
Also used : RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable)

Example 27 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class ElanDmacUtils method buildDmacFlowForExternalRemoteMac.

/**
 * Builds a Flow to be programmed in a DPN's DMAC table. This method must be
 * used when the MAC is located in an External Device (TOR). The flow
 * matches on the specified MAC and 1) sends the packet over the CSS-TOR
 * tunnel if SHFlag is not set, or 2) drops it if SHFlag is set (what means
 * the packet came from an external tunnel)
 *
 * @param dpId
 *            DPN whose DMAC table is going to be modified
 * @param extDeviceNodeId
 *            Hwvtep node where the mac is attached to
 * @param elanTag
 *            ElanId to which the MAC is being added to
 * @param vni
 *            the vni
 * @param dstMacAddress
 *            The mac address to be programmed
 * @param displayName
 *            the display name
 * @return the flow
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildDmacFlowForExternalRemoteMac(BigInteger dpId, String extDeviceNodeId, long elanTag, Long vni, String dstMacAddress, String displayName) {
    List<MatchInfo> mkMatches = ElanUtils.buildMatchesForElanTagShFlagAndDstMac(elanTag, /* shFlag */
    false, dstMacAddress);
    List<Instruction> mkInstructions = new ArrayList<>();
    try {
        List<Action> actions = elanItmUtils.getExternalTunnelItmEgressAction(dpId, new NodeId(extDeviceNodeId), vni);
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get Egress Actions for DpId {} externalNode {}", dpId, extDeviceNodeId, e);
    }
    return MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, ElanUtils.getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, extDeviceNodeId, dstMacAddress, elanTag, false), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 28 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class ElanUtils method buildLocalDmacFlowEntry.

/**
 * Builds the flow to be programmed in the DMAC table of the local DPN (that
 * is, where the MAC is attached to). This flow consists in:
 *
 * <p>Match: + elanTag in metadata + packet goes to a MAC locally attached
 * Actions: + optionally, pop-vlan + set-vlan-id + output to ifName's
 * portNumber
 *
 * @param elanTag
 *            the elan tag
 * @param dpId
 *            the dp id
 * @param ifName
 *            the if name
 * @param macAddress
 *            the mac address
 * @param elanInfo
 *            the elan info
 * @param ifTag
 *            the if tag
 * @return the flow
 */
public Flow buildLocalDmacFlowEntry(long elanTag, BigInteger dpId, String ifName, String macAddress, ElanInstance elanInfo, long ifTag) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
    List<Instruction> mkInstructions = new ArrayList<>();
    List<Action> actions = getEgressActionsForInterface(ifName, /* tunnelKey */
    null);
    mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, ifTag, macAddress, elanTag), 20, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
    return flow;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 29 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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 30 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project netvirt by opendaylight.

the class DhcpExternalTunnelManager method chooseDpn.

/**
 * Choose a dpn among the list of elanDpns such that it has lowest count of being the designated dpn.
 * @param tunnelIp The tunnel Ip address
 * @param elanInstanceName The elan instance name
 * @param dpns The data path nodes
 * @return The designated dpn
 */
private BigInteger chooseDpn(IpAddress tunnelIp, String elanInstanceName, List<BigInteger> dpns) {
    BigInteger designatedDpnId = DhcpMConstants.INVALID_DPID;
    if (dpns != null && dpns.size() != 0) {
        List<BigInteger> candidateDpns = DhcpServiceUtils.getDpnsForElan(elanInstanceName, broker);
        candidateDpns.retainAll(dpns);
        LOG.trace("Choosing new dpn for tunnelIp {}, elanInstanceName {}, among elanDpns {}", tunnelIp, elanInstanceName, candidateDpns);
        boolean elanDpnAvailableFlag = true;
        if (candidateDpns.isEmpty()) {
            candidateDpns = dpns;
            elanDpnAvailableFlag = false;
        }
        int size = 0;
        L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
        if (device == null) {
            LOG.trace("Could not find any device for elanInstanceName {} and tunnelIp {}", elanInstanceName, tunnelIp);
            handleUnableToDesignateDpn(tunnelIp, elanInstanceName);
            return designatedDpnId;
        }
        for (BigInteger dpn : candidateDpns) {
            String hwvtepNodeId = device.getHwvtepNodeId();
            if (!elanDpnAvailableFlag) {
                if (!isTunnelConfigured(dpn, hwvtepNodeId)) {
                    LOG.trace("Tunnel is not configured on dpn {} to TOR {}", dpn, hwvtepNodeId);
                    continue;
                }
            } else if (!isTunnelUp(hwvtepNodeId, dpn)) {
                LOG.trace("Tunnel is not up between dpn {} and TOR {}", dpn, hwvtepNodeId);
                continue;
            }
            Set<Pair<IpAddress, String>> tunnelIpElanNameSet = designatedDpnsToTunnelIpElanNameCache.get(dpn);
            if (tunnelIpElanNameSet == null) {
                designatedDpnId = dpn;
                break;
            }
            if (size == 0 || tunnelIpElanNameSet.size() < size) {
                size = tunnelIpElanNameSet.size();
                designatedDpnId = dpn;
            }
        }
        writeDesignatedSwitchForExternalTunnel(designatedDpnId, tunnelIp, elanInstanceName);
        return designatedDpnId;
    }
    handleUnableToDesignateDpn(tunnelIp, elanInstanceName);
    return designatedDpnId;
}
Also used : BigInteger(java.math.BigInteger) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Aggregations

Test (org.junit.Test)209 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)90 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)79 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)77 ArrayList (java.util.ArrayList)67 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)66 ByteBuf (io.netty.buffer.ByteBuf)57 InetAddress (java.net.InetAddress)57 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)55 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)52 BigInteger (java.math.BigInteger)41 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)41 Inet6Address (java.net.Inet6Address)39 KeyValueAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress)39 Inet4Address (java.net.Inet4Address)36 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)29 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)28 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)27 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)26 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25