From patchwork Mon Jan 11 15:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 566016 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46D0C1402C9 for ; Tue, 12 Jan 2016 03:00:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=qZvcujeA; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933532AbcAKP5V (ORCPT ); Mon, 11 Jan 2016 10:57:21 -0500 Received: from mail-pa0-f66.google.com ([209.85.220.66]:34619 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933454AbcAKP5T (ORCPT ); Mon, 11 Jan 2016 10:57:19 -0500 Received: by mail-pa0-f66.google.com with SMTP id yy13so24707916pab.1; Mon, 11 Jan 2016 07:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=20CE7RgzTuYYVXd2DlZ8fhQ2eUJx0LCtYiev9sZKZfk=; b=qZvcujeAuK5mCHJtV2XCs5/I7IATG1snp5bKq95+MKlYid4Td5UxxGNaJzVzddpUBN XjmmDW1om0jVr/kESOtpqFUWVPmAiV7wHsSlhn7+DtiFTuBL1Z/uz79wcHIH15aCxai+ xD17oODPXXTtD+oDxo9Eg22hIFDiz7r1fXDCxkeMnjHsxleuj7txWO4d98qgJJ6/DWin oB/PP4udxK95R7bUpu45NN+eqZ5IBt7qYlXGQlIkx6ETwgnUjU3QSNsaZDh8lke36spw x7rXiI3HfzCDRKJECDRLKAVjuDUNPlxOGTb97eCkvE0Ljq1bXOOTaNkuJESneXgwLtI8 Fi2g== X-Received: by 10.67.15.73 with SMTP id fm9mr150287701pad.130.1452527839380; Mon, 11 Jan 2016 07:57:19 -0800 (PST) Received: from localhost ([103.192.227.7]) by smtp.gmail.com with ESMTPSA id n84sm24237797pfa.45.2016.01.11.07.57.17 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 11 Jan 2016 07:57:18 -0800 (PST) From: Ming Lei To: linux-kernel@vger.kernel.org, Alexei Starovoitov Cc: "David S. Miller" , netdev@vger.kernel.org, Daniel Borkmann , Martin KaFai Lau , Ming Lei Subject: [PATCH 2/9] bpf: array map: use pre-defined nop map function Date: Mon, 11 Jan 2016 23:56:54 +0800 Message-Id: <1452527821-12276-3-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452527821-12276-1-git-send-email-tom.leiming@gmail.com> References: <1452527821-12276-1-git-send-email-tom.leiming@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org So that we can remove the per-map nop map fucntions. Signed-off-by: Ming Lei --- kernel/bpf/arraymap.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index b0799bc..9ad9031 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -17,6 +17,8 @@ #include #include +#include "bpf_map.h" + /* Called from syscall */ static struct bpf_map *array_map_alloc(union bpf_attr *attr) { @@ -115,12 +117,6 @@ static int array_map_update_elem(struct bpf_map *map, void *key, void *value, return 0; } -/* Called from syscall or from eBPF program */ -static int array_map_delete_elem(struct bpf_map *map, void *key) -{ - return -EINVAL; -} - /* Called when map->refcnt goes to zero, either from workqueue or from syscall */ static void array_map_free(struct bpf_map *map) { @@ -142,7 +138,7 @@ static const struct bpf_map_ops array_ops = { .map_get_next_key = array_map_get_next_key, .map_lookup_elem = array_map_lookup_elem, .map_update_elem = array_map_update_elem, - .map_delete_elem = array_map_delete_elem, + .map_delete_elem = map_delete_elem_nop, }; static struct bpf_map_type_list array_type __read_mostly = { @@ -178,11 +174,6 @@ static void fd_array_map_free(struct bpf_map *map) kvfree(array); } -static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key) -{ - return NULL; -} - /* only called from syscall */ static int fd_array_map_update_elem(struct bpf_map *map, void *key, void *value, u64 map_flags) @@ -262,7 +253,7 @@ static const struct bpf_map_ops prog_array_ops = { .map_alloc = fd_array_map_alloc, .map_free = fd_array_map_free, .map_get_next_key = array_map_get_next_key, - .map_lookup_elem = fd_array_map_lookup_elem, + .map_lookup_elem = map_lookup_elem_nop, .map_update_elem = fd_array_map_update_elem, .map_delete_elem = fd_array_map_delete_elem, .map_fd_get_ptr = prog_fd_array_get_ptr, @@ -328,7 +319,7 @@ static const struct bpf_map_ops perf_event_array_ops = { .map_alloc = fd_array_map_alloc, .map_free = perf_event_array_map_free, .map_get_next_key = array_map_get_next_key, - .map_lookup_elem = fd_array_map_lookup_elem, + .map_lookup_elem = map_lookup_elem_nop, .map_update_elem = fd_array_map_update_elem, .map_delete_elem = fd_array_map_delete_elem, .map_fd_get_ptr = perf_event_fd_array_get_ptr,