All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 835caf4a authored by Mike Hibler's avatar Mike Hibler

Urk. The pcap_breakloop trick for getting a thread out of the pcap dispatch

only works for FC4 (not RHL7 or RHL9) because that function only exists in
the libpcap on FC.  Fortunately, I don't think RHL7 and RHL9 exhibit the
problem in the first place.
parent 4947d608
......@@ -9,6 +9,7 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = tools/pcapper
SYSTEM := $(shell uname -s)
RHLVERSION := $(shell cat /etc/redhat-release | sed -e 's/Red Hat Linux release \([0-9]\).*/Linux\1/' | sed -e 's/Fedora Core release \([0-9]\).*/FC\1/')
include $(OBJDIR)/Makeconf
......@@ -38,6 +39,10 @@ LDFLAGS = -static
CFLAGS_FBSD = $(CFLAGS) $(TBCFLAGS)
CFLAGS_FBSD_NE = $(CFLAGS)
CFLAGS_LINUX = $(CFLAGS) -I/usr/include/pcap $(TBCFLAGS)
ifneq (,$(findstring FC, $(RHLVERSION)))
# XXX should be configed
CFLAGS_LINUX += -DHAVE_PCAP_BREAKLOOP
endif
LIBS_FBSD = $(PTHREADLIBS) $(TBLIBS) $(PCAPLIBS)
LIBS_FBSD_NE = $(PTHREADLIBS) $(PCAPLIBS)
......
......@@ -67,6 +67,20 @@
#define MAX_FILES 16
#define MAX_CLIENTS 8
/*
* What a hoot. The Linux (at least Fedora) version of pcapper
* will not timeout in the dispatch routine. It apparently will stay
* in recvfrom() til it gets a packet. So we blast all the pthreads
* out of recvfrom with a signal after setting the flag to force them
* to return from dispatch (pcap_breakloop).
*
* XXX we can only do this if pcap_breakloop exists, which apparently
* it doesn't on older Linux releases.
*/
#if defined(EVENTSYS) && defined(HAVE_PCAP_BREAKLOOP)
#define MUST_WAKEUP_PCAP
#endif
/*
* Program run to determine the control interface.
*/
......@@ -189,7 +203,7 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header,
const u_char *packet);
int getaddr(char *dev, struct in_addr *addr);
#ifdef EVENTSYS
#ifdef __linux__
#ifdef MUST_WAKEUP_PCAP
static void onusr1(int);
static void pthread_WAKEUPDAMIT(void);
#endif
......@@ -366,11 +380,9 @@ void usage(char *progname) {
static void cleanup(int sig)
{
killme = 1;
#ifdef EVENTSYS
#ifdef __linux__
#ifdef MUST_WAKEUP_PCAP
pthread_WAKEUPDAMIT();
#endif
#endif
}
/*
......@@ -962,15 +974,13 @@ int main (int argc, char **argv) {
action.sa_handler = cleanup;
sigaction(SIGTERM, &action, NULL);
sigaction(SIGINT, &action, NULL);
#ifdef EVENTSYS
#ifdef __linux__
#ifdef MUST_WAKEUP_PCAP
/*
* XXX serious hack. Need to catch SIGUSR1 in all threads
* so they can be signal()ed out of libpcap.
*/
action.sa_handler = onusr1;
sigaction(SIGUSR1, &action, NULL);
#endif
#endif
}
......@@ -1739,7 +1749,7 @@ int getaddr(char *dev, struct in_addr *addr) {
* out of recvfrom with a signal after setting the flag to force them
* to return from dispatch (pcap_breakloop).
*/
#ifdef __linux__
#ifdef MUST_WAKEUP_PCAP
static void
onusr1(int sig)
{
......@@ -1857,7 +1867,7 @@ callback(event_handle_t handle,
pthread_self(), reload);
fflush(stderr);
#ifdef __linux__
#ifdef MUST_WAKEUP_PCAP
pthread_WAKEUPDAMIT();
#endif
while (reload)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment