b20fa0acff4a5268a8603cd653cf005e975550f7
[netvirt.git] /
1 /*
2  * Copyright (c) 2016 HPE, 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 package org.opendaylight.netvirt.aclservice;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
19 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
20 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
21 import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
22 import org.opendaylight.genius.mdsalutil.ActionInfo;
23 import org.opendaylight.genius.mdsalutil.InstructionInfo;
24 import org.opendaylight.genius.mdsalutil.MDSALUtil;
25 import org.opendaylight.genius.mdsalutil.MatchInfoBase;
26 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
27 import org.opendaylight.genius.mdsalutil.NwConstants;
28 import org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable;
29 import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata;
30 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
31 import org.opendaylight.genius.mdsalutil.matches.MatchArpSha;
32 import org.opendaylight.genius.mdsalutil.matches.MatchEthernetType;
33 import org.opendaylight.genius.utils.ServiceIndex;
34 import org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action;
35 import org.opendaylight.netvirt.aclservice.api.utils.AclInterface;
36 import org.opendaylight.netvirt.aclservice.utils.AclConstants;
37 import org.opendaylight.netvirt.aclservice.utils.AclDataUtil;
38 import org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder;
39 import org.opendaylight.netvirt.aclservice.utils.AclServiceUtils;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.actions.PacketHandling;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.AceType;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
47 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
48 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
56 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
57 import org.slf4j.Logger;
58 import org.slf4j.LoggerFactory;
59
60 /**
61  * Provides abstract implementation for egress (w.r.t VM) ACL service.
62  *
63  * <p>
64  * Note: Table names used are w.r.t switch. Hence, switch ingress is VM egress
65  * and vice versa.
66  */
67 public abstract class AbstractEgressAclServiceImpl extends AbstractAclServiceImpl {
68
69     private static final Logger LOG = LoggerFactory.getLogger(AbstractEgressAclServiceImpl.class);
70
71     /**
72      * Initialize the member variables.
73      *
74      * @param dataBroker the data broker instance.
75      * @param mdsalManager the mdsal manager instance.
76      * @param aclDataUtil
77      *            the acl data util.
78      * @param aclServiceUtils
79      *            the acl service util.
80      */
81     public AbstractEgressAclServiceImpl(DataBroker dataBroker, IMdsalApiManager mdsalManager, AclDataUtil aclDataUtil,
82             AclServiceUtils aclServiceUtils) {
83         // Service mode is w.rt. switch
84         super(ServiceModeIngress.class, dataBroker, mdsalManager, aclDataUtil, aclServiceUtils);
85     }
86
87     /**
88      * Bind service.
89      *
90      * @param aclInterface the acl interface
91      */
92     @Override
93     public void bindService(AclInterface aclInterface) {
94         String interfaceName = aclInterface.getInterfaceId();
95         DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
96         dataStoreCoordinator.enqueueJob(interfaceName,
97             () -> {
98                 int instructionKey = 0;
99                 List<Instruction> instructions = new ArrayList<>();
100                 Long vpnId = aclInterface.getVpnId();
101                 if (vpnId != null) {
102                     instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(MetaDataUtil.getVpnIdMetadata(vpnId),
103                         MetaDataUtil.METADATA_MASK_VRFID, ++instructionKey));
104                 } else {
105                     Long elanTag = aclInterface.getElanId();
106                     instructions.add(
107                         MDSALUtil.buildAndGetWriteMetadaInstruction(MetaDataUtil.getElanTagMetadata(elanTag),
108                         MetaDataUtil.METADATA_MASK_SERVICE, ++instructionKey));
109                 }
110                 instructions.add(
111                         MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.INGRESS_ACL_TABLE, ++instructionKey));
112                 short serviceIndex = ServiceIndex.getIndex(NwConstants.ACL_SERVICE_NAME,
113                         NwConstants.ACL_SERVICE_INDEX);
114                 int flowPriority = AclConstants.EGRESS_ACL_DEFAULT_FLOW_PRIORITY;
115                 BoundServices serviceInfo = AclServiceUtils.getBoundServices(
116                         String.format("%s.%s.%s", "acl", "egressacl", interfaceName), serviceIndex, flowPriority,
117                         AclConstants.COOKIE_ACL_BASE, instructions);
118                 InstanceIdentifier<BoundServices> path =
119                     AclServiceUtils.buildServiceId(interfaceName, serviceIndex, ServiceModeIngress.class);
120
121                 WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
122                 writeTxn.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, true);
123
124                 List<ListenableFuture<Void>> futures = new ArrayList<>();
125                 futures.add(writeTxn.submit());
126                 return futures;
127             });
128     }
129
130     /**
131      * Unbind service.
132      *
133      * @param aclInterface the acl interface
134      */
135     @Override
136     protected void unbindService(AclInterface aclInterface) {
137         String interfaceName = aclInterface.getInterfaceId();
138         InstanceIdentifier<BoundServices> path =
139                 AclServiceUtils.buildServiceId(interfaceName,
140                         ServiceIndex.getIndex(NwConstants.ACL_SERVICE_NAME, NwConstants.ACL_SERVICE_INDEX),
141                         ServiceModeIngress.class);
142
143         DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
144         dataStoreCoordinator.enqueueJob(interfaceName,
145             () -> {
146                 WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
147                 writeTxn.delete(LogicalDatastoreType.CONFIGURATION, path);
148
149                 List<ListenableFuture<Void>> futures = new ArrayList<>();
150                 futures.add(writeTxn.submit());
151                 return futures;
152             });
153     }
154
155     @Override
156     protected void programGeneralFixedRules(BigInteger dpid, String dhcpMacAddress,
157             List<AllowedAddressPairs> allowedAddresses, int lportTag, Action action, int addOrRemove) {
158         LOG.info("programFixedRules :  adding default rules.");
159
160         if (action == Action.ADD || action == Action.REMOVE) {
161             egressAclDhcpAllowClientTraffic(dpid, dhcpMacAddress, lportTag, addOrRemove);
162             egressAclDhcpv6AllowClientTraffic(dpid, dhcpMacAddress, lportTag, addOrRemove);
163             egressAclDhcpDropServerTraffic(dpid, dhcpMacAddress, lportTag, addOrRemove);
164             egressAclDhcpv6DropServerTraffic(dpid, dhcpMacAddress, lportTag, addOrRemove);
165             egressAclIcmpv6DropRouterAdvts(dpid, lportTag, addOrRemove);
166             egressAclIcmpv6AllowedList(dpid, lportTag, addOrRemove);
167
168             programArpRule(dpid, allowedAddresses, lportTag, addOrRemove);
169         }
170     }
171
172     @Override
173     protected void updateArpForAllowedAddressPairs(BigInteger dpId, int lportTag, List<AllowedAddressPairs> deletedAAP,
174             List<AllowedAddressPairs> addedAAP) {
175         Set<MacAddress> deletedAAPmacs =
176                 deletedAAP.stream().map(aap -> aap.getMacAddress()).collect(Collectors.toSet());
177         Set<MacAddress> addedAAPmacs = addedAAP.stream().map(aap -> aap.getMacAddress()).collect(Collectors.toSet());
178
179         // Remove common macs to avoid delete and add of ARP flows having same MAC.
180         deletedAAPmacs.removeAll(addedAAPmacs);
181
182         programArpRule(dpId, deletedAAPmacs, lportTag, NwConstants.DEL_FLOW);
183         programArpRule(dpId, addedAAPmacs, lportTag, NwConstants.ADD_FLOW);
184     }
185
186     @Override
187     protected boolean programAclRules(AclInterface port, List<Uuid> aclUuidList, int addOrRemove) {
188         BigInteger dpId = port.getDpId();
189         LOG.trace("Applying custom rules DpId {}, lportTag {}", dpId, port.getLPortTag());
190         if (aclUuidList == null || dpId == null) {
191             LOG.warn("one of the egress acl parameters can not be null. sg {}, dpId {}",
192                     aclUuidList, dpId);
193             return false;
194         }
195         for (Uuid sgUuid :aclUuidList) {
196             Acl acl = AclServiceUtils.getAcl(dataBroker, sgUuid.getValue());
197             if (null == acl) {
198                 LOG.warn("The ACL is empty");
199                 continue;
200             }
201             AccessListEntries accessListEntries = acl.getAccessListEntries();
202             List<Ace> aceList = accessListEntries.getAce();
203             for (Ace ace: aceList) {
204                 programAceRule(port, addOrRemove, acl.getAclName(), ace, null);
205             }
206         }
207         return true;
208     }
209
210     @Override
211     protected void programAceRule(AclInterface port, int addOrRemove, String aclName, Ace ace,
212             List<AllowedAddressPairs> syncAllowedAddresses) {
213         SecurityRuleAttr aceAttr = AclServiceUtils.getAccesssListAttributes(ace);
214         if (!aceAttr.getDirection().equals(DirectionEgress.class)) {
215             return;
216         }
217         Matches matches = ace.getMatches();
218         AceType aceType = matches.getAceType();
219         Map<String,List<MatchInfoBase>> flowMap = null;
220         if (aceType instanceof AceIp) {
221             flowMap = AclServiceOFFlowBuilder.programIpFlow(matches);
222             if (syncAllowedAddresses != null) {
223                 flowMap = AclServiceUtils.getFlowForAllowedAddresses(syncAllowedAddresses, flowMap, false);
224             } else if (aceAttr.getRemoteGroupId() != null) {
225                 flowMap = aclServiceUtils.getFlowForRemoteAcl(port, aceAttr.getRemoteGroupId(), port.getInterfaceId(),
226                         flowMap, false);
227             }
228         }
229         int lportTag = port.getLPortTag();
230         if (null == flowMap) {
231             LOG.error("Failed to apply ACL {} lportTag {}", ace.getKey(), lportTag);
232             return;
233         }
234         for (String flowName : flowMap.keySet()) {
235             syncSpecificAclFlow(port.getDpId(), lportTag, addOrRemove, ace, port.getInterfaceId(), flowMap, flowName);
236         }
237     }
238
239     @Override
240     protected void updateRemoteAclTableForPort(AclInterface port, Uuid acl, int addOrRemove,
241             AllowedAddressPairs ip, BigInteger aclId, BigInteger dpId) {
242         Long elanTag = port.getElanId();
243         Long vpnId = port.getVpnId();
244         List<MatchInfoBase> flowMatches = new ArrayList<>();
245         flowMatches.addAll(AclServiceUtils.buildIpAndDstServiceMatch(elanTag, ip, dataBroker, vpnId));
246
247         List<InstructionInfo> instructions = new ArrayList<>();
248
249         InstructionWriteMetadata writeMetatdata =
250                 new InstructionWriteMetadata(AclServiceUtils.getAclIdMetadata(aclId),
251                         MetaDataUtil.METADATA_MASK_REMOTE_ACL_ID);
252         instructions.add(writeMetatdata);
253         instructions.add(new InstructionGotoTable(getEgressAclFilterTable()));
254
255         Long serviceTag = vpnId != null ? vpnId : elanTag;
256         String flowNameAdded = "Acl_Filter_Egress_" + new String(ip.getIpAddress().getValue()) + "_" + serviceTag;
257
258         syncFlow(dpId, getEgressAclRemoteAclTable(), flowNameAdded, AclConstants.NO_PRIORITY, "ACL", 0, 0,
259                 AclConstants.COOKIE_ACL_BASE, flowMatches, instructions, addOrRemove);
260     }
261
262     protected short getEgressAclFilterTable() {
263         return NwConstants.INGRESS_ACL_FILTER_TABLE;
264     }
265
266     protected short getEgressAclRemoteAclTable() {
267         return NwConstants.INGRESS_ACL_REMOTE_ACL_TABLE;
268     }
269
270     protected abstract String syncSpecificAclFlow(BigInteger dpId, int lportTag, int addOrRemove, Ace ace,
271             String portId, Map<String, List<MatchInfoBase>> flowMap, String flowName);
272
273     /**
274      * Anti-spoofing rule to block the Ipv4 DHCP server traffic from the port.
275      *
276      * @param dpId the dpId
277      * @param dhcpMacAddress the Dhcp mac address
278      * @param lportTag the lport tag
279      * @param addOrRemove add/remove the flow.
280      */
281     protected void egressAclDhcpDropServerTraffic(BigInteger dpId, String dhcpMacAddress, int lportTag,
282             int addOrRemove) {
283         List<MatchInfoBase> matches = AclServiceUtils.buildDhcpMatches(AclConstants.DHCP_SERVER_PORT_IPV4,
284                 AclConstants.DHCP_CLIENT_PORT_IPV4, lportTag, ServiceModeEgress.class);
285
286         String flowName = "Egress_DHCP_Server_v4" + dpId + "_" + lportTag + "_" + dhcpMacAddress + "_Drop_";
287         syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName,
288                 AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY, "ACL", 0,
289                 0, AclConstants.COOKIE_ACL_BASE, matches, Collections.emptyList(), addOrRemove);
290     }
291
292     /**
293      * Anti-spoofing rule to block the Ipv6 DHCP server traffic from the port.
294      *
295      * @param dpId the dpId
296      * @param dhcpMacAddress the Dhcp mac address
297      * @param lportTag the lport tag
298      * @param addOrRemove add/remove the flow.
299      */
300     protected void egressAclDhcpv6DropServerTraffic(BigInteger dpId, String dhcpMacAddress, int lportTag,
301             int addOrRemove) {
302         List<MatchInfoBase> matches = AclServiceUtils.buildDhcpV6Matches(AclConstants.DHCP_SERVER_PORT_IPV6,
303                 AclConstants.DHCP_CLIENT_PORT_IPV6, lportTag, ServiceModeEgress.class);
304
305         String flowName = "Egress_DHCP_Server_v6" + "_" + dpId + "_" + lportTag + "_" + dhcpMacAddress + "_Drop_";
306         syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName,
307                 AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY, "ACL", 0,
308                 0, AclConstants.COOKIE_ACL_BASE, matches, Collections.emptyList(), addOrRemove);
309     }
310
311     /**
312      * Anti-spoofing rule to block the Ipv6 Router Advts from the VM port.
313      *
314      * @param dpId the dpId
315      * @param lportTag the lport tag
316      * @param addOrRemove add/remove the flow.
317      */
318     private void egressAclIcmpv6DropRouterAdvts(BigInteger dpId, int lportTag, int addOrRemove) {
319         List<MatchInfoBase> matches = AclServiceUtils.buildIcmpV6Matches(AclConstants.ICMPV6_TYPE_RA, 0, lportTag,
320                 ServiceModeEgress.class);
321
322         String flowName = "Egress_ICMPv6" + "_" + dpId + "_" + lportTag + "_" + AclConstants.ICMPV6_TYPE_RA + "_Drop_";
323         syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName, AclConstants.PROTO_IPV6_DROP_PRIORITY, "ACL", 0,
324                 0, AclConstants.COOKIE_ACL_BASE, matches, Collections.emptyList(), addOrRemove);
325     }
326
327     /**
328      * Add rule to allow certain ICMPv6 traffic from VM ports.
329      *
330      * @param dpId the dpId
331      * @param lportTag the lport tag
332      * @param addOrRemove add/remove the flow.
333      */
334     private void egressAclIcmpv6AllowedList(BigInteger dpId, int lportTag, int addOrRemove) {
335         List<ActionInfo> actionsInfos = new ArrayList<>();
336         List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(actionsInfos);
337
338         for (Integer icmpv6Type: AclConstants.allowedIcmpv6NdList()) {
339             List<MatchInfoBase> matches = AclServiceUtils.buildIcmpV6Matches(icmpv6Type, 0, lportTag,
340                     ServiceModeEgress.class);
341             String flowName = "Egress_ICMPv6" + "_" + dpId + "_" + lportTag + "_" + icmpv6Type + "_Permit_";
342             syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName, AclConstants.PROTO_IPV6_ALLOWED_PRIORITY,
343                     "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
344         }
345     }
346
347     /**
348      * Add rule to ensure only DHCP server traffic from the specified mac is
349      * allowed.
350      *
351      * @param dpId the dpid
352      * @param dhcpMacAddress the DHCP server mac address
353      * @param lportTag the lport tag
354      * @param addOrRemove whether to add or remove the flow
355      */
356     private void egressAclDhcpAllowClientTraffic(BigInteger dpId, String dhcpMacAddress, int lportTag,
357             int addOrRemove) {
358         final List<MatchInfoBase> matches = AclServiceUtils.buildDhcpMatches(AclConstants.DHCP_CLIENT_PORT_IPV4,
359                 AclConstants.DHCP_SERVER_PORT_IPV4, lportTag, ServiceModeEgress.class);
360
361         List<ActionInfo> actionsInfos = new ArrayList<>();
362         List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(actionsInfos);
363
364         String flowName = "Egress_DHCP_Client_v4" + dpId + "_" + lportTag + "_" + dhcpMacAddress + "_Permit_";
365         syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName, AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY,
366             "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
367     }
368
369     /**
370      * Add rule to ensure only DHCPv6 server traffic from the specified mac is
371      * allowed.
372      *
373      * @param dpId the dpid
374      * @param dhcpMacAddress the DHCP server mac address
375      * @param lportTag the lport tag
376      * @param addOrRemove whether to add or remove the flow
377      */
378     private void egressAclDhcpv6AllowClientTraffic(BigInteger dpId, String dhcpMacAddress, int lportTag,
379             int addOrRemove) {
380         final List<MatchInfoBase> matches = AclServiceUtils.buildDhcpV6Matches(AclConstants.DHCP_CLIENT_PORT_IPV6,
381                 AclConstants.DHCP_SERVER_PORT_IPV6, lportTag, ServiceModeEgress.class);
382
383         List<ActionInfo> actionsInfos = new ArrayList<>();
384         List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(actionsInfos);
385
386         String flowName = "Egress_DHCP_Client_v6" + "_" + dpId + "_" + lportTag + "_" + dhcpMacAddress + "_Permit_";
387         syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName, AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY,
388             "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
389     }
390
391     /**
392      * Program arp rule.
393      *
394      * @param dpId the dp id
395      * @param allowedAddresses the allowed addresses
396      * @param lportTag the lport tag
397      * @param addOrRemove whether to add or remove the flow
398      */
399     protected void programArpRule(BigInteger dpId, List<AllowedAddressPairs> allowedAddresses, int lportTag,
400             int addOrRemove) {
401         // Collecting macs as a set to avoid duplicate
402         Set<MacAddress> macs = allowedAddresses.stream().map(aap -> aap.getMacAddress()).collect(Collectors.toSet());
403         programArpRule(dpId, macs, lportTag, addOrRemove);
404     }
405
406     /**
407      * Adds the rule to allow arp packets.
408      *
409      * @param dpId the dpId
410      * @param macs the set of MACs
411      * @param lportTag the lport tag
412      * @param addOrRemove whether to add or remove the flow
413      */
414     protected void programArpRule(BigInteger dpId, Set<MacAddress> macs, int lportTag, int addOrRemove) {
415         for (MacAddress mac : macs) {
416             List<MatchInfoBase> matches = new ArrayList<>();
417             matches.add(MatchEthernetType.ARP);
418             matches.add(new MatchArpSha(mac));
419             matches.add(buildLPortTagMatch(lportTag));
420
421             List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(new ArrayList<>());
422
423             String flowName = "Egress_ARP_" + dpId + "_" + lportTag + "_" + mac.getValue();
424             syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName,
425                     AclConstants.PROTO_ARP_TRAFFIC_MATCH_PRIORITY, "ACL", 0, 0,
426                     AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
427         }
428     }
429
430     protected MatchInfoBase buildLPortTagMatch(int lportTag) {
431         return AclServiceUtils.buildLPortTagMatch(lportTag, ServiceModeEgress.class);
432     }
433
434     protected int getEgressSpecificAclFlowPriority(BigInteger dpId, int addOrRemove, String flowName,
435                                                  PacketHandling packetHandling) {
436         int priority;
437         if (addOrRemove == NwConstants.DEL_FLOW) {
438             priority = aclServiceUtils.releaseAndRemoveFlowPriorityFromCache(dpId, NwConstants.INGRESS_ACL_FILTER_TABLE,
439                     flowName, packetHandling);
440         } else {
441             priority = aclServiceUtils.allocateAndSaveFlowPriorityInCache(dpId, NwConstants.INGRESS_ACL_FILTER_TABLE,
442                     flowName, packetHandling);
443         }
444         return priority;
445     }
446 }