Search in sources :

Example 1 with ActionGroup

use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.

the class ElanNodeListener method createArpRequestMatchFlows.

private void createArpRequestMatchFlows(BigInteger dpId, WriteTransaction writeFlowTx) {
    long arpRequestGroupId = ArpResponderUtil.retrieveStandardArpResponderGroupId(idManagerService);
    List<BucketInfo> buckets = ArpResponderUtil.getDefaultBucketInfos(NwConstants.ELAN_BASE_TABLE, NwConstants.ARP_RESPONDER_TABLE);
    ArpResponderUtil.installGroup(mdsalManager, dpId, arpRequestGroupId, ArpResponderConstant.GROUP_FLOW_NAME.value(), buckets);
    FlowEntity arpReqArpCheckTbl = ArpResponderUtil.createArpDefaultFlow(dpId, NwConstants.ARP_CHECK_TABLE, NwConstants.ARP_REQUEST, () -> Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REQUEST), () -> Collections.singletonList(new ActionGroup(arpRequestGroupId)));
    LOG.trace("Invoking MDSAL to install Arp Rquest Match Flow for table {}", NwConstants.ARP_CHECK_TABLE);
    mdsalManager.addFlowToTx(arpReqArpCheckTbl, writeFlowTx);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 2 with ActionGroup

use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.

the class ElanInterfaceManager method setBCGrouponOtherDpns.

@SuppressWarnings("checkstyle:IllegalCatch")
private void setBCGrouponOtherDpns(ElanInstance elanInfo, BigInteger dpId, int elanTag, long groupId) {
    int bucketId = 0;
    ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
    if (elanDpns != null) {
        List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
        for (DpnInterfaces dpnInterface : dpnInterfaces) {
            List<Bucket> remoteListBucketInfo = new ArrayList<>();
            if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId) && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
                List<Action> listAction = new ArrayList<>();
                int actionKey = 0;
                listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
                remoteListBucketInfo.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                bucketId++;
                for (DpnInterfaces otherFes : dpnInterfaces) {
                    if (elanUtils.isDpnPresent(otherFes.getDpId()) && !Objects.equals(otherFes.getDpId(), dpnInterface.getDpId()) && otherFes.getInterfaces() != null && !otherFes.getInterfaces().isEmpty()) {
                        try {
                            List<Action> remoteListActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnInterface.getDpId(), otherFes.getDpId(), elanUtils.isOpenstackVniSemanticsEnforced() ? elanUtils.getVxlanSegmentationId(elanInfo) : elanTag);
                            if (!remoteListActionInfo.isEmpty()) {
                                remoteListBucketInfo.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                                bucketId++;
                            }
                        } catch (Exception ex) {
                            LOG.error("setElanBCGrouponOtherDpns failed due to Exception caught; " + "Logical Group Interface not found between source Dpn - {}, " + "destination Dpn - {} ", dpnInterface.getDpId(), otherFes.getDpId(), ex);
                            return;
                        }
                    }
                }
                List<Bucket> elanL2GwDevicesBuckets = elanL2GatewayMulticastUtils.getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnInterface.getDpId(), bucketId);
                remoteListBucketInfo.addAll(elanL2GwDevicesBuckets);
                if (remoteListBucketInfo.isEmpty()) {
                    LOG.debug("No ITM is present on Dpn - {} ", dpnInterface.getDpId());
                    continue;
                }
                Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(remoteListBucketInfo));
                LOG.trace("Installing remote bc group {} on dpnId {}", group, dpnInterface.getDpId());
                mdsalManager.syncInstallGroup(dpnInterface.getDpId(), group);
            }
        }
        try {
            Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
        } catch (InterruptedException e1) {
            LOG.warn("Error while waiting for remote BC group on other DPNs for ELAN {} to install", elanInfo);
        }
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) ArrayList(java.util.ArrayList) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup)

Example 3 with ActionGroup

use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.

the class ArpUtils method createArpRequestInput.

