Search in sources :

Example 11 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method buildNaptPfibFlowEntity.

public FlowEntity buildNaptPfibFlowEntity(BigInteger dpId, long segmentId) {
    LOG.debug("buildNaptPfibFlowEntity : called for dpId {}, segmentId {}", dpId, segmentId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
    ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
    ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
    listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
    listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
    instructionInfo.add(new InstructionApplyActions(listActionInfo));
    String flowRef = getFlowRefTs(dpId, NwConstants.NAPT_PFIB_TABLE, segmentId);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
    LOG.debug("buildNaptPfibFlowEntity : Returning NaptPFib Flow Entity {}", flowEntity);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 12 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method getBucketInfoForNonNaptSwitches.

List<BucketInfo> getBucketInfoForNonNaptSwitches(BigInteger nonNaptSwitchId, BigInteger primarySwitchId, String routerName, long routerId) {
    List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
    String ifNamePrimary = getTunnelInterfaceName(nonNaptSwitchId, primarySwitchId);
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    if (ifNamePrimary != null) {
        LOG.debug("getBucketInfoForNonNaptSwitches : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
        listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
        if (listActionInfoPrimary.isEmpty()) {
            LOG.error("getBucketInfoForNonNaptSwitches : Unable to retrieve output actions on Non-NAPT switch {} " + "for router {} towards Napt-switch {} via tunnel interface {}", nonNaptSwitchId, routerName, primarySwitchId, ifNamePrimary);
        }
    } else {
        LOG.error("getBucketInfoForNonNaptSwitches : Unable to obtain primary tunnel interface to Napt-Switch {} " + "from Non-Napt switch {} for router {}", primarySwitchId, nonNaptSwitchId, routerName);
    }
    BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
    listBucketInfo.add(0, bucketPrimary);
    return listBucketInfo;
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 13 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method buildNaptPfibFlowEntityWithUpdatedVpnId.

public FlowEntity buildNaptPfibFlowEntityWithUpdatedVpnId(BigInteger dpId, long segmentId, long changedVpnId) {
    LOG.debug("buildNaptPfibFlowEntityWithUpdatedVpnId : called for dpId {}, " + "segmentId {}, BGP VPN ID {}", dpId, segmentId, changedVpnId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
    ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
    listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
    listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
    instructionInfo.add(new InstructionApplyActions(listActionInfo));
    String flowRef = getFlowRefTs(dpId, NwConstants.NAPT_PFIB_TABLE, segmentId);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
    LOG.debug("buildNaptPfibFlowEntityWithUpdatedVpnId : Returning NaptPFib Flow Entity {}", flowEntity);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 14 with ActionInfo

use of org.opendaylight.genius.mdsalutil.ActionInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method handleSwitches.

protected void handleSwitches(BigInteger dpnId, String routerName, long routerId, BigInteger primarySwitchId) {
    LOG.debug("handleSwitches : 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("handleSwitches : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
        listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
        if (listActionInfoPrimary.isEmpty()) {
            LOG.error("handleSwitches : Unable to retrieve output actions on Non-NAPT switch {} for router {}" + " towards Napt-switch {} via tunnel interface {}", dpnId, routerName, primarySwitchId, ifNamePrimary);
        }
    } else {
        LOG.error("handleSwitches : Unable to obtain primary tunnel interface to Napt-Switch {} from " + "Non-Napt switch {} for router {}", primarySwitchId, dpnId, routerName);
    }
    BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
    listBucketInfo.add(0, bucketPrimary);
    installSnatMissEntry(dpnId, listBucketInfo, routerName, routerId);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 15 with ActionInfo

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

Aggregations

ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)133 ArrayList (java.util.ArrayList)97 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)74 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)73 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)52 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)39 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)33 Test (org.junit.Test)32 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)32 BigInteger (java.math.BigInteger)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)20 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)17 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)16 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)15 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)14 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)12 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)12 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)11 ActionDrop (org.opendaylight.genius.mdsalutil.actions.ActionDrop)9