Search in sources :

Example 1 with MatchFromField

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

the class ElanNodeListener method createArpPuntAndLearnFlow.

private void createArpPuntAndLearnFlow(Uint64 dpId, TypedReadWriteTransaction<Configuration> tx) {
    LOG.debug("adding arp punt and learn entry in table {}", NwConstants.ARP_LEARN_TABLE_1);
    List<MatchInfo> matches = new ArrayList<>();
    List<ActionInfo> actions = new ArrayList<>();
    Uint64 cookie = Uint64.valueOf("88880000", 16).intern();
    matches.add(MatchEthernetType.ARP);
    actions.add(new ActionPuntToController());
    if (arpPuntTimeout != 0) {
        actions.add(new ActionLearn(0, arpPuntTimeout, ARP_LEARN_FLOW_PRIORITY, cookie, 0, NwConstants.ARP_LEARN_TABLE_1, 0, 0, Arrays.asList(new MatchFromValue(NwConstants.ETHTYPE_ARP, NxmOfFieldType.NXM_OF_ETH_TYPE.getType(), NxmOfFieldType.NXM_OF_ETH_TYPE.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_ARP_OP.getType(), NxmOfFieldType.NXM_OF_ARP_OP.getType(), NxmOfFieldType.NXM_OF_ARP_OP.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_ARP_TPA.getType(), NxmOfFieldType.NXM_OF_ARP_TPA.getType(), NxmOfFieldType.NXM_OF_ARP_TPA.getFlowModHeaderLenInt()), new ActionLearn.MatchFromField(NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_ELAN_TAG_OFFSET, NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_ELAN_TAG_OFFSET, ElanConstants.ELAN_TAG_LENGTH), new CopyFromValue(1, NxmOfFieldType.NXM_NX_REG4.getType(), 8))));
        actions.add(new ActionLearn(0, arpPuntTimeout, ARP_LEARN_FLOW_PRIORITY, cookie, 0, NwConstants.ARP_LEARN_TABLE_2, 0, 0, Arrays.asList(new MatchFromValue(NwConstants.ETHTYPE_ARP, NxmOfFieldType.NXM_OF_ETH_TYPE.getType(), NxmOfFieldType.NXM_OF_ETH_TYPE.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_ARP_OP.getType(), NxmOfFieldType.NXM_OF_ARP_OP.getType(), NxmOfFieldType.NXM_OF_ARP_OP.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_ARP_TPA.getType(), NxmOfFieldType.NXM_OF_ARP_SPA.getType(), NxmOfFieldType.NXM_OF_ARP_TPA.getFlowModHeaderLenInt()), new ActionLearn.MatchFromField(NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_ELAN_TAG_OFFSET, NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_ELAN_TAG_OFFSET, MetaDataUtil.METADATA_ELAN_TAG_BITLEN), new CopyFromValue(1, NxmOfFieldType.NXM_NX_REG4.getType(), 8, 8))));
    }
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actions));
    String flowid = String.valueOf(NwConstants.ARP_LEARN_TABLE_1) + NwConstants.FLOWID_SEPARATOR + "arp.punt";
    FlowEntity flow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ARP_LEARN_TABLE_1, flowid, NwConstants.TABLE_MISS_PRIORITY, "arp punt/learn flow", 0, 0, cookie, matches, instructions);
    mdsalManager.addFlow(tx, flow);
}
Also used : ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchFromField(org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromField) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) ActionLearn(org.opendaylight.genius.mdsalutil.actions.ActionLearn) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) MatchFromField(org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromField) MatchFromValue(org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromValue) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) CopyFromValue(org.opendaylight.genius.mdsalutil.actions.ActionLearn.CopyFromValue) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 2 with MatchFromField

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

the class ExternalRoutersListener method getLearnActionForPunt.

private ActionLearn getLearnActionForPunt(int protocol, int hardTimeout, Uint64 cookie) {
    long l4SrcPortField;
    long l4DstPortField;
    int l4portFieldLen = NxmOfFieldType.NXM_OF_TCP_SRC.getFlowModHeaderLenInt();
    if (protocol == NwConstants.IP_PROT_TCP) {
        l4SrcPortField = NxmOfFieldType.NXM_OF_TCP_SRC.getType();
        l4DstPortField = NxmOfFieldType.NXM_OF_TCP_DST.getType();
    } else {
        l4SrcPortField = NxmOfFieldType.NXM_OF_UDP_SRC.getType();
        l4DstPortField = NxmOfFieldType.NXM_OF_UDP_DST.getType();
    }
    List<ActionLearn.FlowMod> flowMods = Arrays.asList(new MatchFromValue(NwConstants.ETHTYPE_IPV4, NxmOfFieldType.NXM_OF_ETH_TYPE.getType(), NxmOfFieldType.NXM_OF_ETH_TYPE.getFlowModHeaderLenInt()), new MatchFromValue(protocol, NxmOfFieldType.NXM_OF_IP_PROTO.getType(), NxmOfFieldType.NXM_OF_IP_PROTO.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_IP_SRC.getType(), NxmOfFieldType.NXM_OF_IP_SRC.getType(), NxmOfFieldType.NXM_OF_IP_SRC.getFlowModHeaderLenInt()), new MatchFromField(NxmOfFieldType.NXM_OF_IP_DST.getType(), NxmOfFieldType.NXM_OF_IP_DST.getType(), NxmOfFieldType.NXM_OF_IP_DST.getFlowModHeaderLenInt()), new MatchFromField(l4SrcPortField, l4SrcPortField, l4portFieldLen), new MatchFromField(l4DstPortField, l4DstPortField, l4portFieldLen), new MatchFromField(NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_VPN_ID_OFFSET, NxmOfFieldType.OXM_OF_METADATA.getType(), MetaDataUtil.METADATA_VPN_ID_OFFSET, MetaDataUtil.METADATA_VPN_ID_BITLEN));
    return new ActionLearn(0, hardTimeout, 7, cookie, 0, NwConstants.OUTBOUND_NAPT_TABLE, 0, 0, flowMods);
}
Also used : ActionLearn(org.opendaylight.genius.mdsalutil.actions.ActionLearn) MatchFromField(org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromField) MatchFromValue(org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromValue)

Aggregations

ActionLearn (org.opendaylight.genius.mdsalutil.actions.ActionLearn)2 MatchFromField (org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromField)2 MatchFromValue (org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromValue)2 ArrayList (java.util.ArrayList)1 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)1 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)1 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)1 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)1 CopyFromValue (org.opendaylight.genius.mdsalutil.actions.ActionLearn.CopyFromValue)1 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)1 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)1 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)1