when receiving an update with the Encapsulation extended community and a subsequent extended community (MAC mobility) ODL logs an error that the Encapsulation extended community had an unexpected length of 14:
2017-06-09 22:49:02,534 | WARN | ntLoopGroup-11-1 | BGPSessionImpl | 333 - org.opendaylight.bgpcep.bgp-rib-impl - 0.6.3.Boron-SR3 | BGP session encountered error io.netty.handler.codec.DecoderException: org.opendaylight.protocol.bgp.parser.BGPDocumentedException: Could not parse BGP attributes. at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:442)[138:io.netty.codec:4.0.44.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)[138:io.netty.codec:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)[137:io.netty.transport:4.0.44.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)[138:io.netty.codec:4.0.44.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280)[138:io.netty.codec:4.0.44.Final] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396)[138:io.netty.codec:4.0.44.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)[138:io.netty.codec:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)[137:io.netty.transport:4.0.44.Final] at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:934)[141:io.netty.transport-native-epoll:4.0.44.Final] at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:397)[141:io.netty.transport-native-epoll:4.0.44.Final] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:302)[141:io.netty.transport-native-epoll:4.0.44.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131)[136:io.netty.common:4.0.44.Final] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)[136:io.netty.common:4.0.44.Final] at java.lang.Thread.run(Thread.java:748)[:1.8.0_131] Caused by: org.opendaylight.protocol.bgp.parser.BGPDocumentedException: Could not parse BGP attributes. at org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser.parseMessageBody(BGPUpdateMessageParser.java:135)[321:org.opendaylight.bgpcep.bgp-parser-impl:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser.parseMessageBody(BGPUpdateMessageParser.java:46)[321:org.opendaylight.bgpcep.bgp-parser-impl:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleMessageRegistry.parseBody(SimpleMessageRegistry.java:31)[320:org.opendaylight.bgpcep.bgp-parser-spi:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.spi.AbstractMessageRegistry.parseMessage(AbstractMessageRegistry.java:66)[320:org.opendaylight.bgpcep.bgp-parser-spi:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.rib.impl.BGPByteToMessageDecoder.decode(BGPByteToMessageDecoder.java:49)[333:org.opendaylight.bgpcep.bgp-rib-impl:0.6.3.Boron-SR3] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)[138:io.netty.codec:4.0.44.Final] ... 21 more Caused by: java.lang.IllegalArgumentException: Wrong length of array of bytes. Passed: 14. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)[60:com.google.guava:18.0.0] at org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.EncapsulationEC.parseExtendedCommunity(EncapsulationEC.java:39)[321:org.opendaylight.bgpcep.bgp-parser-impl:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleExtendedCommunityRegistry.parseExtendedCommunity(SimpleExtendedCommunityRegistry.java:55)[320:org.opendaylight.bgpcep.bgp-parser-spi:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.impl.message.update.ExtendedCommunitiesAttributeParser.parseAttribute(ExtendedCommunitiesAttributeParser.java:41)[321:org.opendaylight.bgpcep.bgp-parser-impl:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.spi.AttributeParser.parseAttribute(AttributeParser.java:42)[320:org.opendaylight.bgpcep.bgp-parser-spi:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleAttributeRegistry.parseAttributes(SimpleAttributeRegistry.java:138)[320:org.opendaylight.bgpcep.bgp-parser-spi:0.6.3.Boron-SR3] at org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser.parseMessageBody(BGPUpdateMessageParser.java:131)[321:org.opendaylight.bgpcep.bgp-parser-impl:0.6.3.Boron-SR3] ... 26 more
the BGP message is:
ffffffffffffffffffffffffffffffff00780200000061900e002c001946040a00000b00022100010a00000b000600000000000000000000000000003012ccae8942e90000009e400101005002000e02030000fdeb0000fde80000fde9c010180002fde90000009e030c0000000000080600000000000004
the relevant part is the final 16 bytes:
030C000000000080600000000000004
030C is the encapsulation EC. This carries 6 bytes of data: (00000000008) and is followed by a MAC mobility EC (0600) which also has 6 bytes of data (000000000004).
From looking at the code (EncapsulationEC.java)it seems we only handle the case where the encapsulation EC is the last EC as the code does precondition checks that the buffer is not-null, readable and the right length. None of the other EC cases do this.
I'd suggest removing the preconditions and doing better checks in ExtendedCommunitiesAttributeParser.java (basically check there are at least 6 bytes of buffer left before calling any given handler).