Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path builtin function #1492

Merged
merged 8 commits into from
Oct 14, 2020
Merged

Add path builtin function #1492

merged 8 commits into from
Oct 14, 2020

Commits on Oct 12, 2020

  1. Add pointee record to btf set

    When processing pointer attach point arguments we also need
    to add pointer record to the BTF set, se we are able to
    dereference it later on. This will allow to resolve f_path
    member in dpath call (added in following patches):
    
      # bpftrace  -e 'kfunc:filp_close { printf("%s\n", dpath(args->filp->f_path)); }'
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    026b67b View commit details
    Browse the repository at this point in the history
  2. Add fail argument to check_arg

    Adding fail argument to check_arg so we can have it failed,
    but still give a chance for other type. It will be used in
    following patch for d_path check, that allows both pointer
    and record types in the argument.
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    3dd63d4 View commit details
    Browse the repository at this point in the history
  3. Add d_path to features

    Adding BPFfeature::has_d_path function to test
    if dpath helper is available.
    
    Display it for --info option:
    
      # bpftrace --info
      ...
      Kernel helpers
        ...
        get_current_cgroup_id: yes
        send_signal: yes
        override_return: no
        dpath: yes
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    5905717 View commit details
    Browse the repository at this point in the history
  4. Add path builtin function

    Adding path builtin function that returns full path
    referenced by struct path pointer in argument.
    
      path(struct path *path)
    
    Example:
    
      # bpftrace  -e 'kfunc:filp_close { printf("%s\n", path(args->filp->f_path)); }'
      Attaching 1 probe...
      /proc/sys/net/ipv6/conf/eno2/disable_ipv6
      /proc/sys/net/ipv6/conf/eno2/use_tempaddr
      socket:[23276]
      /proc/sys/net/ipv6/conf/eno2/disable_ipv6
      socket:[17655]
      /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.1/net/eno2/type
      socket:[38745]
      /proc/sys/net/ipv6/conf/eno2/disable_ipv6
    
    The path returns the string with the path or empty string
    on error. I don't think it's necessary to return error code
    at the moment, however it can be added later in the second
    optional argument.
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    2df6741 View commit details
    Browse the repository at this point in the history
  5. Add changelog for path builtin

    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    2948244 View commit details
    Browse the repository at this point in the history
  6. Add dpath semantic_analyser test

    Adding semantic_analyser test.
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    c0d03d2 View commit details
    Browse the repository at this point in the history
  7. Adding path runtime test

    Adding path runtime test that checks on close being called
    on file within './testprogs/syscall read' test prog.
    
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    8f11951 View commit details
    Browse the repository at this point in the history
  8. Check a return value of dpath helper

    Signed-off-by: Masanori Misono <m.misono760@gmail.com>
    mmisono authored and olsajiri committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    9ee6139 View commit details
    Browse the repository at this point in the history