Search in sources :

Example 61 with Ip

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip in project netvirt by opendaylight.

the class AbstractAclServiceImpl method syncRemoteAclTable.

private void syncRemoteAclTable(String portId, Uuid acl, Integer aclTag, List<AllowedAddressPairs> aaps, int addOrRemove) {
    Map<String, Set<AclInterface>> mapAclWithPortSet = aclDataUtil.getRemoteAclInterfaces(acl, this.direction);
    Set<BigInteger> dpns = collectDpns(mapAclWithPortSet);
    for (AllowedAddressPairs aap : aaps) {
        if (!AclServiceUtils.isNotIpAllNetwork(aap)) {
            continue;
        }
        if (aclServiceUtils.skipDeleteInCaseOfOverlappingIP(portId, acl, aap.getIpAddress(), addOrRemove)) {
            LOG.debug("Skipping delete of IP={} in remote ACL table for remoteAclId={}, portId={}", aap.getIpAddress(), portId, acl.getValue());
            continue;
        }
        for (BigInteger dpId : dpns) {
            programRemoteAclTableFlow(dpId, aclTag, aap, addOrRemove);
        }
    }
}
Also used : SortedSet(java.util.SortedSet) Set(java.util.Set) HashSet(java.util.HashSet) BigInteger(java.math.BigInteger) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)

Example 62 with Ip

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip in project netvirt by opendaylight.

the class NexthopManager method removeOrUpdateDcGwLoadBalancingGroup.

/**
 * This method is invoked when the tunnel state is removed from DS.
 * If the there is just one DC-GW left in configuration then the LB groups can be deleted.
 * Otherwise, the groups are just updated.
 */
public void removeOrUpdateDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp) {
    Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
    WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
    WriteTransaction operationalTx = dataBroker.newWriteOnlyTransaction();
    int noOfDcGws = availableDcGws.size();
    // If availableDcGws does not contain the destination Ip it means this is a configuration delete.
    if (!availableDcGws.contains(destinationIp)) {
        availableDcGws.add(destinationIp);
        Collections.sort(availableDcGws);
    }
    // TODO : Place the logic to construct all possible DC-GW combination here.
    int bucketId = availableDcGws.indexOf(destinationIp);
    Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
    if (!dpnLbNextHops.isPresent()) {
        return;
    }
    List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
    nextHopKeys.forEach(nextHopKey -> {
        Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
        if (!optionalNextHops.isPresent()) {
            return;
        }
        Nexthops nexthops = optionalNextHops.get();
        final String groupId = nexthops.getGroupId();
        final long groupIdValue = Long.parseLong(groupId);
        if (noOfDcGws > 1) {
            mdsalApiManager.removeBucketToTx(dpnId, groupIdValue, bucketId, configTx);
        } else {
            Group group = MDSALUtil.buildGroup(groupIdValue, nextHopKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
            LOG.trace("Removed LB group {} on dpn {}", group, dpnId);
            mdsalApiManager.removeGroupToTx(dpnId, group, configTx);
            removeNextHopPointer(nextHopKey);
        }
        // When the DC-GW is removed from configuration.
        if (noOfDcGws != availableDcGws.size()) {
            FibUtil.removeOrUpdateNextHopInfo(dpnId, nextHopKey, groupId, nexthops, operationalTx);
        }
    });
    FibUtil.removeDpnIdToNextHopInfo(destinationIp, dpnId, operationalTx);
    configTx.submit();
    operationalTx.submit();
    return;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) Nexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.l3vpn.lb.nexthops.Nexthops) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops)

Example 63 with Ip

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip in project netvirt by opendaylight.

the class RouterInterfaceVrfEntryHandler method installRouterFibEntries.

private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove, RouterInterface routerInterface) {
    final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
    Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
    Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
    synchronized (vpnInstance.getVpnInstanceName().intern()) {
        final Collection<VpnToDpnList> vpnToDpnList;
        if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
            VpnInstanceOpDataEntry parentVpnInstance = getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
            vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
        } else {
            vpnToDpnList = vpnInstance.getVpnToDpnList();
        }
        final Long vpnId = vpnInstance.getVpnId();
        if (vpnToDpnList != null) {
            String routerId = routerInterface.getUuid();
            String macAddress = routerInterface.getMacAddress();
            String ipValue = routerInterface.getIpAddress();
            LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}", routerId, ipValue, macAddress);
            for (VpnToDpnList vpnDpn : vpnToDpnList) {
                if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                    installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, ipValue, new MacAddress(macAddress), addOrRemove);
                }
            }
        }
    }
    return true;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 64 with Ip

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip in project netvirt by opendaylight.

