Skip to content

Commit 86231ef

Browse files
committed
Fix dhcp6Relay
- interfaceIdOption does not proper encode vlanId - AddHost was not using the actual vlan of the host Change-Id: I41a639cc4f7efc0c7159f5bab07166d4032fc60a
1 parent 2d20f33 commit 86231ef

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,23 @@ record = record.clone();
859859
* @param embeddedDhcp6 the dhcp6 payload within relay
860860
* @param srcMac client gw/host macAddress
861861
* @param clientInterface client interface
862+
* @param vlanIdInUse vlanid encoded in the interface id Option
862863
*/
863864
private void addHostOrRoute(boolean directConnFlag, ConnectPoint location, DHCP6 dhcp6Relay,
864-
DHCP6 embeddedDhcp6, MacAddress srcMac, Interface clientInterface) {
865+
DHCP6 embeddedDhcp6, MacAddress srcMac, Interface clientInterface,
866+
VlanId vlanIdInUse) {
865867
log.debug("addHostOrRoute entered.");
866-
VlanId vlanId = clientInterface.vlan();
868+
VlanId vlanId;
869+
if (clientInterface.vlanTagged().isEmpty()) {
870+
vlanId = clientInterface.vlan();
871+
} else {
872+
// might be multiple vlan in same interface
873+
vlanId = vlanIdInUse;
874+
}
875+
if (vlanId == null) {
876+
vlanId = VlanId.NONE;
877+
}
878+
867879
Boolean isMsgReply = Dhcp6HandlerUtil.isDhcp6Reply(dhcp6Relay);
868880
MacAddress leafClientMac;
869881
Byte leafMsgType;
@@ -1315,7 +1327,7 @@ private InternalPacket processDhcp6PacketFromServer(PacketContext context,
13151327
if (hostOrRouteAllowed) {
13161328
// add host or route
13171329
addHostOrRoute(directConnFlag, clientConnectionPoint, dhcp6Relay, embeddedDhcp6,
1318-
clientMac, clientInterface);
1330+
clientMac, clientInterface, vlanIdInUse);
13191331
}
13201332

13211333
udpPacket.setPayload(embeddedDhcp6);

apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ private static Dhcp6Option getInterfaceIdIdOption(PacketContext context, Etherne
452452
byte[] clientSoureMacBytes = clientPacket.getSourceMACAddress();
453453
byte[] inPortStringBytes = inPortString.getBytes();
454454
byte[] vlanIdBytes = new byte[2];
455-
vlanIdBytes[0] = (byte) (clientPacket.getVlanID() & 0xff);
456-
vlanIdBytes[1] = (byte) ((clientPacket.getVlanID() >> 8) & 0xff);
455+
vlanIdBytes[0] = (byte) ((clientPacket.getVlanID() >> 8) & 0xff);
456+
vlanIdBytes[1] = (byte) (clientPacket.getVlanID() & 0xff);
457457
byte[] interfaceIdBytes = new byte[clientSoureMacBytes.length +
458458
inPortStringBytes.length + vlanIdBytes.length];
459459
log.debug("Length: interfaceIdBytes {} clientSoureMacBytes {} inPortStringBytes {} vlan {}",
@@ -468,8 +468,8 @@ private static Dhcp6Option getInterfaceIdIdOption(PacketContext context, Etherne
468468
vlanIdBytes.length);
469469
interfaceId.setData(interfaceIdBytes);
470470
interfaceId.setLength((short) interfaceIdBytes.length);
471-
log.debug("interfaceId write srcMac {} portString {}",
472-
HexString.toHexString(clientSoureMacBytes, ":"), inPortString);
471+
log.debug("interfaceId write srcMac {} portString {}, vlanId {}",
472+
HexString.toHexString(clientSoureMacBytes, ":"), inPortString, vlanIdBytes);
473473
return interfaceId;
474474
}
475475

0 commit comments

Comments
 (0)