Bug 5480 - bfd not supported by SB plugin 62/36062/2
authorVishal Thapar <vishal.thapar@ericsson.com>
Wed, 9 Mar 2016 18:00:06 +0000 (23:30 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Thu, 10 Mar 2016 19:15:33 +0000 (00:45 +0530)
Schema definition for it is present in library but definition in
ovsdb.yang and relevant code is missing.

This fix adds yang model and related code for bfd cofiguration and status.

Change-Id: I171478949079a4c39d8de9f0f7fb2bfcfb53e8b5
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
southbound/southbound-api/src/main/yang/ovsdb.yang
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommandTest.java

index 0b1ee591f0e802b350f0a0ac2bd4e0b924fe28b1..605baa0d96a8dfe6c0cd3e4165cc29e5512b2a6b 100755 (executable)
@@ -1075,6 +1075,143 @@ module ovsdb {
             }
         }
 
+        list interface-bfd {
+            description "BFD configuration for a particular interface.
+                BFD, defined in RFC 5880 and RFC 5881, allows point-to-point
+                detection of connectivity failures by occasional transmission of
+                BFD control messages.
+
+                bfd : enable: optional string, either true or false
+                       True to enable BFD on this Interface. If not specified, BFD
+                       will be disabled by default.
+
+                bfd : min_rx: optional string
+                       containing an integer, at least 1.
+                       The shortest interval, in milliseconds, at which this BFD session
+                       offers to receive BFD control messages.  The remote endpoint may
+                       choose to send messages at a slower rate.  Defaults to 1000.
+
+                bfd : min_tx: optional string
+                       containing an integer, at least 1.
+                       The shortest interval, in milliseconds, at which this BFD session is
+                       willing to transmit BFD control messages.  Messages will actually be
+                       transmitted at a slower rate if the remote endpoint is not willing to
+                       receive as quickly as specified.  Defaults to 100.
+
+                bfd : decay_min_rx: optional string
+                       containing an integer
+                       An alternate receive interval, in milliseconds, that must be greater
+                       than or equal to bfd:min_rx.  The implementation switches from
+                       bfd:min_rx to bfd:decay_min_rx when there is no obvious incoming
+                       data traffic at the interface, to reduce the CPU and bandwidth cost
+                       of monitoring an idle interface.  This feature may be disabled by
+                       setting a value of 0. This feature is reset whenever bfd:decay_min_rx
+                       bfd:min_rx changes.
+
+                bfd : forwarding_if_rx: optional string, either true or false
+                       When true, traffic received on the Interface is used to
+                       indicate the capability of packet I/O. BFD control packets are
+                       still transmitted and received.  At least one BFD control
+                       packet must be received every 100 * bfd:min_rx amount of time.
+                       Otherwise, even if traffic are received, the bfd-status:forwarding
+                       will be false.
+
+                bfd : cpath_down: optional string, either true or false
+                       Set to true to notify the remote endpoint that traffic should not be
+                       forwarded to this system for some reason other than a connectivity
+                       failure on the interface being monitored.  The typical underlying
+                       reason is concatenated path down, that is, that connectivity
+                       beyond the local system is down.  Defaults to false.
+
+                bfd : cpath_down: optional string, either true or false
+                       Set to true to notify the remote endpoint that traffic should not be
+                       forwarded to this system for some reason other than a connectivity
+                       failure on the interface being monitored.  The typical underlying
+                       reason is concatenated path down, that is, that connectivity
+                       beyond the local system is down.  Defaults to false.
+
+                bfd : check_tnl_key: optional string, either true or false
+                       Set to true to make BFD accept only control messages with a tunnel
+                       key of zero.  By default, BFD accepts control messages with any
+                       tunnel key.
+
+                bfd : bfd_local_dst_mac: optional string, mac address
+                       Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+                       to set the MAC used as destination for transmitted BFD packets. The
+                       default is 00:23:20:00:00:01
+
+                bfd : bfd_remote_dst_mac: optional string, mac address
+                       Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+                       to set the MAC used for checking the destination of received BFD packets.
+                       Packets with different destination MAC will not be considered as BFD packets.
+                       If not specified the destination MAC address of received BFD packets
+                       are not checked.
+
+                bfd : bfd_src_ip: optional string, ip address
+                       Set to an IPv4 address to set the IP address used as source
+                       for transmitted BFD packets.  The default is 169.254.1.1
+
+                bfd : bfd_dst_ip: optional string, ip address
+                       Set to an IPv4 address to set the IP address used as destination
+                       for transmitted BFD packets.  The default is 169.254.1.0";
+
+            key "bfd-key";
+            leaf bfd-key {
+                description "bfd name/key";
+                type string;
+            }
+            leaf bfd-value {
+                description "bfd value";
+                type string;
+            }
+        }
+
+        list interface-bfd-status {
+            description "BFD status for a particular interface.
+                The switch sets key-value pairs in the bfd_status column to
+                report the status of BFD on this interface.  When BFD is not
+                enabled, with bfd:enable, the switch clears all key-value
+                pairs from bfd_status.
+
+                bfd_status : state: optional string, one of [admin_down, down, init, up]
+                       Reports the state of the BFD session.  The BFD session is fully
+                       healthy and negotiated if UP.
+
+                bfd_status : forwarding: optional string, true or false
+                       Reports whether the BFD session believes this Interface
+                       may be used to forward traffic.  Typically this means
+                       the local session is signaling UP, and the remote
+                       system isn't signaling a problem such as concatenated path down.
+
+                bfd_status : diagnostic: optional string
+                       A diagnostic code specifying the local system's reason for the
+                       last change in session state. The error messages are defined in
+                       section 4.1 of [RFC 5880].
+
+                bfd_status : remote_state: optional string, one of [admin_down, down, init, up]
+                       Reports the state of the remote endpoint's BFD session.
+
+                bfd_status : remote_diagnostic: optional string
+                       A diagnostic code specifying the remote system's reason for the
+                       last change in session state. The error messages are defined in
+                       section 4.1 of [RFC 5880].
+
+                bfd_status : flap_count: optional string, 
+                       containing an integer, minimum 0
+                       Counts the number of bfd_status:forwarding flaps since start.
+                       A flap is considered as a change of the bfd_status:forwarding value.";
+
+            key "bfd-status-key";
+            leaf bfd-status-key {
+                description "bfd-status name/key";
+                type string;
+            }
+            leaf bfd-status-value {
+                description "bfd-status value";
+                type string;
+            }
+        }
+
         leaf qos {
             description "The unique identifier of the QoS entry for this port.";
             type yang:uuid;
index d6eba9c642666a1c094562adee0399984dbd106e..21214949c97b87a338fcbcc5a9f1c55bda5e2999 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
@@ -124,6 +125,7 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         createInterfaceOtherConfig(terminationPoint, ovsInterface);
         createInterfaceExternalIds(terminationPoint, ovsInterface);
         createInterfaceLldp(terminationPoint, ovsInterface);
+        createInterfaceBfd(terminationPoint, ovsInterface);
     }
 
     private void createInterfaceType(final OvsdbTerminationPointAugmentation terminationPoint,
@@ -239,6 +241,24 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         }
     }
 
