e83fb1
diff -up dhcp-4.3.0a1/Makefile.am.systemtap dhcp-4.3.0a1/Makefile.am
e83fb1
--- dhcp-4.3.0a1/Makefile.am.systemtap	2013-12-20 13:30:26.149645305 +0100
e83fb1
+++ dhcp-4.3.0a1/Makefile.am	2013-12-20 13:30:26.307643109 +0100
e83fb1
@@ -33,5 +33,8 @@ endif
e83fb1
 
e83fb1
 SUBDIRS += includes tests common omapip client dhcpctl relay server
e83fb1
 
e83fb1
+SUBDIRS += tapset
e83fb1
+#DIST_SUBDIRS = $(SUBDIRS)
e83fb1
+
e83fb1
 nobase_include_HEADERS = dhcpctl/dhcpctl.h
e83fb1
 
e83fb1
diff -up dhcp-4.3.0a1/configure.ac.systemtap dhcp-4.3.0a1/configure.ac
e83fb1
--- dhcp-4.3.0a1/configure.ac.systemtap	2013-12-20 13:30:26.229644193 +0100
e83fb1
+++ dhcp-4.3.0a1/configure.ac	2013-12-20 13:31:39.195630065 +0100
e83fb1
@@ -524,6 +524,35 @@ else
6fa69a
     AC_MSG_RESULT(no)
6fa69a
 fi
6fa69a
 
