Bug 7667: SNAT table 46&44 are not getting programmed when private BGPVPN 94/50994/4
authorkarthikeyan <karthikeyan.k@altencalsoftlabs.com>
Wed, 25 Jan 2017 08:05:05 +0000 (13:35 +0530)
committerAlon Kochba <alonko@hpe.com>
Tue, 31 Jan 2017 13:52:39 +0000 (13:52 +0000)
Problem Description:
=====================
SNAT: Table 46(OUTBOUND_NAPT) and table 44 (INBOUND_NAPT) are not getting
programmed (SNAT Forward Traffic and SNAT Reverse Traffic) with NAT
translation when router is
associated with Private/Internal BGP-VPN.Due to this issue, SNAT traffic
is getting failed when interval bgp-vpn is configured.

Root Cause of the Problem:
==========================
As part of bug (Bug 7478) fix SNAT traffic is used to send router-gw mac
address instead of VM mac. With this code changes router gw-mac was
getting from external-router Yang Model using router name as key.

When private/internal bgp-vpn is configured router-id (Internal Private
VPN ID) should be replaced with created private/internal bgp-vpn id. With
this approach when querying external-router Yang model for getting
router-gw mac address using new router-id (bgp-vpn id) will not match with
router-name.

Solution:
===========
When querying external-router yang model for getting router-gw mac address
it should use old router-id instead of bgp-vpn id. For doing this change
in NAPTEventHandler re-aligned the router-gw mac address code to
appropriate place to be working as expected.

Change-Id: Ieefd799d6b2349464bfb737e3fcc8101036c3619
Signed-off-by: karthikeyan <karthikeyan.k@altencalsoftlabs.com>
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NaptEventHandler.java

index 74b03488aca7ef45aa4fadbc9a145e09b3e65204..dcc2ee051a05519c0a8bdd38ddcde05c87c20776 100644 (file)
@@ -118,15 +118,6 @@ public class NaptEventHandler {
             Long routerId = naptEntryEvent.getRouterId();
             LOG.info("NAT Service : handleEvent() entry for IP {}, port {}, routerID {}",
                 naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber(), routerId);
-            // Get the External Gateway MAC Address
-            String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterId(dataBroker, routerId);
-            if (extGwMacAddress != null) {
-                LOG.debug("NAT Service : External Gateway MAC address {} found for External Router ID {}",
-                    extGwMacAddress, routerId);
-            } else {
-                LOG.error("NAT Service : No External Gateway MAC address found for External Router ID {}", routerId);
-                return;
-            }
             //Get the DPN ID
             BigInteger dpnId = NatUtil.getPrimaryNaptfromRouterId(dataBroker, routerId);
             long bgpVpnId = NatConstants.INVALID_ID;
@@ -151,7 +142,16 @@ public class NaptEventHandler {
             }
             if (naptEntryEvent.getOperation() == NAPTEntryEvent.Operation.ADD) {
                 LOG.debug("NAT Service : Inside Add operation of NaptEventHandler");
-
+                // Get the External Gateway MAC Address
+                String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterId(dataBroker, routerId);
+                if (extGwMacAddress != null) {
+                    LOG.debug("NAT Service : External Gateway MAC address {} found for External Router ID {}",
+                            extGwMacAddress, routerId);
+                } else {
+                    LOG.error("NAT Service : No External Gateway MAC address found for External Router ID {}",
+                            routerId);
+                    return;
+                }
                 //Get the external network ID from the ExternalRouter model
                 Uuid networkId = NatUtil.getNetworkIdFromRouterId(dataBroker, routerId);
                 if (networkId == null) {