From c49a6a0cae57591eca859e3dc947fc990fa9b03c Mon Sep 17 00:00:00 2001 From: Milos Fabian Date: Wed, 22 Oct 2014 13:36:25 +0200 Subject: [PATCH] Bug-2116: Added CEASE error code subcodes as defined in RFC4486. Change-Id: I3eb2c6c88629581cdab16e829f9387b3aebef503 Signed-off-by: Milos Fabian --- .../protocol/bgp/parser/BGPError.java | 34 ++++++++++++++++++- .../impl/AbstractBGPSessionNegotiator.java | 2 +- .../protocol/bgp/rib/impl/BGPSessionImpl.java | 3 +- .../bgp/rib/impl/StrictBGPPeerRegistry.java | 9 ++--- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java index f3b7ec382a..91ccca550f 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java @@ -105,7 +105,39 @@ public enum BGPError { /** * Cease. 6/0 */ - CEASE((short) 6, (short) 0); + CEASE((short) 6, (short) 0), + /** + * Maximum Number of Prefixes Reached. 6/1 + */ + MAX_NUMBER_OF_PREFIXES_REACHED((short) 6, (short) 1), + /** + * Administrative Shutdown. 6/2 + */ + ADMINISTRATIVE_SHUTDOWN((short) 6, (short) 2), + /** + * Peer De-configured. 6/3 + */ + PEER_DECONFIGURED((short) 6, (short) 3), + /** + * Administrative Reset. 6/4 + */ + ADMINISTRATIVE_RESTART((short) 6, (short) 4), + /** + * Connection Rejected. 6/5 + */ + CONNECTION_REJECTED((short) 6, (short) 5), + /** + * Other Configuration Change. 6/6 + */ + OTHER_CONFIGURATION_CHANGE((short) 6, (short) 6), + /** + * Connection Collision Resolution. 6/7 + */ + CONNECTION_COLLISION_RESOLUTION((short) 6, (short) 7), + /** + * Out of Resources. 6/8 + */ + OUT_OF_RESOURCES((short) 6, (short) 8); private static final Map VALUE_MAP; 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 b6f459e641..55dc434f66 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 @@ -94,7 +94,7 @@ public abstract class AbstractBGPSessionNegotiator extends AbstractSessionNegoti final BGPDocumentedException cause = new BGPDocumentedException( "BGP peer with ip: " + getRemoteIp() + " not configured, check configured peers in : " - + this.registry, BGPError.CEASE); + + this.registry, BGPError.CONNECTION_REJECTED); negotiationFailed(cause); return; } diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java index 87f99200e6..bda181f667 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java @@ -161,7 +161,8 @@ public class BGPSessionImpl extends AbstractProtocolSession implem public synchronized void close() { LOG.info("Closing session: {}", this); if (this.state != State.Idle) { - this.sendMessage(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode((short)0).build()); + this.sendMessage(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode( + BGPError.CEASE.getSubcode()).build()); this.channel.close(); this.state = State.Idle; } diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java index eded3494a9..e16ab5c4d5 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java @@ -12,17 +12,14 @@ import com.google.common.base.CharMatcher; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; - import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.Map; - import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; - import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; import org.opendaylight.protocol.bgp.parser.BGPError; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; @@ -104,7 +101,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { throw new BGPDocumentedException( String.format("BGP session with %s %s has to be dropped. Same session already present %s", ip, currentConnection, previousConnection), - BGPError.CEASE); + BGPError.CONNECTION_COLLISION_RESOLUTION); // Session reestablished with lower source bgp id, dropping current } else if (previousConnection.isHigherDirection(currentConnection)) { @@ -112,7 +109,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { throw new BGPDocumentedException( String.format("BGP session with %s initiated %s has to be dropped. Opposite session already present", ip, currentConnection), - BGPError.CEASE); + BGPError.CONNECTION_COLLISION_RESOLUTION); // Session reestablished with higher source bgp id, dropping previous } else if (currentConnection.isHigherDirection(previousConnection)) { @@ -126,7 +123,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { throw new BGPDocumentedException( String.format("BGP session with %s initiated %s has to be dropped. Same session already present", ip, currentConnection), - BGPError.CEASE); + BGPError.CONNECTION_COLLISION_RESOLUTION); } } -- 2.36.6