Mindaugas Rasiukevicius
2013-08-04 19:12:49 UTC
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.
Note that bpf_filter(9) would need to take some context structure (which is
preferable in general).
Comments?
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.
Note that bpf_filter(9) would need to take some context structure (which is
preferable in general).
Comments?
--
Mindaugas
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Mindaugas
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de