the class VrfEntryListener method installSubnetBroadcastAddrDropRule.

private void installSubnetBroadcastAddrDropRule(final BigInteger dpnId, final String rd, final long vpnId, final VrfEntry vrfEntry, int addOrRemove, WriteTransaction tx) {
    List<MatchInfo> matches = new ArrayList<>();
    LOG.debug("SUBNETROUTE: installSubnetBroadcastAddrDropRule: destPrefix {} rd {} vpnId {} dpnId {}", vrfEntry.getDestPrefix(), rd, vpnId, dpnId);
    String[] ipAddress = vrfEntry.getDestPrefix().split("/");
    String subnetBroadcastAddr = FibUtil.getBroadcastAddressFromCidr(vrfEntry.getDestPrefix());
    final int prefixLength = ipAddress.length == 1 ? 0 : Integer.parseInt(ipAddress[1]);
    InetAddress destPrefix;
    try {
        destPrefix = InetAddress.getByName(subnetBroadcastAddr);
    } catch (UnknownHostException e) {
        LOG.error("Failed to get destPrefix for prefix {} rd {} VpnId {} DPN {}", vrfEntry.getDestPrefix(), rd, vpnId, dpnId, e);
        return;
    }
    // Match on VpnId and SubnetBroadCast IP address
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    matches.add(MatchEthernetType.IPV4);
    if (prefixLength != 0) {
        matches.add(new MatchIpv4Destination(subnetBroadcastAddr, Integer.toString(IPV4_ADDR_PREFIX_LENGTH)));
    }
    // Action is to drop the packet
    List<InstructionInfo> dropInstructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionDrop());
    dropInstructions.add(new InstructionApplyActions(actionsInfos));
    int priority = DEFAULT_FIB_FLOW_PRIORITY + IPV4_ADDR_PREFIX_LENGTH;
    String flowRef = FibUtil.getFlowRef(dpnId, NwConstants.L3_SUBNET_ROUTE_TABLE, rd, priority, destPrefix);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_SUBNET_ROUTE_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_TABLE_MISS, matches, dropInstructions);
    Flow flow = flowEntity.getFlowBuilder().build();
    String flowId = flowEntity.getFlowId();
    FlowKey flowKey = new FlowKey(new FlowId(flowId));
    Node nodeDpn = FibUtil.buildDpnNode(dpnId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true);
    } else {
        tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
    }
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) UnknownHostException(java.net.UnknownHostException) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) InetAddress(java.net.InetAddress)

Example 65 with Ip

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method getTepIpOfDesignatedSwitchForExternalTunnel.

/**
 * Gets the tep ip of designated switch for external tunnel.
 *
 * @param l2GwDevice
 *            the l2 gw device
 * @param elanInstanceName
 *            the elan instance name
 * @return the tep ip of designated switch for external tunnel
 */
public IpAddress getTepIpOfDesignatedSwitchForExternalTunnel(L2GatewayDevice l2GwDevice, String elanInstanceName) {
    IpAddress tepIp = null;
    if (l2GwDevice.getTunnelIp() == null) {
        LOG.warn("Tunnel IP not found for {}", l2GwDevice.getDeviceName());
        return tepIp;
    }
    DesignatedSwitchForTunnel desgSwitch = getDesignatedSwitchForExternalTunnel(l2GwDevice.getTunnelIp(), elanInstanceName);
    if (desgSwitch != null) {
        tepIp = elanItmUtils.getSourceDpnTepIp(BigInteger.valueOf(desgSwitch.getDpId()), new NodeId(l2GwDevice.getHwvtepNodeId()));
    }
    return tepIp;
}
Also used : DesignatedSwitchForTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.designated.switches._for.external.tunnels.DesignatedSwitchForTunnel) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

ArrayList (java.util.ArrayList)83 BigInteger (java.math.BigInteger)71 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)64 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)61 Test (org.junit.Test)58 List (java.util.List)27 ExecutionException (java.util.concurrent.ExecutionException)27 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)27 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25 UnknownHostException (java.net.UnknownHostException)22 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)20 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)18 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)18 Collections (java.util.Collections)17 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)17 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)17 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)16 Singleton (javax.inject.Singleton)15