Search in sources :

Example 1 with ActionSetFieldTunnelId

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

the class NaptEventHandler method sendNaptPacketOut.

private void sendNaptPacketOut(byte[] pktOut, InterfaceInfo infInfo, List<ActionInfo> actionInfos, Long tunId) {
    LOG.trace("sendNaptPacketOut: Sending packet out DpId {}, interfaceInfo {}", infInfo.getDpId(), infInfo);
    // set inPort, and action as OFPP_TABLE so that it starts from table 0 (lowest table as per spec)
    actionInfos.add(new ActionSetFieldTunnelId(2, BigInteger.valueOf(tunId)));
    actionInfos.add(new ActionOutput(3, new Uri("0xfffffff9")));
    NodeConnectorRef inPort = MDSALUtil.getNodeConnRef(infInfo.getDpId(), String.valueOf(infInfo.getPortNo()));
    LOG.debug("sendNaptPacketOut : inPort for packetout is being set to {}", String.valueOf(infInfo.getPortNo()));
    TransmitPacketInput output = MDSALUtil.getPacketOut(actionInfos, pktOut, infInfo.getDpId().longValue(), inPort);
    LOG.debug("sendNaptPacketOut : Transmitting packet: {}, inPort {}", output, inPort);
    JdkFutures.addErrorLogging(pktService.transmitPacket(output), LOG, "Transmit packet");
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Example 2 with ActionSetFieldTunnelId

use of org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId 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)

Example 3 with ActionSetFieldTunnelId

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

the class NaptSwitchHA method buildSnatFlowEntity.

public FlowEntity buildSnatFlowEntity(BigInteger dpId, String routerName, long groupId, long routerVpnId, int addordel) {
    FlowEntity flowEntity;
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    if (addordel == NatConstants.ADD_FLOW) {
        List<ActionInfo> actionsInfo = new ArrayList<>();
        long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerVpnId, routerName);
        actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(tunnelId)));
        LOG.debug("buildSnatFlowEntity : 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));
        flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    } else {
        flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, null);
    }
    return flowEntity;
}
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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 4 with ActionSetFieldTunnelId

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

the class AbstractSnatService method installSnatMissEntry.

protected void installSnatMissEntry(BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId, String externalIp, long extSubnetId, 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<>();
    actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(routerId)));
    LOG.debug("installSnatMissEntry : 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);
    // Install the FIB entry for traffic destined to SNAT IP in Non-NAPT switch.
    matches = new ArrayList<>();
    actionsInfo = new ArrayList<>();
    matches.add(new MatchEthernetType(0x0800L));
    if (addOrRemove == NwConstants.ADD_FLOW) {
        if (extSubnetId == NatConstants.INVALID_ID) {
            LOG.error("installSnatMissEntry : external subnet id is invalid.");
            return;
        }
        actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(extSubnetId)));
        matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), MetaDataUtil.METADATA_MASK_VRFID));
    }
    matches.add(new MatchIpv4Destination(externalIp, "32"));
    LOG.debug("installSnatMissEntry : Setting the tunnel to the list of action infos {}", actionsInfo);
    actionsInfo.add(new ActionGroup(groupId));
    instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfo));
    flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, routerId);
    flowRef = flowRef + "inboundmiss" + externalIp;
    syncFlow(dpnId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.SNAT_FIB_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) 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) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 5 with ActionSetFieldTunnelId

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

the class BaseVrfEntryHandler method addTunnelInterfaceActions.

protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
    Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(), adjacencyResult.getInterfaceName());
    if (tunnelType == null) {
        LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
        return;
    }
    // TODO - For now have added routePath into adjacencyResult so that we know for which
    // routePath this result is built for. If this is not possible construct a map which does
    // the same.
    String nextHopIp = adjacencyResult.getNextHopIp();
    java.util.Optional<Long> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
    if (!optionalLabel.isPresent()) {
        LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
        return;
    }
    long label = optionalLabel.get();
    BigInteger tunnelId = null;
    Prefixes prefixInfo = null;
    // revisit
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
        // For extra route, the prefixInfo is fetched from the primary adjacency
        if (prefixInfo == null) {
            prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
        }
        // Internet VPN VNI will be used as tun_id for NAT use-cases
        if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
            if (vrfEntry.getL3vni() != null && vrfEntry.getL3vni() != 0) {
                tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
            }
        } else {
            if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId, rd)) {
                java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
                if (!optionalVni.isPresent()) {
                    LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp, vrfEntry, prefixInfo.getSubnetId());
                    return;
                }
                tunnelId = BigInteger.valueOf(optionalVni.get());
            } else {
                tunnelId = BigInteger.valueOf(label);
            }
        }
    } else {
        tunnelId = BigInteger.valueOf(label);
    }
    LOG.debug("adding set tunnel id action for label {}", label);
    actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
    addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
Also used : BigInteger(java.math.BigInteger) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)

Aggregations

ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)15 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)12 ArrayList (java.util.ArrayList)10 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)7 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)6 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)6 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5 ActionOutput (org.opendaylight.genius.mdsalutil.actions.ActionOutput)5 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)5 BigInteger (java.math.BigInteger)4 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)4 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)3 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)3 GroupEntity (org.opendaylight.genius.mdsalutil.GroupEntity)3 Test (org.junit.Test)2 ActionPushMpls (org.opendaylight.genius.mdsalutil.actions.ActionPushMpls)2 ActionPushVlan (org.opendaylight.genius.mdsalutil.actions.ActionPushVlan)2 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)2 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)2 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)2