Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
enfiskutensykkel committed May 19, 2014
1 parent abf195b commit 5122f19
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET := aqmprobe
OBJECTS := main.o message_queue.o qdisc_probe.o file_operations.o
QDISC := pfifo
MODARGS := buffer_size=15 maximum_concurrent_events=20 flush_frequency=20
MODARGS := buffer_size=4096 maximum_concurrent_events=40 flush_frequency=2000

ifneq ($(KERNELRELEASE),)
ccflags-y += -DDEBUG
Expand All @@ -20,7 +20,7 @@ unload:
-rmmod $(TARGET).ko

load:
insmod $(TARGET).ko qdisc=$(QDISC) $(MODARGS)
insmod $(TARGET).ko filename=$(QDISC) qdisc=$(QDISC) $(MODARGS)

clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
Expand Down
4 changes: 1 addition & 3 deletions file_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ static ssize_t handle_read_file(struct file* file, char __user* buf, size_t len,

if (err != 0)
{
#ifdef DEBUG
printk(KERN_DEBUG "Flushing file: /proc/net/%s\n", filename);
#endif
// Force flush file
return err < 0 ? err : count;
}

Expand Down
17 changes: 3 additions & 14 deletions message_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ int mq_reserve(struct msg** slot)
#else
prev = cmpxchg64(&mq.tail, tail, (tail + 1) & size);
#endif

}
while (prev == tail);
while (prev != tail);

*slot = mq.qptr + prev;
*slot = mq.qptr + tail;
return 0;
}

Expand Down Expand Up @@ -125,21 +124,11 @@ int mq_dequeue(struct msg* buf)
mq.fcnt = mq.frst;
}

if (mq.head == mq.tail)
if (mq.head == mq.tail || !mq.qptr[mq.head].mark)
{
#ifdef DEBUG
printk(KERN_DEBUG "mq_dequeue: flushing queue\n");
#endif
return 1;
}

#ifdef DEBUG
if (mq.qptr[mq.head].mark == 0)
{
printk(KERN_ERR "mq_dequeue: dequeuing an unready message\n");
}
#endif

mq.qptr[mq.head].mark = 0;
*buf = mq.qptr[mq.head];
mq.head = (mq.head + 1) & (mq.size - 1);
Expand Down
4 changes: 0 additions & 4 deletions qdisc_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ static int handle_func_invoke(struct kretprobe_instance* ri, struct pt_regs* reg
// Message queue is full
*((struct msg**) ri->data) = NULL;
atomic_inc(&miss_counter);

#ifdef DEBUG
printk(KERN_WARNING "handle_func_invoke: Packet event report buffer is full\n");
#endif
return 0;
}

Expand Down

0 comments on commit 5122f19

Please sign in to comment.