Disable DHCP relay counters

The use of strong consistent counter creates a huge performance overhead.
The semaphore also prevent parallel processing of DHCP packets.
Moving forward, we should replace this with local counter, CRDT, or other less expensive counters.

Change-Id: I4023ae2b6867a3f3ab3675717ce6e9c396580b19
This commit is contained in:
Charles Chan 2019-02-01 11:31:50 -08:00 committed by Charles Chan
parent ee5d4b9366
commit b87495c31c

View File

@ -63,7 +63,6 @@ import org.onosproject.dhcprelay.config.IgnoreDhcpConfig;
import org.onosproject.dhcprelay.store.DhcpRelayStore; import org.onosproject.dhcprelay.store.DhcpRelayStore;
import org.onosproject.dhcprelay.store.DhcpRecord; import org.onosproject.dhcprelay.store.DhcpRecord;
import org.onosproject.dhcprelay.store.DhcpFpmPrefixStore; import org.onosproject.dhcprelay.store.DhcpFpmPrefixStore;
import org.onosproject.dhcprelay.store.DhcpRelayCounters;
import org.onosproject.dhcprelay.store.DhcpRelayCountersStore; import org.onosproject.dhcprelay.store.DhcpRelayCountersStore;
import org.onosproject.net.Device; import org.onosproject.net.Device;
import org.onosproject.net.DeviceId; import org.onosproject.net.DeviceId;
@ -725,12 +724,12 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress()); leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress());
} else { } else {
log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created."); log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created.");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
return; return;
} }
} else { } else {
log.warn("CLIENTID option NOT found. Don't create DhcpRelay Record."); log.warn("CLIENTID option NOT found. Don't create DhcpRelay Record.");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
return; return;
} }
@ -765,7 +764,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId); IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId);
if (nextHopIp == null) { if (nextHopIp == null) {
log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId); log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId);
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
return; return;
} }
@ -835,6 +834,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
record.updateLastSeen(); record.updateLastSeen();
} }
dhcpRelayStore.updateDhcpRecord(leafHostId, record); dhcpRelayStore.updateDhcpRecord(leafHostId, record);
/*
// TODO Use AtomicInteger for the counters // TODO Use AtomicInteger for the counters
try { try {
recordSemaphore.acquire(); recordSemaphore.acquire();
@ -847,6 +847,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
*/
} }
/** /**
@ -875,12 +876,12 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress()); leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress());
} else { } else {
log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created."); log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created.");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
return; return;
} }
} else { } else {
log.warn("CLIENTID option NOT found. No DhcpRelay Record created."); log.warn("CLIENTID option NOT found. No DhcpRelay Record created.");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
return; return;
} }
HostId leafHostId = HostId.hostId(leafClientMac, vlanId); HostId leafHostId = HostId.hostId(leafClientMac, vlanId);
@ -928,7 +929,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId); IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId);
if (nextHopIp == null) { if (nextHopIp == null) {
log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId); log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId);
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
return; return;
} }
@ -994,6 +995,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
record.setDirectlyConnected(directConnFlag); record.setDirectlyConnected(directConnFlag);
record.updateLastSeen(); record.updateLastSeen();
dhcpRelayStore.updateDhcpRecord(leafHostId, record); dhcpRelayStore.updateDhcpRecord(leafHostId, record);
/*
// TODO Use AtomicInteger for the counters // TODO Use AtomicInteger for the counters
try { try {
recordSemaphore.acquire(); recordSemaphore.acquire();
@ -1006,6 +1008,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
*/
} }
private List<InternalPacket> processDhcp6ForwardOnly(PacketContext context, private List<InternalPacket> processDhcp6ForwardOnly(PacketContext context,
@ -1138,7 +1141,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
log.warn("Missing DHCP relay agent interface Ipv6 addr config for " log.warn("Missing DHCP relay agent interface Ipv6 addr config for "
+ "packet from client on port: {}. Aborting packet processing", + "packet from client on port: {}. Aborting packet processing",
clientInterfaces.iterator().next().connectPoint()); clientInterfaces.iterator().next().connectPoint());
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
return Lists.newArrayList(); return Lists.newArrayList();
} }
@ -1219,12 +1222,12 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
if (foundServerInfo == null) { if (foundServerInfo == null) {
log.warn("Cannot find server info for {} server, inPort {}", log.warn("Cannot find server info for {} server, inPort {}",
directConnFlag ? "direct" : "indirect", inPort); directConnFlag ? "direct" : "indirect", inPort);
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_INFO); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_INFO);
return null; return null;
} else { } else {
if (Dhcp6HandlerUtil.isServerIpEmpty(foundServerInfo)) { if (Dhcp6HandlerUtil.isServerIpEmpty(foundServerInfo)) {
log.warn("Cannot find server info's ipaddress"); log.warn("Cannot find server info's ipaddress");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_IP6ADDR); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_IP6ADDR);
return null; return null;
} }
} }
@ -1236,7 +1239,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
.orElse(null); .orElse(null);
if (interfaceIdOption == null) { if (interfaceIdOption == null) {
log.warn("Interface Id option is not present, abort packet..."); log.warn("Interface Id option is not present, abort packet...");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.OPTION_MISSING_FAIL); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.OPTION_MISSING_FAIL);
return null; return null;
} }
@ -1249,7 +1252,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
.findFirst().orElse(null); .findFirst().orElse(null);
if (clientInterface == null) { if (clientInterface == null) {
log.warn("Cannot get client interface for from packet, abort... vlan {}", vlanIdInUse.toString()); log.warn("Cannot get client interface for from packet, abort... vlan {}", vlanIdInUse.toString());
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_MATCHING_INTF); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_MATCHING_INTF);
return null; return null;
} }
etherReply.setVlanID(vlanIdInUse.toShort()); etherReply.setVlanID(vlanIdInUse.toShort());
@ -1257,7 +1260,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
MacAddress relayAgentMac = clientInterface.mac(); MacAddress relayAgentMac = clientInterface.mac();
if (relayAgentMac == null) { if (relayAgentMac == null) {
log.warn("Can not get client interface mac, abort packet.."); log.warn("Can not get client interface mac, abort packet..");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
return null; return null;
} }
etherReply.setSourceMACAddress(relayAgentMac); etherReply.setSourceMACAddress(relayAgentMac);
@ -1275,7 +1278,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
clientMac = clients.iterator().next().mac(); clientMac = clients.iterator().next().mac();
if (clientMac == null) { if (clientMac == null) {
log.warn("No client mac address found, abort packet..."); log.warn("No client mac address found, abort packet...");
dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC); //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
return null; return null;
} }
log.trace("Client mac address found from getHostByIp"); log.trace("Client mac address found from getHostByIp");