annotate src/core/ngx_bpf.h @ 9299:2706b60dc225

Core: error logging rate limiting. With this change, error logging to files can be rate-limited with the "rate=" parameter. The parameter specifies allowed log messages rate to a particular file (per worker), in messages per second (m/s). By default, "rate=1000m/s" is used. Rate limiting is implemented using the "leaky bucket" method, similarly to the limit_req module. Maximum burst size is set to the number of log messages per second for each severity level, so "error" messages are logged even if the rate limit is hit by "info" messages (but not vice versa). When the limit is reached for a particular level, the "too many log messages, limiting" message is logged at this level. If debug logging is enabled, either for the particular log file or for the particular connection, rate limiting is not used.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 25 Jun 2024 22:58:56 +0300
parents d3747ba486e7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8675
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
1
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
2 /*
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
3 * Copyright (C) Nginx, Inc.
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
4 */
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
5
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
6
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
7 #ifndef _NGX_BPF_H_INCLUDED_
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
8 #define _NGX_BPF_H_INCLUDED_
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
9
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
10
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
11 #include <ngx_config.h>
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
12 #include <ngx_core.h>
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
13
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
14 #include <linux/bpf.h>
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
15
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
16
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
17 typedef struct {
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
18 char *name;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
19 int offset;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
20 } ngx_bpf_reloc_t;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
21
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
22 typedef struct {
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
23 char *license;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
24 enum bpf_prog_type type;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
25 struct bpf_insn *ins;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
26 size_t nins;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
27 ngx_bpf_reloc_t *relocs;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
28 size_t nrelocs;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
29 } ngx_bpf_program_t;
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
30
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
31
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
32 void ngx_bpf_program_link(ngx_bpf_program_t *program, const char *symbol,
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
33 int fd);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
34 int ngx_bpf_load_program(ngx_log_t *log, ngx_bpf_program_t *program);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
35
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
36 int ngx_bpf_map_create(ngx_log_t *log, enum bpf_map_type type, int key_size,
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
37 int value_size, int max_entries, uint32_t map_flags);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
38 int ngx_bpf_map_update(int fd, const void *key, const void *value,
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
39 uint64_t flags);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
40 int ngx_bpf_map_delete(int fd, const void *key);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
41 int ngx_bpf_map_lookup(int fd, const void *key, void *value);
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
42
d3747ba486e7 Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
43 #endif /* _NGX_BPF_H_INCLUDED_ */