Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: OISF/suricata Loading
base: master
Choose a base ref
...
head repository: JustinAzoff/suricata Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 22, 2018

  1. problem: 2nd key in bpf_map_get_next_key usage is the current one.

    The 2nd key passed to bpf_map_get_next_key is the one that contains
    the current key in the iteration.
    
    If the map only contains a single key, after one call to
    bpf_map_get_next_key key is undefined and next_key is the first item.
    doing key = next_key and calling bpf_map_get_next_key ends the loop
    because there are no more keys and bpf_map_lookup_elem is never called
    with the first key.  I believe in maps containing more than one key this
    will just result in the first key being skipped.
    
    linux/samples/bpf/sampleip_user.c is one of the only uses of
    bpf_map_get_next_key I can find, and they do:
    
        key = 0, i = 0;
        while (bpf_map_get_next_key(fd, &key, &next_key) == 0) {
                bpf_map_lookup_elem(fd, &next_key, &value);
                counts[i].ip = next_key;
                counts[i++].count = value;
                key = next_key;
        }
    
    Note how bpf_map_lookup_elem is called with next_key, not key.
    
    To avoid having to change a ton of references to key, I just renamed key
    to prev_key and nextkey to key.
    JustinAzoff committed Aug 22, 2018
    Configuration menu
    Copy the full SHA
    be3c7d5 View commit details
    Browse the repository at this point in the history
Loading