6fa69a
+AC_MSG_CHECKING([whether to include systemtap tracing support])
6fa69a
+AC_ARG_ENABLE([systemtap],
6fa69a
+              [AS_HELP_STRING([--enable-systemtap],
6fa69a
+                              [Enable inclusion of systemtap trace support])],
6fa69a
+              [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
6fa69a
+AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
6fa69a
+AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
6fa69a
+
6fa69a
+if test "x${ENABLE_SYSTEMTAP}" = xyes; then
6fa69a
+  # Additional configuration for --enable-systemtap is HERE
6fa69a
+  AC_CHECK_PROGS(DTRACE, dtrace)
6fa69a
+  if test -z "$DTRACE"; then
6fa69a
+    AC_MSG_ERROR([dtrace not found])
6fa69a
+  fi
6fa69a
+  AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
6fa69a
+                [SDT_H_FOUND='no';
6fa69a
+                   AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
6fa69a
+  AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using SystemTap probes.])
6fa69a
+  AC_ARG_WITH([tapset-install-dir],
6fa69a
+	      [AS_HELP_STRING([--with-tapset-install-dir], 
6fa69a
+	         [The absolute path where the tapset dir will be installed])],
6fa69a
+	      [if test "x${withval}" = x; then
6fa69a
+		 ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"
6fa69a
+	       else
6fa69a
+		 ABS_TAPSET_DIR="${withval}"
6fa69a
+	       fi], [ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
6fa69a
+  AC_SUBST(ABS_TAPSET_DIR)
6fa69a
+fi
6fa69a
+
6fa69a
 # Solaris needs some libraries for functions
6fa69a
 AC_SEARCH_LIBS(socket, [socket])
6fa69a
 AC_SEARCH_LIBS(inet_ntoa, [nsl])
e83fb1
@@ -675,6 +704,7 @@ AC_CONFIG_FILES([
6fa69a
   tests/Makefile
c72a79
   server/tests/Makefile
c72a79
   doc/devel/doxyfile
6fa69a
+  tapset/Makefile
6fa69a
 ])
e83fb1
 AC_OUTPUT
6fa69a
 
e83fb1
diff -up dhcp-4.3.0a1/server/Makefile.am.systemtap dhcp-4.3.0a1/server/Makefile.am
e83fb1
--- dhcp-4.3.0a1/server/Makefile.am.systemtap	2013-12-20 13:30:26.156645207 +0100
e83fb1
+++ dhcp-4.3.0a1/server/Makefile.am	2013-12-20 13:34:16.057447630 +0100
e83fb1
@@ -10,7 +10,7 @@ dist_sysconf_DATA = dhcpd.conf.example
e83fb1
 sbin_PROGRAMS = dhcpd
e83fb1
 dhcpd_SOURCES = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \
e83fb1
 		omapi.c mdb.c stables.c salloc.c ddns.c dhcpleasequery.c \
e83fb1
-		dhcpv6.c mdb6.c ldap.c ldap_casa.c
e83fb1
+		dhcpv6.c mdb6.c ldap.c ldap_casa.c probes.d trace.h
6fa69a
 
e83fb1
 dhcpd_CFLAGS = $(LDAP_CFLAGS)
e83fb1
 dhcpd_LDADD = ../common/libdhcp.a ../omapip/libomapi.la ../dhcpctl/libdhcpctl.la \
e83fb1
@@ -18,3 +18,13 @@ dhcpd_LDADD = ../common/libdhcp.a ../oma
e83fb1
 man_MANS = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
e83fb1
 EXTRA_DIST = $(man_MANS)
6fa69a
 
e83fb1
+if ENABLE_SYSTEMTAP
e83fb1
+BUILT_SOURCES = probes.h
e83fb1
+probes.h: probes.d
e83fb1
+	$(DTRACE) -C -h -s $< -o $@
6fa69a
+
e83fb1
+probes.o: probes.d
e83fb1
+	$(DTRACE) -C -G -s $< -o $@
e83fb1
+
e83fb1
+dhcpd_LDADD += probes.o
e83fb1
+endif
e83fb1
diff -up dhcp-4.3.0a1/server/dhcp.c.systemtap dhcp-4.3.0a1/server/dhcp.c
e83fb1
--- dhcp-4.3.0a1/server/dhcp.c.systemtap	2013-12-20 13:30:26.182644846 +0100
e83fb1
+++ dhcp-4.3.0a1/server/dhcp.c	2013-12-20 13:32:22.909022163 +0100
6fa69a
@@ -36,7 +36,7 @@
6fa69a
 #include <errno.h>
6fa69a
 #include <limits.h>
6fa69a
 #include <sys time.h="">
6fa69a
-
6fa69a
+#include "trace.h"
6fa69a
 static void commit_leases_ackout(void *foo);
6fa69a
 static void maybe_return_agent_options(struct packet *packet,
6fa69a
 				       struct option_state *options);
6fa69a
@@ -275,6 +275,8 @@ void dhcpdiscover (packet, ms_nulltp)
6fa69a
 	dhcp_failover_state_t *peer;
6fa69a
 #endif
6fa69a
 
6fa69a
+	TRACE(DHCPD_DISCOVER_START());
6fa69a
+
6fa69a
 	find_lease (&lease, packet, packet -> shared_network,
6fa69a
 		    0, &peer_has_leases, (struct lease *)0, MDL);
6fa69a
 
6fa69a
@@ -399,6 +401,8 @@ void dhcpdiscover (packet, ms_nulltp)
6fa69a
       out:
6fa69a
 	if (lease)
6fa69a
 		lease_dereference (&lease, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_DISCOVER_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 void dhcprequest (packet, ms_nulltp, ip_lease)
d5d042
@@ -421,6 +425,8 @@ void dhcprequest (packet, ms_nulltp, ip_
d5d042
 #endif
6fa69a
 	int have_requested_addr = 0;
6fa69a
 
6fa69a
+	TRACE(DHCPD_REQUEST_START());
6fa69a
+
6fa69a
 	oc = lookup_option (&dhcp_universe, packet -> options,
6fa69a
 			    DHO_DHCP_REQUESTED_ADDRESS);
6fa69a
 	memset (&data, 0, sizeof data);
c72a79
@@ -700,6 +706,9 @@ void dhcprequest (packet, ms_nulltp, ip_
6fa69a
 		log_info ("%s: unknown lease %s.", msgbuf, piaddr (cip));
6fa69a
 
6fa69a
       out:
6fa69a
+
6fa69a
+	TRACE(DHCPD_REQUEST_DONE());
6fa69a
+
6fa69a
 	if (subnet)
6fa69a
 		subnet_dereference (&subnet, MDL);
6fa69a
 	if (lease)
c72a79
@@ -718,6 +727,7 @@ void dhcprelease (packet, ms_nulltp)
6fa69a
 	const char *s;
6fa69a
 	char msgbuf [1024], cstr[16]; /* XXX */
6fa69a
 
6fa69a
+	TRACE(DHCPD_RELEASE_START());
6fa69a
 
6fa69a
 	/* DHCPRELEASE must not specify address in requested-address
6fa69a
 	   option, but old protocol specs weren't explicit about this,
c72a79
@@ -842,6 +852,8 @@ void dhcprelease (packet, ms_nulltp)
6fa69a
 #endif
6fa69a
 	if (lease)
6fa69a
 		lease_dereference (&lease, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_RELEASE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 void dhcpdecline (packet, ms_nulltp)
c72a79
@@ -859,6 +871,8 @@ void dhcpdecline (packet, ms_nulltp)
6fa69a
 	struct option_cache *oc;
6fa69a
 	struct data_string data;
6fa69a
 
6fa69a
+	TRACE(DHCPD_DECLINE_START());
6fa69a
+
6fa69a
 	/* DHCPDECLINE must specify address. */
6fa69a
 	if (!(oc = lookup_option (&dhcp_universe, packet -> options,
6fa69a
 				  DHO_DHCP_REQUESTED_ADDRESS)))
e83fb1
@@ -967,6 +981,8 @@ void dhcpdecline (packet, ms_nulltp)
6fa69a
 		option_state_dereference (&options, MDL);
6fa69a
 	if (lease)
6fa69a
 		lease_dereference (&lease, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_DECLINE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 void dhcpinform (packet, ms_nulltp)
e83fb1
@@ -994,6 +1010,8 @@ void dhcpinform (packet, ms_nulltp)
e83fb1
 	int h_w_fixed_addr = 0;
e83fb1
 #endif
6fa69a
 
6fa69a
+	TRACE(DHCPD_INFORM_START());
6fa69a
+
6fa69a
 	/* The client should set ciaddr to its IP address, but apparently
6fa69a
 	   it's common for clients not to do this, so we'll use their IP
6fa69a
 	   source address if they didn't set ciaddr. */
e83fb1
@@ -1567,6 +1585,8 @@ void dhcpinform (packet, ms_nulltp)
d5d042
 
6fa69a
 	if (subnet)
6fa69a
 		subnet_dereference (&subnet, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_INFORM_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 void nak_lease (packet, cip)
e83fb1
@@ -1583,6 +1603,8 @@ void nak_lease (packet, cip)
6fa69a
 	struct option_state *options = (struct option_state *)0;
6fa69a
 	struct option_cache *oc = (struct option_cache *)0;
6fa69a
 
6fa69a
+	TRACE(DHCPD_NAK_LEASE_START());
6fa69a
+
6fa69a
 	option_state_allocate (&options, MDL);
6fa69a
 	memset (&outgoing, 0, sizeof outgoing);
6fa69a
 	memset (&raw, 0, sizeof raw);
e83fb1
@@ -1749,6 +1771,7 @@ void nak_lease (packet, cip)
d5d042
                            packet->interface->name);
d5d042
         }
d5d042
 
6fa69a
+	TRACE(DHCPD_NAK_LEASE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
e83fb1
@@ -1792,6 +1815,8 @@ void ack_lease (packet, lease, offer, wh
6fa69a
 	if (lease -> state)
6fa69a
 		return;
6fa69a
 
6fa69a
+	TRACE(DHCPD_ACK_LEASE_START());
6fa69a
+
6fa69a
 	/* Save original cltt for comparison later. */
6fa69a
 	lease_cltt = lease->cltt;
6fa69a
 
e83fb1
@@ -3225,6 +3250,8 @@ void ack_lease (packet, lease, offer, wh
6fa69a
 #endif
6fa69a
 			dhcp_reply(lease);
6fa69a
 	}
6fa69a
+
6fa69a
+	TRACE(DHCPD_ACK_LEASE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /*
e83fb1
@@ -3377,6 +3404,8 @@ void dhcp_reply (lease)
6fa69a
 	if (!state)
6fa69a
 		log_fatal ("dhcp_reply was supplied lease with no state!");
6fa69a
 
6fa69a
+	TRACE(DHCPD_REPLY_START());
6fa69a
+
6fa69a
 	/* Compose a response for the client... */
6fa69a
 	memset (&raw, 0, sizeof raw);
6fa69a
 	memset (&d1, 0, sizeof d1);
e83fb1
@@ -3598,6 +3627,8 @@ void dhcp_reply (lease)
6fa69a
 
6fa69a
 	free_lease_state (state, MDL);
6fa69a
 	lease -> state = (struct lease_state *)0;
6fa69a
+
6fa69a
+	TRACE(DHCPD_REPLY_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 int find_lease (struct lease **lp,
e83fb1
@@ -3620,6 +3651,8 @@ int find_lease (struct lease **lp,
6fa69a
 	struct data_string client_identifier;
6fa69a
 	struct hardware h;
6fa69a
 
6fa69a
+	TRACE(DHCPD_FIND_LEASE_START());
6fa69a
+
6fa69a
 #if defined(FAILOVER_PROTOCOL)
6fa69a
 	/* Quick check to see if the peer has leases. */
6fa69a
 	if (peer_has_leases) {
e83fb1
@@ -4347,6 +4380,9 @@ int find_lease (struct lease **lp,
6fa69a
 #if defined (DEBUG_FIND_LEASE)
6fa69a
 	log_info ("Not returning a lease.");
6fa69a
 #endif
6fa69a
+
6fa69a
+	TRACE(DHCPD_FIND_LEASE_DONE());
6fa69a
+
6fa69a
 	return 0;
6fa69a
 }
6fa69a
 
e83fb1
diff -up dhcp-4.3.0a1/server/dhcpd.c.systemtap dhcp-4.3.0a1/server/dhcpd.c
e83fb1
--- dhcp-4.3.0a1/server/dhcpd.c.systemtap	2013-12-20 13:30:26.281643471 +0100
e83fb1
+++ dhcp-4.3.0a1/server/dhcpd.c	2013-12-20 13:33:26.013144200 +0100
ee81fb
@@ -58,6 +58,8 @@ static const char url [] =
ee81fb
 #  undef group
ee81fb
 #endif /* PARANOIA */
6fa69a
 
6fa69a
+#include "trace.h"
6fa69a
+
c72a79
 #ifndef UNIT_TEST
6fa69a
 static void usage(void);
c72a79
 #endif
e83fb1
@@ -793,6 +795,8 @@ main(int argc, char **argv) {
e83fb1
 	/* Log that we are about to start working */
e83fb1
 	log_info("Server starting service.");
ee81fb
 
e83fb1
+	TRACE(DHCPD_MAIN());
e83fb1
+
e83fb1
 	/*
e83fb1
 	 * Receive packets and dispatch them...
e83fb1
 	 * dispatch() will never return.
e83fb1
diff -up dhcp-4.3.0a1/server/dhcpv6.c.systemtap dhcp-4.3.0a1/server/dhcpv6.c
e83fb1
--- dhcp-4.3.0a1/server/dhcpv6.c.systemtap	2013-12-20 13:30:26.272643596 +0100
e83fb1
+++ dhcp-4.3.0a1/server/dhcpv6.c	2013-12-20 13:33:48.296834064 +0100
e83fb1
@@ -17,6 +17,7 @@
e83fb1
 /*! \file server/dhcpv6.c */
6fa69a
 
6fa69a
 #include "dhcpd.h"
6fa69a
+#include "trace.h"
6fa69a
 
6fa69a
 #ifdef DHCPv6
6fa69a
 
e83fb1
@@ -4763,6 +4764,8 @@ static void
6fa69a
 dhcpv6_solicit(struct data_string *reply_ret, struct packet *packet) {
6fa69a
 	struct data_string client_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_SOLICIT_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Validate our input.
6fa69a
 	 */
e83fb1
@@ -4776,6 +4779,8 @@ dhcpv6_solicit(struct data_string *reply
6fa69a
 	 * Clean up.
6fa69a
 	 */
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_SOLICIT_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /*
e83fb1
@@ -4789,6 +4794,8 @@ dhcpv6_request(struct data_string *reply
6fa69a
 	struct data_string client_id;
6fa69a
 	struct data_string server_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_REQUEST_START());
6fa69a
+
6fa69a
 	/*
6fa69a
 	 * Validate our input.
6fa69a
 	 */
e83fb1
@@ -4806,6 +4813,8 @@ dhcpv6_request(struct data_string *reply
6fa69a
 	 */
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
 	data_string_forget(&server_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_REQUEST_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /* Find a DHCPv6 packet's shared network from hints in the packet.
e83fb1
@@ -4918,6 +4927,8 @@ dhcpv6_confirm(struct data_string *reply
6fa69a
 	struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
6fa69a
 	int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_CONFIRM_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Basic client message validation.
6fa69a
 	 */
e83fb1
@@ -5104,6 +5115,8 @@ exit:
6fa69a
 		option_state_dereference(&cli_enc_opt_state, MDL);
6fa69a
 	if (opt_state != NULL)
6fa69a
 		option_state_dereference(&opt_state, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_CONFIRM_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /*
e83fb1
@@ -5118,6 +5131,8 @@ dhcpv6_renew(struct data_string *reply,
6fa69a
 	struct data_string client_id;
6fa69a
 	struct data_string server_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_RENEW_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Validate the request.
6fa69a
 	 */
e83fb1
@@ -5135,6 +5150,8 @@ dhcpv6_renew(struct data_string *reply,
6fa69a
 	 */
6fa69a
 	data_string_forget(&server_id, MDL);
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_RENEW_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /*
e83fb1
@@ -5148,6 +5165,8 @@ static void
6fa69a
 dhcpv6_rebind(struct data_string *reply, struct packet *packet) {
6fa69a
 	struct data_string client_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_REBIND_START());
6fa69a
+
6fa69a
 	if (!valid_client_msg(packet, &client_id)) {
6fa69a
 		return;
6fa69a
 	}
e83fb1
@@ -5155,6 +5174,8 @@ dhcpv6_rebind(struct data_string *reply,
6fa69a
 	lease_to_client(reply, packet, &client_id, NULL);
6fa69a
 
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_REBIND_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 static void
e83fb1
@@ -5599,6 +5620,8 @@ dhcpv6_decline(struct data_string *reply
6fa69a
 	struct data_string client_id;
6fa69a
 	struct data_string server_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_DECLINE_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Validate our input.
6fa69a
 	 */
e83fb1
@@ -5619,6 +5642,8 @@ dhcpv6_decline(struct data_string *reply
6fa69a
 
6fa69a
 	data_string_forget(&server_id, MDL);
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_DECLINE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 static void
e83fb1
@@ -6067,6 +6092,8 @@ dhcpv6_release(struct data_string *reply
6fa69a
 	struct data_string client_id;
6fa69a
 	struct data_string server_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_RELEASE_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Validate our input.
6fa69a
 	 */
e83fb1
@@ -6088,6 +6115,8 @@ dhcpv6_release(struct data_string *reply
6fa69a
 
6fa69a
 	data_string_forget(&server_id, MDL);
6fa69a
 	data_string_forget(&client_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_RELEASE_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /*
e83fb1
@@ -6100,6 +6129,8 @@ dhcpv6_information_request(struct data_s
6fa69a
 	struct data_string client_id;
6fa69a
 	struct data_string server_id;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_INFORMATION_REQUEST_START());
6fa69a
+
6fa69a
 	/*
6fa69a
 	 * Validate our input.
6fa69a
 	 */
e83fb1
@@ -6131,6 +6162,8 @@ dhcpv6_information_request(struct data_s
6fa69a
 		data_string_forget(&client_id, MDL);
6fa69a
 	}
6fa69a
 	data_string_forget(&server_id, MDL);
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_INFORMATION_REQUEST_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 /* 
e83fb1
@@ -6159,6 +6192,8 @@ dhcpv6_relay_forw(struct data_string *re
6fa69a
 	struct dhcpv6_relay_packet *reply;
6fa69a
 	int reply_ofs;
6fa69a
 
6fa69a
+	TRACE(DHCPD_6_RELAY_FORW_START());
6fa69a
+
6fa69a
 	/* 
6fa69a
 	 * Initialize variables for early exit.
6fa69a
 	 */
e83fb1
@@ -6418,6 +6453,8 @@ exit:
6fa69a
 	if (enc_packet != NULL) {
6fa69a
 		packet_dereference(&enc_packet, MDL);
6fa69a
 	}
6fa69a
+
6fa69a
+	TRACE(DHCPD_6_RELAY_FORW_DONE());
6fa69a
 }
6fa69a
 
6fa69a
 static void
e83fb1
diff -up dhcp-4.3.0a1/server/failover.c.systemtap dhcp-4.3.0a1/server/failover.c
e83fb1
--- dhcp-4.3.0a1/server/failover.c.systemtap	2013-12-11 01:25:12.000000000 +0100
e83fb1
+++ dhcp-4.3.0a1/server/failover.c	2013-12-20 13:30:26.314643012 +0100
d5d042
@@ -36,6 +36,8 @@
6fa69a
 #include "dhcpd.h"
6fa69a
 #include <omapip omapip_p.h="">
6fa69a
 
6fa69a
+#include "trace.h"
6fa69a
+
6fa69a
 #if defined (FAILOVER_PROTOCOL)
6fa69a
 dhcp_failover_state_t *failover_states;
6fa69a
 static isc_result_t do_a_failover_option (omapi_object_t *,
e83fb1
@@ -1710,6 +1712,8 @@ isc_result_t dhcp_failover_set_state (dh
6fa69a
     struct lease *l;
6fa69a
     struct timeval tv;
6fa69a
 
6fa69a
+    TRACE(DHCPD_FAILOVER_SET_STATE_START(state->me.state, new_state));
6fa69a
+
6fa69a
     /* If we're in certain states where we're sending updates, and the peer
6fa69a
      * state changes, we need to re-schedule any pending updates just to
6fa69a
      * be on the safe side.  This results in retransmission.
e83fb1
@@ -1941,6 +1945,8 @@ isc_result_t dhcp_failover_set_state (dh
6fa69a
 	    break;
6fa69a
     }
6fa69a
 
6fa69a
+    TRACE(DHCPD_FAILOVER_SET_STATE_DONE());
6fa69a
+
6fa69a
     return ISC_R_SUCCESS;
6fa69a
 }
6fa69a
 
e83fb1
@@ -2428,6 +2434,8 @@ dhcp_failover_pool_dobalance(dhcp_failov
6fa69a
 	if (state -> me.state != normal)
6fa69a
 		return 0;
6fa69a
 
6fa69a
+	TRACE(DHCPD_FAILOVER_POOL_DOBALANCE_START());
6fa69a
+
6fa69a
 	state->last_balance = cur_time;
6fa69a
 
6fa69a
 	for (s = shared_networks ; s ; s = s->next) {
e83fb1
@@ -2588,6 +2596,8 @@ dhcp_failover_pool_dobalance(dhcp_failov
6fa69a
 	if (leases_queued)
6fa69a
 		commit_leases();
6fa69a
 
6fa69a
+	TRACE(DHCPD_FAILOVER_POOL_DOBALANCE_DONE());
6fa69a
+
6fa69a
 	return leases_queued;
6fa69a
 }
6fa69a
 
e83fb1
diff -up dhcp-4.3.0a1/server/probes.d.systemtap dhcp-4.3.0a1/server/probes.d
e83fb1
--- dhcp-4.3.0a1/server/probes.d.systemtap	2013-12-20 13:30:26.314643012 +0100
e83fb1
+++ dhcp-4.3.0a1/server/probes.d	2013-12-20 13:30:26.314643012 +0100
6fa69a
@@ -0,0 +1,43 @@
6fa69a
+provider dhcpd {
6fa69a
+	 probe main();
6fa69a
+	 probe discover_start()
6fa69a
+	 probe discover_done()
6fa69a
+	 probe request_start()
6fa69a
+	 probe request_done()
6fa69a
+	 probe release_start()
6fa69a
+	 probe release_done()
6fa69a
+	 probe decline_start()
6fa69a
+	 probe decline_done()
6fa69a
+	 probe inform_start()
6fa69a
+	 probe inform_done()
6fa69a
+	 probe nak_lease_start()
6fa69a
+	 probe nak_lease_done()
6fa69a
+	 probe ack_lease_start()
6fa69a
+	 probe ack_lease_done()
6fa69a
+	 probe reply_start()
6fa69a
+	 probe reply_done()
6fa69a
+	 probe find_lease_start()
6fa69a
+	 probe find_lease_done()
6fa69a
+	 probe 6_solicit_start()
6fa69a
+	 probe 6_solicit_done()
6fa69a
+	 probe 6_request_start()
6fa69a
+	 probe 6_request_done()
6fa69a
+	 probe 6_confirm_start()
6fa69a
+	 probe 6_confirm_done()
6fa69a
+	 probe 6_renew_start()
6fa69a
+	 probe 6_renew_done()
6fa69a
+	 probe 6_rebind_start()
6fa69a
+	 probe 6_rebind_done()
6fa69a
+	 probe 6_decline_start()
6fa69a
+	 probe 6_decline_done()
6fa69a
+	 probe 6_release_start()
6fa69a
+	 probe 6_release_done()
6fa69a
+	 probe 6_information_request_start()
6fa69a
+	 probe 6_information_request_done()
6fa69a
+	 probe 6_relay_forw_start()
6fa69a
+	 probe 6_relay_forw_done()
6fa69a
+	 probe failover_pool_dobalance_start()
6fa69a
+	 probe failover_pool_dobalance_done()
6fa69a
+	 probe failover_set_state_start(int, int) /* state, new_state */
6fa69a
+	 probe failover_set_state_done()
6fa69a
+};
e83fb1
diff -up dhcp-4.3.0a1/server/tests/Makefile.am.systemtap dhcp-4.3.0a1/server/tests/Makefile.am
e83fb1
--- dhcp-4.3.0a1/server/tests/Makefile.am.systemtap	2013-12-20 13:30:26.315642998 +0100
e83fb1
+++ dhcp-4.3.0a1/server/tests/Makefile.am	2013-12-20 13:34:57.263873891 +0100
e83fb1
@@ -21,6 +21,10 @@ DHCPLIBS = $(top_builddir)/common/libdhc
e83fb1
           $(top_builddir)/dhcpctl/libdhcpctl.la \
e83fb1
           $(BIND9_LIBDIR) -lirs-export -ldns-export -lisccfg-export -lisc-export
c72a79
 
c72a79
+if ENABLE_SYSTEMTAP
c72a79
+DHCPLIBS += ../probes.o
c72a79
+endif
c72a79
+
c72a79
 ATF_TESTS =
c72a79
 TESTS = 
c72a79
 if HAVE_ATF
e83fb1
diff -up dhcp-4.3.0a1/server/trace.h.systemtap dhcp-4.3.0a1/server/trace.h
e83fb1
--- dhcp-4.3.0a1/server/trace.h.systemtap	2013-12-20 13:30:26.315642998 +0100
e83fb1
+++ dhcp-4.3.0a1/server/trace.h	2013-12-20 13:30:26.315642998 +0100
6fa69a
@@ -0,0 +1,11 @@
6fa69a
+// trace.h
6fa69a
+
6fa69a
+#include "config.h"
6fa69a
+#ifdef HAVE_SYSTEMTAP
6fa69a
+// include the generated probes header and put markers in code
6fa69a
+#include "probes.h"
6fa69a
+#define TRACE(probe) probe
6fa69a
+#else
6fa69a
+// Wrap the probe to allow it to be removed when no systemtap available
6fa69a
+#define TRACE(probe)
6fa69a
+#endif
e83fb1
diff -up dhcp-4.3.0a1/tapset/Makefile.am.systemtap dhcp-4.3.0a1/tapset/Makefile.am
e83fb1
--- dhcp-4.3.0a1/tapset/Makefile.am.systemtap	2013-12-20 13:30:26.315642998 +0100
e83fb1
+++ dhcp-4.3.0a1/tapset/Makefile.am	2013-12-20 13:30:26.315642998 +0100
e83fb1
@@ -0,0 +1,26 @@
e83fb1
+# Makefile.am for dhcp/tapset
e83fb1
+# Jiri Popelka
e83fb1
+
e83fb1
+.PHONY: clean-local install-data-hook uninstall-local
e83fb1
+
e83fb1
+#
e83fb1
+EXTRA_DIST = dhcpd.stp
e83fb1
+TAPSET_FILES = $(EXTRA_DIST)
e83fb1
+TAPSET_INSTALL_DIR = $(DESTDIR)@ABS_TAPSET_DIR@
e83fb1
+
e83fb1
+if ENABLE_SYSTEMTAP
e83fb1
+all-local: $(TAPSET_FILES)
e83fb1
+
e83fb1
+clean-local:
e83fb1
+
e83fb1
+install-data-hook:
e83fb1
+	$(MKDIR_P) $(TAPSET_INSTALL_DIR)
e83fb1
+	$(INSTALL_DATA) $(TAPSET_FILES) $(TAPSET_INSTALL_DIR)
e83fb1
+
e83fb1
+uninstall-local:
e83fb1
+	@list='$(TAPSET_FILES)'; for p in $$list; do \
e83fb1
+	  echo " rm -f '$(TAPSET_INSTALL_DIR)/$$p'"; \
e83fb1
+	  rm -f "$(TAPSET_INSTALL_DIR)/$$p"; \
e83fb1
+	done
e83fb1
+endif
e83fb1
+
e83fb1
diff -up dhcp-4.3.0a1/tapset/dhcpd.stp.systemtap dhcp-4.3.0a1/tapset/dhcpd.stp
e83fb1
--- dhcp-4.3.0a1/tapset/dhcpd.stp.systemtap	2013-12-20 13:30:26.315642998 +0100
e83fb1
+++ dhcp-4.3.0a1/tapset/dhcpd.stp	2013-12-20 13:30:26.315642998 +0100
6fa69a
@@ -0,0 +1,212 @@
6fa69a
+/* dhcpd tapset
6fa69a
+   Copyright (C) 2011, Red Hat Inc.
6fa69a
+ */
6fa69a
+
6fa69a
+probe dhcpd_main = process("dhcpd").mark("main")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s(locals: %s)", $$name, $$locals);
6fa69a
+  
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_discover_start = process("dhcpd").mark("discover_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_discover_done = process("dhcpd").mark("discover_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_request_start = process("dhcpd").mark("request_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_request_done = process("dhcpd").mark("request_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_release_start = process("dhcpd").mark("release_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_release_done = process("dhcpd").mark("release_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_decline_start = process("dhcpd").mark("decline_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_decline_done = process("dhcpd").mark("decline_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_inform_start = process("dhcpd").mark("inform_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_inform_done = process("dhcpd").mark("inform_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_nak_lease_start = process("dhcpd").mark("nak_lease_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_nak_lease_done = process("dhcpd").mark("nak_lease_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_ack_lease_start = process("dhcpd").mark("ack_lease_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_ack_lease_done = process("dhcpd").mark("ack_lease_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_reply_start = process("dhcpd").mark("reply_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_reply_done = process("dhcpd").mark("reply_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_find_lease_start = process("dhcpd").mark("find_lease_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_find_lease_done = process("dhcpd").mark("find_lease_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_solicit_start = process("dhcpd").mark("6_solicit_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_solicit_done = process("dhcpd").mark("6_solicit_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_request_start = process("dhcpd").mark("6_request_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_request_done = process("dhcpd").mark("6_request_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_confirm_start = process("dhcpd").mark("6_confirm_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_confirm_done = process("dhcpd").mark("6_confirm_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_renew_start = process("dhcpd").mark("6_renew_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_renew_done = process("dhcpd").mark("6_renew_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_rebind_start = process("dhcpd").mark("6_rebind_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_rebind_done = process("dhcpd").mark("6_rebind_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_decline_start = process("dhcpd").mark("6_decline_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_decline_done = process("dhcpd").mark("6_decline_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_release_start = process("dhcpd").mark("6_release_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_release_done = process("dhcpd").mark("6_release_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_information_request_start = process("dhcpd").mark("6_information_request_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_information_request_done = process("dhcpd").mark("6_information_request_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_relay_forw_start = process("dhcpd").mark("6_relay_forw_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_6_relay_forw_done = process("dhcpd").mark("6_relay_forw_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_failover_pool_dobalance_start = process("dhcpd").mark("failover_pool_dobalance_start")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_failover_pool_dobalance_done = process("dhcpd").mark("failover_pool_dobalance_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}
6fa69a
+
6fa69a
+
6fa69a
+probe dhcpd_failover_set_state_start = process("dhcpd").mark("failover_set_state_start")
6fa69a
+{
6fa69a
+  state = $arg1;
6fa69a
+  new_state = $arg2;
6fa69a
+  probestr = sprintf("%s(state=%d, new_state=%d)", $$name, state, new_state);
6fa69a
+}
6fa69a
+
6fa69a
+probe dhcpd_failover_set_state_done = process("dhcpd").mark("failover_set_state_done")
6fa69a
+{
6fa69a
+  probestr = sprintf("%s", $$name);
6fa69a
+}