From owner-freebsd-net@FreeBSD.ORG Mon Aug 5 05:20:13 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8E5E3973 for ; Mon, 5 Aug 2013 05:20:13 +0000 (UTC) (envelope-from freebsd-net@m.gmane.org) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5086F28C9 for ; Mon, 5 Aug 2013 05:20:12 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V6DD9-0002Ui-Gr for freebsd-net@freebsd.org; Mon, 05 Aug 2013 07:20:03 +0200 Received: from rebar.astron.com ([38.117.134.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 Aug 2013 07:20:03 +0200 Received: from christos by rebar.astron.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 Aug 2013 07:20:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-net@freebsd.org From: christos@astron.com (Christos Zoulas) Subject: Re: BPF_MISC+BPF_COP and BPF_COPX Date: Mon, 5 Aug 2013 04:36:59 +0000 (UTC) Lines: 32 Message-ID: References: <20130804191310.2FFBB14A152@mail.netbsd.org> <9813E50B-C557-4FE1-BADF-A2CFFCBB8BD7@felyko.com> X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: rebar.astron.com X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Cc: tech-net@netbsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2013 05:20:13 -0000 In article <9813E50B-C557-4FE1-BADF-A2CFFCBB8BD7@felyko.com>, Rui Paulo wrote: >On 4 Aug 2013, at 12:12, Mindaugas Rasiukevicius wrote: > >> Hello, >> >> I would like propose new BPF instructions for the misc category: BPF_COP >> and BPF_COPX. It would provide a capability of calling an external >> function - think of BPF "coprocessor". The argument for BPF_COP is an >> index to a pre-loaded array of function pointers. BPF_COPX takes the >> function index from the register X rather than a constant. >> >> BPF_STMT(BPF_MISC+BPF_COP, 0), /* A <- funcs[0](...) */ >> >> typedef uint32_t(*bpf_copfunc_t)(struct mbuf *pkt, >> uint32_t A, uint32_t *M); >> >> int bpf_set_cop(bpf_ctx_t *c, bpf_copfunc_t funcs[], size_t n); >> >> The arguments passed to a called function would be the packet, accumulator >> and the memory store. The return value would be stored in the accumulator >> and the register X would be reset to 0. Note that the function may also >> change the memory store. If the function index is out of range, then the >> register X would be set to 0xffffffff. Well, aside from the consideration that somehow bpf needs to understand what memory locations the coproc function alters (so that it considers them initialized), the bigger question is how does the code for those functions gets loaded and unloaded, and which bpf programs have access to those functions. christos