2 * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.natservice.internal;
10 import com.google.common.base.Optional;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import org.apache.commons.lang3.tuple.ImmutablePair;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
17 import org.opendaylight.genius.infra.Datastore.Configuration;
18 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
19 import org.opendaylight.genius.infra.TypedWriteTransaction;
20 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
21 import org.opendaylight.genius.mdsalutil.ActionInfo;
22 import org.opendaylight.genius.mdsalutil.InstructionInfo;
23 import org.opendaylight.genius.mdsalutil.MatchInfo;
24 import org.opendaylight.genius.mdsalutil.MatchInfoBase;
25 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
26 import org.opendaylight.genius.mdsalutil.NWUtil;
27 import org.opendaylight.genius.mdsalutil.NwConstants;
28 import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack;
29 import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction;
30 import org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort;
31 import org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata;
32 import org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit;
33 import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource;
34 import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
35 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
36 import org.opendaylight.genius.mdsalutil.matches.MatchEthernetType;
37 import org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination;
38 import org.opendaylight.genius.mdsalutil.matches.MatchMetadata;
39 import org.opendaylight.genius.mdsalutil.matches.MatchTunnelId;
40 import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState;
41 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
42 import org.opendaylight.netvirt.natservice.ha.NatDataUtil;
43 import org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
48 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;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddressBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatFlags;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.NxActionNatRangePresent;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
58 public abstract class ConntrackBasedSnatService extends AbstractSnatService {
59 private static final Logger LOG = LoggerFactory.getLogger(ConntrackBasedSnatService.class);
61 protected static final int TRACKED_NEW_CT_STATE = 0x21;
62 protected static final int TRACKED_NEW_CT_MASK = 0x21;
63 protected static final int SNAT_CT_STATE = 0x40;
64 protected static final int SNAT_CT_STATE_MASK = 0x40;
65 protected static final int DNAT_CT_STATE = 0x80;
66 protected static final int DNAT_CT_STATE_MASK = 0x80;
68 public ConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager, ItmRpcService itmManager,
69 IdManagerService idManager, NAPTSwitchSelector naptSwitchSelector,
70 OdlInterfaceRpcService odlInterfaceRpcService,
71 IInterfaceManager interfaceManager, IVpnFootprintService vpnFootprintService,
72 IFibManager fibManager, NatDataUtil natDataUtil,
73 DataTreeEventCallbackRegistrar eventCallbacks) {
74 super(dataBroker, mdsalManager, itmManager, odlInterfaceRpcService, idManager, naptSwitchSelector,
75 interfaceManager, vpnFootprintService, fibManager, natDataUtil, eventCallbacks);
79 protected void addSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
80 Routers routers, BigInteger dpnId) {
81 LOG.info("installSnatSpecificEntriesForNaptSwitch: called for router {}",
82 routers.getRouterName());
83 String routerName = routers.getRouterName();
84 Long routerId = NatUtil.getVpnId(confTx, routerName);
85 int elanId = NatUtil.getElanInstanceByName(confTx, routers.getNetworkId().getValue())
86 .getElanTag().intValue();
87 if (routerId == NatConstants.INVALID_ID) {
88 LOG.error("InvalidRouterId: unable to installSnatSpecificEntriesForNaptSwitch on dpn {}", dpnId);
91 /* Install Outbound NAT entries */
93 addSnatMissEntryForPrimrySwch(confTx, dpnId, routerId, elanId);
94 addTerminatingServiceTblEntry(confTx, dpnId, routerId, elanId);
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.
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);
108 //Install Inbound NAT entries
109 addInboundEntry(confTx, dpnId, routerId, externalIp.getIpAddress(), elanId, extSubnetId);
110 addNaptPfibEntry(confTx, dpnId, routerId);
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),
126 protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
127 Routers routers, BigInteger dpnId) {
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);
136 /* Remove Outbound NAT entries */
138 removeSnatMissEntryForPrimrySwch(confTx, dpnId, routerId);
139 removeTerminatingServiceTblEntry(confTx, dpnId, routerId);
141 removeOutboundTblTrackEntry(confTx, dpnId, routerId);
142 for (ExternalIps externalIp : routers.getExternalIps()) {
143 if (!NWUtil.isIpv4Address(externalIp.getIpAddress())) {
144 // In this class we handle only IPv4 use-cases.
147 //The logic now handle only one external IP per router, others if present will be ignored.
148 removeOutboundTblEntry(confTx, dpnId, routerId);
149 removeNaptPfibFlow(confTx, routers, dpnId, routerId);
151 //Install Inbound NAT entries
152 removeInboundEntry(confTx, dpnId, routerId);
153 removeNaptPfibEntry(confTx, dpnId, routerId);
155 String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp.getIpAddress());
156 Optional<Subnets> externalSubnet = NatUtil.getOptionalExternalSubnets(confTx, externalIp.getSubnetId());
157 if (externalSubnet.isPresent()) {
158 String externalVpn = externalIp.getSubnetId().getValue();
159 String vpnRd = NatUtil.getVpnRd(confTx, externalVpn);
160 vpnFootprintService.updateVpnToDpnMapping(dpnId, externalVpn, vpnRd, null /* interfaceName*/,
161 new ImmutablePair<>(IpAddresses.IpAddressSource.ExternalFixedIP, fibExternalIp),
169 protected void addSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
170 Routers routers, BigInteger dpnId) {
171 // Nothing to to do here
175 protected void removeSnatSpecificEntriesForNonNaptSwitch(TypedReadWriteTransaction<Configuration> confTx,
176 Routers routers, BigInteger dpnId) {
177 // Nothing to to do here
180 protected void addSnatMissEntryForPrimrySwch(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
181 Long routerId, int elanId) {
182 LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
183 List<MatchInfo> matches = new ArrayList<>();
184 matches.add(MatchEthernetType.IPV4);
185 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
186 List<InstructionInfo> instructions = new ArrayList<>();
187 List<ActionInfo> actionsInfos = new ArrayList<>();
188 List<NxCtAction> ctActionsList = new ArrayList<>();
189 NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
190 ctActionsList.add(nxCtAction);
191 ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId,
192 NwConstants.OUTBOUND_NAPT_TABLE,ctActionsList);
194 actionsInfos.add(actionNxConntrack);
195 instructions.add(new InstructionApplyActions(actionsInfos));
197 String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
198 addFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef,
199 NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
202 protected void removeSnatMissEntryForPrimrySwch(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
204 LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
206 String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
207 removeFlow(confTx, dpnId, NwConstants.PSNAT_TABLE, flowRef);
210 protected void addTerminatingServiceTblEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
211 Long routerId, int elanId) {
212 LOG.info("installTerminatingServiceTblEntry : creating entry for Terminating Service Table "
213 + "for switch {}, routerId {}", dpnId, routerId);
214 List<MatchInfo> matches = new ArrayList<>();
215 matches.add(MatchEthernetType.IPV4);
216 matches.add(new MatchTunnelId(BigInteger.valueOf(routerId)));
218 List<ActionInfo> actionsInfos = new ArrayList<>();
219 List<NxCtAction> ctActionsList = new ArrayList<>();
220 NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
221 ctActionsList.add(nxCtAction);
222 ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants
223 .OUTBOUND_NAPT_TABLE,ctActionsList);
224 ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil
225 .getVpnIdMetadata(routerId), LOAD_START, LOAD_END);
226 actionsInfos.add(actionLoadMeta);
227 actionsInfos.add(actionNxConntrack);
228 List<InstructionInfo> instructions = new ArrayList<>();
229 instructions.add(new InstructionApplyActions(actionsInfos));
230 String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
231 addFlow(confTx, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY,
232 flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
235 protected void removeTerminatingServiceTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
237 LOG.info("installTerminatingServiceTblEntry : creating entry for Terminating Service Table "
238 + "for switch {}, routerId {}", dpnId, routerId);
240 String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
241 removeFlow(confTx, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef);
244 protected void addOutboundTblTrackEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId,
245 Long routerId, String extGwMacAddress) {
246 LOG.info("createOutboundTblTrackEntry : called for switch {}, routerId {}", dpnId, routerId);
247 List<MatchInfoBase> matches = new ArrayList<>();
248 matches.add(MatchEthernetType.IPV4);
249 matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
250 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
251 ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
252 listActionInfo.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
253 ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
254 listActionInfo.add(new ActionNxResubmit(NwConstants.NAPT_PFIB_TABLE));
255 instructionInfo.add(new InstructionApplyActions(listActionInfo));
257 String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
258 addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef,
259 NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
262 protected void removeOutboundTblTrackEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
264 LOG.info("createOutboundTblTrackEntry : called for switch {}, routerId {}", dpnId, routerId);
266 String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId) + "trkest";
267 removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
270 protected void addOutboundTblEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId,
271 String externalIp, int elanId, String extGwMacAddress) {
272 LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
273 List<MatchInfoBase> matches = new ArrayList<>();
274 matches.add(MatchEthernetType.IPV4);
275 matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
276 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
277 List<ActionInfo> actionsInfos = new ArrayList<>();
278 actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
279 List<NxCtAction> ctActionsListCommit = new ArrayList<>();
280 int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
281 int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
282 NxCtAction nxCtActionCommit = new ActionNxConntrack.NxNat(0, flags, rangePresent,
283 IpPrefixOrAddressBuilder.getDefaultInstance(externalIp).getIpAddress(), null,0, 0);
284 ctActionsListCommit.add(nxCtActionCommit);
285 int ctCommitFlag = 1;
286 ActionNxConntrack actionNxConntrackSubmit = new ActionNxConntrack(ctCommitFlag, 0, elanId,
287 NwConstants.NAPT_PFIB_TABLE, ctActionsListCommit);
288 actionsInfos.add(actionNxConntrackSubmit);
289 List<InstructionInfo> instructions = new ArrayList<>();
290 instructions.add(new InstructionApplyActions(actionsInfos));
291 String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
292 addFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_NEW_FLOW_PRIORITY,
293 flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
296 protected void removeOutboundTblEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
298 LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
299 String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
300 removeFlow(confTx, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef);
303 protected void addNaptPfibFlow(TypedReadWriteTransaction<Configuration> confTx, Routers routers, BigInteger dpnId,
304 long routerId, long extSubnetId) {
305 Long extNetId = NatUtil.getVpnId(confTx, routers.getNetworkId().getValue());
306 LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
307 List<MatchInfoBase> matches = new ArrayList<>();
308 matches.add(MatchEthernetType.IPV4);
309 matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
310 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
311 List<ActionInfo> listActionInfo = new ArrayList<>();
312 if (extSubnetId == NatConstants.INVALID_ID) {
313 LOG.error("installNaptPfibFlow : external subnet id is invalid.");
316 ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil
317 .getVpnIdMetadata(extSubnetId), LOAD_START, LOAD_END);
318 listActionInfo.add(actionLoadMeta);
319 ArrayList<InstructionInfo> instructions = new ArrayList<>();
320 listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
321 listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
322 instructions.add(new InstructionApplyActions(listActionInfo));
323 String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
324 flowRef = flowRef + "OUTBOUND";
325 addFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY,
326 flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
329 protected void removeNaptPfibFlow(TypedReadWriteTransaction<Configuration> confTx, Routers routers,
330 BigInteger dpnId, long routerId) {
331 Long extNetId = NatUtil.getVpnId(confTx, routers.getNetworkId().getValue());
332 LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
333 String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "OUTBOUND";
334 removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);
337 protected void addInboundEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId,
338 String externalIp, int elanId, long extSubnetId) {
339 LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
340 List<MatchInfoBase> matches = new ArrayList<>();
341 matches.add(MatchEthernetType.IPV4);
342 matches.add(new MatchIpv4Destination(externalIp,"32"));
343 if (extSubnetId == NatConstants.INVALID_ID) {
344 LOG.error("installInboundEntry : external subnet id is invalid.");
347 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId),
348 MetaDataUtil.METADATA_MASK_VRFID));
349 List<ActionInfo> actionsInfos = new ArrayList<>();
350 List<NxCtAction> ctActionsList = new ArrayList<>();
351 NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0,null, null,0, 0);
352 ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil
353 .getVpnIdMetadata(routerId), LOAD_START, LOAD_END);
354 actionsInfos.add(actionLoadMeta);
355 ctActionsList.add(nxCtAction);
356 ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants
357 .NAPT_PFIB_TABLE,ctActionsList);
359 actionsInfos.add(actionNxConntrack);
360 List<InstructionInfo> instructions = new ArrayList<>();
361 instructions.add(new InstructionApplyActions(actionsInfos));
362 String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId);
363 flowRef = flowRef + "OUTBOUND";
364 addFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef,
365 NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
368 protected void removeInboundEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
370 LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
372 String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId) + "OUTBOUND";
373 removeFlow(confTx, dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef);
376 protected void addNaptPfibEntry(TypedWriteTransaction<Configuration> confTx, BigInteger dpnId, long routerId) {
377 LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
378 List<MatchInfoBase> matches = new ArrayList<>();
379 matches.add(MatchEthernetType.IPV4);
380 matches.add(new NxMatchCtState(DNAT_CT_STATE, DNAT_CT_STATE_MASK));
381 matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
383 ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
384 ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
385 listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
386 listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
387 instructionInfo.add(new InstructionApplyActions(listActionInfo));
389 String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "INBOUND";
390 addFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef,
391 NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
394 protected void removeNaptPfibEntry(TypedReadWriteTransaction<Configuration> confTx, BigInteger dpnId,
396 LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
397 String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId) + "INBOUND";
398 removeFlow(confTx, dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef);