From 2f883069230493b31c4df3a53dbb2cb26fbca11e Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Thu, 8 Nov 2018 10:21:16 +0100 Subject: [PATCH] P2MP path computation capability https://tools.ietf.org/html/rfc8306#section-3.1.2 JIRA: BGPCEP-406 Change-Id: Idee90c040d1cf242c3b3146722097f8c68a8b9f8 Signed-off-by: Claudio D. Gasparini --- features/pcep/features-pcep/pom.xml | 6 ++ .../pcep/odl-bgpcep-pcep-p2mp-te-lsp/pom.xml | 36 +++++++++++ features/pcep/odl-bgpcep-pcep/pom.xml | 6 ++ features/pcep/pom.xml | 1 + pcep/ietf-p2mp-te-lsp/pom.xml | 59 +++++++++++++++++++ .../protocol/pcep/p2mp/te/lsp/Activator.java | 26 ++++++++ .../pcep/p2mp/te/lsp/P2MPTeLspCapability.java | 37 ++++++++++++ .../te/lsp/P2MPTeLspCapabilityParser.java | 44 ++++++++++++++ ....opendaylight.protocol.pcep.PCEPCapability | 7 +++ ...ol.pcep.spi.PCEPExtensionProviderActivator | 7 +++ .../blueprint/pcep-p2mp-te-lsp.xml | 28 +++++++++ .../src/main/yang/odl-pcep-p2mp-te-lsp.yang | 49 +++++++++++++++ .../main/yang/pcep-p2mp-te-lsp-config.yang | 29 +++++++++ .../p2mp/te/lsp/P2MPTeLspTlvsParserTest.java | 31 ++++++++++ pcep/pcep-artifacts/pom.xml | 12 ++++ pcep/pom.xml | 1 + 16 files changed, 379 insertions(+) create mode 100644 features/pcep/odl-bgpcep-pcep-p2mp-te-lsp/pom.xml create mode 100644 pcep/ietf-p2mp-te-lsp/pom.xml create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/Activator.java create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapability.java create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapabilityParser.java create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/resources/org/opendaylight/blueprint/pcep-p2mp-te-lsp.xml create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/yang/odl-pcep-p2mp-te-lsp.yang create mode 100644 pcep/ietf-p2mp-te-lsp/src/main/yang/pcep-p2mp-te-lsp-config.yang create mode 100644 pcep/ietf-p2mp-te-lsp/src/test/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspTlvsParserTest.java diff --git a/features/pcep/features-pcep/pom.xml b/features/pcep/features-pcep/pom.xml index 29d2f99d5f..f8459987a1 100644 --- a/features/pcep/features-pcep/pom.xml +++ b/features/pcep/features-pcep/pom.xml @@ -63,6 +63,12 @@ xml features + + ${project.groupId} + odl-bgpcep-pcep-p2mp-te-lsp + xml + features + ${project.groupId} odl-bgpcep-pcep-topology-provider diff --git a/features/pcep/odl-bgpcep-pcep-p2mp-te-lsp/pom.xml b/features/pcep/odl-bgpcep-pcep-p2mp-te-lsp/pom.xml new file mode 100644 index 0000000000..416bee717a --- /dev/null +++ b/features/pcep/odl-bgpcep-pcep-p2mp-te-lsp/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + org.opendaylight.bgpcep + single-feature-parent + 0.11.0-SNAPSHOT + ../../../single-feature-parent + + + odl-bgpcep-pcep-p2mp-te-lsp + feature + OpenDaylight :: PCEP :: P2MP TE LSP + + + + ${project.groupId} + pcep-ietf-p2mp-te-lsp + + + ${project.groupId} + odl-bgpcep-pcep-api + xml + features + + + \ No newline at end of file diff --git a/features/pcep/odl-bgpcep-pcep/pom.xml b/features/pcep/odl-bgpcep-pcep/pom.xml index f5e5e261cc..dfcd9fca97 100644 --- a/features/pcep/odl-bgpcep-pcep/pom.xml +++ b/features/pcep/odl-bgpcep-pcep/pom.xml @@ -64,6 +64,12 @@ xml features + + ${project.groupId} + odl-bgpcep-pcep-p2mp-te-lsp + xml + features + ${project.groupId} odl-bgpcep-pcep-topology-provider diff --git a/features/pcep/pom.xml b/features/pcep/pom.xml index d7187c2c04..daa5ae33da 100644 --- a/features/pcep/pom.xml +++ b/features/pcep/pom.xml @@ -38,5 +38,6 @@ odl-bgpcep-pcep-config-example odl-bgpcep-pcep-cli odl-bgpcep-pcep-base-parser + odl-bgpcep-pcep-p2mp-te-lsp diff --git a/pcep/ietf-p2mp-te-lsp/pom.xml b/pcep/ietf-p2mp-te-lsp/pom.xml new file mode 100644 index 0000000000..931103b273 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + org.opendaylight.bgpcep + binding-parent + 0.11.0-SNAPSHOT + ../../binding-parent + + + pcep-ietf-p2mp-te-lsp + PCE IETF Point-to-Multipoint Traffic Engineering Label Switched Paths + bundle + ${project.artifactId} + + + + ${project.groupId} + pcep-api + + + ${project.groupId} + pcep-spi + + + org.opendaylight.yangtools + concepts + + + org.opendaylight.mdsal.model + yang-ext + + + org.opendaylight.yangtools + yang-common + + + com.google.guava + guava + + + io.netty + netty-buffer + + + ${project.groupId} + util + + + + + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git + https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main + HEAD + + \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/Activator.java b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/Activator.java new file mode 100644 index 0000000000..27d157d30f --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/Activator.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.protocol.pcep.p2mp.te.lsp; + +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext; +import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.p2mp.pce.capability.tlv.P2mpPceCapability; + +public final class Activator extends AbstractPCEPExtensionProviderActivator { + @Override + protected List startImpl(final PCEPExtensionProviderContext context) { + final List regs = new ArrayList<>(2); + + final P2MPTeLspCapabilityParser p2mpCapabilityParser = new P2MPTeLspCapabilityParser(); + regs.add(context.registerTlvParser(P2MPTeLspCapabilityParser.TYPE, p2mpCapabilityParser)); + regs.add(context.registerTlvSerializer(P2mpPceCapability.class, p2mpCapabilityParser)); + return regs; + } +} \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapability.java b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapability.java new file mode 100644 index 0000000000..9218250f25 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapability.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.protocol.pcep.p2mp.te.lsp; + +import java.net.InetSocketAddress; +import org.opendaylight.protocol.pcep.PCEPCapability; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.TlvsP2mpCapabilityAug; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.TlvsP2mpCapabilityAugBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.p2mp.pce.capability.tlv.P2mpPceCapabilityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder; + +public final class P2MPTeLspCapability implements PCEPCapability { + private static TlvsP2mpCapabilityAug PATH_COMPUTATION_CAP_AUG = new TlvsP2mpCapabilityAugBuilder() + .setP2mpPceCapability(new P2mpPceCapabilityBuilder().build()).build(); + private final boolean supportsPathComputation; + + public P2MPTeLspCapability(final boolean supportsP2MPTeLspPathComputation) { + this.supportsPathComputation = supportsP2MPTeLspPathComputation; + } + + @Override + public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) { + if (this.supportsPathComputation) { + builder.addAugmentation(TlvsP2mpCapabilityAug.class, PATH_COMPUTATION_CAP_AUG); + } + } + + @Override + public boolean isStateful() { + return false; + } +} diff --git a/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapabilityParser.java b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapabilityParser.java new file mode 100644 index 0000000000..15d6882c5e --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspCapabilityParser.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.protocol.pcep.p2mp.te.lsp; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException; +import org.opendaylight.protocol.pcep.spi.TlvParser; +import org.opendaylight.protocol.pcep.spi.TlvSerializer; +import org.opendaylight.protocol.pcep.spi.TlvUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.p2mp.pce.capability.tlv.P2mpPceCapability; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.p2mp.te.lsp.rev181109.p2mp.pce.capability.tlv.P2mpPceCapabilityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv; + +public final class P2MPTeLspCapabilityParser implements TlvParser, TlvSerializer { + public static final int TYPE = 6; + private static final int CONTENT_LENGTH = 2; + @VisibleForTesting + static P2mpPceCapability P2MP_CAPABILITY = new P2mpPceCapabilityBuilder().build(); + + @Override + public void serializeTlv(final Tlv tlv, final ByteBuf buffer) { + Preconditions.checkArgument(tlv instanceof P2mpPceCapability, "P2mpPceCapability is mandatory."); + final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); + body.writeZero(2); + TlvUtil.formatTlv(TYPE, body, buffer); + } + + @Override + public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException { + if (buffer == null) { + return null; + } + buffer.skipBytes(CONTENT_LENGTH); + return P2MP_CAPABILITY; + } +} diff --git a/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability b/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability new file mode 100644 index 0000000000..1277963547 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability @@ -0,0 +1,7 @@ +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html +# +org.opendaylight.protocol.pcep.p2mp.te.lsp.P2MPTeLspCapability \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator b/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator new file mode 100644 index 0000000000..2c34e7b935 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/resources/META-INF/services/org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator @@ -0,0 +1,7 @@ +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html +# +org.opendaylight.protocol.pcep.p2mp.te.lsp.Activator diff --git a/pcep/ietf-p2mp-te-lsp/src/main/resources/org/opendaylight/blueprint/pcep-p2mp-te-lsp.xml b/pcep/ietf-p2mp-te-lsp/src/main/resources/org/opendaylight/blueprint/pcep-p2mp-te-lsp.xml new file mode 100644 index 0000000000..57f457a433 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/resources/org/opendaylight/blueprint/pcep-p2mp-te-lsp.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/main/yang/odl-pcep-p2mp-te-lsp.yang b/pcep/ietf-p2mp-te-lsp/src/main/yang/odl-pcep-p2mp-te-lsp.yang new file mode 100644 index 0000000000..4f78102855 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/yang/odl-pcep-p2mp-te-lsp.yang @@ -0,0 +1,49 @@ +module odl-pcep-p2mp-te-lsp { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:pcep:p2mp:te:lsp"; + prefix "pcep-p2mp"; + + import pcep-types { prefix pcep; revision-date 2018-11-09; } + import pcep-message { prefix msg; revision-date 2018-11-09; } + import yang-ext { prefix ext; revision-date 2013-07-09; } + + description + "This module contains the data model of PCEP extensions defined + in rfc8306. + Copyright (c)2018 AT&T Services, Inc. All rights reserved.; + + This program and the accompanying materials are made available + under the terms of the Eclipse Public License v1.0 which + accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html"; + + organization "AT&T Services, Inc."; + contact "Claudio D. Gasparini "; + + revision "2018-11-09" { + description "Initial revision"; + } + + grouping p2mp-pce-capability-tlv { + description "P2MP-PCE-CAPABILITY TLV"; + reference "https://tools.ietf.org/html/rfc8306#section-3.1.2"; + + container p2mp-pce-capability { + uses pcep:tlv; + presence + "Capability indicates that the sender can perform P2MP path computations"; + } + } + + augment "/msg:open/msg:open-message/msg:open/msg:tlvs" { + reference "https://tools.ietf.org/html/rfc8306#section-3.1.2"; + uses p2mp-pce-capability-tlv; + ext:augment-identifier tlvs-p2mp-capability-aug; + } + + augment "/msg:pcerr/msg:pcerr-message/msg:error-type/msg:session-case/msg:session/msg:open/msg:tlvs" { + reference "https://tools.ietf.org/html/rfc8306#section-3.1.2"; + uses p2mp-pce-capability-tlv; + ext:augment-identifier tlvs-p2mp-capability-error-aug; + } +} \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/main/yang/pcep-p2mp-te-lsp-config.yang b/pcep/ietf-p2mp-te-lsp/src/main/yang/pcep-p2mp-te-lsp-config.yang new file mode 100644 index 0000000000..0508bccc3e --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/main/yang/pcep-p2mp-te-lsp-config.yang @@ -0,0 +1,29 @@ +module pcep-p2mp-te-lsp-config { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:p2mp:te:lsp:config"; + prefix "pcep-p2mp-config"; + + description + "Configuration for the PCEP p2mp te lsp extension. + Copyright (c)2018 AT&T Services, Inc. All rights reserved.; + + This program and the accompanying materials are made available + under the terms of the Eclipse Public License v1.0 which + accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html"; + + organization "AT&T Services, Inc."; + contact "Claudio D. Gasparini "; + + revision "2018-11-09" { + description "Initial revision"; + } + + container pcep-p2mp-te-lsp-config { + leaf path-computation-capable { + description "Advertize pcep-p2mp-te-lsp path computation capability"; + type boolean; + default false; + } + } +} \ No newline at end of file diff --git a/pcep/ietf-p2mp-te-lsp/src/test/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspTlvsParserTest.java b/pcep/ietf-p2mp-te-lsp/src/test/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspTlvsParserTest.java new file mode 100644 index 0000000000..960ce27047 --- /dev/null +++ b/pcep/ietf-p2mp-te-lsp/src/test/java/org/opendaylight/protocol/pcep/p2mp/te/lsp/P2MPTeLspTlvsParserTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.protocol.pcep.p2mp.te.lsp; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.opendaylight.protocol.pcep.p2mp.te.lsp.P2MPTeLspCapabilityParser.P2MP_CAPABILITY; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.junit.Test; +import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException; +import org.opendaylight.protocol.util.ByteArray; + +public class P2MPTeLspTlvsParserTest { + private static final byte[] SPC_TLV_BYTES = {0x0, 0x06, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0}; + + @Test + public void testSrPceCapabilityParser() throws PCEPDeserializerException { + final P2MPTeLspCapabilityParser parser = new P2MPTeLspCapabilityParser(); + assertEquals(P2MP_CAPABILITY, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SPC_TLV_BYTES, 4)))); + final ByteBuf buff = Unpooled.buffer(); + parser.serializeTlv(P2MP_CAPABILITY, buff); + assertArrayEquals(SPC_TLV_BYTES, ByteArray.getAllBytes(buff)); + } +} \ No newline at end of file diff --git a/pcep/pcep-artifacts/pom.xml b/pcep/pcep-artifacts/pom.xml index 5f6850ce54..b8cde174ae 100644 --- a/pcep/pcep-artifacts/pom.xml +++ b/pcep/pcep-artifacts/pom.xml @@ -62,6 +62,11 @@ pcep-ietf-stateful07 ${project.version} + + ${project.groupId} + pcep-ietf-p2mp-te-lsp + ${project.version} + ${project.groupId} pcep-pcc-mock @@ -181,6 +186,13 @@ xml ${project.version} + + ${project.groupId} + odl-bgpcep-pcep-p2mp-te-lsp + features + xml + ${project.version} + ${project.groupId} odl-bgpcep-pcep-topology-provider diff --git a/pcep/pom.xml b/pcep/pom.xml index 61877824b4..61349f9fd2 100644 --- a/pcep/pom.xml +++ b/pcep/pom.xml @@ -37,6 +37,7 @@ spi base-parser ietf-stateful07 + ietf-p2mp-te-lsp testtool topology segment-routing -- 2.36.6