BUG-4545: PCEP SR- ERO/RRO codepoint configurable 32/28932/2
authorClaudio D. Gasparini <cgaspari@cisco.com>
Wed, 28 Oct 2015 14:57:49 +0000 (15:57 +0100)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Fri, 30 Oct 2015 08:30:52 +0000 (09:30 +0100)
Since we dont have IANA stablished code point for
SR- ERO/RRO subobjects,  and there are new one
proposed by draft (ref) we made the code point
configurable, setting by default previouly used.
ref:https://tools.ietf.org/html/draft-ietf-pce-segment-routing-06

Change-Id: I2055f1cd6644ad1506cb6d2ceb05bcaf9f794dd4
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
pcep/controller-config/src/main/resources/initial/33-pcep-segment-routing.xml
pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SegmentRoutingPCEPParserModule.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRoutingActivator.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SrEroSubobjectParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SrRroSubobjectParser.java
pcep/segment-routing/src/main/yang/odl-pcep-segment-routing-cfg.yang
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/SrEroSubobjectParserTest.java
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/SrRroSubobjectParserTest.java

index bb8dd75f0cb863eccd07d017feac9372bbf029d4..5b704b6a5c931a835903984a671a9f8cbd7a3ef2 100644 (file)
@@ -20,6 +20,9 @@
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-parser-segment-routing</type>
                     <name>pcep-parser-segment-routing</name>
+                    <!-- Proposed code point for SR-ERO/RRO subobject by draft (=36) https://tools.ietf.org/html/draft-ietf-pce-segment-routing-06.
+                     to preserve (TYPE = 5/6) assigned type set the value to false or remove (false by default) or set true to use proposed ones
+                    <iana-sr-subobjects-type>true</iana-sr-subobjects-type>-->
                 </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-segment-routing-capability</type>
index ccb661441f6c7521118c049b90e81a716a4ee297..17ec55a77b1f9e77c39d96335e5237690d2f53b1 100644 (file)
@@ -26,7 +26,7 @@ public class SegmentRoutingPCEPParserModule extends org.opendaylight.controller.
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new SegmentRoutingActivator();
+        return new SegmentRoutingActivator(getIanaSrSubobjectsType());
     }
 
 }
index 48b37fcf4c89401d68c3add4649777a1e483771e..f91830d8441cacad4d091642e43f2c3243eccf04 100644 (file)
@@ -22,6 +22,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 
 public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActivator {
 
+    private final boolean ianaSrSubobjectsType;
+
+    public SegmentRoutingActivator() {
+        this.ianaSrSubobjectsType = false;
+    }
+
+    public SegmentRoutingActivator(final boolean ianaSrSubobjectsType) {
+        this.ianaSrSubobjectsType = ianaSrSubobjectsType;
+    }
+
     @Override
     protected List<AutoCloseable> startImpl(final PCEPExtensionProviderContext context) {
         final List<AutoCloseable> regs = Lists.newArrayList();
@@ -34,8 +44,8 @@ public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActiva
         regs.add(context.registerTlvSerializer(SrPceCapability.class, new SrPceCapabilityTlvParser()));
 
         /* Subobjects */
-        final SrEroSubobjectParser srEroSubobjectParser = new SrEroSubobjectParser();
-        regs.add(context.registerEROSubobjectParser(SrEroSubobjectParser.TYPE, srEroSubobjectParser));
+        final SrEroSubobjectParser srEroSubobjectParser = new SrEroSubobjectParser(this.ianaSrSubobjectsType);
+        regs.add(context.registerEROSubobjectParser(srEroSubobjectParser.getCodePoint(), srEroSubobjectParser));
         regs.add(context.registerEROSubobjectSerializer(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.network.topology.topology.node.path.computation.client.reported.lsp.path.ero.subobject.subobject.type.SrEroType.class,
                 srEroSubobjectParser));
@@ -56,8 +66,8 @@ public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActiva
                 srEroSubobjectParser));
         regs.add(context.registerEROSubobjectSerializer(SrEroType.class, srEroSubobjectParser));
 
-        final SrRroSubobjectParser srRroSubobjectParser = new SrRroSubobjectParser();
-        regs.add(context.registerRROSubobjectParser(SrRroSubobjectParser.TYPE, srRroSubobjectParser));
+        final SrRroSubobjectParser srRroSubobjectParser = new SrRroSubobjectParser(this.ianaSrSubobjectsType);
+        regs.add(context.registerRROSubobjectParser(srRroSubobjectParser.getCodePoint(), srRroSubobjectParser));
         regs.add(context.registerRROSubobjectSerializer(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.network.topology.topology.node.path.computation.client.reported.lsp.path.rro.subobject.subobject.type.SrRroType.class,
                 srRroSubobjectParser));
index 0b7704d22b696d547aabe9084aca77c00e884e21..b4e2cf7175ca6abfcf009319fdfae4467d08aa19 100644 (file)
@@ -8,9 +8,7 @@
 package org.opendaylight.protocol.pcep.segment.routing;
 
 import com.google.common.base.Preconditions;
-
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
@@ -22,7 +20,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 
 public class SrEroSubobjectParser extends AbstractSrSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
-    public static final int TYPE = 5;
+    private static final int LEGACY_TYPE = 5;
+    private static final int PROPOSED_TYPE = 36;
+
+    private final int type;
+
+    SrEroSubobjectParser(final boolean isIanaAssignedType) {
+        this.type = (isIanaAssignedType) ? PROPOSED_TYPE : LEGACY_TYPE;
+    }
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
@@ -32,7 +37,7 @@ public class SrEroSubobjectParser extends AbstractSrSubobjectParser implements E
 
         final SrSubobject srSubobject = (SrSubobject) subobject.getSubobjectType();
         final ByteBuf body = serializeSubobject(srSubobject);
