Commit 87218145 authored by Gary Lin's avatar Gary Lin

Add BPF_PROG_ARRAY for BPF_MAP_TYPE_PROG_ARRAY

Define a new macro to make it easier to declare a program array.
Also replace BPF_TABLE("prog") in examples and tests with
BPF_PROG_ARRAY.
Signed-off-by: default avatarGary Lin <glin@suse.com>
parent 40a0aee6
...@@ -17,7 +17,7 @@ struct counters { ...@@ -17,7 +17,7 @@ struct counters {
}; };
BPF_HASH(stats, struct ipkey, struct counters, 1024); BPF_HASH(stats, struct ipkey, struct counters, 1024);
BPF_TABLE("prog", int, int, parser, 10); BPF_PROG_ARRAY(parser, 10);
enum cb_index { enum cb_index {
CB_FLAGS = 0, CB_FLAGS = 0,
......
...@@ -186,6 +186,9 @@ struct bpf_stacktrace { ...@@ -186,6 +186,9 @@ struct bpf_stacktrace {
#define BPF_STACK_TRACE(_name, _max_entries) \ #define BPF_STACK_TRACE(_name, _max_entries) \
BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, _max_entries) BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, _max_entries)
#define BPF_PROG_ARRAY(_name, _max_entries) \
BPF_TABLE("prog", u32, u32, _name, _max_entries)
// packet parsing state machine helpers // packet parsing state machine helpers
#define cursor_advance(_cursor, _len) \ #define cursor_advance(_cursor, _len) \
({ void *_tmp = _cursor; _cursor += _len; _tmp; }) ({ void *_tmp = _cursor; _cursor += _len; _tmp; })
......
...@@ -22,7 +22,7 @@ typedef struct eth_addr { ...@@ -22,7 +22,7 @@ typedef struct eth_addr {
} eth_addr_t; } eth_addr_t;
// Program table definitions for tail calls // Program table definitions for tail calls
BPF_TABLE("prog", u32, u32, jump, 16); BPF_PROG_ARRAY(jump, 16);
// physical endpoint manager (pem) tables which connects to boeht bridge 1 and bridge 2 // physical endpoint manager (pem) tables which connects to boeht bridge 1 and bridge 2
// <port_id, bpf_dest> // <port_id, bpf_dest>
......
// Copyright (c) PLUMgrid, Inc. // Copyright (c) PLUMgrid, Inc.
// Licensed under the Apache License, Version 2.0 (the "License") // Licensed under the Apache License, Version 2.0 (the "License")
BPF_TABLE("prog", int, int, jump, 64); BPF_PROG_ARRAY(jump, 64);
BPF_ARRAY(stats, u64, 64); BPF_ARRAY(stats, u64, 64);
enum states { enum states {
......
...@@ -426,7 +426,7 @@ int many(struct pt_regs *ctx, int a, int b, int c, int d, int e, int f, int g) { ...@@ -426,7 +426,7 @@ int many(struct pt_regs *ctx, int a, int b, int c, int d, int e, int f, int g) {
def test_call_macro_arg(self): def test_call_macro_arg(self):
text = """ text = """
BPF_TABLE("prog", u32, u32, jmp, 32); BPF_PROG_ARRAY(jmp, 32);
#define JMP_IDX_PIPE (1U << 1) #define JMP_IDX_PIPE (1U << 1)
...@@ -607,7 +607,7 @@ void do_trace(struct pt_regs *ctx) { ...@@ -607,7 +607,7 @@ void do_trace(struct pt_regs *ctx) {
def test_prog_array_delete(self): def test_prog_array_delete(self):
text = """ text = """
BPF_TABLE("prog", int, int, dummy, 256); BPF_PROG_ARRAY(dummy, 256);
""" """
b1 = BPF(text=text) b1 = BPF(text=text)
text = """ text = """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment