From 2c8a2a4f8431ce80dca19963d3e2bc1a5dbf5d44 Mon Sep 17 00:00:00 2001 From: Jian Li Date: Thu, 24 Nov 2016 02:51:03 +0900 Subject: [PATCH] Bugfix: Acknowledge to ETR only if want-map-notify is set to true Change-Id: I684bc1f1a7958b9777f90fe512980523490598ac --- .../lisp/ctl/LispChannelHandler.java | 4 +- .../onosproject/lisp/ctl/LispMapResolver.java | 2 +- .../onosproject/lisp/ctl/LispMapServer.java | 38 +++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispChannelHandler.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispChannelHandler.java index 2a7b74063f..2303f85135 100644 --- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispChannelHandler.java +++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispChannelHandler.java @@ -61,7 +61,9 @@ public class LispChannelHandler extends ChannelInboundHandlerAdapter { LispMapNotify mapNotify = mapServer.processMapRegister((LispMapRegister) msg); - ctx.writeAndFlush(mapNotify); + if (mapNotify != null) { + ctx.writeAndFlush(mapNotify); + } } if (msg instanceof LispInfoRequest) { diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapResolver.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapResolver.java index 5661681a2b..285b397a74 100644 --- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapResolver.java +++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapResolver.java @@ -54,7 +54,7 @@ public class LispMapResolver { LispEncapsulatedControl ecm = (LispEncapsulatedControl) message; LispMapRequest request = (LispMapRequest) ecm.getControlMessage(); - // TODO: for now we always generate map-notify message and send to ITR + // TODO: for now we always generate map-reply message and send to ITR // no matter proxy bit is set or not // build map-reply message diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java index ffabf79a3a..8c2a7b7b70 100644 --- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java +++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java @@ -83,26 +83,32 @@ public final class LispMapServer { return null; } - NotifyBuilder notifyBuilder = new DefaultNotifyBuilder(); - notifyBuilder.withKeyId(authConfig.lispAuthKeyId()); - notifyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength()); - notifyBuilder.withAuthKey(authConfig.lispAuthKey()); - notifyBuilder.withNonce(register.getNonce()); - notifyBuilder.withMapRecords(register.getMapRecords()); + // we only acknowledge back to ETR when want-map-notify bit is set to true + // otherwise, we do not acknowledge back to ETR + if (register.isWantMapNotify()) { + NotifyBuilder notifyBuilder = new DefaultNotifyBuilder(); + notifyBuilder.withKeyId(authConfig.lispAuthKeyId()); + notifyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength()); + notifyBuilder.withAuthKey(authConfig.lispAuthKey()); + notifyBuilder.withNonce(register.getNonce()); + notifyBuilder.withMapRecords(register.getMapRecords()); - LispMapNotify notify = notifyBuilder.build(); + LispMapNotify notify = notifyBuilder.build(); - InetSocketAddress address = - new InetSocketAddress(register.getSender().getAddress(), MAP_NOTIFY_PORT); - notify.configSender(address); + InetSocketAddress address = + new InetSocketAddress(register.getSender().getAddress(), MAP_NOTIFY_PORT); + notify.configSender(address); - register.getMapRecords().forEach(record -> { - LispEidRecord eidRecord = - new LispEidRecord(record.getMaskLength(), record.getEidPrefixAfi()); - eidRlocMap.insertMapRecord(eidRecord, record); - }); + register.getMapRecords().forEach(record -> { + LispEidRecord eidRecord = + new LispEidRecord(record.getMaskLength(), record.getEidPrefixAfi()); + eidRlocMap.insertMapRecord(eidRecord, record); + }); - return notify; + return notify; + } + + return null; } /**