diff --git a/src/Makefile b/src/Makefile index 9f259b6..4cf10c3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -26,7 +26,7 @@ LLC ?= llc LLVM_STRIP ?= llvm-strip BPFTOOL ?= bpftool BPF_INCLUDE := /usr/include -BPF_CFLAGS := -g -fno-stack-protector +BPF_CFLAGS := -g -fno-stack-protector -Wall NL_INCLUDE := /usr/include/libnl3 INCLUDES := -I../include -I$(BPF_INCLUDE) -I$(NL_INCLUDE) -I../include/uapi diff --git a/src/netns_tuner.bpf.c b/src/netns_tuner.bpf.c index ea1347e..314a06f 100644 --- a/src/netns_tuner.bpf.c +++ b/src/netns_tuner.bpf.c @@ -39,7 +39,6 @@ SEC("kretprobe/setup_net") int BPF_KRETPROBE(bpftune_setup_net_return, int ret) { struct bpftune_event event = {}; - __u64 current, *netnsp; struct net *netns; if (ret != 0) diff --git a/src/route_table_tuner.bpf.c b/src/route_table_tuner.bpf.c index 320d74d..4f54c2c 100644 --- a/src/route_table_tuner.bpf.c +++ b/src/route_table_tuner.bpf.c @@ -31,7 +31,7 @@ SEC("kprobe/fib6_run_gc") int BPF_KPROBE(bpftune_fib6_run_gc_entry, unsigned long expires, struct net *net, bool force) { - struct dst_net *dst_netp, dst_net = {}; + struct dst_net *dst_netp; get_entry_struct(dst_net_map, dst_netp); /* already in gc, skip */ diff --git a/src/sysctl_tuner.bpf.c b/src/sysctl_tuner.bpf.c index 1b2bcd3..15713a9 100644 --- a/src/sysctl_tuner.bpf.c +++ b/src/sysctl_tuner.bpf.c @@ -36,7 +36,7 @@ int BPF_KPROBE(bpftune_sysctl, struct ctl_table_header *head, struct bpftune_event event = {}; struct ctl_dir *root, *parent, *gparent, *ggparent; struct ctl_dir *gggparent; - struct ctl_table *tbl, *parent_table; + struct ctl_table *parent_table; int len = sizeof(event.str); const char *procname; int current_pid = 0; @@ -81,8 +81,6 @@ int BPF_KPROBE(bpftune_sysctl, struct ctl_table_header *head, procname = BPF_CORE_READ(parent_table, procname); if (procname) { if (!bpf_probe_read(event.str, sizeof(event.str), procname)) { - int i; - for (; len > 0 && *str; len--, str++) {} if (len == 0) return 0; diff --git a/src/tcp_cong_tuner.bpf.c b/src/tcp_cong_tuner.bpf.c index 77957b3..d83be0b 100644 --- a/src/tcp_cong_tuner.bpf.c +++ b/src/tcp_cong_tuner.bpf.c @@ -68,22 +68,6 @@ retransmit_threshold(struct remote_host *remote_host, return remote_host->retransmit_threshold; } -static __always_inline int get_sk_key(struct sock *sk, struct in6_addr *key) -{ - int family = BPF_CORE_READ(sk, sk_family); - switch (family) { - case AF_INET: - return bpf_probe_read_kernel(key, sizeof(sk->sk_daddr), - __builtin_preserve_access_index(&sk->sk_daddr)); - - case AF_INET6: - return bpf_probe_read_kernel(key, sizeof(*key), - __builtin_preserve_access_index(&sk->sk_v6_daddr)); - default: - return -EINVAL; - } -} - static __always_inline struct remote_host *get_remote_host(struct in6_addr *key) { struct remote_host *remote_host = NULL; @@ -129,8 +113,6 @@ int cong_tuner_sockops(struct bpf_sock_ops *ops) struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&event.raw_data; struct in6_addr *key = &sin6->sin6_addr; bool prior_retransmit_threshold; - char buf[CONG_MAXNAME] = {}; - int ret; switch (ops->op) { case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: @@ -179,6 +161,22 @@ int cong_tuner_sockops(struct bpf_sock_ops *ops) return 1; } #else +static __always_inline int get_sk_key(struct sock *sk, struct in6_addr *key) +{ + int family = BPF_CORE_READ(sk, sk_family); + + switch (family) { + case AF_INET: + return bpf_probe_read_kernel(key, sizeof(sk->sk_daddr), + __builtin_preserve_access_index(&sk->sk_daddr)); + case AF_INET6: + return bpf_probe_read_kernel(key, sizeof(*key), + __builtin_preserve_access_index(&sk->sk_v6_daddr)); + default: + return -EINVAL; + } +} + SEC("tp_btf/tcp_retransmit_skb") int BPF_PROG(cong_retransmit, struct sock *sk, struct sk_buff *skb) { @@ -188,7 +186,6 @@ int BPF_PROG(cong_retransmit, struct sock *sk, struct sk_buff *skb) struct tcp_sock *tp = (struct tcp_sock *)sk; struct in6_addr *key = &sin6->sin6_addr; __u32 segs_out = 0, total_retrans = 0; - const char bbr[CONG_MAXNAME] = "bbr"; int id = TCP_CONG_BBR; struct net *net; @@ -232,10 +229,8 @@ int bpftune_cong_iter(struct bpf_iter__tcp *ctx) { struct sock_common *skc = ctx->sk_common; struct remote_host *remote_host; - char buf[CONG_MAXNAME] = {}; struct in6_addr key = {}; struct sock *sk = NULL; - int ret; if (skc) sk = (struct sock *)bpf_skc_to_tcp_sock(skc);