use of org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromValue 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);
}
use of org.opendaylight.genius.mdsalutil.actions.ActionLearn.MatchFromValue 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);
}
Aggregations