diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-02-21 08:42:28 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-02-21 17:23:31 +0100 |
commit | f93fc373a265382b88673a3b8636714924e71a9e (patch) | |
tree | 3d9e7945b4a8da917c3e2c032b1b92836339a9f4 /v3po/v3po2vpp/src/main/java | |
parent | f674354dbb4ee89aea8f748aa21e8c43602db9f2 (diff) |
HC2VPP-81: add support for ARP proxy enable/disable
Change-Id: Ib0cd5ce9175161a3e9bc83076931fb75e6d82a09
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java | 2 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizer.java | 34 |
2 files changed, 32 insertions, 4 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java index 62fbe822a..b321930d6 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java @@ -153,7 +153,7 @@ public final class InterfacesWriterFactory implements WriterFactory { SubinterfaceAugmentationWriterFactory.SUB_IFC_ID); // Proxy Arp (execute after specific interface customizers) registry.addAfter( - new GenericWriter<>(VPP_IFC_AUG_ID.child(ProxyArp.class), new ProxyArpCustomizer(jvpp)), + new GenericWriter<>(VPP_IFC_AUG_ID.child(ProxyArp.class), new ProxyArpCustomizer(jvpp, ifcNamingContext)), specificIfcTypes); // Ingress (execute after classify table and session writers) // also handles L2Acl, Ip4Acl and Ip6Acl: diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizer.java index 66f2e3e81..9f5c4ac66 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizer.java @@ -17,13 +17,15 @@ package io.fd.hc2vpp.v3po.interfaces; import com.google.common.net.InetAddresses; -import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel; import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply; +import io.fd.vpp.jvpp.core.dto.ProxyArpIntfcEnableDisable; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.util.concurrent.Future; @@ -38,16 +40,20 @@ import org.slf4j.LoggerFactory; public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCustomizer<ProxyArp>, JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(ProxyArpCustomizer.class); + private final NamingContext interfaceContext; - public ProxyArpCustomizer(final FutureJVppCore vppApi) { + public ProxyArpCustomizer(final FutureJVppCore vppApi, final NamingContext interfaceContext) { super(vppApi); + this.interfaceContext = interfaceContext; } @Override public void writeCurrentAttributes(@Nonnull InstanceIdentifier<ProxyArp> id, @Nonnull ProxyArp dataAfter, @Nonnull WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); + final int swIfIndex = interfaceContext.getIndex(swIfName, writeContext.getMappingContext()); createProxyArp(getProxyArpRequestFuture(id, swIfName, dataAfter, (byte) 1 /* 1 is add */), id, dataAfter); + enableProxyArp(swIfName, swIfIndex, id); } @Override @@ -63,7 +69,9 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu @Nonnull WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); + final int swIfIndex = interfaceContext.getIndex(swIfName, writeContext.getMappingContext()); deleteProxyArp(getProxyArpRequestFuture(id, swIfName, dataBefore, (byte) 0 /* 0 is delete */), id); + disableProxyArp(swIfName, swIfIndex, id); } private Future<ProxyArpAddDelReply> getProxyArpRequestFuture(InstanceIdentifier<ProxyArp> id, String swIfName, @@ -86,7 +94,7 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu } private void deleteProxyArp(final Future<ProxyArpAddDelReply> future, final InstanceIdentifier<ProxyArp> identifier) - throws WriteFailedException { + throws WriteFailedException { final ProxyArpAddDelReply reply = getReplyForDelete(future, identifier); LOG.debug("Proxy ARP setting delete successful, with reply context:", reply.context); } @@ -105,4 +113,24 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu private String getv4AddressString(@Nonnull final Ipv4Address addr) { return addr.getValue(); } + + private void enableProxyArp(final String swIfName, final int swIfIndex, + final InstanceIdentifier<ProxyArp> identifier) + throws WriteFailedException { + final ProxyArpIntfcEnableDisable request = new ProxyArpIntfcEnableDisable(); + request.swIfIndex = swIfIndex; + request.enableDisable = 1; + getReplyForWrite(getFutureJVpp().proxyArpIntfcEnableDisable(request).toCompletableFuture(), identifier); + LOG.debug("Proxy ARP was successfully enabled on interface {} (id={})", swIfName, swIfIndex); + } + + private void disableProxyArp(final String swIfName, final int swIfIndex, + final InstanceIdentifier<ProxyArp> identifier) + throws WriteFailedException { + final ProxyArpIntfcEnableDisable request = new ProxyArpIntfcEnableDisable(); + request.swIfIndex = swIfIndex; + request.enableDisable = 0; + getReplyForDelete(getFutureJVpp().proxyArpIntfcEnableDisable(request).toCompletableFuture(), identifier); + LOG.debug("Proxy ARP was successfully disabled on interface {} (id={})", swIfName, swIfIndex); + } } |