Git Product home page Git Product logo

bpf-samples's People

Contributors

dcbeckett avatar qmonnet 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bpf-samples's Issues

Error on start rss -i eth0

Hi
AFter make with latest libbpf and test i get this error:

libbpf: failed to create map (name: 'ctrl_map'): Invalid argument(-22)
libbpf: failed to load object 'rss_kern.o'
Err: Cannot load file

error: expected top-level entity

Hi,

I am trying to setup the programmable rss demo app using the master branch from https://github.com/libbpf/libbpf :

git clone  https://github.com/Netronome/bpf-samples.git
cd programmable_rss/
make clean && make
cd ../libbpf/src/ && make clean;
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
rm -f *.o *.a *.so
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
rm -f rss
rm -f rss_kern.o
rm -f rss_user.o
rm -f *.ll
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c bpf.c -o bpf.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c btf.c -o btf.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c libbpf.c -o libbpf.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c libbpf_errno.c -o libbpf_errno.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c netlink.c -o netlink.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c nlattr.c -o nlattr.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c str_error.c -o str_error.o
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -g -O2 -Werror -Wall -c libbpf_probes.c -o libbpf_probes.o
ar rcs libbpf.a bpf.o btf.o libbpf.o libbpf_errno.o netlink.o nlattr.o str_error.o libbpf_probes.o
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
make[1]: Entering directory '/opt/bpf-samples/libbpf/src'
if [ ! -d 'root/usr/include/bpf' ]; then install -d -m 755 'root/usr/include/bpf'; fi; install bpf.h libbpf.h btf.h -m 644 'root/usr/include/bpf'
make[1]: Leaving directory '/opt/bpf-samples/libbpf/src'
cc -I../libbpf/src//root/usr/include/ -I../headers/ -L../libbpf/src/ -o rss rss_user.c -lbpf -lelf
clang -S \
    -D __BPF_TRACING__ \
    -I../libbpf/src//root/usr/include/ -I../headers/ \
    -Wall \
    -Wno-unused-value -Wno-pointer-sign \
    -Wno-compare-distinct-pointer-types \
    -Werror \
    -O2 -emit-llvm -c -g rss_kern.c
llc -march=bpf -filetype=obj -o rss_kern.o rss_kern.ll
llc: rss_kern.ll:2:1: error: expected top-level entity
source_filename = "rss_kern.c"
^
Makefile:56: recipe for target 'rss_kern.o' failed
make: *** [rss_kern.o] Error 1

Was just wondering if i am not missing something?

the bpf_map_update_elem in xdpdump_user.c crashes when key is more than 127

The the number of cpus are more than 127, then it hits assert, and upon checking we can see it is hitting following error:
If the key is 128 or more then the bpf syscall is failing.
bpf(BPF_MAP_UPDATE_ELEM, {map_fd=3, key=0x7fffae9f9478, value=0x7fffae9f9474, flags=BPF_ANY}, 72) = -1 E2BIG (Argument list too long)

I have verified the same key value works using linux bpf self test test_maps.

test_hashmap(unsigned int task, void *data)
  38 {
  39         long long key, next_key, first_key, value;
  40         int fd;
  41
  42         fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
  43                             2, map_flags);
  44         if (fd < 0) {
  45                 printf("Failed to create hashmap '%s'!\n", strerror(errno));
  46                 exit(1);
  47         }
  48
  49         key = 128;
  50         value = 1234;
  51         /* Insert key=1 element. */
  52         printf("insert key 128 and value 1234\n");
  53         assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0);
  54         printf("no assert\n");

l4lb program error

I am trying to run l4lb but when I run ./l4lb_stats.py -I ens4np0 to see the Load balancer outbound statistics, all the statistics are 0.
When I sniff on the interface with XDP program I can see the incoming traffic. So I think there is a problem with l4lb_stats.py file.

[Question]Two methods for BPF verifier

Hi there,

Newbie for bpf and xdp here and I like ur great repo very much.

I just found two methods for BPF verifier, which confuses me a lot:

  1. use the offset, something like https://github.com/Netronome/bpf-samples/blob/master/xdpdump/xdpdump_kern.c#L101
        void *data_end = (void *)(long)ctx->data_end;
	void *data = (void *)(long)ctx->data;
	struct ethhdr *eth = data;
        ...
       // use the offset
	off = sizeof(struct ethhdr);
        if (data + off > data_end)
		return XDP_PASS;
  1. just use the number 1, something like https://github.com/Netronome/bpf-samples/blob/master/xdpdump/xdpdump_kern.c#L45
        struct tcphdr *tcp;
	tcp = data + off;
	if (tcp + 1 > data_end)
		return false;

I learn that they are both for BPF verifier and I am wondering what's the difference between them, and when should I use one of them?
Feel free to correct me if I misunderstood something.

Look forwarding to your reply.

Could l4 load balance use XDP_REDIRECT?

I found that the xdp return code of l4lb_xdp.c finally is XDP_TX. However , The XDP_TX return code only support to send the packets to the same NIC card .

XDP_REDIRECT can send the received packets to another NIC . So if there any possibility to implement this load balance using XDP_REDIRECT ?

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.