GithubHelp home page GithubHelp logo

hoang-tranviet / tcp-options-bpf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from torvalds/linux

27.0 3.0 11.0 2.36 GB

Linux kernel: eBPF support for user-defined TCP options

License: Other

Makefile 0.26% Roff 0.02% C 96.34% Assembly 1.35% C++ 1.37% Objective-C 0.31% Shell 0.10% Perl 0.13% Awk 0.01% Python 0.09% sed 0.01% Yacc 0.02% Lex 0.01% UnrealScript 0.01% Gherkin 0.01% XS 0.01% Clojure 0.01% M4 0.01% SmPL 0.02% Raku 0.01%

tcp-options-bpf's Introduction

eBPF support for user-defined TCP options
=========================================

This work is based on TCP-BPF framework by Lawrence Brakmo, 
which is already merged in recent kernels.

This is a part of our academic work. For more information, please read our paper:

    https://www.arxiv-vanity.com/papers/1901.01863/

The BPF programs and user daemon/script are in the tcp-option/ folder.

- test_tcp_user.c: user daemon to load BPF program and run experiments 
- my_net*.sh: script to set up the network environment, similar to mininet.
 We cannot use mininet since it based on cgroup-v1, while tcp-bpf use cgroup-v2.
- bpf_tcp_*.c: BPF programs.

How to run
-----------

    cd tcp-option
    make
    sudo ./test_tcp_user  bpf_tcp_cc_kern.o

Be aware to specify the BPF-compiled object (ended with '.o').
Or add ``-q`` to suppress the debug information:

    sudo ./test_tcp_user  bpf_tcp_cc_kern.o -q

Authors
-------

Viet-Hoang Tran and Olivier Bonaventure.
@ INL, ICTEAM, UCLouvain.

tcp-options-bpf's People

Contributors

acmel avatar adrianbunk avatar airlied avatar alexdeucher avatar arndb avatar axellin avatar bigguiness avatar broonie avatar bzolnier avatar danvet avatar davem330 avatar dhowells avatar geertu avatar gregkh avatar htejun avatar ickle avatar jmberg-intel avatar joeperches avatar larsclausen avatar linusw avatar mchehab avatar morimoto avatar olofj avatar pmundt avatar rafaeljw avatar ralfbaechle avatar rddunlap avatar tiwai avatar torvalds avatar vsyrjala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tcp-options-bpf's Issues

Compile bpf_tcp_uto_kern.c

Environment:

clang version 6.0.0-1ubuntu2
Ubuntu 18.04

Description:

I want to compile the code as the README file says. However, first I got the problem as follows:

bpf_tcp_uto_kern.c:93:25: error: use of undeclared identifier 'IPPROTO_TCP'
                bpf_setsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));

I include the head file netinet/in.h in bpf_tcp_uto_kern.c and get the broken pip problem:

/bin/sh: 1: llc: not found
make -C ../tools/lib/bpf OUTPUT=/home/yan/tcpEBPF/tcp-options-bpf/tcp-option/
make[1]: Entering directory '/home/yan/tcpEBPF/tcp-options-bpf/tools/lib/bpf'
make[1]: Leaving directory '/home/yan/tcpEBPF/tcp-options-bpf/tools/lib/bpf'
clang -I. -I./tools/testing/selftests/bpf/include/uapi -I../tools/include/uapi -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c bpf_tcp_uto_kern.c -o - |      \
llc -march=bpf -mcpu=probe -filetype=obj -o /home/yan/tcpEBPF/tcp-options-bpf/tcp-option/bpf_tcp_uto_kern.o
/bin/sh: 3: llc: not found
clang: error: unable to execute command: Broken pipe
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/bpf_tcp_uto_kern-dbf30b.c
clang: note: diagnostic msg: /tmp/bpf_tcp_uto_kern-dbf30b.sh
clang: note: diagnostic msg: 


Makefile:61: recipe for target '/home/yan/tcpEBPF/tcp-options-bpf/tcp-option/bpf_tcp_uto_kern.o' failed
make: *** [/home/yan/tcpEBPF/tcp-options-bpf/tcp-option/bpf_tcp_uto_kern.o] Error 127

Is there something wrong about my compile environment?

How to reproduce:

cd tcp-option
make

error in "sudo ./test_tcp_user bpf_tcp_cc_kern.o"

