From patchwork Thu Jul 3 07:52:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Shen Lim X-Patchwork-Id: 366603 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 DE6A91400B9 for ; Thu, 3 Jul 2014 17:52:48 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756485AbaGCHw3 (ORCPT ); Thu, 3 Jul 2014 03:52:29 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:58669 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756056AbaGCHw2 (ORCPT ); Thu, 3 Jul 2014 03:52:28 -0400 Received: by mail-pd0-f174.google.com with SMTP id y10so13349657pdj.19 for ; Thu, 03 Jul 2014 00:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0Xvpr9rResk9HT44AzkQX5QeoqwOmn8epJksLwyL+Ho=; b=dgAz/Dq695W1QmkZWQXMXuDXaWTfgENkIipaeXvXnh4dj8NUaltMpDPAR1YIxbA0pq icj2UKVfyYp3CaTflKP1eGP/ysKbEHYcPOnZ6GqB59eWcj9dh5PomrknAdcaeRx6ued3 YG5xZViWPaDKAtd0FIQAiZViI1otYsqhQGp5jj69qlQt45KUCedTAwypjANPJk0K5IMo 4+bg4M6C1OhLeiN8GvwtuEaAgwD2f3UeP1zhWXu97UaGpffDnTXwzSAqNkqqecAGfslX AkjxAL9wRwWAupAXIs4YFJ+J0vQBWsLABhYUM4uUDnfcfEGVSOzlMaY/yJo6wpt18PJl S4bg== X-Received: by 10.68.132.42 with SMTP id or10mr3054184pbb.80.1404373947871; Thu, 03 Jul 2014 00:52:27 -0700 (PDT) Received: from gup76.hsd1.ca.comcast.net ([98.234.176.204]) by mx.google.com with ESMTPSA id nj8sm35379696pbc.39.2014.07.03.00.52.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Jul 2014 00:52:27 -0700 (PDT) From: Zi Shen Lim To: "David S. Miller" Cc: Zi Shen Lim , Alexei Starovoitov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: filter: move load_pointer() into filter.h Date: Thu, 3 Jul 2014 00:52:12 -0700 Message-Id: <1404373932-10929-1-git-send-email-zlim.lnx@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org load_pointer() is already a static inline function. Let's move it into filter.h so BPF JIT implementations can reuse this function. Signed-off-by: Zi Shen Lim --- This patch is based on discussion with Alexei in the context of reusing load_pointer for upcoming arm64 BPF JIT compiler. [1] Compile tested on x86_64 and arm64. [1] https://lkml.org/lkml/2014/7/3/14 include/linux/filter.h | 13 +++++++++++++ net/core/filter.c | 9 --------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index a7e3c48..2288e31 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -406,6 +407,18 @@ static inline u16 bpf_anc_helper(const struct sock_filter *ftest) } } +void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, + int k, unsigned int size); + +static inline void *load_pointer(const struct sk_buff *skb, int k, + unsigned int size, void *buffer) +{ + if (k >= 0) + return skb_header_pointer(skb, k, size, buffer); + + return bpf_internal_load_pointer_neg_helper(skb, k, size); +} + #ifdef CONFIG_BPF_JIT #include #include diff --git a/net/core/filter.c b/net/core/filter.c index 1dbf646..1c726ea 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -84,15 +84,6 @@ void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, uns return NULL; } -static inline void *load_pointer(const struct sk_buff *skb, int k, - unsigned int size, void *buffer) -{ - if (k >= 0) - return skb_header_pointer(skb, k, size, buffer); - - return bpf_internal_load_pointer_neg_helper(skb, k, size); -} - /** * sk_filter - run a packet through a socket filter * @sk: sock associated with &sk_buff