Learn PPPoE server MAC address from return packet
Change-Id: Ie3ecb4ed1e86878e8e61cdecb7d45d53d98c7770
diff --git a/app/src/main/java/org/opencord/bng/PppoeHandlerRelay.java b/app/src/main/java/org/opencord/bng/PppoeHandlerRelay.java
index e01db20..da77299 100644
--- a/app/src/main/java/org/opencord/bng/PppoeHandlerRelay.java
+++ b/app/src/main/java/org/opencord/bng/PppoeHandlerRelay.java
@@ -113,6 +113,7 @@
private ApplicationId appId;
private InternalPacketProcessor internalPacketProcessor;
private PppoeRelayConfig pppoeRelayConfig;
+ private MacAddress macPppoeServer;
/**
* Ephemeral internal map to trace the attachment information. This map is
@@ -146,6 +147,7 @@
pppoeRelayConfig = null;
mapSrcMacToAttInfo = null;
internalPacketProcessor = null;
+ macPppoeServer = null;
log.info("PPPoE Handler Relay deactivated");
}
@@ -216,6 +218,12 @@
if (heardOn.equals(pppoeRelayConfig.getPppoeServerConnectPoint())) {
// DOWNSTREAM PACKET: from the PPPoE server to the attachment.
+
+ // Learn the MAC address of the PPPoE server
+ if (macPppoeServer == null) {
+ macPppoeServer = eth.getSourceMAC();
+ }
+
MacAddress dstMac = eth.getDestinationMAC();
log.debug("Packet to the attachment: {}", eth);
if (!mapSrcMacToAttInfo.containsKey(dstMac)) {
@@ -232,7 +240,6 @@
// Generate the events for this attachment
manageAttachmentStateDownstream(eth, pppoe, attInfo);
-
modPacketForAttachment(eth, attInfo, bnguMac);
log.debug("Packet modified as: {}", eth);
@@ -464,7 +471,11 @@
}
// Modify DST Mac Address with the one of the PPPoE Server
if (!eth.getDestinationMAC().isBroadcast()) {
- eth.setDestinationMACAddress(pppoeRelayConfig.getPppoeMacAddress());
+ if (macPppoeServer == null) {
+ log.warn("NO Mac address for PPPoE server available! Dropping packet");
+ return;
+ }
+ eth.setDestinationMACAddress(macPppoeServer);
}
}