693104d76de6219a7f9c6ca6ec145b69b571c7aa
[netvirt.git] / openstack / net-virt-sfc / impl / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / sfc / workaround / services / SfcClassifierService.java
1 /*
2  * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services;
10
11 import com.google.common.collect.Lists;
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.List;
15 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
16 import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
17 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
18 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
19 import org.opendaylight.ovsdb.openstack.netvirt.sfc.ISfcClassifierService;
20 import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
21 import org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils;
22 import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
23 import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
24 import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.Matches;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
48 import org.osgi.framework.BundleContext;
49 import org.osgi.framework.ServiceReference;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52
53 public class SfcClassifierService extends AbstractServiceInstance implements ConfigInterface, ISfcClassifierService {
54     private static final Logger LOG = LoggerFactory.getLogger(SfcClassifierService.class);
55     private static final short TABLE_0 = 0;
56     private static final short UDP_SHORT = 17;
57
58     public SfcClassifierService(Service service) {
59         super(service);
60     }
61
62     public SfcClassifierService() {
63         super(Service.SFC_CLASSIFIER);
64     }
65
66     @Override
67     public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
68         super.setDependencies(bundleContext.getServiceReference(ISfcClassifierService.class.getName()), this);
69     }
70
71     @Override
72     public void setDependencies(Object impl) {}
73
74     @Override
75     public void programIngressClassifier(long dataPathId, String ruleName, Matches matches,
76                                          NshUtils nshHeader, long vxGpeOfPort, boolean write) {
77         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
78         FlowBuilder flowBuilder = new FlowBuilder();
79
80         MatchBuilder matchBuilder = buildMatch(matches);
81         //flowBuilder.setMatch(matchBuilder.build());
82         flowBuilder.setMatch(MatchUtils.addNxRegMatch(
83                 matchBuilder,
84                 new MatchUtils.RegMatch(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL)).build());
85
86         String flowId = "sfcIngressClass_" + ruleName;// + "_" + nshHeader.getNshNsp();
87         flowBuilder.setId(new FlowId(flowId));
88         FlowKey key = new FlowKey(new FlowId(flowId));
89         flowBuilder.setBarrier(true);
90         flowBuilder.setTableId(getTable());
91         flowBuilder.setKey(key);
92         flowBuilder.setFlowName(flowId);
93         flowBuilder.setHardTimeout(0);
94         flowBuilder.setIdleTimeout(0);
95
96         if (write) {
97             ActionBuilder ab = new ActionBuilder();
98             List<Action> actionList = new ArrayList<>();
99
100             ab.setAction(ActionUtils.nxMoveTunIdtoNshc2());
101             ab.setOrder(actionList.size());
102             ab.setKey(new ActionKey(actionList.size()));
103             actionList.add(ab.build());
104
105             getNshAction(nshHeader, actionList);
106
107             ab.setAction(ActionUtils.outputAction(FlowUtils.getNodeConnectorId(dataPathId, vxGpeOfPort)));
108             ab.setOrder(actionList.size());
109             ab.setKey(new ActionKey(actionList.size()));
110             actionList.add(ab.build());
111
112             ApplyActionsBuilder aab = new ApplyActionsBuilder();
113             aab.setAction(actionList);
114
115             InstructionBuilder ib = new InstructionBuilder();
116             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
117             ib.setOrder(0);
118             ib.setKey(new InstructionKey(0));
119             List<Instruction> instructions = Lists.newArrayList();
120             instructions.add(ib.build());
121
122             InstructionsBuilder isb = new InstructionsBuilder();
123             isb.setInstruction(instructions);
124             flowBuilder.setInstructions(isb.build());
125             writeFlow(flowBuilder, nodeBuilder);
126         } else {
127             removeFlow(flowBuilder, nodeBuilder);
128         }
129     }
130
131     @Override
132     public void programSfcTable(long dataPathId, long vxGpeOfPort, short goToTableId, boolean write) {
133         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
134         FlowBuilder flowBuilder = new FlowBuilder();
135
136         MatchBuilder matchBuilder = new MatchBuilder();
137         flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort).build());
138
139         String flowId = "sfcTable_" + vxGpeOfPort;
140         flowBuilder.setId(new FlowId(flowId));
141         FlowKey key = new FlowKey(new FlowId(flowId));
142         flowBuilder.setBarrier(true);
143         flowBuilder.setTableId(TABLE_0);
144         flowBuilder.setKey(key);
145         flowBuilder.setFlowName(flowId);
146         flowBuilder.setHardTimeout(0);
147         flowBuilder.setIdleTimeout(0);
148         flowBuilder.setPriority(1000);
149
150         if (write) {
151             InstructionsBuilder isb = new InstructionsBuilder();
152             List<Instruction> instructions = Lists.newArrayList();
153             InstructionBuilder ib =
154                     InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), goToTableId);
155             ib.setOrder(0);
156             ib.setKey(new InstructionKey(0));
157             instructions.add(ib.build());
158
159             isb.setInstruction(instructions);
160             flowBuilder.setInstructions(isb.build());
161             writeFlow(flowBuilder, nodeBuilder);
162         } else {
163             removeFlow(flowBuilder, nodeBuilder);
164         }
165     }
166
167     @Override
168     public void programEgressClassifier1(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
169                                          int tunnelOfPort, int tunnelId, short gotoTableId, boolean write) {
170         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
171         FlowBuilder flowBuilder = new FlowBuilder();
172
173         MatchBuilder matchBuilder = new MatchBuilder();
174         MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort);
175         MatchUtils.addNxNspMatch(matchBuilder, nsp);
176         flowBuilder.setMatch(MatchUtils.addNxNsiMatch(matchBuilder, nsi).build());
177
178         String flowId = "sfcEgressClass1_" + vxGpeOfPort;
179         flowBuilder.setId(new FlowId(flowId));
180         FlowKey key = new FlowKey(new FlowId(flowId));
181         flowBuilder.setBarrier(true);
182         flowBuilder.setTableId(TABLE_0);
183         flowBuilder.setKey(key);
184         flowBuilder.setFlowName(flowId);
185         flowBuilder.setHardTimeout(0);
186         flowBuilder.setIdleTimeout(0);
187
188         if (write) {
189             InstructionsBuilder isb = new InstructionsBuilder();
190             List<Instruction> instructions = Lists.newArrayList();
191             InstructionBuilder ib = new InstructionBuilder();
192
193             /*List<Action> actionList = Lists.newArrayList();
194
195             ActionBuilder ab = new ActionBuilder();
196             ab.setAction(ActionUtils.nxMoveNshc2ToTunId());
197             ab.setOrder(0);
198             ab.setKey(new ActionKey(0));
199             actionList.add(ab.build());
200
201             ApplyActionsBuilder aab = new ApplyActionsBuilder();
202             aab.setAction(actionList);
203             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
204
205             ib.setOrder(instructions.size());
206             ib.setKey(new InstructionKey(instructions.size()));
207             instructions.add(ib.build());*/
208
209             ib = InstructionUtils.createGotoTableInstructions(new InstructionBuilder(), getTable());
210             ib.setOrder(instructions.size());
211             ib.setKey(new InstructionKey(instructions.size()));
212             instructions.add(ib.build());
213
214             isb.setInstruction(instructions);
215             flowBuilder.setInstructions(isb.build());
216             writeFlow(flowBuilder, nodeBuilder);
217         } else {
218             removeFlow(flowBuilder, nodeBuilder);
219         }
220     }
221
222     @Override
223     public void programEgressClassifier2(long dataPathId, long vxGpeOfPort, long nsp, short nsi,
224                                          int tunnelOfPort, int tunnelId, boolean write) {
225         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
226         FlowBuilder flowBuilder = new FlowBuilder();
227
228         MatchBuilder matchBuilder = new MatchBuilder();
229         MatchUtils.createInPortMatch(matchBuilder, dataPathId, vxGpeOfPort);
230         MatchUtils.addNxNspMatch(matchBuilder, nsp);
231         flowBuilder.setMatch(MatchUtils.addNxNsiMatch(matchBuilder, nsi).build());
232
233         String flowId = "sfcEgressClass2_" + vxGpeOfPort;
234         flowBuilder.setId(new FlowId(flowId));
235         FlowKey key = new FlowKey(new FlowId(flowId));
236         flowBuilder.setBarrier(true);
237         flowBuilder.setTableId(getTable());
238         flowBuilder.setKey(key);
239         flowBuilder.setFlowName(flowId);
240         flowBuilder.setHardTimeout(0);
241         flowBuilder.setIdleTimeout(0);
242
243         if (write) {
244             InstructionsBuilder isb = new InstructionsBuilder();
245             List<Instruction> instructions = Lists.newArrayList();
246             List<Action> actionList = Lists.newArrayList();
247
248             ActionBuilder ab = new ActionBuilder();
249             ab.setAction(ActionUtils.nxResubmitAction(tunnelOfPort, TABLE_0));
250             ab.setOrder(0);
251             ab.setKey(new ActionKey(0));
252             actionList.add(ab.build());
253
254             ApplyActionsBuilder aab = new ApplyActionsBuilder();
255             aab.setAction(actionList);
256             InstructionBuilder ib = new InstructionBuilder();
257             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
258
259             ib.setOrder(0);
260             ib.setKey(new InstructionKey(0));
261             instructions.add(ib.build());
262
263             isb.setInstruction(instructions);
264             flowBuilder.setInstructions(isb.build());
265             writeFlow(flowBuilder, nodeBuilder);
266
267         } else {
268             removeFlow(flowBuilder, nodeBuilder);
269         }
270     }
271
272     // packet from sf to sff that need to go out local
273     @Override
274     public void program_sfEgress(long dataPathId, int dstPort, boolean write) {
275         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
276         FlowBuilder flowBuilder = new FlowBuilder();
277
278         MatchBuilder matchBuilder = new MatchBuilder();
279         MatchUtils.createIpProtocolMatch(matchBuilder, UDP_SHORT);
280         MatchUtils.addLayer4Match(matchBuilder, UDP_SHORT, 0, dstPort);
281         flowBuilder.setMatch(MatchUtils.addNxRegMatch(
282                 matchBuilder, new MatchUtils.RegMatch(FlowUtils.REG_FIELD, FlowUtils.REG_VALUE_FROM_LOCAL)).build());
283
284         String flowId = "sfEgress_" + dstPort;
285         flowBuilder.setId(new FlowId(flowId));
286         FlowKey key = new FlowKey(new FlowId(flowId));
287         flowBuilder.setBarrier(true);
288         flowBuilder.setTableId(getTable());
289         flowBuilder.setKey(key);
290         flowBuilder.setFlowName(flowId);
291         flowBuilder.setHardTimeout(0);
292         flowBuilder.setIdleTimeout(0);
293
294         if (write) {
295             InstructionBuilder ib = new InstructionBuilder();
296             InstructionsBuilder isb = new InstructionsBuilder();
297             List<Instruction> instructions = Lists.newArrayList();
298             InstructionUtils.createLocalInstructions(ib, dataPathId);
299             ib.setOrder(0);
300             ib.setKey(new InstructionKey(0));
301             instructions.add(ib.build());
302
303             isb.setInstruction(instructions);
304             flowBuilder.setInstructions(isb.build());
305             writeFlow(flowBuilder, nodeBuilder);
306         } else {
307             removeFlow(flowBuilder, nodeBuilder);
308         }
309     }
310
311     // looped back sff to sf packets
312     @Override
313     public void program_sfIngress(long dataPathId, int dstPort, long sfOfPort,
314                                   String ipAddress, String sfDplName, boolean write) {
315         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
316         FlowBuilder flowBuilder = new FlowBuilder();
317
318         MatchBuilder matchBuilder = new MatchBuilder();
319         MatchUtils.createIpProtocolMatch(matchBuilder, UDP_SHORT);
320         Ipv4Prefix ipCidr = MatchUtils.iPv4PrefixFromIPv4Address(ipAddress);
321         MatchUtils.createDstL3IPv4Match(matchBuilder, new Ipv4Prefix(ipCidr));
322         flowBuilder.setMatch(MatchUtils.addLayer4Match(matchBuilder, UDP_SHORT, 0, dstPort).build());
323
324         String flowId = "sfIngress_" + dstPort + "_" + ipAddress;
325         flowBuilder.setId(new FlowId(flowId));
326         FlowKey key = new FlowKey(new FlowId(flowId));
327         flowBuilder.setBarrier(true);
328         flowBuilder.setTableId(TABLE_0);
329         flowBuilder.setKey(key);
330         flowBuilder.setFlowName(flowId);
331         flowBuilder.setHardTimeout(0);
332         flowBuilder.setIdleTimeout(0);
333
334         if (write) {
335             InstructionBuilder ib = new InstructionBuilder();
336             InstructionsBuilder isb = new InstructionsBuilder();
337             List<Instruction> instructions = Lists.newArrayList();
338             InstructionUtils.createOutputPortInstructions(ib, dataPathId, sfOfPort);
339
340             ib.setOrder(0);
341             ib.setKey(new InstructionKey(0));
342             instructions.add(ib.build());
343
344             isb.setInstruction(instructions);
345             flowBuilder.setInstructions(isb.build());
346             writeFlow(flowBuilder, nodeBuilder);
347         } else {
348             removeFlow(flowBuilder, nodeBuilder);
349         }
350     }
351
352     @Override
353     public void programStaticArpEntry(long dataPathId, long ofPort, String macAddressStr,
354                                       String ipAddress, boolean write) {
355         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dataPathId);
356         FlowBuilder flowBuilder = new FlowBuilder();
357
358         MacAddress macAddress = new MacAddress(macAddressStr);
359
360         MatchBuilder matchBuilder = new MatchBuilder();
361         MatchUtils.createEtherTypeMatch(matchBuilder, new EtherType(Constants.ARP_ETHERTYPE));
362         MatchUtils.createArpDstIpv4Match(matchBuilder, MatchUtils.iPv4PrefixFromIPv4Address(ipAddress));
363         flowBuilder.setMatch(matchBuilder.build());
364
365         String flowId = "ArpResponder_" + ipAddress;
366         flowBuilder.setId(new FlowId(flowId));
367         FlowKey key = new FlowKey(new FlowId(flowId));
368         flowBuilder.setBarrier(true);
369         flowBuilder.setTableId(TABLE_0);
370         flowBuilder.setKey(key);
371         flowBuilder.setPriority(1024);
372         flowBuilder.setFlowName(flowId);
373         flowBuilder.setHardTimeout(0);
374         flowBuilder.setIdleTimeout(0);
375
376         if (write == true) {
377             InstructionBuilder ib = new InstructionBuilder();
378             InstructionsBuilder isb = new InstructionsBuilder();
379             List<Instruction> instructions = Lists.newArrayList();
380             ApplyActionsBuilder aab = new ApplyActionsBuilder();
381             ActionBuilder ab = new ActionBuilder();
382             List<Action> actionList = Lists.newArrayList();
383
384             // Move Eth Src to Eth Dst
385             ab.setAction(ActionUtils.nxMoveEthSrcToEthDstAction());
386             ab.setOrder(0);
387             ab.setKey(new ActionKey(0));
388             actionList.add(ab.build());
389
390             // Set Eth Src
391             ab.setAction(ActionUtils.setDlSrcAction(new MacAddress(macAddress)));
392             ab.setOrder(1);
393             ab.setKey(new ActionKey(1));
394             actionList.add(ab.build());
395
396             // Set ARP OP
397             ab.setAction(ActionUtils.nxLoadArpOpAction(BigInteger.valueOf(0x02L)));
398             ab.setOrder(2);
399             ab.setKey(new ActionKey(2));
400             actionList.add(ab.build());
401
402             // Move ARP SHA to ARP THA
403             ab.setAction(ActionUtils.nxMoveArpShaToArpThaAction());
404             ab.setOrder(3);
405             ab.setKey(new ActionKey(3));
406             actionList.add(ab.build());
407
408             // Move ARP SPA to ARP TPA
409             ab.setAction(ActionUtils.nxMoveArpSpaToArpTpaAction());
410             ab.setOrder(4);
411             ab.setKey(new ActionKey(4));
412             actionList.add(ab.build());
413
414             // Load Mac to ARP SHA
415             ab.setAction(ActionUtils.nxLoadArpShaAction(macAddress));
416             ab.setOrder(5);
417             ab.setKey(new ActionKey(5));
418             actionList.add(ab.build());
419
420             // Load IP to ARP SPA
421             ab.setAction(ActionUtils.nxLoadArpSpaAction(ipAddress));
422             ab.setOrder(6);
423             ab.setKey(new ActionKey(6));
424             actionList.add(ab.build());
425
426             // Output of InPort
427             ab.setAction(ActionUtils.outputAction(
428                     FlowUtils.getSpecialNodeConnectorId(dataPathId, OutputPortValues.INPORT.toString())));
429             ab.setOrder(7);
430             ab.setKey(new ActionKey(7));
431             actionList.add(ab.build());
432
433             // Create Apply Actions Instruction
434             aab.setAction(actionList);
435             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
436             ib.setOrder(0);
437             ib.setKey(new InstructionKey(0));
438             instructions.add(ib.build());
439
440             isb.setInstruction(instructions);
441             flowBuilder.setInstructions(isb.build());
442             writeFlow(flowBuilder, nodeBuilder);
443         } else {
444             removeFlow(flowBuilder, nodeBuilder);
445         }
446     }
447
448     private List<Action> getNshAction(NshUtils header, List<Action> actionList) {
449         // Build the Actions to Add the NSH Header
450         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC1Load =
451                 ActionUtils.nxLoadNshc1RegAction(header.getNshMetaC1());
452         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nshC2Load =
453                 ActionUtils.nxLoadNshc2RegAction(header.getNshMetaC2());
454         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nspLoad =
455                 ActionUtils.nxSetNspAction(header.getNshNsp());
456         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nsiLoad =
457                 ActionUtils.nxSetNsiAction(header.getNshNsi());
458         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunVnid =
459                 ActionUtils.nxLoadTunIdAction(BigInteger.valueOf(header.getNshNsp()), false);
460         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action loadChainTunDest =
461                 ActionUtils.nxLoadTunIPv4Action(header.getNshTunIpDst().getValue(), false);
462
463         int count = actionList.size();
464         actionList.add(new ActionBuilder()
465                 .setKey(new ActionKey(count)).setOrder(count++).setAction(nshC1Load).build());
466         //actionList.add(new ActionBuilder()
467         // .setKey(new ActionKey(count)).setOrder(count++).setAction(nshC2Load).build());
468         actionList.add(new ActionBuilder()
469                 .setKey(new ActionKey(count)).setOrder(count++).setAction(nspLoad).build());
470         actionList.add(new ActionBuilder()
471                 .setKey(new ActionKey(count)).setOrder(count++).setAction(nsiLoad).build());
472         actionList.add(new ActionBuilder()
473                 .setKey(new ActionKey(count)).setOrder(count++).setAction(loadChainTunDest).build());
474         actionList.add(new ActionBuilder()
475                 .setKey(new ActionKey(count)).setOrder(count).setAction(loadChainTunVnid).build());
476         return actionList;
477     }
478
479     public MatchBuilder buildMatch(Matches matches) {
480         MatchBuilder matchBuilder = new MatchBuilder();
481
482         if (matches.getAceType() instanceof AceIp) {
483             AceIp aceIp = (AceIp)matches.getAceType();
484             if (aceIp.getAceIpVersion() instanceof AceIpv4) {
485                 //AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
486                 //MatchUtils.createSrcL3IPv4Match(matchBuilder, aceIpv4.getSourceIpv4Network());
487                 //MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Network());
488                 MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
489                 MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
490                         aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
491             } else {
492                 MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol());
493                 MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0,
494                         aceIp.getDestinationPortRange().getLowerPort().getValue().intValue());
495             }
496         } else if (matches.getAceType() instanceof AceEth) {
497             AceEth aceEth = (AceEth) matches.getAceType();
498             MatchUtils.createEthSrcMatch(matchBuilder, new MacAddress(aceEth.getSourceMacAddress().getValue()));
499             MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(aceEth.getDestinationMacAddress().getValue()),
500                     new MacAddress(aceEth.getDestinationMacAddressMask().getValue()));
501         }
502
503         LOG.info("buildMatch: {}", matchBuilder.build());
504         return matchBuilder;
505     }
506 }