Skip to content

Commit

Permalink
logging: Updated libccp with logging support
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayknarayan committed Apr 22, 2019
1 parent fb42c28 commit 1d0c64e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Comment/uncomment the following line to disable/enable debugging

DEBUG = n
ONE_PIPE = n
IPC = 0 # 0 == netlink, 1 == chardev

# Add your debugging flag (or not) to EXTRA_CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O1 -g -D__DEBUG__ # "-O" is needed to expand inlines
DEBFLAGS = -O1 -g -D__DEBUG__ -D__LOG_DEBUG__ # "-O" is needed to expand inlines
else
DEBFLAGS = -Ofast
endif
Expand All @@ -28,9 +28,11 @@ ccp-objs := libccp/serialize.o libccp/ccp_priv.o libccp/machine.o libccp/ccp.o c
obj-m := $(TARGET).o

all:
ifneq ($(KERNEL_VERSION_MAJOR),4)
$(error "Only kernel version 4 is supported: $(KERNEL_VERSION_MAJOR) $(KERNEL_VERSION_MINOR)")
ifneq ($(shell expr $(KERNEL_VERSION_MAJOR) \>= 4),1)
$(error "Only kernel version >= 4 is supported: $(KERNEL_VERSION_MAJOR) $(KERNEL_VERSION_MINOR)")
endif
ifeq ($(shell expr $(KERNEL_VERSION_MINOR) \>= 4),1)
endif
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) modules

clean:
Expand Down
2 changes: 1 addition & 1 deletion libccp
Submodule libccp updated 8 files
+22 −3 Makefile
+0 −1 README.md
+96 −68 ccp.c
+17 −41 ccp.h
+80 −28 ccp_priv.h
+226 −270 machine.c
+8 −4 serialize.c
+0 −5 test.c
23 changes: 4 additions & 19 deletions tcp_ccp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "tcp_ccp.h"
#include "libccp/ccp.h"

#if __KERNEL_VERSION_MINOR__ <= 16 && __KERNEL_VERSION_MINOR__ >= 13
#if __KERNEL_VERSION_MINOR__ <= 14 && __KERNEL_VERSION_MINOR__ >= 13
#define COMPAT_MODE
#elif __KERNEL_VERSION_MINOR__ >= 19
#define RATESAMPLE_MODE
Expand Down Expand Up @@ -71,21 +71,6 @@ static void do_set_rate_abs(
ccp_set_pacing_rate(sk, rate);
}

static void do_set_rate_rel(
struct ccp_datapath *dp,
struct ccp_connection *conn,
uint32_t factor
) {
struct sock *sk;
uint64_t newrate;
get_sock_from_ccp(&sk, conn);

// factor is * 100
newrate = sk->sk_pacing_rate * factor;
do_div(newrate, 100);
ccp_set_pacing_rate(sk, newrate);
}

struct timespec64 tzero;
static u64 ccp_now(void) {
struct timespec64 now, diff;
Expand Down Expand Up @@ -183,6 +168,7 @@ int load_primitives(struct sock *sk, const struct rate_sample *rs) {
#ifdef COMPAT_MODE
// receive rate
ack_us = tcp_stamp_us_delta(tp->tcp_mstamp, rs->prior_mstamp);

// send rate
for (i=0; i < MAX_SKB_STORED; i++) {
if (ca->skb_array[i].first_tx_mstamp == tp->first_tx_mstamp) {
Expand All @@ -202,7 +188,6 @@ int load_primitives(struct sock *sk, const struct rate_sample *rs) {
do_div(rout, ack_us);
}


mmt->bytes_acked = tp->bytes_acked - ca->last_bytes_acked;
ca->last_bytes_acked = tp->bytes_acked;

Expand All @@ -226,6 +211,7 @@ int load_primitives(struct sock *sk, const struct rate_sample *rs) {
if ( rout != 0 ) {
mmt->rate_incoming = rout;
}

mmt->bytes_in_flight = tcp_packets_in_flight(tp) * tp->mss_cache;
mmt->packets_in_flight = tcp_packets_in_flight(tp);
if (tp->snd_cwnd <= 0) {
Expand Down Expand Up @@ -348,7 +334,7 @@ void tcp_ccp_init(struct sock *sk) {
cpl->last_bytes_acked = tp->bytes_acked;
cpl->last_sacked_out = tp->sacked_out;

cpl->skb_array = (struct skb_info*)__MALLOC__(MAX_SKB_STORED * sizeof(struct skb_info));
cpl->skb_array = (struct skb_info*)kmalloc(MAX_SKB_STORED * sizeof(struct skb_info), GFP_KERNEL);
if (!(cpl->skb_array)) {
pr_info("ccp: could not allocate skb array\n");
}
Expand Down Expand Up @@ -405,7 +391,6 @@ static int __init tcp_ccp_register(void) {
struct ccp_datapath dp = {
.set_cwnd = &do_set_cwnd,
.set_rate_abs = &do_set_rate_abs,
.set_rate_rel = &do_set_rate_rel,
.now = &ccp_now,
.since_usecs = &ccp_since,
.after_usecs = &ccp_after
Expand Down

0 comments on commit 1d0c64e

Please sign in to comment.