iovisor / iovisor/bcc

string functions

Open
#691 5 comments 14 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

This is on BPF tasks #574 as string factory (stringmap). Can we propose a minimal set of functions we'd like, to begin with? Here's my list:
- strstr() or strncmp() (or both)
- strlcat() and strlen(), or a basic snprintf()

Examples of current workarounds: strcmp():
- https://github.com/iovisor/bcc/blob/master/examples/networking/http_filter/http-parse-simple.c#L71
- https://github.com/weaveworks/scope/blob/master/examples/plugins/http-requests/http-requests.c#L95

strlcat():
- https://github.com/iovisor/bcc/blob/master/tools/execsnoop.py#L73

This emits arguments one by one. This is tricky, since we need to walk argv[] (currently using an unrolled loop). I was thinking strlcat() would let us build a concatenated args string, but it might need strlen() at some point. A basic snprintf() sounds much better, but .. gah this is awful.

How about a helper just for the argv[] case? :) Ie, take an argv[] argument and return a truncated string of the arguments. bpf_strarray_to_str().

Then, in lieu of another use case, my list is just:
- strstr() or strncmp() (or both)
- bpf_strarray_to_str()

@4ast may have another thread of discussion about this. I'm posting this here as it was suggested in IRC.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading BPF tasks #574 and the cited workarounds in http-parse-simple.c, http-requests.c, and execsnoop.py. The issue needs a decided minimal helper set—such as string comparison/search or argv[] conversion—before implementation can begin; done would mean an agreed scope and corresponding BPF string functionality.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.