Git Product home page Git Product logo

Comments (3)

jschwinger233 avatar jschwinger233 commented on May 26, 2024 2

Not for now.

This is because currently we specify DLT_RAW to generate cbpf insns for skb without L2 header, as explained at

/*
DLT_RAW linktype tells pcap_compile() to generate cbpf instructions for
skb without link layer. This is because kernel doesn't supply L2 data
for many of functions, where skb->mac_len == 0, while the default
pcap_compile mode only works for a complete frame data, so we have to
specify this linktype to tell pcap that the data starts from L3 network
header.
*/
pcap := C.pcap_open_dead(C.DLT_RAW, MAXIMUM_SNAPLEN)

However it seems possible to make improvement for L2 skb. The rough idea is something like:

if (skb->mac_len == 0) {
    data_start = skb->mac_header;
    pcap_filter_l2(data_start, data_end);
} else {
    data_start = skb->network_header;
    pcap_filter_l3(data_start, data_end);
}

We can compile ebpf filter insns for both situations and inject them into pcap_filter_l2 and pcap_filter_l3 correspondingly.

from pwru.

llhhbc avatar llhhbc commented on May 26, 2024

@jschwinger233 Can this will be merged to master?

from pwru.

llhhbc avatar llhhbc commented on May 26, 2024

Thanks very much.

from pwru.

Related Issues (20)

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.