Add Long-lived Graceful Restart communities 61/78461/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 14:54:59 +0000 (15:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 14:57:26 +0000 (15:57 +0100)
https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04
introduces two new communities, NO_LLGR and LLGR_STALE.

This patch adds support for them.

JIRA: BGPCEP-495
Change-Id: I21745dffe9d57164f55020cf50bb443fcf6fc533
Signed-off-by: Matej Perina <matej.perina@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunityUtil.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParserTest.java

index cc0122a185b0c2109b83b32eba353923b0021017..0ed72608b4058a8927eb93de43a29269fda1d25e 100644 (file)
@@ -39,6 +39,10 @@ public final class CommunitiesAttributeParser implements AttributeParser, Attrib
 
     private static final byte[] NO_EXPORT_SUBCONFED = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x03 };
 
+    private static final byte[] LLGR_STALE = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x06 };
+
+    private static final byte[] NO_LLGR = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x07 };
+
     private final ReferenceCache refCache;
 
     public CommunitiesAttributeParser(final ReferenceCache refCache) {
@@ -78,6 +82,10 @@ public final class CommunitiesAttributeParser implements AttributeParser, Attrib
             return CommunityUtil.NO_ADVERTISE;
         } else if (Arrays.equals(body, NO_EXPORT_SUBCONFED)) {
             return CommunityUtil.NO_EXPORT_SUBCONFED;
+        } else if (Arrays.equals(body, LLGR_STALE)) {
+            return CommunityUtil.LLGR_STALE;
+        } else if (Arrays.equals(body, NO_LLGR)) {
+            return CommunityUtil.NO_LLGR;
         }
         return CommunityUtil.create(refCache, buffer.readUnsignedShort(), buffer.readUnsignedShort());
     }
index 1e198e0677ec5a2a738d5e8bd60ec5d78621ac83..8e13945ec3f5faadc6f27de3a6809af214051644 100644 (file)
@@ -41,6 +41,21 @@ public final class CommunityUtil {
     public static final Community NO_EXPORT_SUBCONFED
             = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF03);
 
+    /**
+     * LLGR_STALE community can be used to mark stale routes retained for a longer period of time.
+     * Such long-lived stale routes are to be handled according to the procedures specified in
+     * https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04#section-4.
+     */
+    public static final Community LLGR_STALE
+            = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0x0006);
+
+    /**
+     * NO_LLGR community can be used to mark routes which a BGP speaker does not want treated according
+     * to procedures, as detailed in https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04#section-4.
+     */
+    public static final Community NO_LLGR
+            = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0x0007);
+
     private final ReferenceCache refCache;
 
     public CommunityUtil(final ReferenceCache refCache) {
index d48c59c89ca560b778765810d46f9577bb4446ad..68c467671b746237c240be89ebd76dbc16ed65ad 100644 (file)
@@ -25,11 +25,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 
 public class CommunitiesAttributeParserTest {
 
-    private static final byte[] CommunitiesBytes = {(byte) 0xC0, (byte) 0x08, (byte) 0x10,
+    private static final byte[] CommunitiesBytes = {(byte) 0xC0, (byte) 0x08, (byte) 0x18,
         (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x1,
         (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x2,
         (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x3,
-        (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x10};
+        (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x10,
+        (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x06,
+        (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x07};
 
     @Test
     public void testCommunitiesAttributeParser() throws Exception {
@@ -38,6 +40,8 @@ public class CommunitiesAttributeParserTest {
         comms.add((Communities) CommunityUtil.NO_ADVERTISE);
         comms.add((Communities) CommunityUtil.NO_EXPORT_SUBCONFED);
         comms.add((Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
+        comms.add((Communities) CommunityUtil.LLGR_STALE);
+        comms.add((Communities) CommunityUtil.NO_LLGR);
 
         final AttributesBuilder paBuilder = new AttributesBuilder();
         paBuilder.setCommunities(comms);