--- /dev/null
+/*
+ * Copyright (c) 2015, 2017 Ericsson India Global Services Pvt Ltd. 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
+ */
+package org.opendaylight.genius.arputil.api;
+
+public final class ArpConstants {
+
+ private ArpConstants() {
+ // prevent instantiation
+ }
+
+ public static final String PREFIX = "/32";
+ public static final String NODE_CONNECTOR_NOT_FOUND_ERROR = "Node connector id not found for interface %s";
+ public static final String FAILED_TO_GET_SRC_IP_FOR_INTERFACE = "Failed to get src ip for %s";
+ public static final String FAILED_TO_GET_SRC_MAC_FOR_INTERFACE = "Failed to get src mac for interface %s iid %s ";
+ public static final String FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE = "failed to send arp req for interface ";
+ public static final String UNKNOWN_IP_ADDRESS_SUPPLIED = "unknown ip address supplied";
+ public static final String DPN_NOT_FOUND_ERROR = "dpn not found for interface %s ";
+ public static final short ARP_REQUEST_OP = (short) 1;
+ public static final short ARP_RESPONSE_OP = (short) 2;
+ public static final short ETH_TYPE_ARP = 0x0806;
+ public static final String ARPJOB = "Arpcache";
+ private static final long DEFAULT_ARP_LEARNED_CACHE_TIMEOUT = 120000; /* 120 seconds = 2 minutes */
+ private static final String ARP_CACHE_TIMEOUT_PROP = "arp.cache.timeout";
+ public static final long ARP_CACHE_TIMEOUT_MILLIS = Long.getLong(ArpConstants.ARP_CACHE_TIMEOUT_PROP,
+ ArpConstants.DEFAULT_ARP_LEARNED_CACHE_TIMEOUT);
+ public static final long FAILURE_THRESHOLD = 2;
+ public static final long MONITORING_WINDOW = 4;
+}
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.arputil.api.ArpConstants;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NWUtil;
private final NotificationPublishService notificationPublishService;
private final NotificationService notificationService;
private final OdlInterfaceRpcService odlInterfaceRpcService;
-
private ListenerRegistration<ArpUtilImpl> listenerRegistration;
-
- private static final String FAILED_TO_GET_SRC_IP_FOR_INTERFACE = "Failed to get src ip for %s";
- private static final String FAILED_TO_GET_SRC_MAC_FOR_INTERFACE = "Failed to get src mac for interface %s iid %s ";
- private static final String FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE = "failed to send arp req for interface ";
- private static final String UNKNOWN_IP_ADDRESS_SUPPLIED = "unknown ip address supplied";
- private static final String NODE_CONNECTOR_NOT_FOUND_ERROR = "Node connector id not found for interface %s";
- private static final String DPN_NOT_FOUND_ERROR = "dpn not found for interface %s ";
- private static final short ARP_REQUEST_OP = (short) 1;
- private static final short ARP_RESPONSE_OP = (short) 2;
- private static final short ETH_TYPE_ARP = 0x0806;
-
private final ExecutorService threadPool = Executors.newFixedThreadPool(1);
-
private final ConcurrentMap<String, String> macsDB = new ConcurrentHashMap<>();
private final ConcurrentMap<String, SettableFuture<RpcResult<GetMacOutput>>> macAddrs = new ConcurrentHashMap<>();
dstIpBytes = getIpAddressBytes(arpReqInput.getIpaddress());
} catch (UnknownHostException e) {
LOG.error("Cannot get IP address", e);
- failureBuilder.withError(ErrorType.APPLICATION, UNKNOWN_IP_ADDRESS_SUPPLIED);
+ failureBuilder.withError(ErrorType.APPLICATION, ArpConstants.UNKNOWN_IP_ADDRESS_SUPPLIED);
return Futures.immediateFuture(failureBuilder.build());
}
checkNotNull(portResult);
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
- checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId), DPN_NOT_FOUND_ERROR, interfaceName);
+ checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId),
+ ArpConstants.DPN_NOT_FOUND_ERROR, interfaceName);
NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
- checkNotNull(ref, NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
+ checkNotNull(ref, ArpConstants.NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
LOG.trace("sendArpRequest received dpnId {} out interface {}", dpnId, interfaceName);
if (interfaceAddress.getMacaddress() == null) {
String macAddr = interfaceAddress.getMacaddress().getValue();
srcMac = HexEncode.bytesFromHexString(macAddr);
}
- checkNotNull(srcMac, FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, ref.getValue());
- checkNotNull(srcIpBytes, FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
+ checkNotNull(srcMac, ArpConstants.FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, ref.getValue());
+ checkNotNull(srcIpBytes, ArpConstants.FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
- payload = ArpPacketUtil.getPayload(ARP_REQUEST_OP, srcMac, srcIpBytes,
+ payload = ArpPacketUtil.getPayload(ArpConstants.ARP_REQUEST_OP, srcMac, srcIpBytes,
ArpPacketUtil.ETHERNET_BROADCAST_DESTINATION, dstIpBytes);
List<Action> actions = getEgressAction(interfaceName);
} catch (UnknownHostException | PacketException | InterruptedException | ExecutionException e) {
LOG.trace("failed to send arp req for {} on interface {}", arpReqInput.getIpaddress(), interfaceName);
- failureBuilder.withError(ErrorType.APPLICATION, FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName,
- e);
- successBuilder.withError(ErrorType.APPLICATION, FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName,
- e);
+ failureBuilder.withError(ErrorType.APPLICATION,
+ ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
+ successBuilder.withError(ErrorType.APPLICATION,
+ ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
localErrorCount++;
}
}
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
- checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId), DPN_NOT_FOUND_ERROR, interfaceName);
- checkNotNull(ref, NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
+ checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId),
+ ArpConstants.DPN_NOT_FOUND_ERROR, interfaceName);
+ checkNotNull(ref, ArpConstants.NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
LOG.trace("sendArpRequest received dpnId {} out interface {}", dpnId, interfaceName);
srcMac = HexEncode.bytesFromHexString(macAddr);
}
byte[] dstMac = NWUtil.parseMacAddress(input.getDstMacaddress().getValue());
- checkNotNull(srcIpBytes, FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
- payload = ArpPacketUtil.getPayload(ARP_RESPONSE_OP, srcMac, srcIpBytes, dstMac, dstIpBytes);
+ checkNotNull(srcIpBytes, ArpConstants.FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
+ payload = ArpPacketUtil.getPayload(ArpConstants.ARP_RESPONSE_OP, srcMac, srcIpBytes, dstMac, dstIpBytes);
List<Action> actions = getEgressAction(interfaceName);
sendPacketOutWithActions(dpnId, payload, ref, actions);
Ethernet ethernet = new Ethernet();
ethernet.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
- if (ethernet.getEtherType() != ETH_TYPE_ARP) {
+ if (ethernet.getEtherType() != ArpConstants.ETH_TYPE_ARP) {
return;
}
checkAndFireMacChangedNotification(interfaceName, srcInetAddr, srcMac);
macsDB.put(interfaceName + "-" + srcInetAddr.getHostAddress(), NWUtil.toStringMacAddress(srcMac));
- if (arp.getOpCode() == ARP_REQUEST_OP) {
+ if (arp.getOpCode() == ArpConstants.ARP_REQUEST_OP) {
fireArpReqRecvdNotification(interfaceName, srcInetAddr, srcMac, dstInetAddr, tableId,
metadata.getMetadata());
} else {