{"id":2789,"date":"2022-12-20T15:17:18","date_gmt":"2022-12-20T18:17:18","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/bpf-classifier-and-actions-in-tc-man8\/"},"modified":"2022-12-20T15:17:18","modified_gmt":"2022-12-20T18:17:18","slug":"bpf-classifier-and-actions-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/bpf-classifier-and-actions-in-tc-man8\/","title":{"rendered":"BPF classifier and actions in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">BPF classifier and actions in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#PARAMETERS\">PARAMETERS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#FURTHER READING\">FURTHER READING<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">BPF \u2212 BPF programmable classifier and actions for ingress\/egress queueing disciplines<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>eBPF classifier (filter) or action: <br \/> tc filter &#8230; bpf<\/b> [ <b>object-file<\/b> OBJ_FILE ] [ <b>section<\/b> CLS_NAME ] [ <b>export<\/b> UDS_FILE ] [ <b>verbose<\/b> ] [ <b>direct-action<\/b> | <b>da<\/b> ] [ <b>skip_hw<\/b> | <b>skip_sw<\/b> ] [ <b>police<\/b> POLICE_SPEC ] [ <b>action<\/b> ACTION_SPEC ] [ <b>classid<\/b> CLASSID ] <b><br \/> tc action &#8230; bpf<\/b> [ <b>object-file<\/b> OBJ_FILE ] [ <b>section<\/b> CLS_NAME ] [ <b>export<\/b> UDS_FILE ] [ <b>verbose<\/b> ]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cBPF classifier (filter) or action: <br \/> tc filter &#8230; bpf<\/b> [ <b>bytecode-file<\/b> BPF_FILE | <b>bytecode<\/b> BPF_BYTECODE ] [ <b>police<\/b> POLICE_SPEC ] [ <b>action<\/b> ACTION_SPEC ] [ <b>classid<\/b> CLASSID ] <b><br \/> tc action &#8230; bpf<\/b> [ <b>bytecode-file<\/b> BPF_FILE | <b>bytecode<\/b> BPF_BYTECODE ]<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Extended Berkeley Packet Filter ( <b>eBPF<\/b> ) and classic Berkeley Packet Filter (originally known as BPF, for better distinction referred to as <b>cBPF<\/b> here) are both available as a fully programmable and highly efficient classifier and actions. They both offer a minimal instruction set for implementing small programs which can safely be loaded into the kernel and thus executed in a tiny virtual machine from kernel space. An in-kernel verifier guarantees that a specified program always terminates and neither crashes nor leaks data from the kernel.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In Linux, it\u2019s generally considered that eBPF is the successor of cBPF. The kernel internally transforms cBPF expressions into eBPF expressions and executes the latter. Execution of them can be performed in an interpreter or at setup time, they can be just-in-time compiled (JIT\u2019ed) to run as native machine code.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Currently, the eBPF JIT compiler is available for the following architectures:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>x86_64 (since Linux 3.18)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>arm64 (since Linux 3.18)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>s390 (since Linux 4.1)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>ppc64 (since Linux 4.8)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>sparc64 (since Linux 4.12)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>mips64 (since Linux 4.13)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>arm32 (since Linux 4.14)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p>x86_32 (since Linux 4.18)<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">Whereas the following architectures have cBPF, but did not (yet) switch to eBPF JIT support:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p style=\"margin-top: 1em\">ppc32<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p>sparc32<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p>mips32<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">eBPF\u2019s instruction set has similar underlying principles as the cBPF instruction set, it however is modelled closer to the underlying architecture to better mimic native instruction sets with the aim to achieve a better run-time performance. It is designed to be JIT\u2019ed with a one to one mapping, which can also open up the possibility for compilers to generate optimized eBPF code through an eBPF backend that performs almost as fast as natively compiled code. Given that LLVM provides such an eBPF backend, eBPF programs can therefore easily be programmed in a subset of the C language. Other than that, eBPF infrastructure also comes with a construct called &#8220;maps&#8221;. eBPF maps are key\/value stores that are shared between multiple eBPF programs, but also between eBPF programs and user space applications.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For the traffic control subsystem, classifier and actions that can be attached to ingress and egress qdiscs can be written in eBPF or cBPF. The advantage over other classifier and actions is that eBPF\/cBPF provides the generic framework, while users can implement their highly specialized use cases efficiently. This means that the classifier or action written that way will not suffer from feature bloat, and can therefore execute its task highly efficient. It allows for non-linear classification and even merging the action part into the classification. Combined with efficient eBPF map data structures, user space can push new policies like classids into the kernel without reloading a classifier, or it can gather statistics that are pushed into one map and use another one for dynamically load balancing traffic based on the determined load, just to provide a few examples.<\/p>\n<h2>PARAMETERS <a name=\"PARAMETERS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>object-file<\/b> <br \/> points to an object file that has an executable and linkable format (ELF) and contains eBPF opcodes and eBPF map definitions. The LLVM compiler infrastructure with <b>clang(1)<\/b> as a C language front end is one project that supports emitting eBPF object files that can be passed to the eBPF classifier (more details in the <b>EXAMPLES<\/b> section). This option is mandatory when an eBPF classifier or action is to be loaded.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>section<\/b> <br \/> is the name of the ELF section from the object file, where the eBPF classifier or action resides. By default the section name for the classifier is called &#8220;classifier&#8221;, and for the action &#8220;action&#8221;. Given that a single object file can contain multiple classifier and actions, the corresponding section name needs to be specified, if it differs from the defaults.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>export<\/b> <br \/> points to a Unix domain socket file. In case the eBPF object file also contains a section named &#8220;maps&#8221; with eBPF map specifications, then the map file descriptors can be handed off via the Unix domain socket to an eBPF &#8220;agent&#8221; herding all descriptors after tc lifetime. This can be some third party application implementing the IPC counterpart for the import, that uses them for calling into <b>bpf(2)<\/b> system call to read out or update eBPF map data from user space, for example, for monitoring purposes or to push down new policies.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>verbose<\/b> <br \/> if set, it will dump the eBPF verifier output, even if loading the eBPF program was successful. By default, only on error, the verifier log is being emitted to the user.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>direct-action | da<\/b> <br \/> instructs eBPF classifier to not invoke external TC actions, instead use the TC actions return codes (<b>TC_ACT_OK<\/b>, <b>TC_ACT_SHOT<\/b> etc.) for classifiers.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>skip_hw | skip_sw<\/b> <br \/> hardware offload control flags. By default TC will try to offload filters to hardware if possible. <b>skip_hw<\/b> explicitly disables the attempt to offload. <b>skip_sw<\/b> forces the offload and disables running the eBPF program in the kernel. If hardware offload is not possible and this flag was set kernel will report an error and filter will not be installed at all.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>police<\/b> <br \/> is an optional parameter for an eBPF\/cBPF classifier that specifies a police in <b>tc(1)<\/b> which is attached to the classifier, for example, on an ingress qdisc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>action<\/b> <br \/> is an optional parameter for an eBPF\/cBPF classifier that specifies a subsequent action in <b>tc(1)<\/b> which is attached to a classifier.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>classid <br \/> flowid<\/b> <br \/> provides the default traffic control class identifier for this eBPF\/cBPF classifier. The default class identifier can also be overwritten by the return code of the eBPF\/cBPF program. A default return code of <b>-1<\/b> specifies the here provided default class identifier to be used. A return code of the eBPF\/cBPF program of 0 implies that no match took place, and a return code other than these two will override the default classid. This allows for efficient, non-linear classification with only a single eBPF\/cBPF program as opposed to having multiple individual programs for various class identifiers which would need to reparse packet contents.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>bytecode<\/b> <br \/> is being used for loading cBPF classifier and actions only. The cBPF bytecode is directly passed as a text string in the form of <b>\u00b4s,c t f k,c t f k,c t f k,&#8230;\u00b4<\/b> , where <b>s<\/b> denotes the number of subsequent 4-tuples. One such 4-tuple consists of <b>c t f k<\/b> decimals, where <b>c<\/b> represents the cBPF opcode, <b>t<\/b> the jump true offset target, <b>f<\/b> the jump false offset target and <b>k<\/b> the immediate constant\/literal. There are various tools that generate code in this loadable format, for example, <b>bpf_asm<\/b> that ships with the Linux kernel source tree under <b>tools\/net\/<\/b> , so it is certainly not expected to hack this by hand. The <b>bytecode<\/b> or <b>bytecode-file<\/b> option is mandatory when a cBPF classifier or action is to be loaded.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>bytecode-file<\/b> <br \/> also being used to load a cBPF classifier or action. It\u2019s effectively the same as <b>bytecode<\/b> only that the cBPF bytecode is not passed directly via command line, but rather resides in a text file.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>eBPF TOOLING<\/b> <br \/> A full blown example including eBPF agent code can be found inside the iproute2 source package under: <b>examples\/bpf\/<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">As prerequisites, the kernel needs to have the eBPF system call namely <b>bpf(2)<\/b> enabled and ships with <b>cls_bpf<\/b> and <b>act_bpf<\/b> kernel modules for the traffic control subsystem. To enable eBPF\/eBPF JIT support, depending which of the two the given architecture supports:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>echo 1 > \/proc\/sys\/net\/core\/bpf_jit_enable<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A given restricted C file can be compiled via LLVM as:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>clang -O2 -emit-llvm -c bpf.c -o &#8211; | llc -march=bpf -filetype=obj -o bpf.o<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The compiler invocation might still simplify in future, so for now, it\u2019s quite handy to alias this construct in one way or another, for example:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">__bcc() { <br \/> clang -O2 -emit-llvm -c $1 -o &#8211; |  <br \/> llc -march=bpf -filetype=obj -o &#8220;\u2018basename $1 .c\u2018.o&#8221; <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">alias bcc=__bcc<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A minimal, stand-alone unit, which matches on all traffic with the default classid (return code of -1) looks like:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <linux\/bpf.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#ifndef __section <br \/> # define __section(x) __attribute__((section(x), used)) <br \/> #endif<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">__section(&#8220;classifier&#8221;) int cls_main(struct __sk_buff *skb) <br \/> { <br \/> return -1; <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char __license[] __section(&#8220;license&#8221;) = &#8220;GPL&#8221;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">More examples can be found further below in subsection <b>eBPF PROGRAMMING<\/b> as focus here will be on tooling.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There can be various other sections, for example, also for actions. Thus, an object file in eBPF can contain multiple entrance points. Always a specific entrance point, however, must be specified when configuring with tc. A license must be part of the restricted C code and the license string syntax is the same as with Linux kernel modules. The kernel reserves its right that some eBPF helper functions can be restricted to GPL compatible licenses only, and thus may reject a program from loading into the kernel when such a license mismatch occurs.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The resulting object file from the compilation can be inspected with the usual set of tools that also operate on normal object files, for example <b>objdump(1)<\/b> for inspecting ELF section headers:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">objdump -h bpf.o <br \/> [&#8230;] <br \/> 3 classifier 000007f8 0000000000000000 0000000000000000 00000040 2**3 <br \/> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE <br \/> 4 action-mark 00000088 0000000000000000 0000000000000000 00000838 2**3 <br \/> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE <br \/> 5 action-rand 00000098 0000000000000000 0000000000000000 000008c0 2**3 <br \/> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE <br \/> 6 maps 00000030 0000000000000000 0000000000000000 00000958 2**2 <br \/> CONTENTS, ALLOC, LOAD, DATA <br \/> 7 license 00000004 0000000000000000 0000000000000000 00000988 2**0 <br \/> CONTENTS, ALLOC, LOAD, DATA <br \/> [&#8230;]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Adding an eBPF classifier from an object file that contains a classifier in the default ELF section is trivial (note that instead of &#8220;object-file&#8221; also shortcuts such as &#8220;obj&#8221; can be used):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>bcc bpf.c <br \/> tc filter add dev em1 parent 1: bpf obj bpf.o flowid 1:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In case the classifier resides in ELF section &#8220;mycls&#8221;, then that same command needs to be invoked as:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc filter add dev em1 parent 1: bpf obj bpf.o sec mycls flowid 1:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Dumping the classifier configuration will tell the location of the classifier, in other words that it\u2019s from object file &#8220;bpf.o&#8221; under section &#8220;mycls&#8221;:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc filter show dev em1 <br \/> filter parent 1: protocol all pref 49152 bpf <br \/> filter parent 1: protocol all pref 49152 bpf handle 0x1 flowid 1:1 bpf.o:[mycls]<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The same program can also be installed on ingress qdisc side as opposed to egress &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc qdisc add dev em1 handle ffff: ingress <br \/> tc filter add dev em1 parent ffff: bpf obj bpf.o sec mycls flowid ffff:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8230; and again dumped from there:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc filter show dev em1 parent ffff: <br \/> filter protocol all pref 49152 bpf <br \/> filter protocol all pref 49152 bpf handle 0x1 flowid ffff:1 bpf.o:[mycls]<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Attaching a classifier and action on ingress has the restriction that it doesn\u2019t have an actual underlying queueing discipline. What ingress can do is to classify, mangle, redirect or drop packets. When queueing is required on ingress side, then ingress must redirect packets to the <b>ifb<\/b> device, otherwise policing can be used. Moreover, ingress can be used to have an early drop point of unwanted packets before they hit upper layers of the networking stack, perform network accounting with eBPF maps that could be shared with egress, or have an early mangle and\/or redirection point to different networking devices.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Multiple eBPF actions and classifier can be placed into a single object file within various sections. In that case, non-default section names must be provided, which is the case for both actions in this example:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc filter add dev em1 parent 1: bpf obj bpf.o flowid 1:1 <\/b><\/p>\n<p style=\"margin-left:55%;\"><b>action bpf obj bpf.o sec action-mark  <br \/> action bpf obj bpf.o sec action-rand ok<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The advantage of this is that the classifier and the two actions can then share eBPF maps with each other, if implemented in the programs.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In order to access eBPF maps from user space beyond <b>tc(8)<\/b> setup lifetime, the ownership can be transferred to an eBPF agent via Unix domain sockets. There are two possibilities for implementing this:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>1)<\/b> implementation of an own eBPF agent that takes care of setting up the Unix domain socket and implementing the protocol that <b>tc(8)<\/b> dictates. A code example of this can be found inside the iproute2 source package under: <b>examples\/bpf\/<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>2)<\/b> use <b>tc exec<\/b> for transferring the eBPF map file descriptors through a Unix domain socket, and spawning an application such as <b>sh(1)<\/b> . This approach\u2019s advantage is that tc will place the file descriptors into the environment and thus make them available just like stdin, stdout, stderr file descriptors, meaning, in case user applications run from within this fd-owner shell, they can terminate and restart without losing eBPF maps file descriptors. Example invocation with the previous classifier and action mixture:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc exec bpf imp \/tmp\/bpf <br \/> tc filter add dev em1 parent 1: bpf obj bpf.o exp \/tmp\/bpf flowid 1:1 <\/b><\/p>\n<p style=\"margin-left:55%;\"><b>action bpf obj bpf.o sec action-mark  <br \/> action bpf obj bpf.o sec action-rand ok<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Assuming that eBPF maps are shared with classifier and actions, it\u2019s enough to export them once, for example, from within the classifier or action command. tc will setup all eBPF map file descriptors at the time when the object file is first parsed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When a shell has been spawned, the environment will have a couple of eBPF related variables. BPF_NUM_MAPS provides the total number of maps that have been transferred over the Unix domain socket. BPF_MAP<X>\u2019s value is the file descriptor number that can be accessed in eBPF agent applications, in other words, it can directly be used as the file descriptor value for the <b>bpf(2)<\/b> system call to retrieve or alter eBPF map values. <X> denotes the identifier of the eBPF map. It corresponds to the <b>id<\/b> member of <b>struct bpf_elf_map<\/b> from the tc eBPF map specification.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The environment in this example looks as follows:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">sh# env | grep BPF <br \/> BPF_NUM_MAPS=3 <br \/> BPF_MAP1=6 <br \/> BPF_MAP0=5 <br \/> BPF_MAP2=7 <br \/> sh# ls -la \/proc\/self\/fd <br \/> [&#8230;] <br \/> lrwx&#8212;&#8212;. 1 root root 64 Apr 14 16:46 5 -> anon_inode:bpf-map <br \/> lrwx&#8212;&#8212;. 1 root root 64 Apr 14 16:46 6 -> anon_inode:bpf-map <br \/> lrwx&#8212;&#8212;. 1 root root 64 Apr 14 16:46 7 -> anon_inode:bpf-map <br \/> sh# my_bpf_agent<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">eBPF agents are very useful in that they can prepopulate eBPF maps from user space, monitor statistics via maps and based on that feedback, for example, rewrite classids in eBPF map values during runtime. Given that eBPF agents are implemented as normal applications, they can also dynamically receive traffic control policies from external controllers and thus push them down into eBPF maps to dynamically adapt to network conditions. Moreover, eBPF maps can also be shared with other eBPF program types (e.g. tracing), thus very powerful combination can therefore be implemented.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>eBPF PROGRAMMING<\/b> <br \/> eBPF classifier and actions are being implemented in restricted C syntax (in future, there could additionally be new language frontends supported).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The header file <b>linux\/bpf.h<\/b> provides eBPF helper functions that can be called from an eBPF program. This man page will only provide two minimal, stand-alone examples, have a look at <b>examples\/bpf<\/b> from the iproute2 source package for a fully fledged flow dissector example to better demonstrate some of the possibilities with eBPF.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Supported 32 bit classifier return codes from the C program and their meanings:<\/p>\n<p style=\"margin-left:17%;\"><b>0<\/b> , denotes a mismatch <b><br \/> -1<\/b> , denotes the default classid configured from the command line <b><br \/> else<\/b> , everything else will override the default classid to provide a facility for non-linear matching<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Supported 32 bit action return codes from the C program and their meanings ( <b>linux\/pkt_cls.h<\/b> ):<\/p>\n<p style=\"margin-left:17%;\"><b>TC_ACT_OK (0)<\/b> , will terminate the packet processing pipeline and allows the packet to proceed <b><br \/> TC_ACT_SHOT (2)<\/b> , will terminate the packet processing pipeline and drops the packet <b><br \/> TC_ACT_UNSPEC (-1)<\/b> , will use the default action configured from tc (similarly as returning <b>-1<\/b> from a classifier) <b><br \/> TC_ACT_PIPE (3)<\/b> , will iterate to the next action, if available <b><br \/> TC_ACT_RECLASSIFY (1)<\/b> , will terminate the packet processing pipeline and start classification from the beginning <b><br \/> else<\/b> , everything else is an unspecified return code<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Both classifier and action return codes are supported in eBPF and cBPF programs.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To demonstrate restricted C syntax, a minimal toy classifier example is provided, which assumes that egress packets, for instance originating from a container, have previously been marked in interval [0, 255]. The program keeps statistics on different marks for user space and maps the classid to the root qdisc with the marking itself as the minor handle:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <stdint.h> <br \/> #include <asm\/types.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <linux\/bpf.h> #include <linux\/pkt_sched.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include &#8220;helpers.h&#8221;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct tuple { <br \/> long packets; <br \/> long bytes; <br \/> };<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#define BPF_MAP_ID_STATS 1 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var agent\u2019s map identifier bodies\/ usr\/ <br \/> #define BPF_MAX_MARK 256<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct bpf_elf_map __section(&#8220;maps&#8221;) map_stats = { <br \/> .type = BPF_MAP_TYPE_ARRAY, <br \/> .id = BPF_MAP_ID_STATS, <br \/> .size_key = sizeof(uint32_t), <br \/> .size_value = sizeof(struct tuple), <br \/> .max_elem = BPF_MAX_MARK, <br \/> .pinning = PIN_GLOBAL_NS, <br \/> };<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">static inline void cls_update_stats(const struct __sk_buff *skb, <br \/> uint32_t mark) <br \/> { <br \/> struct tuple *tu;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">tu = bpf_map_lookup_elem(&#038;map_stats, &#038;mark); <br \/> if (likely(tu)) { <br \/> __sync_fetch_and_add(&#038;tu->packets, 1); <br \/> __sync_fetch_and_add(&#038;tu->bytes, skb->len); <br \/> } <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">__section(&#8220;cls&#8221;) int cls_main(struct __sk_buff *skb) <br \/> { <br \/> uint32_t mark = skb->mark;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">if (unlikely(mark >= BPF_MAX_MARK)) <br \/> return 0;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">cls_update_stats(skb, mark);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">return TC_H_MAKE(TC_H_ROOT, mark); <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char __license[] __section(&#8220;license&#8221;) = &#8220;GPL&#8221;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Another small example is a port redirector which demuxes destination port 80 into the interval [8080, 8087] steered by RSS, that can then be attached to ingress qdisc. The exercise of adding the egress counterpart and IPv6 support is left to the reader:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <asm\/types.h> <br \/> #include <asm\/byteorder.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <linux\/bpf.h> #include <linux\/filter.h> #include <linux\/in.h> #include <linux\/if_ether.h> #include <linux\/ip.h> #include <linux\/tcp.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include &#8220;helpers.h&#8221;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">static inline void set_tcp_dport(struct __sk_buff *skb, int nh_off, <br \/> __u16 old_port, __u16 new_port) <br \/> { <br \/> bpf_l4_csum_replace(skb, nh_off + offsetof(struct tcphdr, check), <br \/> old_port, new_port, sizeof(new_port)); <br \/> bpf_skb_store_bytes(skb, nh_off + offsetof(struct tcphdr, dest), <br \/> &#038;new_port, sizeof(new_port), 0); <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">static inline int lb_do_ipv4(struct __sk_buff *skb, int nh_off) <br \/> { <br \/> __u16 dport, dport_new = 8080, off; <br \/> __u8 ip_proto, ip_vl;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">ip_proto = load_byte(skb, nh_off + <br \/> offsetof(struct iphdr, protocol)); <br \/> if (ip_proto != IPPROTO_TCP) <br \/> return 0;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">ip_vl = load_byte(skb, nh_off); <br \/> if (likely(ip_vl == 0x45)) <br \/> nh_off += sizeof(struct iphdr); <br \/> else <br \/> nh_off += (ip_vl &#038; 0xF) << 2;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">dport = load_half(skb, nh_off + offsetof(struct tcphdr, dest)); <br \/> if (dport != 80) <br \/> return 0;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">off = skb->queue_mapping &#038; 7; <br \/> set_tcp_dport(skb, nh_off &#8211; BPF_LL_OFF, __constant_htons(80), <br \/> __cpu_to_be16(dport_new + off)); <br \/> return -1; <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">__section(&#8220;lb&#8221;) int lb_main(struct __sk_buff *skb) <br \/> { <br \/> int ret = 0, nh_off = BPF_LL_OFF + ETH_HLEN;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">if (likely(skb->protocol == __constant_htons(ETH_P_IP))) <br \/> ret = lb_do_ipv4(skb, nh_off);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">return ret; <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char __license[] __section(&#8220;license&#8221;) = &#8220;GPL&#8221;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The related helper header file <b>helpers.h<\/b> in both examples was:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Misc helper macros. bodies\/ usr\/ <br \/> #define __section(x) __attribute__((section(x), used)) <br \/> #define offsetof(x, y) __builtin_offsetof(x, y) <br \/> #define likely(x) __builtin_expect(!!(x), 1) <br \/> #define unlikely(x) __builtin_expect(!!(x), 0)<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Object pinning settings bodies\/ usr\/ <br \/> #define PIN_NONE 0 <br \/> #define PIN_OBJECT_NS 1 <br \/> #define PIN_GLOBAL_NS 2<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* ELF map definition bodies\/ usr\/ <br \/> struct bpf_elf_map { <br \/> __u32 type; <br \/> __u32 size_key; <br \/> __u32 size_value; <br \/> __u32 max_elem; <br \/> __u32 flags; <br \/> __u32 id; <br \/> __u32 pinning; <br \/> __u32 inner_id; <br \/> __u32 inner_idx; <br \/> };<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Some used BPF function calls. bodies\/ usr\/ <br \/> static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, <br \/> int len, int flags) = <br \/> (void *) BPF_FUNC_skb_store_bytes; <br \/> static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, <br \/> int to, int flags) = <br \/> (void *) BPF_FUNC_l4_csum_replace; <br \/> static void *(*bpf_map_lookup_elem)(void *map, void *key) = <br \/> (void *) BPF_FUNC_map_lookup_elem;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Some used BPF intrinsics. bodies\/ usr\/ <br \/> unsigned long long load_byte(void *skb, unsigned long long off) <br \/> asm (&#8220;llvm.bpf.load.byte&#8221;); <br \/> unsigned long long load_half(void *skb, unsigned long long off) <br \/> asm (&#8220;llvm.bpf.load.half&#8221;);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Best practice, we recommend to only have a single eBPF classifier loaded in tc and perform <b>all<\/b> necessary matching and mangling from there instead of a list of individual classifier and separate actions. Just a single classifier tailored for a given use-case will be most efficient to run.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>eBPF DEBUGGING<\/b> <br \/> Both tc <b>filter<\/b> and <b>action<\/b> commands for <b>bpf<\/b> support an optional <b>verbose<\/b> parameter that can be used to inspect the eBPF verifier log. It is dumped by default in case of an error.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In case the eBPF\/cBPF JIT compiler has been enabled, it can also be instructed to emit a debug output of the resulting opcode image into the kernel log, which can be read via <b>dmesg(1)<\/b> :<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>echo 2 > \/proc\/sys\/net\/core\/bpf_jit_enable<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Linux kernel source tree ships additionally under <b>tools\/net\/<\/b> a small helper called <b>bpf_jit_disasm<\/b> that reads out the opcode image dump from the kernel log and dumps the resulting disassembly:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>bpf_jit_disasm -o<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Other than that, the Linux kernel also contains an extensive eBPF\/cBPF test suite module called <b>test_bpf<\/b> . Upon &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>modprobe test_bpf<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8230; it performs a diversity of test cases and dumps the results into the kernel log that can be inspected with <b>dmesg(1)<\/b> . The results can differ depending on whether the JIT compiler is enabled or not. In case of failed test cases, the module will fail to load. In such cases, we urge you to file a bug report to the related JIT authors, Linux kernel and networking mailing lists.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cBPF<\/b> <br \/> Although we generally recommend switching to implementing <b>eBPF<\/b> classifier and actions, for the sake of completeness, a few words on how to program in cBPF will be lost here.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Likewise, the <b>bpf_jit_enable<\/b> switch can be enabled as mentioned already. Tooling such as <b>bpf_jit_disasm<\/b> is also independent whether eBPF or cBPF code is being loaded.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Unlike in eBPF, classifier and action are not implemented in restricted C, but rather in a minimal assembler-like language or with the help of other tooling.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The raw interface with tc takes opcodes directly. For example, the most minimal classifier matching on every packet resulting in the default classid of 1:1 looks like:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tc filter add dev em1 parent 1: bpf bytecode \u20191,6 0 0 4294967295,\u2019 flowid 1:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first decimal of the bytecode sequence denotes the number of subsequent 4-tuples of cBPF opcodes. As mentioned, such a 4-tuple consists of <b>c t f k<\/b> decimals, where <b>c<\/b> represents the cBPF opcode, <b>t<\/b> the jump true offset target, <b>f<\/b> the jump false offset target and <b>k<\/b> the immediate constant\/literal. Here, this denotes an unconditional return from the program with immediate value of -1.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, for egress classification, Willem de Bruijn implemented a minimal stand-alone helper tool under the GNU General Public License version 2 for <b>iptables(8)<\/b> BPF extension, which abuses the <b>libpcap<\/b> internal classic BPF compiler, his code derived here for usage with <b>tc(8)<\/b> :<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <pcap.h> #include <stdio.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">int main(int argc, char **argv) <br \/> { <br \/> struct bpf_program prog; <br \/> struct bpf_insn *ins; <br \/> int i, ret, dlt = DLT_RAW;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">if (argc < 2 || argc > 3) <br \/> return 1; <br \/> if (argc == 3) { <br \/> dlt = pcap_datalink_name_to_val(argv[1]); <br \/> if (dlt == -1) <br \/> return 1; <br \/> }<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">ret = pcap_compile_nopcap(-1, dlt, &#038;prog, argv[argc &#8211; 1], <br \/> 1, PCAP_NETMASK_UNKNOWN); <br \/> if (ret) <br \/> return 1;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">printf(&#8220;%d,&#8221;, prog.bf_len); <br \/> ins = prog.bf_insns;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">for (i = 0; i < prog.bf_len - 1; ++ins, ++i) <br \/> printf(&#8220;%u %u %u %u,&#8221;, ins->code, <br \/> ins->jt, ins->jf, ins->k); <br \/> printf(&#8220;%u %u %u %u&#8221;, <br \/> ins->code, ins->jt, ins->jf, ins->k);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">pcap_freecode(&#038;prog); <br \/> return 0; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Given this small helper, any <b>tcpdump(8)<\/b> filter expression can be abused as a classifier where a match will result in the default classid:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>bpftool EN10MB \u2019tcp[tcpflags] &#038; tcp-syn != 0\u2019 > \/var\/bpf\/tcp-syn <br \/> tc filter add dev em1 parent 1: bpf bytecode-file \/var\/bpf\/tcp-syn flowid 1:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Basically, such a minimal generator is equivalent to:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>tcpdump -iem1 -ddd \u2019tcp[tcpflags] &#038; tcp-syn != 0\u2019 | tr \u2019n\u2019 \u2019,\u2019 > \/var\/bpf\/tcp-syn<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since <b>libpcap<\/b> does not support all Linux\u2019 specific cBPF extensions in its compiler, the Linux kernel also ships under <b>tools\/net\/<\/b> a minimal BPF assembler called <b>bpf_asm<\/b> for providing full control. For detailed syntax and semantics on implementing such programs by hand, see references under <b>FURTHER READING<\/b> .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Trivial toy example in <b>bpf_asm<\/b> for classifying IPv4\/TCP packets, saved in a text file called <b>foobar<\/b> :<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">ldh [12] <br \/> jne #0x800, drop <br \/> ldb [23] <br \/> jneq #6, drop <br \/> ret #-1 <br \/> drop: ret #0<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Similarly, such a classifier can be loaded as:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>bpf_asm foobar > \/var\/bpf\/tcp-syn <br \/> tc filter add dev em1 parent 1: bpf bytecode-file \/var\/bpf\/tcp-syn flowid 1:1<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For BPF classifiers, the Linux kernel provides additionally under <b>tools\/net\/<\/b> a small BPF debugger called <b>bpf_dbg<\/b> , which can be used to test a classifier against pcap files, single-step or add various breakpoints into the classifier program and dump register contents during runtime.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Implementing an action in classic BPF is rather limited in the sense that packet mangling is not supported. Therefore, it\u2019s generally recommended to make the switch to eBPF, whenever possible.<\/p>\n<h2>FURTHER READING <a name=\"FURTHER READING\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Further and more technical details about the BPF architecture can be found in the Linux kernel source tree under <b>Documentation\/networking\/filter.txt<\/b> .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Further details on eBPF <b>tc(8)<\/b> examples can be found in the iproute2 source tree under <b>examples\/bpf\/<\/b> .<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8), <b>tc-ematch<\/b>(8) <b>bpf<\/b>(2) <b>bpf<\/b>(4)<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Manpage written by Daniel Borkmann.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please report corrections or improvements to the Linux kernel networking mailing list: <b><netdev@vger.kernel.org><\/b><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  BPF \u2212 BPF programmable classifier and actions for ingress\/egress queueing disciplines <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,143],"class_list":["post-2789","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-bpf"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=2789"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2789\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=2789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=2789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=2789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}