From patchwork Mon Jan 11 15:56:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 566017 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 29DDB1402C9 for ; Tue, 12 Jan 2016 03:00:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=QjQoCuBl; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760678AbcAKP5S (ORCPT ); Mon, 11 Jan 2016 10:57:18 -0500 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34903 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759403AbcAKP5P (ORCPT ); Mon, 11 Jan 2016 10:57:15 -0500 Received: by mail-pa0-f65.google.com with SMTP id gi1so32041043pac.2; Mon, 11 Jan 2016 07:57:15 -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=Yq0seoeTOqVa6j88RjbR3oHeQ0Tf1EREdXOFxieLolo=; b=QjQoCuBlvDSE1LPTV02RurUZtHKxMGBmPFybB7e21niPhCDek+LTf+TrzM1v4XD4mT ir4fyX9xP7bYvsCtek4v/En787mjsVazLc6ebOWY7GMKG6OpQdXJjoUR/A2qkrQWc2Yi DNn6zb6UXLN6KliXVIOxFHC9teKApfhQSFtyzaiJ/MenPt0UAzuYqO2/wgVXp//D+sa5 SyTSD7L6d9WRpYVA6FU9amyZ+x4VEepLsSomdVGtWv5Qk1wbYgGkE/h8moy0aUR95p80 EEjBfZ0z/BDxQ32WVmWWbIzZYx+Y7mhKlznndm7935LjjWRjNcOduz9z64eLyH3iyVlu aPSg== X-Received: by 10.67.2.73 with SMTP id bm9mr182298827pad.94.1452527835284; Mon, 11 Jan 2016 07:57:15 -0800 (PST) Received: from localhost ([103.192.227.7]) by smtp.gmail.com with ESMTPSA id v26sm24250576pfi.56.2016.01.11.07.57.14 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 11 Jan 2016 07:57:14 -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 1/9] bpf: prepare for moving map common stuff into one place Date: Mon, 11 Jan 2016 23:56:53 +0800 Message-Id: <1452527821-12276-2-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 This patch introduces some nop functions of map callback for use in all map implementation. Signed-off-by: Ming Lei --- kernel/bpf/Makefile | 2 +- kernel/bpf/bpf_map.h | 9 +++++++++ kernel/bpf/map.c | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 kernel/bpf/bpf_map.h create mode 100644 kernel/bpf/map.c diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile index 13272582..191d54b 100644 --- a/kernel/bpf/Makefile +++ b/kernel/bpf/Makefile @@ -1,4 +1,4 @@ obj-y := core.o obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o -obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o +obj-$(CONFIG_BPF_SYSCALL) += map.o hashtab.o arraymap.o diff --git a/kernel/bpf/bpf_map.h b/kernel/bpf/bpf_map.h new file mode 100644 index 0000000..7e596c1 --- /dev/null +++ b/kernel/bpf/bpf_map.h @@ -0,0 +1,9 @@ +#ifndef INT_BPF_MAP_COMMON_H +#define INT_BPF_MAP_COMMON_H + +#include + +extern void *map_lookup_elem_nop(struct bpf_map *map, void *key); +extern int map_delete_elem_nop(struct bpf_map *map, void *key); + +#endif diff --git a/kernel/bpf/map.c b/kernel/bpf/map.c new file mode 100644 index 0000000..bf113fb --- /dev/null +++ b/kernel/bpf/map.c @@ -0,0 +1,26 @@ +/* + * bpf map common stuff + * + * Copyright (c) 2016 Ming Lei + * + * Authors: + * Ming Lei + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include + +void *map_lookup_elem_nop(struct bpf_map *map, void *key) +{ + return NULL; +} + +int map_delete_elem_nop(struct bpf_map *map, void *key) +{ + return -EINVAL; +} +