X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=bgp%2Frib-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Frib%2Fimpl%2FAbstractBGPSessionNegotiator.java;h=7c022d7b28f50e2567bcf6d899af9f8809430f7b;hb=66b8611ab00a626167bf20556d7cbb5ec00ca124;hp=e001e9f76eda0fdcd5d04eb43040c0d29f1cefd8;hpb=e5175429f6c9c018b31440d9c8f39cd8772c4c5b;p=bgpcep.git diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java index e001e9f76e..7c022d7b28 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java @@ -17,7 +17,8 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import javax.annotation.concurrent.GuardedBy; +import org.checkerframework.checker.lock.qual.GuardedBy; +import org.checkerframework.checker.lock.qual.Holding; import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; import org.opendaylight.protocol.bgp.parser.BGPError; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; @@ -26,8 +27,8 @@ import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener; import org.opendaylight.protocol.bgp.rib.spi.SessionNegotiator; import org.opendaylight.protocol.util.Ipv6Util; import org.opendaylight.protocol.util.Values; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Keepalive; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.KeepaliveBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Notify; @@ -35,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.OpenBuilder; import org.opendaylight.yangtools.yang.binding.Notification; +import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +50,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter // BGP Support for 4-Octet AS Number Space @VisibleForTesting - static final int AS_TRANS = 23456; + static final Uint16 AS_TRANS = Uint16.valueOf(23456).intern(); private static final Logger LOG = LoggerFactory.getLogger(AbstractBGPSessionNegotiator.class); private final BGPPeerRegistry registry; private final Promise promise; @@ -94,7 +96,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter return; } // Open can be sent first either from ODL (IDLE) or from peer (OPEN_CONFIRM) - final IpAddress remoteIp = getRemoteIp(); + final IpAddressNoZone remoteIp = getRemoteIp(); try { // Check if peer is configured in registry before retrieving preferences if (!this.registry.isPeerConfigured(remoteIp)) { @@ -106,7 +108,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter } final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp); - final int as = openASNumber(preferences.getMyAs().getValue().longValue()); + final Uint16 as = openASNumber(preferences.getMyAs().getValue().longValue()); sendMessage(new OpenBuilder().setMyAsNumber(as).setHoldTimer(preferences.getHoldTime()).setBgpIdentifier( preferences.getBgpId()).setBgpParameters(preferences.getParams()).build()); if (this.state != State.FINISHED) { @@ -129,10 +131,10 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter } } - private IpAddress getRemoteIp() { - final IpAddress remoteIp = StrictBGPPeerRegistry.getIpAddress(this.channel.remoteAddress()); - if (remoteIp.getIpv6Address() != null) { - return new IpAddress(Ipv6Util.getFullForm(remoteIp.getIpv6Address())); + private IpAddressNoZone getRemoteIp() { + final IpAddressNoZone remoteIp = StrictBGPPeerRegistry.getIpAddress(this.channel.remoteAddress()); + if (remoteIp.getIpv6AddressNoZone() != null) { + return new IpAddressNoZone(Ipv6Util.getFullForm(remoteIp.getIpv6AddressNoZone())); } return remoteIp; } @@ -195,7 +197,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter } private synchronized void handleOpen(final Open openObj) { - final IpAddress remoteIp = getRemoteIp(); + final IpAddressNoZone remoteIp = getRemoteIp(); final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp); try { final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences), @@ -234,7 +236,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter * @param preferences Local BGP speaker preferences * @return BGP Id of device that accepted the connection */ - protected abstract Ipv4Address getDestinationId(Open openMsg, BGPSessionPreferences preferences); + protected abstract Ipv4AddressNoZone getDestinationId(Open openMsg, BGPSessionPreferences preferences); /** * Get source identifier. @@ -243,13 +245,13 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter * @param preferences Local BGP speaker preferences * @return BGP Id of device that accepted the connection */ - protected abstract Ipv4Address getSourceId(Open openMsg, BGPSessionPreferences preferences); + protected abstract Ipv4AddressNoZone getSourceId(Open openMsg, BGPSessionPreferences preferences); public synchronized State getState() { return this.state; } - @GuardedBy("this") + @Holding("this") private void negotiationSuccessful() { LOG.debug("Negotiation on channel {} successful with session {}", this.channel, session); this.channel.pipeline().replace(this, "session", session); @@ -305,8 +307,8 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter } @VisibleForTesting - static int openASNumber(final long configuredASNumber) { + static Uint16 openASNumber(final long configuredASNumber) { // Return AS_TRANS if the value is bigger than 2B. - return configuredASNumber > Values.UNSIGNED_SHORT_MAX_VALUE ? AS_TRANS : (int) configuredASNumber; + return configuredASNumber > Values.UNSIGNED_SHORT_MAX_VALUE ? AS_TRANS : Uint16.valueOf(configuredASNumber); } }