From patchwork Wed Sep 27 14:04:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Gallek X-Patchwork-Id: 819190 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y2KMl0kLjz9sRq for ; Thu, 28 Sep 2017 00:05:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932204AbdI0OFD (ORCPT ); Wed, 27 Sep 2017 10:05:03 -0400 Received: from mail-qk0-f182.google.com ([209.85.220.182]:45690 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753142AbdI0OFB (ORCPT ); Wed, 27 Sep 2017 10:05:01 -0400 Received: by mail-qk0-f182.google.com with SMTP id r141so13378397qke.2 for ; Wed, 27 Sep 2017 07:05:01 -0700 (PDT) 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; bh=ysvAHJ056HZWDTS+1pzZpZ3w36j9Xf+p7rPsi2bnTwA=; b=NDNfhojxCRMbUOeAiVHEBrv8HQ29ZuuCEC25QZb1byXCVtOkRVkPFzAcCIoLjIViBv qvHweRmW2vwptxhA1BHSRB1QynQ2G+5mfE8m2XdQppuBwLq7VbM6GkI9MZdD6qpP3uiL z6kVG6Wc5el4tbZJTXXOLSsDIIWu84NZD7/4/YatYLwnCeImDLvsdObI3zPKUksPTDPu 3XVGjpOlNZnc5BkwKFbc/72W5LFze/qG1Tm4W7BxxlYUTHH9IyibFOW931WUTuIfJ6HR Qt/yQBqUOnx0Shur0Nm5ntouoVFnCGjSmfHUUei7al7vMqTCTBJCQQZcS9sb4TKpdN4K YTpw== X-Gm-Message-State: AMCzsaXLAS6CMI9ji4zKM+HbzOPwdAkrgR9S0TPXcD19eyarF93C/pmA 4b+VzfP6U++9WhoziPieJdHJrg== X-Google-Smtp-Source: AOwi7QCW+tN0dhSWcIDnClmID2vn0RfDSZjVwBEgA4V+GM9LQVDA0tt58XPKEuNCFFCPXOSbKQuXpg== X-Received: by 10.55.166.131 with SMTP id p125mr2452251qke.264.1506521100637; Wed, 27 Sep 2017 07:05:00 -0700 (PDT) Received: from monkey.nyc.corp.google.com ([100.101.213.10]) by smtp.gmail.com with ESMTPSA id v192sm8564834qka.76.2017.09.27.07.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 07:04:59 -0700 (PDT) From: Craig Gallek To: Alexei Starovoitov , Daniel Borkmann , "David S . Miller" Cc: Chonggang Li , netdev@vger.kernel.org Subject: [PATCH net-next] libbpf: use map_flags when creating maps Date: Wed, 27 Sep 2017 10:04:58 -0400 Message-Id: <20170927140458.44337-1-kraigatgoog@gmail.com> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Craig Gallek This extends struct bpf_map_def to include a flags field. Note that this has the potential to break the validation logic in bpf_object__validate_maps and bpf_object__init_maps as they use sizeof(struct bpf_map_def) as a minimal allowable size of a map section. Any bpf program compiled with a smaller struct bpf_map_def will fail this check. I don't believe this will be an issue in practice as both compile-time definitions of struct bpf_map_def (in samples/bpf/bpf_load.h and tools/testing/selftests/bpf/bpf_helpers.h) have always been larger than this newly updated version in libbpf.h. Signed-off-by: Craig Gallek --- tools/lib/bpf/libbpf.c | 2 +- tools/lib/bpf/libbpf.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 35f6dfcdc565..6bea85f260a3 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -874,7 +874,7 @@ bpf_object__create_maps(struct bpf_object *obj) def->key_size, def->value_size, def->max_entries, - 0); + def->map_flags); if (*pfd < 0) { size_t j; int err = *pfd; diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 7959086eb9c9..6e20003109e0 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -207,6 +207,7 @@ struct bpf_map_def { unsigned int key_size; unsigned int value_size; unsigned int max_entries; + unsigned int map_flags; }; /*