Dear Viet-Hoang Tran,

I would like to run tcp-options-bpf (https://github.com/hoang-tranviet/tcp-options-bpf) on my own PC to better understand your work. I have put this set of source code in Ubuntu 18 04, got kernel 4.17-rc5 after compilation. However, when I execute the "sudo ./test_tcp_user bpf_tcp_cc_kern.o" instruction, it always report an error. I tried to google this error but found nothing helpful. Could you give me some hints about this error?
The details:

loading bpf program: bpf_tcp_cc_kern.o
system(echo**** 53709 >> /tmp/cgroupv2/foo/cgroup.procs) PASS!
libbpf: bpf_tcp_cc_kern.o doesn't provide kernel version
FAILED: load_bpf_file failed for: bpf_tcp_cc_kern.o

I will be very happy if you offered me an answer to this problem.

TCP-eBPF tuning between two VMs

Environment:

Ubuntu 18.04
Kernel: 5.0.6

Description:

Hi,
I want to set up a test case where there is one server and one client (download) on two different VMs. I was using a python server and curl command to download a big file from server VM. I want to use TCP-eBPF to tune the TCP options. I set the bandwidth and delay to be 2Mbit and 40 ms. However, I get the result as follows:
image
I seems that the eBPF program is not tuning the TCP options. The cubic is the default congestion control I am using. The bpf_reno and bpf_bbr is what I get when I was using TCP-eBPF.

How I run TCP-eBPF:

I use TC command to configure the network bandwidth and delay to 2Mbit and 40ms delay on server VM
I use command ./test_tcp_user bpf_tcp_cc_bbr.o to launch the program
I replace the network configuration file (my_net.sh )with a simple line of command to launch the python server I wrote. (This part works properly, the python server I write will give me the network delay information)
I use curl command on other machine to download the big file on server(without network configuration and TCP-eBPF)

Could you tell me why tcp-eBPF program is not tuning the TCP packets?

Thanks

Problems with compiling the Kernel

I am trying to run the repo on my Linux Host.

  • Step1: Cloned the repo
  • Step2: make menuconfig
  • Step3 : make -j3

I am getting the error while compiling . Can anyone help me resolve this issue. Thanks

Error

abn@abn-VirtualBox:~/tcp-options-bpf$ make -j3
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --syncconfig Kconfig
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  CHK     include/config/kernel.release
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
  UPD     include/config/kernel.release
  WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
  WRAP    arch/x86/include/generated/uapi/asm/poll.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  DESCEND  objtool
  HOSTCC   /home/abn/tcp-options-bpf/tools/objtool/fixdep.o
  HOSTLD   /home/abn/tcp-options-bpf/tools/objtool/fixdep-in.o
  LINK     /home/abn/tcp-options-bpf/tools/objtool/fixdep
  CC       /home/abn/tcp-options-bpf/tools/objtool/exec-cmd.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/help.o
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  CC       /home/abn/tcp-options-bpf/tools/objtool/pager.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/parse-options.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/run-command.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/sigchain.o
  GEN      /home/abn/tcp-options-bpf/tools/objtool/arch/x86/lib/inat-tables.c
  CC       /home/abn/tcp-options-bpf/tools/objtool/arch/x86/decode.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/subcmd-config.o
  LD       /home/abn/tcp-options-bpf/tools/objtool/libsubcmd-in.o
  AR       /home/abn/tcp-options-bpf/tools/objtool/libsubcmd.a
  CC       /home/abn/tcp-options-bpf/tools/objtool/builtin-check.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/builtin-orc.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/check.o
  LD       /home/abn/tcp-options-bpf/tools/objtool/arch/x86/objtool-in.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/orc_gen.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/orc_dump.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/elf.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/special.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/objtool.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/libstring.o
  CC       /home/abn/tcp-options-bpf/tools/objtool/str_error_r.o
  LD       /home/abn/tcp-options-bpf/tools/objtool/objtool-in.o
  LINK     /home/abn/tcp-options-bpf/tools/objtool/objtool
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  WRAP    arch/x86/include/generated/asm/dma-contiguous.h
  WRAP    arch/x86/include/generated/asm/early_ioremap.h
  WRAP    arch/x86/include/generated/asm/mcs_spinlock.h
  WRAP    arch/x86/include/generated/asm/mm-arch-hooks.h
  CC      scripts/mod/empty.o
  HOSTCC  scripts/selinux/genheaders/genheaders
  HOSTLD  arch/x86/tools/relocs
  HOSTCC  scripts/mod/mk_elfconfig
In file included from scripts/selinux/genheaders/genheaders.c:19:
./security/selinux/include/classmap.h:247:2: error: #error New address family defined, please update secclass_map.
  247 | #error New address family defined, please update secclass_map.
      |  ^~~~~
make[3]: *** [scripts/Makefile.host:90: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:559: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:559: scripts/selinux] Error 2
make[1]: *** Waiting for unfinished jobs....
  CC      scripts/mod/devicetable-offsets.s
  CC      kernel/bounds.s
  CHK     scripts/mod/devicetable-offsets.h
  UPD     scripts/mod/devicetable-offsets.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  UPD     include/generated/timeconst.h
  UPD     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/file2alias.o
  CHK     include/generated/asm-offsets.h
  UPD     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
make: *** [Makefile:1076: scripts] Error 2

Errors encountered compiling the kernel

Environment

Ubuntu 18.04

Problem

Sorry for the trouble I caused for you.
I try to compile the kernel you provided by running the Makefile under the tcp-option-bpf, but I came with this error information:

net/ipv4/tcp_input.c: In function ‘tcp_parse_options’:
net/ipv4/tcp_input.c:3814:9: error: ‘tp’ undeclared (first use in this function); did you mean ‘th’?
     if (tp == NULL)
         ^~
         th
net/ipv4/tcp_input.c:3814:9: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:312: recipe for target 'net/ipv4/tcp_input.o' failed
make[2]: *** [net/ipv4/tcp_input.o] Error 1
scripts/Makefile.build:559: recipe for target 'net/ipv4' failed
make[1]: *** [net/ipv4] Error 2
Makefile:1060: recipe for target 'net' failed
make: *** [net] Error 2

It says that the problem lies with the net/ipv4/tcp_input.
Is there some dependencies on my computer is wrong? Or some of the configurations are mistaken?
Thanks for your guidance and help.

Further information

I go through the code and find that the problem lies with the following code:

default:
{
	unsigned int data = 0;
	pr_debug("%s: Received unknown option type: %d, len: %d\n",
			 __func__, opcode, opsize);
	if (tp == NULL)
		break;
        memcpy(&data, ptr - 2, opsize);
        tcp_call_bpf_3arg((struct sock *)tp, BPF_TCP_PARSE_OPTIONS,opcode, opsize, data);
	break;
}

This part of code lies in the function:

void tcp_parse_options(const struct net *net,
		       const struct sk_buff *skb,
		       struct tcp_options_received *opt_rx, int estab,
		       struct tcp_fastopen_cookie *foc)

In this function, there is no definition of tp , although the definition of struct tcp_sock *tp is widespread across this file. This part is included in a Conditional Compiling part so I think that certain environment will trigger this problems while others won't.

It seems that you added this fraction of code in the commit on 4-Sept-2018, and I wonder whether this commitment introduced some potential failures.

If I have made any mistake in my analysis, please figure them out and I will be very happy if you offered me an answer to this problem.

Errors in make

Hi, I'm trying to use the code but I faced the problem in 'make' process.
Error msgs are as follows:

bpf_tcp_uto_kern.c:83:25: error: use of undeclared identifier 'IPPROTO_TCP'
bpf_setsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));
^
bpf_tcp_uto_kern.c:85:25: error: use of undeclared identifier 'IPPROTO_TCP'
bpf_getsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));
^
bpf_tcp_uto_kern.c:128:30: error: use of undeclared identifier 'IPPROTO_TCP'
rv = bpf_getsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));
^
bpf_tcp_uto_kern.c:144:30: error: use of undeclared identifier 'IPPROTO_TCP'
rv = bpf_setsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));
^
bpf_tcp_uto_kern.c:147:30: error: use of undeclared identifier 'IPPROTO_TCP'
rv = bpf_getsockopt(skops, IPPROTO_TCP, TCP_BPF_USER_TIMEOUT, &UserTimeout, sizeof(UserTimeout));

Similar errors occurs in other bpf_*.c
Is there any solution that I can do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.