Git Product home page Git Product logo

bpf-samples's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ I'm an Open Source Software contributor and contributed Cilium VTEP to Cilium project
  • ๐ŸŒฑ Iโ€™m now working on eBPF networking, XDP DDoS
  • ๐Ÿ˜„ My youtube channel: BPFireOS
  • โšก Fun fact: I am a self-taught Linux user since 1998

bpf-samples's People

Contributors

vincentmli avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

bpf-samples's Issues

[Question]Two ways of BPF verifier

Hi Vincent,

Came from ur youtube video and great video.
I am a newbie for bpf and xdp here and trying learning everything about #bpf.

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

  1. just use the number 1, like https://github.com/vincentmli/bpf-samples/blob/master/tcp_ack.c#L42
        struct ethhdr *eth = (struct ethhdr *)data;
	struct iphdr *iph = (struct iphdr *)(eth + 1);
	struct tcphdr *tcphdr = (struct tcphdr *)(iph + 1);
        ...
	/* sanity check needed by the eBPF verifier */
	if ((void *)(tcphdr + 1) > data_end)
		return 0;
  1. use the offset, like sth beblow:
        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;

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.

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.