[BGPCEP-910] Non ipv4 advertising peer causes BGP session flaps Created: 29/Jun/20  Updated: 06/Nov/23  Resolved: 03/Aug/20

Status: Resolved
Project: bgpcep
Component/s: BGP
Affects Version/s: None
Fix Version/s: Aluminium, Magnesium SR2, Sodium SR4

Type: Bug Priority: Medium
Reporter: Vikram Singh Kalakoti Assignee: Vikram Singh Kalakoti
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

During the session establishment phase, if a peer doesn't advertise ipv4-unicast, controller automatically adds ipv4-unicast as supported family for the session to support classic BGP sessions. Currently, we are adding Ipv4 family in the BGPPeer but not updating AdjRibInWriter which causes the BGP session to not recover from session flap.

Patch fixes this issue by adding ipv4 support before updating AdjRibInWriter.



 Comments   
Comment by Ivan Hrasko [ 06/Nov/23 ]

The logs from unit test on Neon SR1 where fix is not applied:

[epollEventLoopGroup-3-2] ERROR org.opendaylight.protocol.bgp.parser.BGPDocumentedException - Error = FSM_ERROR
org.opendaylight.protocol.bgp.parser.BGPDocumentedException
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleMessage(BGPSessionImpl.java:275)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:516)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:82)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:796)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:427)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:328)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:750)
[epollEventLoopGroup-3-2] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - Closing session: BGPSessionImpl{channel=[id: 0x53fcc4c2, L:/127.0.0.1:25508 - R:/127.0.0.3:25508], state=UP}
[epollEventLoopGroup-3-2] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Session with peer 127.0.0.3 terminated: BGPTerminationReason{error=FSM_ERROR}
[epollEventLoopGroup-3-2] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Closing session with peer
[epollEventLoopGroup-7-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - Session closed because Notification message received: 5 / 0, data=null
[epollEventLoopGroup-7-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - Closing session: BGPSessionImpl{channel=[id: 0x1073203e, L:/127.0.0.3:25508 - R:127.0.0.1/127.0.0.1:25508], state=UP}
[epollEventLoopGroup-3-2] WARN org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - BGP session encountered error
java.lang.NullPointerException
    at org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.lambda$clearTables$1(AdjRibInWriter.java:435)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.clearTables(AdjRibInWriter.java:433)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.releaseConnection(BGPPeer.java:536)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.releaseConnectionGracefully(BGPPeer.java:625)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.onSessionTerminated(BGPPeer.java:516)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.notifyTerminationReasonAndCloseWithoutMessage(BGPSessionImpl.java:311)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.terminate(BGPSessionImpl.java:384)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleMessage(BGPSessionImpl.java:275)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:516)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:82)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:796)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:427)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:328)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:750)
[epollEventLoopGroup-3-2] ERROR org.opendaylight.protocol.bgp.parser.BGPDocumentedException - Error = CEASE
org.opendaylight.protocol.bgp.parser.BGPDocumentedException
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleException(BGPSessionImpl.java:540)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.exceptionCaught(BGPSessionImpl.java:526)
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:282)
    at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:820)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:361)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:796)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:427)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:328)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:750)
[epollEventLoopGroup-3-2] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Session with peer 127.0.0.3 terminated: BGPTerminationReason{error=CEASE}
[epollEventLoopGroup-3-2] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Closing session with peer
[epollEventLoopGroup-3-2] WARN io.netty.channel.AbstractChannelHandlerContext - An exception 'java.lang.IllegalStateException: Previous transaction OPER-16 is not ready yet' [enable DEBUG level for full stacktrace] was thrown by a user handler's exceptionCaught() method while handling the following exception:
java.lang.NullPointerException
    at org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.lambda$clearTables$1(AdjRibInWriter.java:435)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.opendaylight.protocol.bgp.rib.impl.AdjRibInWriter.clearTables(AdjRibInWriter.java:433)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.releaseConnection(BGPPeer.java:536)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.releaseConnectionGracefully(BGPPeer.java:625)
    at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.onSessionTerminated(BGPPeer.java:516)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.notifyTerminationReasonAndCloseWithoutMessage(BGPSessionImpl.java:311)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.terminate(BGPSessionImpl.java:384)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleMessage(BGPSessionImpl.java:275)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:516)
    at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.channelRead0(BGPSessionImpl.java:82)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:796)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:427)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:328)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:750)
[main] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - Closing session: BGPSessionImpl{channel=[id: 0x70d5cc44, L:/127.0.0.2:25508 - R:127.0.0.1/127.0.0.1:25508], state=UP}
[epollEventLoopGroup-3-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - End of input detected. Close the session.
[epollEventLoopGroup-3-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Session with peer 127.0.0.2 went down
[epollEventLoopGroup-3-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPPeer - Closing session with peer
[epollEventLoopGroup-3-1] INFO org.opendaylight.protocol.bgp.rib.impl.AbstractPeer - Closing peer chain Uri{_value=bgp://127.0.0.2}
[epollEventLoopGroup-3-1] INFO org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl - Closing session: BGPSessionImpl{channel=[id: 0x10df3206, L:/127.0.0.1:25508 ! R:/127.0.0.2:25508], state=UP}
[main] INFO org.opendaylight.bgpcep.config.loader.impl.ConfigLoaderImpl - Config Loader service closed
Generated at Wed Feb 07 19:14:28 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.