public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox•net>
To: Joe Stringer <joe@ovn•org>, netdev@vger•kernel.org
Cc: wangnan0@huawei•com, ast@fb•com
Subject: Re: [PATCH net-next 2/3] tools lib bpf: Sync with samples/bpf/libbpf
Date: Wed, 02 Nov 2016 03:52:54 +0100	[thread overview]
Message-ID: <58195506.8040205@iogearbox.net> (raw)
In-Reply-To: <20161031183917.9938-3-joe@ovn.org>

On 10/31/2016 07:39 PM, Joe Stringer wrote:
> Extend the tools/ version of libbpf to include all of the functionality
> provided in the samples/bpf version.
>
> Signed-off-by: Joe Stringer <joe@ovn•org>
> ---
>   tools/lib/bpf/bpf.c    | 139 +++++++++++++++++++++++++++------
>   tools/lib/bpf/bpf.h    | 208 +++++++++++++++++++++++++++++++++++++++++++++++--
>   tools/lib/bpf/libbpf.c |   3 +-
>   3 files changed, 317 insertions(+), 33 deletions(-)
>
[...]
> +int open_raw_sock(const char *name)
> +{
> +	struct sockaddr_ll sll;
> +	int sock;
> +
> +	sock = socket(PF_PACKET, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC,
> +		      htons(ETH_P_ALL));
> +	if (sock < 0) {
> +		printf("cannot create raw socket\n");
> +		return -1;
> +	}
> +
> +	memset(&sll, 0, sizeof(sll));
> +	sll.sll_family = AF_PACKET;
> +	sll.sll_ifindex = if_nametoindex(name);
> +	sll.sll_protocol = htons(ETH_P_ALL);
> +	if (bind(sock, (struct sockaddr *)&sll, sizeof(sll)) < 0) {
> +		printf("bind to %s: %s\n", name, strerror(errno));
> +		close(sock);
> +		return -1;
> +	}
> +
> +	return sock;
> +}
> +
> +int perf_event_open(struct perf_event_attr *attr, int pid, int cpu,
> +		    int group_fd, unsigned long flags)
> +{
> +	return syscall(__NR_perf_event_open, attr, pid, cpu,
> +		       group_fd, flags);
>   }

I'm actually wondering, above bits are not really libbpf related. Maybe
these should go elsewhere into some other misc header file just for the
samples to use?

> diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
> index e8ba54087497..227edb23c022 100644
> --- a/tools/lib/bpf/bpf.h
> +++ b/tools/lib/bpf/bpf.h
> @@ -23,16 +23,208 @@
>
>   #include <linux/bpf.h>
>
> +struct bpf_insn;
> +

Isn't that already defined in the above uapi bpf.h anyway?

>   int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
> -		   int max_entries);
> +		   int max_entries, int map_flags);
> +int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags);
> +int bpf_lookup_elem(int fd, void *key, void *value);
> +int bpf_delete_elem(int fd, void *key);
> +int bpf_get_next_key(int fd, void *key, void *next_key);
> +
> +int bpf_load_program(enum bpf_prog_type prog_type,
> +		     const struct bpf_insn *insns, int insn_len,
> +		     const char *license, int kern_version,
> +		     char *log_buf, size_t log_buf_sz);
> +
> +int bpf_obj_pin(int fd, const char *pathname);
> +int bpf_obj_get(const char *pathname);

  reply	other threads:[~2016-11-02  2:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 18:39 [PATCH net-next 0/3] tools lib bpf: Synchronize implementations Joe Stringer
2016-10-31 18:39 ` [PATCH net-next 1/3] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h Joe Stringer
2016-10-31 18:39 ` [PATCH net-next 2/3] tools lib bpf: Sync with samples/bpf/libbpf Joe Stringer
2016-11-02  2:52   ` Daniel Borkmann [this message]
2016-11-02  3:50     ` Joe Stringer
2016-10-31 18:39 ` [PATCH net-next 3/3] tools lib bpf: Sync bpf_map_def with tc Joe Stringer
2016-11-02  3:09   ` Daniel Borkmann
2016-11-02  4:09     ` Joe Stringer
2016-11-02 14:12       ` Daniel Borkmann
2016-11-02 15:08         ` Daniel Borkmann
2016-11-01 15:48 ` [PATCH net-next 0/3] tools lib bpf: Synchronize implementations David Miller
2016-11-01 20:51 ` David Ahern
2016-11-01 22:17   ` Joe Stringer
2016-11-02  2:46     ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58195506.8040205@iogearbox.net \
    --to=daniel@iogearbox$(echo .)net \
    --cc=ast@fb$(echo .)com \
    --cc=joe@ovn$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=wangnan0@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox