From patchwork Sun Jan 17 22:54:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 12025875 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE14C433DB for ; Sun, 17 Jan 2021 22:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1622224B0 for ; Sun, 17 Jan 2021 22:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729625AbhAQWzP (ORCPT ); Sun, 17 Jan 2021 17:55:15 -0500 Received: from mail-wm1-f50.google.com ([209.85.128.50]:56156 "EHLO mail-wm1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbhAQWzN (ORCPT ); Sun, 17 Jan 2021 17:55:13 -0500 Received: by mail-wm1-f50.google.com with SMTP id c124so11996537wma.5 for ; Sun, 17 Jan 2021 14:54:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S+9BoYevb6oGYlL5PcDUa+DB5WIMCM4Zg5ujR0S9IFY=; b=RoS3wGh4RY7d+jUbHcrvXy0Xf/9wjMb2pn6w7sdVJ0/yrySwJVT1Wb5jlyI0sTwZHr XAyHCMuCHa4gZl9ZXbSelN8Aser2oa5PcxaWGashpWP6DWzIBaaozM8NEhQk6eQs/50C z0J+Q7yY/oqmE9gQ7KZ1t9G8a55N6KoNj7G06ZsZTtLxXP7Qohfys8RKj3Dmlgi2ZJvE EKMMj79w/eeDxpoh6PE4tKJ7RCkTkElYSU9QnSz2503aHS/Rt2isP1fgjPHbgwgUDchB cGQcpdvr1DqhNB4s4sVsExP24tte3kH1KXZLjzBdDdJkAkk0Jtv0GnaMf/MH1cb30NPM F2cA== X-Gm-Message-State: AOAM530vVUbY450jRk/L0nnnpfcy/OfkZ6ASVzjcyBWAbGf69kXP0d+S yQq+dzxKG3k/5z0gS/HCVu25ZlF1VSsj4Q== X-Google-Smtp-Source: ABdhPJyU1ZBBn9AsLv9HYQIcssEDXne7JSrvaWbB6Cb19z/XybykUQnHy8vN9v7dNO7jQvbQKj+GOQ== X-Received: by 2002:a05:600c:4101:: with SMTP id j1mr17998487wmi.55.1610924071771; Sun, 17 Jan 2021 14:54:31 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:e2db:6a88:4676:d01b]) by smtp.gmail.com with ESMTPSA id m14sm25301640wrh.94.2021.01.17.14.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 14:54:31 -0800 (PST) From: Luca Boccassi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org Subject: [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails Date: Sun, 17 Jan 2021 22:54:26 +0000 Message-Id: <20210117225427.29658-1-bluca@debian.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Necessary to understand what is going on when bpf_program_load fails Signed-off-by: Luca Boccassi Reviewed-by: David Ahern --- ip/ipvrf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ip/ipvrf.c b/ip/ipvrf.c index 42779e5c..91578031 100644 --- a/ip/ipvrf.c +++ b/ip/ipvrf.c @@ -278,8 +278,8 @@ static int vrf_configure_cgroup(const char *path, int ifindex) */ prog_fd = prog_load(ifindex); if (prog_fd < 0) { - fprintf(stderr, "Failed to load BPF prog: '%s'\n", - strerror(errno)); + fprintf(stderr, "Failed to load BPF prog: '%s'\n%s", + strerror(errno), bpf_log_buf); if (errno != EPERM) { fprintf(stderr, From patchwork Sun Jan 17 22:54:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 12025877 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F14DC433E6 for ; Sun, 17 Jan 2021 22:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 064CE224DF for ; Sun, 17 Jan 2021 22:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730128AbhAQWzS (ORCPT ); Sun, 17 Jan 2021 17:55:18 -0500 Received: from mail-wr1-f42.google.com ([209.85.221.42]:40913 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728543AbhAQWzP (ORCPT ); Sun, 17 Jan 2021 17:55:15 -0500 Received: by mail-wr1-f42.google.com with SMTP id 91so14744390wrj.7 for ; Sun, 17 Jan 2021 14:54:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1IC7EhsJCEVB8nk6o2Q/1uFPjRZrIlPtCyIE7xN/ecY=; b=p8EhgnLMmL+HsezPn/ftIBsVia4/BobX3pZ+0tU9qyIZ/hDu7KzcE6gyg8IOTS5Nwv klannIVgWR8aAMJNokxlcsIvjneHilj1LQhiQhuPo7RxFI/Fc5JEuzdjldQUOdrGW3Z7 QC6CHGzKGkhnk9iXC2lzCefvpNFiLCGGifXi6xVSm67DPaoXfhaAHCteZDlg8GoQDTXZ WR45rUDm5DzA6HLXIT+BNo9MrZvaY1fT5MlufSknlPFvRF+2nHT2dBozPHowT8pKQtyP FPU7DxtBDs7qAmi3TnWJnzcDP5TrcVSDef/YNzUorWst6hov/wYeu0e6xhR/Pc1T2tm3 2DtQ== X-Gm-Message-State: AOAM53268V55fqiEj3CUwq43xh2YAUhmxWL6A34Ha2oG4sDSwUhiJD47 lyIPEDyRnCECqXyE+ErIJUf90PC4M8+kZg== X-Google-Smtp-Source: ABdhPJz+p3g92xgJtfEzN85yo64OR+qd2orCcEjdhV6b/ruxxP6GOr0wSq/b0uk3/W+H1ye8L5sk8A== X-Received: by 2002:a5d:5005:: with SMTP id e5mr22617808wrt.279.1610924072866; Sun, 17 Jan 2021 14:54:32 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:e2db:6a88:4676:d01b]) by smtp.gmail.com with ESMTPSA id b7sm25052067wrv.47.2021.01.17.14.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 14:54:32 -0800 (PST) From: Luca Boccassi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org Subject: [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf Date: Sun, 17 Jan 2021 22:54:27 +0000 Message-Id: <20210117225427.29658-2-bluca@debian.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210117225427.29658-1-bluca@debian.org> References: <20210117225427.29658-1-bluca@debian.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com The size of bpf_insn is passed to bpf_load_program instead of the number of elements as it expects, so ip vrf exec fails with: $ sudo ip link add vrf-blue type vrf table 10 $ sudo ip link set dev vrf-blue up $ sudo ip/ip vrf exec vrf-blue ls Failed to load BPF prog: 'Invalid argument' last insn is not an exit or jmp processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 Kernel compiled with CGROUP_BPF enabled? https://bugs.debian.org/980046 Reported-by: Emmanuel DECAEN Signed-off-by: Luca Boccassi Reviewed-by: David Ahern --- lib/bpf_glue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bpf_glue.c b/lib/bpf_glue.c index fa609bfe..d00a0dc1 100644 --- a/lib/bpf_glue.c +++ b/lib/bpf_glue.c @@ -14,7 +14,8 @@ int bpf_program_load(enum bpf_prog_type type, const struct bpf_insn *insns, size_t size_log) { #ifdef HAVE_LIBBPF - return bpf_load_program(type, insns, size_insns, license, 0, log, size_log); + return bpf_load_program(type, insns, size_insns / sizeof(struct bpf_insn), + license, 0, log, size_log); #else return bpf_prog_load_dev(type, insns, size_insns, license, 0, log, size_log); #endif