+    private void createInterfaceBfd(final OvsdbTerminationPointAugmentation terminationPoint,
+                    final Interface ovsInterface) {
+
+        try {
+            List<InterfaceBfd> interfaceBfdList = terminationPoint.getInterfaceBfd();
+            if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+                try {
+                    ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+                                    InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete OVSDB interface bfd", e);
+                }
+            }
+        } catch (SchemaVersionMismatchException e) {
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+        }
+    }
+
     private void createPortExternalIds(
             final OvsdbTerminationPointAugmentation terminationPoint,
             final Port port) {
index a7c788db57795b771f8fb245f25bac6b7bea3cfe..f59183cbce548f9d79cbda02de4e936750bf22b7 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.ovsdb.utils.yang.YangUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
@@ -113,6 +114,7 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         updateInterfaceOtherConfig(terminationPoint, ovsInterface);
         updateInterfaceExternalIds(terminationPoint, ovsInterface);
         updateInterfaceLldp(terminationPoint, ovsInterface);
+        updateInterfaceBfd(terminationPoint, ovsInterface);
     }
 
     private void updatePort(
@@ -231,6 +233,26 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         }
     }
 
+    private void updateInterfaceBfd(
+            final OvsdbTerminationPointAugmentation terminationPoint,
+            final Interface ovsInterface) {
+
+        try {
+            List<InterfaceBfd> interfaceBfdList =
+                    terminationPoint.getInterfaceBfd();
+            if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+                try {
+                    ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+                            InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete OVSDB interface bfd", e);
+                }
+            }
+        } catch (SchemaVersionMismatchException e) {
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+        }
+    }
+
     private void updatePortExternalIds(
             final OvsdbTerminationPointAugmentation terminationPoint,
             final Port port) {
index 120ef5e6a5a60840174a4e1dc7e39517dae4410d..0bfb3e22cecd573f850e7a5ffbf25d00985b1f14 100644 (file)
@@ -42,6 +42,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
@@ -259,6 +265,8 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         updateOptions(interf, ovsdbTerminationPointBuilder);
         updateInterfaceOtherConfig(interf, ovsdbTerminationPointBuilder);
         updateInterfaceLldp(interf, ovsdbTerminationPointBuilder);
+        updateInterfaceBfd(interf, ovsdbTerminationPointBuilder);
+        updateInterfaceBfdStatus(interf, ovsdbTerminationPointBuilder);
     }
 
     private void updateVlan(final Port port,
@@ -492,6 +500,56 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         }
     }
 
