Code Monkey home page Code Monkey logo

Comments (1)

andrea-tomassi avatar andrea-tomassi commented on September 16, 2024

I'm adding some more details, I think this is somehow interesting:

I finally solved the issue, this is my final analysis with the fix that makes the code working just fine:
The problem was inside the key itself. It is a struct with char[] fields.
In fact the BPF_MAP_TYPE_HASH consider as unique key the whole char[] content, INCLUDING the part following the '\0' termination charcter (and this is just obvious, my fault).
On the other hand, the user-space program reads keys as String, so the meaningful part of the key is just the one before the '\0' character.
I use PER_CPU_ARRAY to store keys (to overcome the 512 bytes limit). So the actual memory area is initialized to 0, but it gets dirty after the first usage.
This causes that multiple keys with the same meaningful part of the string gives a clash of keys.
e.g.
key1[] {'f', 'o', 'o', '\0', 'Q', 'z', '3' .....}
key2[] {'f', 'o', 'o', '\0', 'F', '3', '?' .....}
The solution is initializing the whole char[] to all zeros all the time before updating the my_bpf_hash_map_counter

from bumblebee.

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.