-        EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
+        EROSubobjectUtil.formatSubobject(type, subobject.isLoose(), body, buffer);
     }
 
     @Override
@@ -43,4 +48,8 @@ public class SrEroSubobjectParser extends AbstractSrSubobjectParser implements E
         subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
         return subobjectBuilder.build();
     }
+
+    public int getCodePoint() {
+        return this.type;
+    }
 }
\ No newline at end of file
index 19235ec264b382e837000935dc30e4152521cad9..3830cb6fdfa70dcecdaee6d95049c84c14655868 100644 (file)
@@ -23,8 +23,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 
 public class SrRroSubobjectParser extends AbstractSrSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
 
-    public static final int TYPE = 6;
+    private static final int LEGACY_TYPE = 6;
+    private static final int PROPOSED_TYPE = 36;
 
+    private final int type;
+
+    SrRroSubobjectParser(final boolean isIanaAssignedType) {
+        this.type = (isIanaAssignedType) ? PROPOSED_TYPE : LEGACY_TYPE;
+    }
     @Override
     public void serializeSubobject(Subobject subobject, ByteBuf buffer) {
         Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrSubobject,
@@ -32,7 +38,7 @@ public class SrRroSubobjectParser extends AbstractSrSubobjectParser implements R
                         .getClass());
         final SrSubobject srSubobject = (SrSubobject) subobject.getSubobjectType();
         final ByteBuf body = serializeSubobject(srSubobject);
-        RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
+        RROSubobjectUtil.formatSubobject(type, body, buffer);
     }
 
     @Override
@@ -42,4 +48,8 @@ public class SrRroSubobjectParser extends AbstractSrSubobjectParser implements R
         subobjectBuilder.setSubobjectType(srRroSubobjectBuilder.build());
         return subobjectBuilder.build();
     }
+
+    public int getCodePoint() {
+        return this.type;
+    }
 }
index 04203a1b3e37febae3c331dff3d7264e63ec9a40..d49b37fbcdda7b748c9db4d63dd20b0e574642ce 100644 (file)
@@ -38,6 +38,12 @@ module odl-pcep-segment-routing-cfg {
     augment "/config:modules/config:module/config:configuration" {
         case pcep-parser-segment-routing {
             when "/config:modules/config:module/config:type = 'pcep-parser-segment-routing'";
+            leaf iana-sr-subobjects-type {
+                description "If false (default) SR-ERO type (=5) and SR-RRO type (=6) is used,
+                    else proposed type (36) is used for parsing/serialization";
+                type boolean;
+                default false;
+            }
         }
     }
 
index 44a6ea4fe18b78e0d10f33f8b114a8b195ce6e84..b65a9f603f3b6fad9dbc461abff92832f934426d 100644 (file)
@@ -97,17 +97,19 @@ public class SrEroSubobjectParserTest {
 
     private SimplePCEPExtensionProviderContext ctx;
     private SegmentRoutingActivator act;
+    private SrEroSubobjectParser parser;
 
     @Before
     public void setUp() {
         this.ctx = new SimplePCEPExtensionProviderContext();
         this.act = new SegmentRoutingActivator();
         this.act.start(this.ctx);
+        final boolean isIanaAssignedType = false;
+        parser = new SrEroSubobjectParser(isIanaAssignedType);
     }
 
     @Test
     public void testSrEroSubobjectIpv4NodeIdNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123456L);
@@ -124,7 +126,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv6NodeId);
         builder.setSid(123456L);
@@ -141,7 +142,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv4Adjacency);
         builder.setSid(123456L);
@@ -159,7 +159,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv6Adjacency);
         builder.setSid(123456L);
@@ -177,7 +176,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Unnumbered);
         builder.setSid(123456L);
@@ -194,7 +192,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectWithoutNAI() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123456L);
@@ -210,7 +207,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectWithoutBody() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setCFlag(false);
@@ -226,7 +222,6 @@ public class SrEroSubobjectParserTest {
 
     @Test
     public void testSrEroSubobjectIpv4NodeIdNAIMFlag() throws PCEPDeserializerException {
-        final SrEroSubobjectParser parser = new SrEroSubobjectParser();
         final SrEroTypeBuilder builder = new SrEroTypeBuilder();
         builder.setCFlag(false);
         builder.setMFlag(true);
index 37811ade435c471e1453fb85bcfc616194bfdc38..24371384ef369041a48c170d649a36ea0edd70f3 100644 (file)
@@ -86,17 +86,20 @@ public class SrRroSubobjectParserTest {
 
     private SimplePCEPExtensionProviderContext ctx;
     private SegmentRoutingActivator act;
+    private boolean isIanaAssignedType;
+    private SrRroSubobjectParser parser;
 
     @Before
     public void setUp() {
         this.ctx = new SimplePCEPExtensionProviderContext();
         this.act = new SegmentRoutingActivator();
         this.act.start(this.ctx);
+        isIanaAssignedType = false;
+        parser = new SrRroSubobjectParser(isIanaAssignedType);
     }
 
     @Test
     public void testSrRroSubobjectIpv4NodeIdNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123456L);
@@ -113,7 +116,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv6NodeId);
         builder.setCFlag(false);
@@ -130,7 +132,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4Adjacency);
         builder.setSid(123456L);
@@ -148,7 +149,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv6Adjacency);
         builder.setSid(123456L);
@@ -166,7 +166,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Unnumbered);
         builder.setSid(123456L);
@@ -183,7 +182,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectWithoutNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123470L);
@@ -199,7 +197,6 @@ public class SrRroSubobjectParserTest {
 
     @Test
     public void testSrRroSubobjectWithoutBody() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setCFlag(false);