From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: [PATCH iproute2-next] bpf: support map offload Date: Tue, 16 Jan 2018 23:50:54 -0800 Message-ID: <20180117075054.21899-1-jakub.kicinski@netronome.com> Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Jakub Kicinski To: dsahern@gmail.com, stephen@networkplumber.org, daniel@iogearbox.net Return-path: Received: from mail-pg0-f68.google.com ([74.125.83.68]:41780 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbeAQHvH (ORCPT ); Wed, 17 Jan 2018 02:51:07 -0500 Received: by mail-pg0-f68.google.com with SMTP id 136so10301865pgd.8 for ; Tue, 16 Jan 2018 23:51:07 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: When program is loaded with a specified ifindex, use that ifindex also when creating maps. Signed-off-by: Jakub Kicinski --- lib/bpf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/bpf.c b/lib/bpf.c index d32f1b808180..2db151e4dd3c 100644 --- a/lib/bpf.c +++ b/lib/bpf.c @@ -1208,7 +1208,7 @@ static int bpf_log_realloc(struct bpf_elf_ctx *ctx) static int bpf_map_create(enum bpf_map_type type, uint32_t size_key, uint32_t size_value, uint32_t max_elem, - uint32_t flags, int inner_fd) + uint32_t flags, int inner_fd, uint32_t ifindex) { union bpf_attr attr = {}; @@ -1218,6 +1218,7 @@ static int bpf_map_create(enum bpf_map_type type, uint32_t size_key, attr.max_entries = max_elem; attr.map_flags = flags; attr.inner_map_fd = inner_fd; + attr.map_ifindex = ifindex; return bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); } @@ -1632,7 +1633,9 @@ static int bpf_map_attach(const char *name, struct bpf_elf_ctx *ctx, errno = 0; fd = bpf_map_create(map->type, map->size_key, map->size_value, - map->max_elem, map->flags, map_inner_fd); + map->max_elem, map->flags, map_inner_fd, + ctx->ifindex); + if (fd < 0 || ctx->verbose) { bpf_map_report(fd, name, map, ctx, map_inner_fd); if (fd < 0) -- 2.15.1