import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.List;
+import java.util.ServiceLoader;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.kohsuke.MetaInfServices;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser;
import org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer;
+import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPTeObjectRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCase;
import org.opendaylight.yangtools.concepts.Registration;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
/**
* Activator for registering linkstate extensions to BGP parser.
*/
+@Singleton
+@Component(immediate = true,
+ configurationPid = "org.opendaylight.bgp.extensions.linkstate",
+ service = BGPExtensionProviderActivator.class,
+ property = "type=org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator")
+@Designate(ocd = BGPActivator.Configuration.class)
@MetaInfServices(value = BGPExtensionProviderActivator.class)
public final class BGPActivator extends AbstractBGPExtensionProviderActivator {
+ /**
+ * Configuration for BGP linkstate extension.
+ */
+ @ObjectClassDefinition(description = "Configuration for the RFC7752 (BGP-LS) extension")
+ public static @interface Configuration {
+ @AttributeDefinition(description = "If true (default) linkstate attribute type (=29) allocated by IANA is used,"
+ + " else type (=99) is used for parsing/serialization")
+ boolean ianaAttributeType() default true;
+ }
+
private static final int LINKSTATE_AFI = 16388;
private static final int LINKSTATE_SAFI = 71;
private final RSVPTeObjectRegistry rsvpTeObjectRegistry;
public BGPActivator() {
- this(true, null);
+ this(ServiceLoader.load(RSVPExtensionConsumerContext.class).findFirst().orElseThrow(
+ () -> new IllegalStateException("Cannot find an RSVPExtensionConsumerContext implementation")));
+ }
+
+ @Inject
+ public BGPActivator(final RSVPExtensionConsumerContext rsvpExtensions) {
+ this(rsvpExtensions, true);
+ }
+
+ @Activate
+ public BGPActivator(final @Reference RSVPExtensionConsumerContext rsvpExtensions, final Configuration config) {
+ this(rsvpExtensions, config.ianaAttributeType());
}
- // FIXME: this should be properly injected
- public BGPActivator(final boolean ianaLinkstateAttributeType, final RSVPTeObjectRegistry rsvpTeObjectRegistry) {
- this.rsvpTeObjectRegistry = rsvpTeObjectRegistry;
+ public BGPActivator(final RSVPExtensionConsumerContext rsvpExtensions, final boolean ianaLinkstateAttributeType) {
+ this.rsvpTeObjectRegistry = rsvpExtensions.getRsvpRegistry();
this.ianaLinkstateAttributeType = ianaLinkstateAttributeType;
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2016 Brocade Communications Systems, Inc. and others. 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-
- <reference id="rsvpExtensionContext" interface="org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext"/>
-
- <odl:clustered-app-config id="linkStateAppConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.bgp.linkstate.app.config.rev160614.BgpLinkstateAppConfig"/>
-
- <bean id="BGPActivator" class="org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator">
- <argument>
- <bean factory-ref="linkStateAppConfig" factory-method="isIanaLinkstateAttributeType"/>
- </argument>
- <argument>
- <bean factory-ref="rsvpExtensionContext" factory-method="getRsvpRegistry"/>
- </argument>
- </bean>
-
- <service ref="BGPActivator" interface="org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator"
- odl:type="org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator"/>
-</blueprint>
+++ /dev/null
-module bgp-linkstate-app-config {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate-app-config";
- prefix "bgp-linkstate-app-config";
-
- description
- "Configuration for the BGP linkstate application.";
-
- revision "2016-06-14" {
- description
- "Initial revision.
-
- Copyright (c)2016 Brocade Communications Systems, Inc. and others. 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";
- }
-
- container bgp-linkstate-app-config {
- leaf iana-linkstate-attribute-type {
- description "If true (default) linkstate attribute type (=29) allocated by IANA is used,
- else type (=99) is used for parsing/serialization";
- type boolean;
- default true;
- }
- }
-}
\ No newline at end of file
public class ActivatorTest extends AbstractRIBActivatorTest {
@Test
public void testActivator() {
- final BGPActivator act = new BGPActivator(true,
- ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ final BGPActivator act = new BGPActivator(ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
assertNull(context.getAddressFamilyRegistry().classForFamily(16388));
assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(71));
final LinkstateNlriParser parser = new LinkstateNlriParser();
final MpReachNlriBuilder builder = new MpReachNlriBuilder();
this.registry = SimpleNlriTypeRegistry.getInstance();
- final BGPActivator act = new BGPActivator(true,
- ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ final BGPActivator act = new BGPActivator(ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
@Before
public void setUp() throws Exception {
- final BGPActivator act = new BGPActivator(true,
- ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ final BGPActivator act = new BGPActivator(ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
}
Linkstate path attribute
''''''''''''''''''''''''
-IANA allocation for BGP-LS path attribute is TYPE 29.
-Some older BGP-LS implementations might still require earliest asigned allocation TYPE 99.
-To use TYPE = 99, you need to set value bellow to false.
+The BGP-LS specification has seen early field deployments before the code point assignments have been
+properly allocated. RFC7752 specifies this attribute to be TYPE 29, while earlier software is using
+TYPE 99.
-**URL:** ``/restconf/config/bgp-linkstate-app-config:bgp-linkstate-app-config``
+OpenDaylight defaults to using the RFC7752 allocation, but can be reconfigured to recognize the legacy
+code point allocation. This can be achieved through Karaf shell in a running instance:
-**RFC8040 URL:** ``/rests/data/bgp-linkstate-app-config:bgp-linkstate-app-config``
-
-**Method:** ``PUT``
-
-.. tabs::
-
- .. tab:: XML
-
- **Content-Type:** ``application/xml``
-
- **Request Body:**
-
- .. code-block:: xml
-
- <bgp-linkstate-app-config xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate-app-config">
- <iana-linkstate-attribute-type>false</iana-linkstate-attribute-type>
- </bgp-linkstate-app-config>
-
- .. tab:: JSON
-
- **Content-Type:** ``application/json``
-
- **Request Body:**
+.. code-block:: console
- .. code-block:: json
+ opendaylight-user@root>config:edit org.opendaylight.bgp.extensions.linkstate
+ opendaylight-user@root>config:property-set ianaAttributeType false
+ opendaylight-user@root>config:update
- {
- "bgp-linkstate-app-config": {
- "iana-linkstate-attribute-type": false
- }
- }
+Alternatively, the same effect can be achieved by placing the line ``ianaAttributeType = false`` into
+``etc/org.opendaylight.bgp.extensions.linkstate.cfg`` in the installation directory.
BGP Peer
''''''''