public static TransmitPacketInput createArpRequestInput(BigInteger dpnId, Long groupId, byte[] abySenderMAC, byte[] abyTargetMAC, byte[] abySenderIpAddress, byte[] abyTargetIpAddress, NodeConnectorRef ingress, List<ActionInfo> lstActionInfo) {
    LOG.info("SubnetRoutePacketInHandler: sendArpRequest dpnId {}, actions {}," + " groupId {}, senderIPAddress {}, targetIPAddress {}", dpnId, lstActionInfo, groupId, NWUtil.toStringIpAddress(abySenderIpAddress), NWUtil.toStringIpAddress(abyTargetIpAddress));
    if (abySenderIpAddress != null) {
        byte[] arpPacket;
        byte[] ethPacket;
        byte[] targetMac = abyTargetMAC != null ? abyTargetMAC : MAC_BROADCAST;
        arpPacket = createARPPacket(ARP.REQUEST, abySenderMAC, abySenderIpAddress, targetMac, abyTargetIpAddress);
        ethPacket = createEthernetPacket(abySenderMAC, ETHERNETDESTINATION_BROADCAST, arpPacket);
        if (groupId != null) {
            lstActionInfo.add(new ActionGroup(groupId));
        }
        if (ingress != null) {
            return MDSALUtil.getPacketOutFromController(lstActionInfo, ethPacket, dpnId.longValue(), ingress);
        } else {
            return MDSALUtil.getPacketOutDefault(lstActionInfo, ethPacket, dpnId);
        }
    } else {
        LOG.info("SubnetRoutePacketInHandler: Unable to send ARP request because client port has no IP  ");
        return null;
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup)

Example 4 with ActionGroup

use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.

the class NatUtil method buildDefaultNATFlowEntityForExternalSubnet.

static FlowEntity buildDefaultNATFlowEntityForExternalSubnet(BigInteger dpId, long vpnId, String subnetId, IdManagerService idManager) {
    InetAddress defaultIP = null;
    try {
        defaultIP = InetAddress.getByName("0.0.0.0");
    } catch (UnknownHostException e) {
        LOG.error("buildDefaultNATFlowEntityForExternalSubnet : Failed to build FIB Table Flow for " + "Default Route to NAT.", e);
        return null;
    }
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    // add match for vrfid
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    List<InstructionInfo> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfo = new ArrayList<>();
    long groupId = createGroupId(NatUtil.getGroupIdKey(subnetId), idManager);
    actionsInfo.add(new ActionGroup(groupId));
    String flowRef = getFlowRef(dpId, NwConstants.L3_FIB_TABLE, defaultIP, vpnId);
    instructions.add(new InstructionApplyActions(actionsInfo));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) UnknownHostException(java.net.UnknownHostException) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) InetAddress(java.net.InetAddress)

Example 5 with ActionGroup

use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.

the class VxlanGreConntrackBasedSnatService method installSnatMissEntry.

protected void installSnatMissEntry(BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId, int addOrRemove) {
    LOG.debug("installSnatMissEntry : Installing SNAT miss entry in switch {}", dpnId);
    List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
    String ifNamePrimary = getTunnelInterfaceName(dpnId, primarySwitchId);
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    if (ifNamePrimary != null) {
        LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
        listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
    }
    BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
    listBucketInfo.add(0, bucketPrimary);
    LOG.debug("installSnatMissEntry : installSnatMissEntry called for dpnId {} with primaryBucket {} ", dpnId, listBucketInfo.get(0));
    // Install the select group
    long groupId = createGroupId(getGroupIdKey(routerName));
    GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
    LOG.debug("installSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
    mdsalManager.installGroup(groupEntity);
    // Install miss entry pointing to group
    LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}", dpnId, routerName, groupId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchEthernetType(0x0800L));
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
    List<ActionInfo> actionsInfo = new ArrayList<>();
    BigInteger tunnelId = BigInteger.valueOf(routerId);
    if (elanManager.isOpenStackVniSemanticsEnforced()) {
        tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, routerId);
    }
    actionsInfo.add(new ActionSetFieldTunnelId(tunnelId));
    LOG.debug("AbstractSnatService : Setting the tunnel to the list of action infos {}", actionsInfo);
    actionsInfo.add(new ActionGroup(groupId));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfo));
    String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
    syncFlow(dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) BigInteger(java.math.BigInteger) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)26 ArrayList (java.util.ArrayList)20 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)15 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)13 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)12 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)8 BigInteger (java.math.BigInteger)7 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)7 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)7 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)6 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)5 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 Test (org.junit.Test)3 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 InetAddress (java.net.InetAddress)2