Search in sources :

Example 1 with BucketInfo

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

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

the class ExternalNetworkGroupInstaller method buildExtNetGroupEntity.

private GroupEntity buildExtNetGroupEntity(String macAddress, String subnetName, long groupId, String extInterface, BigInteger dpnId) {
    List<ActionInfo> actionList = new ArrayList<>();
    final int setFieldEthDestActionPos = 0;
    List<ActionInfo> egressActionList = new ArrayList<>();
    if (extInterface != null) {
        egressActionList = NatUtil.getEgressActionsForInterface(interfaceManager, extInterface, null, setFieldEthDestActionPos + 1);
    }
    if (Strings.isNullOrEmpty(macAddress) || egressActionList.isEmpty()) {
        if (Strings.isNullOrEmpty(macAddress)) {
            LOG.trace("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "GW mac has not been resolved for subnet {} extInterface {}", groupId, subnetName, extInterface);
        } else {
            LOG.warn("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "no egress actions were found for subnet {} extInterface {}", groupId, subnetName, extInterface);
        }
        actionList.add(new ActionDrop());
    } else {
        LOG.trace("Building ext-net group {} entry for subnet {} extInterface {} macAddress {}", groupId, subnetName, extInterface, macAddress);
        actionList.add(new ActionSetFieldEthernetDestination(setFieldEthDestActionPos, new MacAddress(macAddress)));
        actionList.addAll(egressActionList);
    }
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    listBucketInfo.add(new BucketInfo(actionList));
    return MDSALUtil.buildGroupEntity(dpnId, groupId, subnetName, GroupTypes.GroupAll, listBucketInfo);
}
Also used : ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop)

Example 3 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo 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 4 with BucketInfo

use of org.opendaylight.genius.mdsalutil.BucketInfo 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 5 with BucketInfo

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

the class NatTunnelInterfaceStateListener method hndlTepAddOnNonNaptSwitch.

private boolean hndlTepAddOnNonNaptSwitch(BigInteger srcDpnId, BigInteger primaryDpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, String routerName, long routerId, Uuid vpnName, WriteTransaction writeFlowInvTx) {
    /*
        1) Install default NAT rule from table 21 to 26
        2) Install the group which forward packet to the tunnel port for the NAPT switch.
        3) Install the flow 26 which forwards the packet to the group.
        */
    LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Processing TEP add for the DPN {} having the router {} since " + "its THE NON NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} " + "and TUNNEL NAME {} ", srcDpnId, routerName, tunnelType, srcTepIp, destTepIp, tunnelName);
    LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Install default NAT rule from table 21 to 26");
    Long vpnId;
    if (vpnName == null) {
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Internal VPN associated to router {}", routerId);
        vpnId = routerId;
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid Internal VPN ID returned for routerName {}", routerId);
            return false;
        }
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerName);
        // Install default entry in FIB to SNAT table
        LOG.debug("hndlTepAddOnNonNaptSwitch : Installing default route in FIB on DPN {} for router {} with" + " vpn {}...", srcDpnId, routerName, vpnId);
        defaultRouteProgrammer.installDefNATRouteInDPN(srcDpnId, vpnId, writeFlowInvTx);
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Install the group which forward packet to the tunnel port " + "for the NAPT switch {} and the flow 26 which forwards to group", primaryDpnId);
        externalRouterListner.handleSwitches(srcDpnId, routerName, routerId, primaryDpnId);
    } else {
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> External BGP VPN (Private BGP) associated to router {}", routerId);
        vpnId = NatUtil.getVpnId(dataBroker, vpnName.getValue());
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid Private BGP VPN ID returned for routerName {}", routerId);
            return false;
        }
        if (routerId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid routId returned for routerName {}", routerId);
            return false;
        }
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerId);
        // Install default entry in FIB to SNAT table
        LOG.debug("hndlTepAddOnNonNaptSwitch : Installing default route in FIB on dpn {} for routerId {} " + "with vpnId {}...", srcDpnId, routerId, vpnId);
        defaultRouteProgrammer.installDefNATRouteInDPN(srcDpnId, vpnId, routerId, writeFlowInvTx);
        LOG.debug("hndlTepAddOnNonNaptSwitch : Install group in non NAPT switch {} for router {}", srcDpnId, routerName);
        List<BucketInfo> bucketInfoForNonNaptSwitches = externalRouterListner.getBucketInfoForNonNaptSwitches(srcDpnId, primaryDpnId, routerName, routerId);
        long groupId = externalRouterListner.installGroup(srcDpnId, routerName, bucketInfoForNonNaptSwitches);
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> in the SNAT miss entry pointing to group {} " + "in the non NAPT switch {}", groupId, srcDpnId);
        FlowEntity flowEntity = externalRouterListner.buildSnatFlowEntityWithUpdatedVpnId(srcDpnId, routerName, groupId, vpnId);
        mdsalManager.addFlowToTx(flowEntity, writeFlowInvTx);
    }
    return true;
}
Also used : BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Aggregations

BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)19 ArrayList (java.util.ArrayList)14 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)13 BigInteger (java.math.BigInteger)7 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)5 GroupEntity (org.opendaylight.genius.mdsalutil.GroupEntity)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)3 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)3 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)3 ActionOutput (org.opendaylight.genius.mdsalutil.actions.ActionOutput)3 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)3 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)3 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)3 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)2 ActionPushVlan (org.opendaylight.genius.mdsalutil.actions.ActionPushVlan)2 ActionSetFieldEthernetSource (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource)2 ActionSetFieldVlanVid (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid)2 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)2