diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2018-01-17 16:25:36 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2018-01-31 14:56:24 +0000 |
commit | 51941632d33a17a96e2c10d1d59d762258b1839f (patch) | |
tree | 95217cc768fe75425afdda2215bbfd2b24520a13 /mpls/impl/src | |
parent | 1fdb0b77a24367484287c2eeb3c31cc8b91ee097 (diff) |
Add direct update support for static lsp
This is workaround for HONEYCOMB-421
(subtree writers + default update does not work well currently).
Fixes HC2VPP-277 (at least basic scenarios).
Change-Id: I7659436d6c376bdc63eaa36291d5c08792faad94
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
(cherry picked from commit fc06ca33bc587ba2acff16e59645b3d386aa498d)
Diffstat (limited to 'mpls/impl/src')
-rw-r--r-- | mpls/impl/src/main/java/io/fd/hc2vpp/mpls/StaticLspCustomizer.java | 11 | ||||
-rw-r--r-- | mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java | 21 |
2 files changed, 28 insertions, 4 deletions
diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/StaticLspCustomizer.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/StaticLspCustomizer.java index d93e0343c..6aab1ed42 100644 --- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/StaticLspCustomizer.java +++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/StaticLspCustomizer.java @@ -69,6 +69,17 @@ final class StaticLspCustomizer implements ListWriterCustomizer<StaticLsp, Stati } @Override + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<StaticLsp> id, + @Nonnull final StaticLsp dataBefore, + @Nonnull final StaticLsp dataAfter, + @Nonnull final WriteContext writeContext) throws WriteFailedException { + LOG.debug("Updating MPLS LSP: before={} after={}", dataBefore, dataAfter); + write(id, dataBefore, writeContext.getMappingContext(), false); + write(id, dataAfter, writeContext.getMappingContext(), true); + LOG.debug("MPLS LSP successfully configured: {}", dataAfter); + } + + @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<StaticLsp> id, @Nonnull final StaticLsp dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java index 50c86ac26..a4689a74c 100644 --- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java +++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java @@ -59,14 +59,15 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa private static final InstanceIdentifier<StaticLsp> IID = InstanceIdentifier.create(Routing.class).augmentation (Routing1.class).child(Mpls.class).augmentation(Mpls1.class).child(StaticLsps.class) .child(StaticLsp.class, new StaticLspKey(LSP_NAME)); - private static final StaticLsp SIMPLE_LSP = getSimpleLsp(); + private static final int LABEL = 111; + private static final StaticLsp SIMPLE_LSP = getSimpleLsp((long) LABEL); private static final StaticLsp COMPLEX_LSP = getComplexLsp(); @Mock private FutureJVppCoreFacade jvpp; private StaticLspCustomizer customizer; - private static StaticLsp getSimpleLsp() { + private static StaticLsp getSimpleLsp(final long label) { return new StaticLspBuilder() .setName(LSP_NAME) .setConfig(new ConfigBuilder() @@ -79,7 +80,7 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa .setOutSegment(new SimplePathBuilder() .setNextHop(IpAddressBuilder.getDefaultInstance("5.6.7.8")) .setOutgoingInterface(IF_NAME) - .setOutgoingLabel(new MplsLabel(111L)) + .setOutgoingLabel(new MplsLabel(label)) .build()) .build()) .build(); @@ -127,6 +128,14 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa } @Test + public void testUpdateSimple() throws WriteFailedException { + final int newLabel = LABEL + 1; + customizer.updateCurrentAttributes(IID, SIMPLE_LSP, getSimpleLsp(newLabel), writeContext); + verify(jvpp).ipAddDelRoute(getRequestForSimpleLsp(false, LABEL)); + verify(jvpp).ipAddDelRoute(getRequestForSimpleLsp(true, newLabel)); + } + + @Test public void testDeleteSimple() throws WriteFailedException { customizer.deleteCurrentAttributes(IID, SIMPLE_LSP, writeContext); verify(jvpp).ipAddDelRoute(getRequestForSimpleLsp(false)); @@ -139,6 +148,10 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa } private IpAddDelRoute getRequestForSimpleLsp(final boolean add) { + return getRequestForSimpleLsp(add, LABEL); + } + + private IpAddDelRoute getRequestForSimpleLsp(final boolean add, final int label) { final IpAddDelRoute request = new IpAddDelRoute(); request.nextHopSwIfIndex = IF_INDEX; request.isAdd = booleanToByte(add); @@ -148,7 +161,7 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa request.nextHopAddress = new byte[] {5, 6, 7, 8}; request.nextHopNOutLabels = 1; request.nextHopViaLabel = LspWriter.MPLS_LABEL_INVALID; - request.nextHopOutLabelStack = new int[] {111}; + request.nextHopOutLabelStack = new int[] {label}; return request; } |