Ensure External Connectivity for NAPT Switch
[netvirt.git] / natservice / impl / src / main / java / org / opendaylight / netvirt / natservice / internal / ConntrackBasedSnatService.java
1 /*
2  * Copyright (c) 2017 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 package org.opendaylight.netvirt.natservice.internal;
9
10 import com.google.common.base.Optional;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.concurrent.ExecutionException;
15 import org.apache.commons.lang3.tuple.ImmutablePair;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
18 import org.opendaylight.genius.infra.Datastore.Configuration;
19 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
20 import org.opendaylight.genius.infra.TypedWriteTransaction;
21 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
22 import org.opendaylight.genius.mdsalutil.ActionInfo;
23 import org.opendaylight.genius.mdsalutil.InstructionInfo;
24 import org.opendaylight.genius.mdsalutil.MatchInfo;
25 import org.opendaylight.genius.mdsalutil.MatchInfoBase;
26 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
27 import org.opendaylight.genius.mdsalutil.NWUtil;
28 import org.opendaylight.genius.mdsalutil.NwConstants;
29 import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack;
30 import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction;
31 import org.opendaylight.genius.mdsalutil.actions.ActionNxCtClear;
32 import org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort;
33 import org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata;
34 import org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit;
35 import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource;
36 import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
37 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
38 import org.opendaylight.genius.mdsalutil.matches.MatchEthernetType;
39 import org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination;
40 import org.opendaylight.genius.mdsalutil.matches.MatchMetadata;
41 import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState;
42 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
43 import org.opendaylight.netvirt.natservice.ha.NatDataUtil;
44 import org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddressBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatFlags;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatRangePresent;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58
59 public abstract class ConntrackBasedSnatService extends AbstractSnatService {
60     private static final Logger LOG = LoggerFactory.getLogger(ConntrackBasedSnatService.class);
61
62     protected static final int TRACKED_NEW_CT_STATE = 0x21;
63     protected static final int TRACKED_NEW_CT_MASK = 0x21;
64     protected static final int SNAT_CT_STATE = 0x40;
65     protected static final int SNAT_CT_STATE_MASK = 0x40;
66     protected static final int DNAT_CT_STATE = 0x80;
67     protected static final int DNAT_CT_STATE_MASK = 0x80;
68
69     public ConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager, ItmRpcService itmManager,
70                                      IdManagerService idManager, NAPTSwitchSelector naptSwitchSelector,
71                                      OdlInterfaceRpcService odlInterfaceRpcService,
72                                      IInterfaceManager interfaceManager, IVpnFootprintService vpnFootprintService,
73                                      IFibManager fibManager, NatDataUtil natDataUtil,
74                                      DataTreeEventCallbackRegistrar eventCallbacks) {
75         super(dataBroker, mdsalManager, itmManager, odlInterfaceRpcService, idManager, naptSwitchSelector,
76                 interfaceManager, vpnFootprintService, fibManager, natDataUtil, eventCallbacks);
77     }
78
79     @Override
80     protected void addSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
81         Routers routers, BigInteger dpnId) {
82         LOG.info("installSnatSpecificEntriesForNaptSwitch: called for router {}",
83             routers.getRouterName());
84         String routerName = routers.getRouterName();
85         Long routerId = NatUtil.getVpnId(confTx, routerName);
86         int elanId = NatUtil.getElanInstanceByName(confTx, routers.getNetworkId().getValue())
87             .getElanTag().intValue();
88         if (routerId == NatConstants.INVALID_ID) {
89             LOG.error("InvalidRouterId: unable to installSnatSpecificEntriesForNaptSwitch on dpn {}", dpnId);
90             return;
91         }
92         /* Install Outbound NAT entries */
93
94         addSnatMissEntryForPrimrySwch(confTx, dpnId, routerId, elanId);
95
96         String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterName(confTx, routerName);
97         addOutboundTblTrackEntry(confTx, dpnId, routerId, extGwMacAddress);
98         for (ExternalIps externalIp : routers.getExternalIps()) {
99             if (!NWUtil.isIpv4Address(externalIp.getIpAddress())) {
100                 // In this class we handle only IPv4 use-cases.
101                 continue;
102             }
103             //The logic now handle only one external IP per router, others if present will be ignored.
104             long extSubnetId = NatUtil.getExternalSubnetVpnId(confTx, externalIp.getSubnetId());
105             addOutboundTblEntry(confTx, dpnId, routerId, externalIp.getIpAddress(), elanId, extGwMacAddress);
106             addNaptPfibFlow(confTx, routers, dpnId, routerId, extSubnetId);
107
108             //Install Inbound NAT entries
109             addInboundEntry(confTx, dpnId, routerId, externalIp.getIpAddress(), elanId, extSubnetId);
110             addNaptPfibEntry(confTx, dpnId, routerId);
111
112             String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp.getIpAddress());
113             Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(confTx, externalIp.getSubnetId());
114             if (externalSubnet.isPresent()) {
115                 String externalVpn =  externalIp.getSubnetId().getValue();
116                 String vpnRd = NatUtil.getVpnRd(confTx, externalVpn);
117                 vpnFootprintService.updateVpnToDpnMapping(dpnId, externalVpn, vpnRd, null /* interfaceName*/,
118                     new ImmutablePair<>(IpAddresses.IpAddressSource.ExternalFixedIP, fibExternalIp),
119                     true);
120             }
121             break;
122         }
123     }
124
125     @Override
126     protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
127             Routers routers, BigInteger dpnId) throws ExecutionException, InterruptedException {
128         LOG.info("installSnatSpecificEntriesForNaptSwitch: called for router {}",
129             routers.getRouterName());
130         String routerName = routers.getRouterName();
131         Long routerId = NatUtil.getVpnId(confTx, routerName);
132         if (routerId == NatConstants.INVALID_ID) {
133             LOG.error("InvalidRouterId: unable to installSnatSpecificEntriesForNaptSwitch on dpn {}", dpnId);
134             return;
135         }
136         /* Remove Outbound NAT entries */
137
138         removeSnatMissEntryForPrimrySwch(confTx, dpnId, routerId);
139
140         removeOutboundTblTrackEntry(confTx, dpnId, routerId);
141         for (ExternalIps externalIp : routers.getExternalIps()) {
142             if (!NWUtil.isIpv4Address(externalIp.getIpAddress())) {
143                 // In this class we handle only IPv4 use-cases.
144                 continue;
145             }
146             //The logic now handle only one external IP per router, others if present will be ignored.
147             removeOutboundTblEntry(confTx, dpnId, routerId);
148             removeNaptPfibFlow(confTx, routers, dpnId, routerId);
149
150             //Install Inbound NAT entries
151             removeInboundEntry(confTx, dpnId, routerId);
152             removeNaptPfibEntry(confTx, dpnId, routerId);
153
154             String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp.getIpAddress());
155             Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(confTx, externalIp.getSubnetId());
156             if (externalSubnet.isPresent()) {
157                 String externalVpn =  externalIp.getSubnetId().getValue();
158                 String vpnRd = NatUtil.getVpnRd(confTx, externalVpn);
159                 vpnFootprintService.updateVpnToDpnMapping(dpnId, externalVpn, vpnRd, null /* interfaceName*/,
160                     new ImmutablePair<>(IpAddresses.IpAddressSource.ExternalFixedIP, fibExternalIp),
161                     false);
162             }
163             break;
164         }
165     }
166
167     @Override
168     protected void addSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
169         Routers routers, BigInteger dpnId) {
170         // Nothing to to do here
171     }
172
173     @Override
174     protected void removeSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
175         Routers routers, BigInteger dpnId) {
176         // Nothing to to do here
177     }
178
179     protected void addSnatMissEntryForPrimrySwch(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
180         Long routerId, int elanId) {
181         LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
182         List<MatchInfo> matches = new ArrayList<>();
183         matches.add(MatchEthernetType.IPV4);
184         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
185         List<InstructionInfo> instructions = new ArrayList<>();
186         List<ActionInfo> actionsInfos = new ArrayList<>();
187         List<NxCtAction> ctActionsList = new ArrayList<>();
188         NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
189         ctActionsList.add(nxCtAction);
190         ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId,
191                 NwConstants.OUTBOUND_NAPT_TABLE,ctActionsList);
192
193         actionsInfos.add(actionNxConntrack);
194         instructions.add(new InstructionApplyActions(actionsInfos));
195
196         String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
197         addFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef,
198                 NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
199     }
200
201     protected void removeSnatMissEntryForPrimrySwch(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
202             Long routerId) throws ExecutionException, InterruptedException {
203         LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
204
205         String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
206         removeFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef);
207     }
208
209     protected void addOutboundTblTrackEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
210         Long routerId, String extGwMacAddress) {
211         LOG.info("createOutboundTblTrackEntry : called for switch {}, routerId {}", dpnId, routerId);
212         List<MatchInfoBase> matches = new ArrayList<>();
213         matches.add(MatchEthernetType.IPV4);
214         matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
215         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
216         ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
217         listActionInfo.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
218         ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
219         listActionInfo.add(new ActionNxResubmit(NwConstants.NAPT_PFIB_TABLE));
220         instructionInfo.add(new InstructionApplyActions(listActionInfo));
221
222         String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
223         addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef,
224                 NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
225     }
226
227     protected void removeOutboundTblTrackEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
228             Long routerId) throws ExecutionException, InterruptedException {
229         LOG.info("createOutboundTblTrackEntry : called for switch {}, routerId {}", dpnId, routerId);
230
231         String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
232         removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
233     }
234
235     protected void addOutboundTblEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId,
236         String externalIp, int elanId, String extGwMacAddress) {
237         LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
238         List<MatchInfoBase> matches = new ArrayList<>();
239         matches.add(MatchEthernetType.IPV4);
240         matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
241         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
242         List<ActionInfo> actionsInfos = new ArrayList<>();
243         actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
244         List<NxCtAction> ctActionsListCommit = new ArrayList<>();
245         int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
246         int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
247         NxCtAction nxCtActionCommit = new ActionNxConntrack.NxNat(0, flags, rangePresent,
248             IpPrefixOrAddressBuilder.getDefaultInstance(externalIp).getIpAddress(), null,0, 0);
249         ctActionsListCommit.add(nxCtActionCommit);
250         int ctCommitFlag = 1;
251         ActionNxConntrack actionNxConntrackSubmit = new ActionNxConntrack(ctCommitFlag, 0, elanId,
252             NwConstants.NAPT_PFIB_TABLE, ctActionsListCommit);
253         actionsInfos.add(actionNxConntrackSubmit);
254         List<InstructionInfo> instructions = new ArrayList<>();
255         instructions.add(new InstructionApplyActions(actionsInfos));
256         String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
257         addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef,  NatConstants.SNAT_NEW_FLOW_PRIORITY,
258             flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
259     }
260
261     protected void removeOutboundTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
262             long routerId) throws ExecutionException, InterruptedException {
263         LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
264         String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
265         removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
266     }
267
268     protected void addNaptPfibFlow(TypedReadWriteTransaction<Configuration> confTx, Routers routers, BigInteger dpnId,
269         long routerId, long extSubnetId) {
270         Long extNetId = NatUtil.getVpnId(confTx, routers.getNetworkId().getValue());
271         LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
272         List<MatchInfoBase> matches = new ArrayList<>();
273         matches.add(MatchEthernetType.IPV4);
274         matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
275         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
276         List<ActionInfo> listActionInfo = new ArrayList<>();
277         if (extSubnetId == NatConstants.INVALID_ID) {
278             LOG.error("installNaptPfibFlow : external subnet id is invalid.");
279             return;
280         }
281         ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil
282             .getVpnIdMetadata(extSubnetId), LOAD_START, LOAD_END);
283         listActionInfo.add(actionLoadMeta);
284         listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
285         listActionInfo.add(new ActionNxCtClear());
286         listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
287         ArrayList<InstructionInfo> instructions = new ArrayList<>();
288         instructions.add(new InstructionApplyActions(listActionInfo));
289         String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
290         flowRef = flowRef + "OUTBOUND";
291         addFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY,
292             flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
293     }
294
295     protected void removeNaptPfibFlow(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
296             BigInteger dpnId, long routerId) throws ExecutionException, InterruptedException {
297         Long extNetId = NatUtil.getVpnId(confTx, routers.getNetworkId().getValue());
298         LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
299         String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "OUTBOUND";
300         removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
301     }
302
303     protected void addInboundEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId,
304         String externalIp, int elanId, long extSubnetId) {
305         LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
306         List<MatchInfoBase> matches = new ArrayList<>();
307         matches.add(MatchEthernetType.IPV4);
308         matches.add(new MatchIpv4Destination(externalIp,"32"));
309         if (extSubnetId == NatConstants.INVALID_ID) {
310             LOG.error("installInboundEntry : external subnet id is invalid.");
311             return;
312         }
313         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId),
314             MetaDataUtil.METADATA_MASK_VRFID));
315         List<ActionInfo> actionsInfos = new ArrayList<>();
316         List<NxCtAction> ctActionsList = new ArrayList<>();
317         NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
318         ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil
319             .getVpnIdMetadata(routerId), LOAD_START, LOAD_END);
320         actionsInfos.add(actionLoadMeta);
321         ctActionsList.add(nxCtAction);
322         ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants
323             .NAPT_PFIB_TABLE,ctActionsList);
324
325         actionsInfos.add(actionNxConntrack);
326         List<InstructionInfo> instructions = new ArrayList<>();
327         instructions.add(new InstructionApplyActions(actionsInfos));
328         String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId);
329         flowRef = flowRef + "OUTBOUND";
330         addFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef,
331             NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
332     }
333
334     protected void removeInboundEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
335             long routerId) throws ExecutionException, InterruptedException {
336         LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
337
338         String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId) + "OUTBOUND";
339         removeFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef);
340     }
341
342     protected void addNaptPfibEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId) {
343         LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
344         List<MatchInfoBase> matches = new ArrayList<>();
345         matches.add(MatchEthernetType.IPV4);
346         matches.add(new NxMatchCtState(DNAT_CT_STATE, DNAT_CT_STATE_MASK));
347         matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
348
349         ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
350         ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
351         listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
352         listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
353         instructionInfo.add(new InstructionApplyActions(listActionInfo));
354
355         String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "INBOUND";
356         addFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef,
357             NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
358     }
359
360     protected void removeNaptPfibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
361             long routerId) throws ExecutionException, InterruptedException {
362         LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
363         String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "INBOUND";
364         removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
365     }
366 }