+    private void updateInterfaceBfdStatus(final Interface interf,
+            final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+        try {
+            Map<String, String> interfaceBfdStatusMap = interf.getBfdStatusColumn().getData();
+            if (interfaceBfdStatusMap != null && !interfaceBfdStatusMap.isEmpty()) {
+                List<InterfaceBfdStatus> interfaceBfdStatusList = new ArrayList<>();
+                for (String interfaceBfdStatusKeyString : interfaceBfdStatusMap.keySet()) {
+                    String interfaceBfdStatusValueString = interfaceBfdStatusMap.get(interfaceBfdStatusKeyString);
+                    if (interfaceBfdStatusKeyString != null && interfaceBfdStatusValueString!=null) {
+                        interfaceBfdStatusList.add(new InterfaceBfdStatusBuilder()
+                                .setKey(new InterfaceBfdStatusKey(interfaceBfdStatusKeyString))
+                                .setBfdStatusKey(interfaceBfdStatusKeyString)
+                                .setBfdStatusValue(interfaceBfdStatusValueString)
+                                .build());
+                    }
+                }
+                ovsdbTerminationPointBuilder.setInterfaceBfdStatus(interfaceBfdStatusList);
+            }
+        } catch (SchemaVersionMismatchException e) {
+            // We don't care about the exception stack trace here
+            LOG.debug("bfd-status column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+        }
+    }
+
+    private void updateInterfaceBfd(final Interface interf,
+            final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+        try {
+            Map<String, String> interfaceBfdMap = interf.getBfdColumn().getData();
+            if (interfaceBfdMap != null && !interfaceBfdMap.isEmpty()) {
+                List<InterfaceBfd> interfaceBfdList = new ArrayList<>();
+                for (String interfaceBfdKeyString : interfaceBfdMap.keySet()) {
+                    String interfaceBfdValueString = interfaceBfdMap.get(interfaceBfdKeyString);
+                    if (interfaceBfdKeyString != null && interfaceBfdValueString!=null) {
+                        interfaceBfdList.add(new InterfaceBfdBuilder()
+                                .setKey(new InterfaceBfdKey(interfaceBfdKeyString))
+                                .setBfdKey(interfaceBfdKeyString)
+                                .setBfdValue(interfaceBfdValueString)
+                                .build());
+                    }
+                }
+                ovsdbTerminationPointBuilder.setInterfaceBfd(interfaceBfdList);
+            }
+        } catch (SchemaVersionMismatchException e) {
+            // We don't care about the exception stack trace here
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+        }
+    }
+
     private boolean portQosCleared(Entry<UUID, Port> portUpdate) {
         if (portUpdate.getValue().getQosColumn() == null) {
             return false;
index f85fd02df53509c0ff788d7cc26bf8ed9fa45390..2f26fd3dc05e06a9dcd4a9e539a70d63bd8d98eb 100644 (file)
@@ -386,6 +386,8 @@ import com.google.common.util.concurrent.CheckedFuture;
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateOptions", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceOtherConfig", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceLldp", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+        MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfd", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+        MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfdStatus", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
 
         Whitebox.invokeMethod(ovsdbPortUpdateCommand, "updateInterface", interf, OVSDB_INTERFACE_TYPE, ovsdbTerminationPointBuilder);
         verify(ovsdbTerminationPointBuilder).setInterfaceUuid(any(Uuid.class));