€• Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ%/translations/zh_CN/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/zh_TW/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/it_IT/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ja_JP/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ko_KR/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/pt_BR/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/sp_SP/networking/filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)�”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ?/var/lib/git/docbuild/linux/Documentation/networking/filter.rst”h´KubhŒtarget”“”)�”}”(hŒ.. _networking-filter:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œnetworking-filter”uh1hÈh´Khhh²hh³hÇubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ7Linux Socket Filtering aka Berkeley Packet Filter (BPF)”h]”hŒ7Linux Socket Filtering aka Berkeley Packet Filter (BPF)”…”�”}”(hhÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhØh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒNotice”h]”hŒNotice”…”�”}”(hhîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhëh²hh³hÇh´K ubhŒ paragraph”“”)�”}”(hŒ”This file used to document the eBPF format and mechanisms even when not related to socket filtering. The ../bpf/index.rst has more details on eBPF.”h]”hŒ”This file used to document the eBPF format and mechanisms even when not related to socket filtering. The ../bpf/index.rst has more details on eBPF.”…”�”}”(hhþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K hhëh²hubeh}”(h]”Œnotice”ah ]”h"]”Œnotice”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Introduction”h]”hŒ Introduction”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´Kubhý)�”}”(hXLinux Socket Filtering (LSF) is derived from the Berkeley Packet Filter. Though there are some distinct differences between the BSD and Linux Kernel filtering, but when we speak of BPF or LSF in Linux context, we mean the very same mechanism of filtering in the Linux kernel.”h]”hXLinux Socket Filtering (LSF) is derived from the Berkeley Packet Filter. Though there are some distinct differences between the BSD and Linux Kernel filtering, but when we speak of BPF or LSF in Linux context, we mean the very same mechanism of filtering in the Linux kernel.”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khjh²hubhý)�”}”(hXBPF allows a user-space program to attach a filter onto any socket and allow or disallow certain types of data to come through the socket. LSF follows exactly the same filter code structure as BSD's BPF, so referring to the BSD bpf.4 manpage is very helpful in creating filters.”h]”hXBPF allows a user-space program to attach a filter onto any socket and allow or disallow certain types of data to come through the socket. LSF follows exactly the same filter code structure as BSD’s BPF, so referring to the BSD bpf.4 manpage is very helpful in creating filters.”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khjh²hubhý)�”}”(hX5On Linux, BPF is much simpler than on BSD. One does not have to worry about devices or anything like that. You simply create your filter code, send it to the kernel via the SO_ATTACH_FILTER option and if your filter code passes the kernel check on it, you then immediately begin filtering data on that socket.”h]”hX5On Linux, BPF is much simpler than on BSD. One does not have to worry about devices or anything like that. You simply create your filter code, send it to the kernel via the SO_ATTACH_FILTER option and if your filter code passes the kernel check on it, you then immediately begin filtering data on that socket.”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khjh²hubhý)�”}”(hXYou can also detach filters from your socket via the SO_DETACH_FILTER option. This will probably not be used much since when you close a socket that has a filter on it the filter is automagically removed. The other less common case may be adding a different filter on the same socket where you had another filter that is still running: the kernel takes care of removing the old one and placing your new one in its place, assuming your filter has passed the checks, otherwise if it fails the old filter will remain on that socket.”h]”hXYou can also detach filters from your socket via the SO_DETACH_FILTER option. This will probably not be used much since when you close a socket that has a filter on it the filter is automagically removed. The other less common case may be adding a different filter on the same socket where you had another filter that is still running: the kernel takes care of removing the old one and placing your new one in its place, assuming your filter has passed the checks, otherwise if it fails the old filter will remain on that socket.”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K#hjh²hubhý)�”}”(hXSO_LOCK_FILTER option allows to lock the filter attached to a socket. Once set, a filter cannot be removed or changed. This allows one process to setup a socket, attach a filter, lock it then drop privileges and be assured that the filter will be kept until the socket is closed.”h]”hXSO_LOCK_FILTER option allows to lock the filter attached to a socket. Once set, a filter cannot be removed or changed. This allows one process to setup a socket, attach a filter, lock it then drop privileges and be assured that the filter will be kept until the socket is closed.”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K,hjh²hubhý)�”}”(hXQThe biggest user of this construct might be libpcap. Issuing a high-level filter command like `tcpdump -i em1 port 22` passes through the libpcap internal compiler that generates a structure that can eventually be loaded via SO_ATTACH_FILTER to the kernel. `tcpdump -i em1 port 22 -ddd` displays what is being placed into this structure.”h]”(hŒ^The biggest user of this construct might be libpcap. Issuing a high-level filter command like ”…”�”}”(hjkh²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ`tcpdump -i em1 port 22`”h]”hŒtcpdump -i em1 port 22”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jshjkubhŒ‹ passes through the libpcap internal compiler that generates a structure that can eventually be loaded via SO_ATTACH_FILTER to the kernel. ”…”�”}”(hjkh²hh³Nh´Nubjt)�”}”(hŒ`tcpdump -i em1 port 22 -ddd`”h]”hŒtcpdump -i em1 port 22 -ddd”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jshjkubhŒ3 displays what is being placed into this structure.”…”�”}”(hjkh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K1hjh²hubhý)�”}”(hXAlthough we were only speaking about sockets here, BPF in Linux is used in many more places. There's xt_bpf for netfilter, cls_bpf in the kernel qdisc layer, SECCOMP-BPF (SECure COMPuting [1]_), and lots of other places such as team driver, PTP code, etc where BPF is being used.”h]”(hŒ¾Although we were only speaking about sockets here, BPF in Linux is used in many more places. There’s xt_bpf for netfilter, cls_bpf in the kernel qdisc layer, SECCOMP-BPF (SECure COMPuting ”…”�”}”(hjŸh²hh³Nh´NubhŒfootnote_reference”“”)�”}”(hŒ[1]_”h]”hŒ1”…”�”}”(hj©h²hh³Nh´Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”hÔŒid2”Œdocname”Œnetworking/filter”uh1j§hjŸŒresolved”KubhŒW), and lots of other places such as team driver, PTP code, etc where BPF is being used.”…”�”}”(hjŸh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K7hjh²hubhŒfootnote”“”)�”}”(hŒ/Documentation/userspace-api/seccomp_filter.rst ”h]”(hŒlabel”“”)�”}”(hŒ1”h]”hŒ1”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÌhjÈubhý)�”}”(hŒ.Documentation/userspace-api/seccomp_filter.rst”h]”hŒ.Documentation/userspace-api/seccomp_filter.rst”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khjh²hubhý)�”}”(hXFSteven McCanne and Van Jacobson. 1993. The BSD packet filter: a new architecture for user-level packet capture. In Proceedings of the USENIX Winter 1993 Conference Proceedings on USENIX Winter 1993 Conference Proceedings (USENIX'93). USENIX Association, Berkeley, CA, USA, 2-2. [http://www.tcpdump.org/papers/bpf-usenix93.pdf]”h]”(hXSteven McCanne and Van Jacobson. 1993. The BSD packet filter: a new architecture for user-level packet capture. In Proceedings of the USENIX Winter 1993 Conference Proceedings on USENIX Winter 1993 Conference Proceedings (USENIX’93). USENIX Association, Berkeley, CA, USA, 2-2. [”…”�”}”(hjÿh²hh³Nh´NubhŒ reference”“”)�”}”(hŒ.http://www.tcpdump.org/papers/bpf-usenix93.pdf”h]”hŒ.http://www.tcpdump.org/papers/bpf-usenix93.pdf”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”j uh1jhjÿubhŒ]”…”�”}”(hjÿh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K@hjh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Structure”h]”hŒ Structure”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj*h²hh³hÇh´KGubhý)�”}”(hŒcUser space applications include which contains the following relevant structures::”h]”hŒbUser space applications include which contains the following relevant structures:”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KIhj*h²hubhŒ literal_block”“”)�”}”(hŒästruct sock_filter { /* Filter block */ __u16 code; /* Actual filter code */ __u8 jt; /* Jump true */ __u8 jf; /* Jump false */ __u32 k; /* Generic multiuse field */ };”h]”hŒästruct sock_filter { /* Filter block */ __u16 code; /* Actual filter code */ __u8 jt; /* Jump true */ __u8 jf; /* Jump false */ __u32 k; /* Generic multiuse field */ };”…”�”}”hjKsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´KLhj*h²hubhý)�”}”(hŒ²Such a structure is assembled as an array of 4-tuples, that contains a code, jt, jf and k value. jt and jf are jump offsets and k a generic value to be used for a provided code::”h]”hŒ±Such a structure is assembled as an array of 4-tuples, that contains a code, jt, jf and k value. jt and jf are jump offsets and k a generic value to be used for a provided code:”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KShj*h²hubjJ)�”}”(hŒÀstruct sock_fprog { /* Required for SO_ATTACH_FILTER. */ unsigned short len; /* Number of filter blocks */ struct sock_filter __user *filter; };”h]”hŒÀstruct sock_fprog { /* Required for SO_ATTACH_FILTER. */ unsigned short len; /* Number of filter blocks */ struct sock_filter __user *filter; };”…”�”}”hjgsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´KWhj*h²hubhý)�”}”(hŒ†For socket filtering, a pointer to this structure (as shown in follow-up example) is being passed to the kernel through setsockopt(2).”h]”hŒ†For socket filtering, a pointer to this structure (as shown in follow-up example) is being passed to the kernel through setsockopt(2).”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K\hj*h²hubeh}”(h]”Œ structure”ah ]”h"]”Œ structure”ah$]”h&]”uh1hÖhhØh²hh³hÇh´KGubh×)�”}”(hhh]”(hÜ)�”}”(hŒExample”h]”hŒExample”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj‹h²hh³hÇh´K`ubjJ)�”}”(hXŸ#include #include #include #include /* ... */ /* From the example above: tcpdump -i em1 port 22 -dd */ struct sock_filter code[] = { { 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 8, 0x000086dd }, { 0x30, 0, 0, 0x00000014 }, { 0x15, 2, 0, 0x00000084 }, { 0x15, 1, 0, 0x00000006 }, { 0x15, 0, 17, 0x00000011 }, { 0x28, 0, 0, 0x00000036 }, { 0x15, 14, 0, 0x00000016 }, { 0x28, 0, 0, 0x00000038 }, { 0x15, 12, 13, 0x00000016 }, { 0x15, 0, 12, 0x00000800 }, { 0x30, 0, 0, 0x00000017 }, { 0x15, 2, 0, 0x00000084 }, { 0x15, 1, 0, 0x00000006 }, { 0x15, 0, 8, 0x00000011 }, { 0x28, 0, 0, 0x00000014 }, { 0x45, 6, 0, 0x00001fff }, { 0xb1, 0, 0, 0x0000000e }, { 0x48, 0, 0, 0x0000000e }, { 0x15, 2, 0, 0x00000016 }, { 0x48, 0, 0, 0x00000010 }, { 0x15, 0, 1, 0x00000016 }, { 0x06, 0, 0, 0x0000ffff }, { 0x06, 0, 0, 0x00000000 }, }; struct sock_fprog bpf = { .len = ARRAY_SIZE(code), .filter = code, }; sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock < 0) /* ... bail out ... */ ret = setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)); if (ret < 0) /* ... bail out ... */ /* ... */ close(sock);”h]”hXŸ#include #include #include #include /* ... */ /* From the example above: tcpdump -i em1 port 22 -dd */ struct sock_filter code[] = { { 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 8, 0x000086dd }, { 0x30, 0, 0, 0x00000014 }, { 0x15, 2, 0, 0x00000084 }, { 0x15, 1, 0, 0x00000006 }, { 0x15, 0, 17, 0x00000011 }, { 0x28, 0, 0, 0x00000036 }, { 0x15, 14, 0, 0x00000016 }, { 0x28, 0, 0, 0x00000038 }, { 0x15, 12, 13, 0x00000016 }, { 0x15, 0, 12, 0x00000800 }, { 0x30, 0, 0, 0x00000017 }, { 0x15, 2, 0, 0x00000084 }, { 0x15, 1, 0, 0x00000006 }, { 0x15, 0, 8, 0x00000011 }, { 0x28, 0, 0, 0x00000014 }, { 0x45, 6, 0, 0x00001fff }, { 0xb1, 0, 0, 0x0000000e }, { 0x48, 0, 0, 0x0000000e }, { 0x15, 2, 0, 0x00000016 }, { 0x48, 0, 0, 0x00000010 }, { 0x15, 0, 1, 0x00000016 }, { 0x06, 0, 0, 0x0000ffff }, { 0x06, 0, 0, 0x00000000 }, }; struct sock_fprog bpf = { .len = ARRAY_SIZE(code), .filter = code, }; sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock < 0) /* ... bail out ... */ ret = setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)); if (ret < 0) /* ... bail out ... */ /* ... */ close(sock);”…”�”}”hjœsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´Kdhj‹h²hubhý)�”}”(hŒ©The above example code attaches a socket filter for a PF_PACKET socket in order to let all IPv4/IPv6 packets with port 22 pass. The rest will be dropped for this socket.”h]”hŒ©The above example code attaches a socket filter for a PF_PACKET socket in order to let all IPv4/IPv6 packets with port 22 pass. The rest will be dropped for this socket.”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K–hj‹h²hubhý)�”}”(hŒ¦The setsockopt(2) call to SO_DETACH_FILTER doesn't need any arguments and SO_LOCK_FILTER for preventing the filter to be detached, takes an integer value with 0 or 1.”h]”hŒ¨The setsockopt(2) call to SO_DETACH_FILTER doesn’t need any arguments and SO_LOCK_FILTER for preventing the filter to be detached, takes an integer value with 0 or 1.”…”�”}”(hj¸h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kšhj‹h²hubhý)�”}”(hŒuNote that socket filters are not restricted to PF_PACKET sockets only, but can also be used on other socket families.”h]”hŒuNote that socket filters are not restricted to PF_PACKET sockets only, but can also be used on other socket families.”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kžhj‹h²hubhý)�”}”(hŒSummary of system calls:”h]”hŒSummary of system calls:”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¡hj‹h²hubhŒ block_quote”“”)�”}”(hŒÕ* setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &val, sizeof(val)); * setsockopt(sockfd, SOL_SOCKET, SO_DETACH_FILTER, &val, sizeof(val)); * setsockopt(sockfd, SOL_SOCKET, SO_LOCK_FILTER, &val, sizeof(val)); ”h]”hŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒDsetsockopt(sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &val, sizeof(val));”h]”hý)�”}”(hjñh]”hŒDsetsockopt(sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &val, sizeof(val));”…”�”}”(hjóh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K£hjïubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhjêubjî)�”}”(hŒDsetsockopt(sockfd, SOL_SOCKET, SO_DETACH_FILTER, &val, sizeof(val));”h]”hý)�”}”(hjh]”hŒDsetsockopt(sockfd, SOL_SOCKET, SO_DETACH_FILTER, &val, sizeof(val));”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¤hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhjêubjî)�”}”(hŒEsetsockopt(sockfd, SOL_SOCKET, SO_LOCK_FILTER, &val, sizeof(val)); ”h]”hý)�”}”(hŒDsetsockopt(sockfd, SOL_SOCKET, SO_LOCK_FILTER, &val, sizeof(val));”h]”hŒDsetsockopt(sockfd, SOL_SOCKET, SO_LOCK_FILTER, &val, sizeof(val));”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¥hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhjêubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jèh³hÇh´K£hjäubah}”(h]”h ]”h"]”h$]”h&]”uh1jâh³hÇh´K£hj‹h²hubhý)�”}”(hŒÖNormally, most use cases for socket filtering on packet sockets will be covered by libpcap in high-level syntax, so as an application developer you should stick to that. libpcap wraps its own layer around all that.”h]”hŒÖNormally, most use cases for socket filtering on packet sockets will be covered by libpcap in high-level syntax, so as an application developer you should stick to that. libpcap wraps its own layer around all that.”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K§hj‹h²hubhý)�”}”(hXëUnless i) using/linking to libpcap is not an option, ii) the required BPF filters use Linux extensions that are not supported by libpcap's compiler, iii) a filter might be more complex and not cleanly implementable with libpcap's compiler, or iv) particular filter codes should be optimized differently than libpcap's internal compiler does; then in such cases writing such a filter "by hand" can be of an alternative. For example, xt_bpf and cls_bpf users might have requirements that could result in more complex filter code, or one that cannot be expressed with libpcap (e.g. different return codes for various code paths). Moreover, BPF JIT implementors may wish to manually write test cases and thus need low-level access to BPF code as well.”h]”hXõUnless i) using/linking to libpcap is not an option, ii) the required BPF filters use Linux extensions that are not supported by libpcap’s compiler, iii) a filter might be more complex and not cleanly implementable with libpcap’s compiler, or iv) particular filter codes should be optimized differently than libpcap’s internal compiler does; then in such cases writing such a filter “by handâ€� can be of an alternative. For example, xt_bpf and cls_bpf users might have requirements that could result in more complex filter code, or one that cannot be expressed with libpcap (e.g. different return codes for various code paths). Moreover, BPF JIT implementors may wish to manually write test cases and thus need low-level access to BPF code as well.”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K«hj‹h²hubeh}”(h]”Œexample”ah ]”h"]”Œexample”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K`ubh×)�”}”(hhh]”(hÜ)�”}”(hŒBPF engine and instruction set”h]”hŒBPF engine and instruction set”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjgh²hh³hÇh´K¸ubhý)�”}”(hŒ£The examples below use an assembly notation instead of less readable opcodes. The notation is closely modelled after Steven McCanne's and Van Jacobson's BPF paper.”h]”hŒ§The examples below use an assembly notation instead of less readable opcodes. The notation is closely modelled after Steven McCanne’s and Van Jacobson’s BPF paper.”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kºhjgh²hubhý)�”}”(hŒ>The BPF architecture consists of the following basic elements:”h]”hŒ>The BPF architecture consists of the following basic elements:”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¾hjgh²hubjã)�”}”(hX·======= ==================================================== Element Description ======= ==================================================== A 32 bit wide accumulator X 32 bit wide X register M[] 16 x 32 bit wide misc registers aka "scratch memory store", addressable from 0 to 15 ======= ==================================================== ”h]”hŒtable”“”)�”}”(hhh]”hŒtgroup”“”)�”}”(hhh]”(hŒcolspec”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1j¢hjŸubj£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K4uh1j¢hjŸubhŒthead”“”)�”}”(hhh]”hŒrow”“”)�”}”(hhh]”(hŒentry”“”)�”}”(hhh]”hý)�”}”(hŒElement”h]”hŒElement”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÁhjÄubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¿ubjÃ)�”}”(hhh]”hý)�”}”(hŒ Description”h]”hŒ Description”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÁhjÛubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¿ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjºubah}”(h]”h ]”h"]”h$]”h&]”uh1j¸hjŸubhŒtbody”“”)�”}”(hhh]”(j¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒA”h]”hŒA”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÃhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒ32 bit wide accumulator”h]”hŒ32 bit wide accumulator”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÃhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒX”h]”hŒX”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÄhj=ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj:ubjÃ)�”}”(hhh]”hý)�”}”(hŒ32 bit wide X register”h]”hŒ32 bit wide X register”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÄhjTubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj:ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒM[]”h]”hŒM[]”…”�”}”(hjwh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÅhjtubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjqubjÃ)�”}”(hhh]”hý)�”}”(hŒT16 x 32 bit wide misc registers aka "scratch memory store", addressable from 0 to 15”h]”hŒX16 x 32 bit wide misc registers aka “scratch memory storeâ€�, addressable from 0 to 15”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÅhj‹ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjqubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jþhjŸubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j�hjšubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1jâh³hÇh´KÀhjgh²hubhý)�”}”(hŒ^A BPF program is an array of instructions with the following elements (as already mentioned)::”h]”hŒ]A BPF program is an array of instructions with the following elements (as already mentioned):”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÉhjgh²hubjJ)�”}”(hŒop:16, jt:8, jf:8, k:32”h]”hŒop:16, jt:8, jf:8, k:32”…”�”}”hjÏsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´KÌhjgh²hubhý)�”}”(hXIThe element op is a 16 bit wide opcode that has a particular instruction encoded. jt and jf are two 8 bit wide jump targets, one for condition "jump if true", the other one "jump if false". Eventually, element k contains a miscellaneous argument that can be interpreted in different ways depending on the given instruction in op.”h]”hXQThe element op is a 16 bit wide opcode that has a particular instruction encoded. jt and jf are two 8 bit wide jump targets, one for condition “jump if trueâ€�, the other one “jump if falseâ€�. Eventually, element k contains a miscellaneous argument that can be interpreted in different ways depending on the given instruction in op.”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÎhjgh²hubhý)�”}”(hŒÈThe instruction set consists of load, store, branch, alu, miscellaneous and return instructions. This table lists the assembly notation and what the corresponding opcodes defined in linux/filter.h do:”h]”hŒÈThe instruction set consists of load, store, branch, alu, miscellaneous and return instructions. This table lists the assembly notation and what the corresponding opcodes defined in linux/filter.h do:”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÔhjgh²hubjã)�”}”(hX‹=========== =================== ===================== Instruction Addressing mode Description =========== =================== ===================== ld 1, 2, 3, 4, 12 Load word into A ldi 4 Load word into A ldh 1, 2 Load half-word into A ldb 1, 2 Load byte into A ldx 3, 4, 5, 12 Load word into X ldxi 4 Load word into X ldxb 5 Load byte into X st 3 Store A into M[] stx 3 Store X into M[] jmp 6 Jump to label ja 6 Jump to label jeq 7, 8, 9, 10 Jump on A == jneq 9, 10 Jump on A != jne 9, 10 Jump on A != jlt 9, 10 Jump on A < jle 9, 10 Jump on A <= jgt 7, 8, 9, 10 Jump on A > jge 7, 8, 9, 10 Jump on A >= jset 7, 8, 9, 10 Jump on A & add 0, 4 A + sub 0, 4 A - mul 0, 4 A * div 0, 4 A / mod 0, 4 A % neg !A and 0, 4 A & or 0, 4 A | xor 0, 4 A ^ lsh 0, 4 A << rsh 0, 4 A >> tax Copy A into X txa Copy X into A ret 4, 11 Return =========== =================== ===================== ”h]”j™)�”}”(hhh]”jž)�”}”(hhh]”(j£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K uh1j¢hjubj£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1j¢hjubj£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1j¢hjubj¹)�”}”(hhh]”j¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ Instruction”h]”hŒ Instruction”…”�”}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÙhj'ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj$ubjÃ)�”}”(hhh]”hý)�”}”(hŒAddressing mode”h]”hŒAddressing mode”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÙhj>ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj$ubjÃ)�”}”(hhh]”hý)�”}”(hŒ Description”h]”hŒ Description”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÙhjUubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj$ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¸hjubjÿ)�”}”(hhh]”(j¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒld”h]”hŒld”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÛhj~ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj{ubjÃ)�”}”(hhh]”hý)�”}”(hŒ1, 2, 3, 4, 12”h]”hŒ1, 2, 3, 4, 12”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÛhj•ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj{ubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad word into A”h]”hŒLoad word into A”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÛhj¬ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj{ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldi”h]”hŒldi”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÜhjÌubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÉubjÃ)�”}”(hhh]”hý)�”}”(hŒ4”h]”hŒ4”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÜhjãubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÉubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad word into A”h]”hŒLoad word into A”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÜhjúubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÉubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldh”h]”hŒldh”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÝhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒ1, 2”h]”hŒ1, 2”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÝhj1ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad half-word into A”h]”hŒLoad half-word into A”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÝhjHubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldb”h]”hŒldb”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÞhjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjeubjÃ)�”}”(hhh]”hý)�”}”(hŒ1, 2”h]”hŒ1, 2”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÞhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjeubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad byte into A”h]”hŒLoad byte into A”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KÞhj–ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjeubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldx”h]”hŒldx”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kßhj¶ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj³ubjÃ)�”}”(hhh]”hý)�”}”(hŒ 3, 4, 5, 12”h]”hŒ 3, 4, 5, 12”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KßhjÍubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj³ubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad word into X”h]”hŒLoad word into X”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kßhjäubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj³ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldxi”h]”hŒldxi”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kàhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hjèh]”hŒ4”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kàhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad word into X”h]”hŒLoad word into X”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kàhj1ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒldxb”h]”hŒldxb”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KáhjQubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjNubjÃ)�”}”(hhh]”hý)�”}”(hŒ5”h]”hŒ5”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Káhjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjNubjÃ)�”}”(hhh]”hý)�”}”(hŒLoad byte into X”h]”hŒLoad byte into X”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Káhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjNubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒst”h]”hŒst”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KãhjŸubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjœubjÃ)�”}”(hhh]”hý)�”}”(hŒ3”h]”hŒ3”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kãhj¶ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjœubjÃ)�”}”(hhh]”hý)�”}”(hŒStore A into M[]”h]”hŒStore A into M[]”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KãhjÍubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjœubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒstx”h]”hŒstx”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kähjíubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjêubjÃ)�”}”(hhh]”hý)�”}”(hj»h]”hŒ3”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kähjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjêubjÃ)�”}”(hhh]”hý)�”}”(hŒStore X into M[]”h]”hŒStore X into M[]”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kähjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjêubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjmp”h]”hŒjmp”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kæhj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj7ubjÃ)�”}”(hhh]”hý)�”}”(hŒ6”h]”hŒ6”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KæhjQubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj7ubjÃ)�”}”(hhh]”hý)�”}”(hŒ Jump to label”h]”hŒ Jump to label”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kæhjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj7ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒja”h]”hŒja”…”�”}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kçhjˆubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj…ubjÃ)�”}”(hhh]”hý)�”}”(hjVh]”hŒ6”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KçhjŸubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj…ubjÃ)�”}”(hhh]”hý)�”}”(hŒ Jump to label”h]”hŒ Jump to label”…”�”}”(hj¸h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kçhjµubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj…ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjeq”h]”hŒjeq”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KèhjÕubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÒubjÃ)�”}”(hhh]”hý)�”}”(hŒ 7, 8, 9, 10”h]”hŒ 7, 8, 9, 10”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kèhjìubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÒubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A == ”h]”hŒJump on A == ”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kèhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÒubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjneq”h]”hŒjneq”…”�”}”(hj& h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kéhj# ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒ9, 10”h]”hŒ9, 10”…”�”}”(hj= h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kéhj: ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A != ”h]”hŒJump on A != ”…”�”}”(hjT h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KéhjQ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjne”h]”hŒjne”…”�”}”(hjt h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kêhjq ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjn ubjÃ)�”}”(hhh]”hý)�”}”(hŒ9, 10”h]”hŒ9, 10”…”�”}”(hj‹ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kêhjˆ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjn ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A != ”h]”hŒJump on A != ”…”�”}”(hj¢ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KêhjŸ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjn ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjlt”h]”hŒjlt”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Këhj¿ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¼ ubjÃ)�”}”(hhh]”hý)�”}”(hŒ9, 10”h]”hŒ9, 10”…”�”}”(hjÙ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KëhjÖ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¼ ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A < ”h]”hŒJump on A < ”…”�”}”(hjð h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Këhjí ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¼ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjle”h]”hŒjle”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kìhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒ9, 10”h]”hŒ9, 10”…”�”}”(hj' h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kìhj$ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A <= ”h]”hŒJump on A <= ”…”�”}”(hj> h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kìhj; ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjgt”h]”hŒjgt”…”�”}”(hj^ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kíhj[ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjX ubjÃ)�”}”(hhh]”hý)�”}”(hŒ 7, 8, 9, 10”h]”hŒ 7, 8, 9, 10”…”�”}”(hju h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kíhjr ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjX ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A > ”h]”hŒJump on A > ”…”�”}”(hjŒ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kíhj‰ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjX ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjge”h]”hŒjge”…”�”}”(hj¬ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kîhj© ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¦ ubjÃ)�”}”(hhh]”hý)�”}”(hŒ 7, 8, 9, 10”h]”hŒ 7, 8, 9, 10”…”�”}”(hjà h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KîhjÀ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¦ ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A >= ”h]”hŒJump on A >= ”…”�”}”(hjÚ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kîhj× ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¦ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒjset”h]”hŒjset”…”�”}”(hjú h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kïhj÷ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjô ubjÃ)�”}”(hhh]”hý)�”}”(hŒ 7, 8, 9, 10”h]”hŒ 7, 8, 9, 10”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kïhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjô ubjÃ)�”}”(hhh]”hý)�”}”(hŒJump on A & ”h]”hŒJump on A & ”…”�”}”(hj( h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kïhj% ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjô ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒadd”h]”hŒadd”…”�”}”(hjH h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KñhjE ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjB ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hj_ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kñhj\ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjB ubjÃ)�”}”(hhh]”hý)�”}”(hŒA + ”h]”hŒA + ”…”�”}”(hjv h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kñhjs ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjB ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒsub”h]”hŒsub”…”�”}”(hj– h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kòhj“ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj� ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hj­ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kòhjª ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj� ubjÃ)�”}”(hhh]”hý)�”}”(hŒA - ”h]”hŒA - ”…”�”}”(hjÄ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KòhjÁ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj� ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒmul”h]”hŒmul”…”�”}”(hjä h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kóhjá ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÞ ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hjû h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kóhjø ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÞ ubjÃ)�”}”(hhh]”hý)�”}”(hŒA * ”h]”hŒA * ”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kóhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÞ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒdiv”h]”hŒdiv”…”�”}”(hj2 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kôhj/ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj, ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hjI h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KôhjF ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj, ubjÃ)�”}”(hhh]”hý)�”}”(hŒA / ”h]”hŒA / ”…”�”}”(hj` h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kôhj] ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj, ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒmod”h]”hŒmod”…”�”}”(hj€ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kõhj} ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjz ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hj— h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kõhj” ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjz ubjÃ)�”}”(hhh]”hý)�”}”(hŒA % ”h]”hŒA % ”…”�”}”(hj® h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kõhj« ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjz ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒneg”h]”hŒneg”…”�”}”(hjÎ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KöhjË ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÈ ubjÃ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÈ ubjÃ)�”}”(hhh]”hý)�”}”(hŒ!A”h]”hŒ!A”…”�”}”(hjî h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Köhjë ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÈ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒand”h]”hŒand”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K÷hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hj% h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K÷hj" ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒA & ”h]”hŒA & ”…”�”}”(hj< h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K÷hj9 ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒor”h]”hŒor”…”�”}”(hj\ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KøhjY ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjV ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hjs h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Køhjp ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjV ubjÃ)�”}”(hhh]”hý)�”}”(hŒA | ”h]”hŒA | ”…”�”}”(hjŠ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Køhj‡ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjV ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒxor”h]”hŒxor”…”�”}”(hjª h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kùhj§ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¤ ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hjÁ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kùhj¾ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¤ ubjÃ)�”}”(hhh]”hý)�”}”(hŒA ^ ”h]”hŒA ^ ”…”�”}”(hjØ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KùhjÕ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj¤ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒlsh”h]”hŒlsh”…”�”}”(hjø h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kúhjõ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjò ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kúhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjò ubjÃ)�”}”(hhh]”hý)�”}”(hŒA << ”h]”hŒA << ”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kúhj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjò ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒrsh”h]”hŒrsh”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KûhjCubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj@ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0, 4”h]”hŒ0, 4”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KûhjZubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj@ubjÃ)�”}”(hhh]”hý)�”}”(hŒA >> ”h]”hŒA >> ”…”�”}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kûhjqubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj@ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒtax”h]”hŒtax”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kýhj‘ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjŽubjÃ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjŽubjÃ)�”}”(hhh]”hý)�”}”(hŒ Copy A into X”h]”hŒ Copy A into X”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kýhj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjŽubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒtxa”h]”hŒtxa”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KþhjÑubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÎubjÃ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÎubjÃ)�”}”(hhh]”hý)�”}”(hŒ Copy X into A”h]”hŒ Copy X into A”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kþhjñubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÎubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒret”h]”hŒret”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒ4, 11”h]”hŒ4, 11”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj(ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒReturn”h]”hŒReturn”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjxubeh}”(h]”h ]”h"]”h$]”h&]”uh1jþhjubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j�hjýubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjùubah}”(h]”h ]”h"]”h$]”h&]”uh1jâh³hÇh´KØhjgh²hubhý)�”}”(hŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ11”h]”hŒ11”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj^ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj[ubjÃ)�”}”(hhh]”hý)�”}”(hŒa/%a”h]”hŒa/%a”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjuubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj[ubjÃ)�”}”(hhh]”hý)�”}”(hŒ Accumulator A”h]”hŒ Accumulator A”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MhjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj[ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ12”h]”hŒ12”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj¬ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj©ubjÃ)�”}”(hhh]”hý)�”}”(hŒ extension”h]”hŒ extension”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MhjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj©ubjÃ)�”}”(hhh]”hý)�”}”(hŒ BPF extension”h]”hŒ BPF extension”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MhjÚubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj©ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jþhjŠubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j�hj‡ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjƒubah}”(h]”h ]”h"]”h$]”h&]”uh1jâh³hÇh´Mhjgh²hubhý)�”}”(hŒùThe Linux kernel also has a couple of BPF extensions that are used along with the class of load instructions by "overloading" the k argument with a negative offset + a particular extension offset. The result of such BPF extensions are loaded into A.”h]”hŒýThe Linux kernel also has a couple of BPF extensions that are used along with the class of load instructions by “overloadingâ€� the k argument with a negative offset + a particular extension offset. The result of such BPF extensions are loaded into A.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjgh²hubhý)�”}”(hŒ9Possible BPF extensions are shown in the following table:”h]”hŒ9Possible BPF extensions are shown in the following table:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjgh²hubjã)�”}”(hXß=================================== ================================================= Extension Description =================================== ================================================= len skb->len proto skb->protocol type skb->pkt_type poff Payload start offset ifidx skb->dev->ifindex nla Netlink attribute of type X with offset A nlan Nested Netlink attribute of type X with offset A mark skb->mark queue skb->queue_mapping hatype skb->dev->type rxhash skb->hash cpu raw_smp_processor_id() vlan_tci skb_vlan_tag_get(skb) vlan_avail skb_vlan_tag_present(skb) vlan_tpid skb->vlan_proto rand get_random_u32() =================================== ================================================= ”h]”j™)�”}”(hhh]”jž)�”}”(hhh]”(j£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K#uh1j¢hj3ubj£)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K1uh1j¢hj3ubj¹)�”}”(hhh]”j¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ Extension”h]”hŒ Extension”…”�”}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MhjPubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjMubjÃ)�”}”(hhh]”hý)�”}”(hŒ Description”h]”hŒ Description”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjgubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjMubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjJubah}”(h]”h ]”h"]”h$]”h&]”uh1j¸hj3ubjÿ)�”}”(hhh]”(j¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒlen”h]”hŒlen”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M!hj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj�ubjÃ)�”}”(hhh]”hý)�”}”(hŒskb->len”h]”hŒskb->len”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M!hj§ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒproto”h]”hŒproto”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M"hjÇubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÄubjÃ)�”}”(hhh]”hý)�”}”(hŒ skb->protocol”h]”hŒ skb->protocol”…”�”}”(hjáh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M"hjÞubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÄubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒtype”h]”hŒtype”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M#hjþubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjûubjÃ)�”}”(hhh]”hý)�”}”(hŒ skb->pkt_type”h]”hŒ skb->pkt_type”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M#hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjûubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒpoff”h]”hŒpoff”…”�”}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M$hj5ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj2ubjÃ)�”}”(hhh]”hý)�”}”(hŒPayload start offset”h]”hŒPayload start offset”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M$hjLubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj2ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒifidx”h]”hŒifidx”…”�”}”(hjoh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M%hjlubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjiubjÃ)�”}”(hhh]”hý)�”}”(hŒskb->dev->ifindex”h]”hŒskb->dev->ifindex”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M%hjƒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjiubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒnla”h]”hŒnla”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M&hj£ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubjÃ)�”}”(hhh]”hý)�”}”(hŒ)Netlink attribute of type X with offset A”h]”hŒ)Netlink attribute of type X with offset A”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M&hjºubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒnlan”h]”hŒnlan”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M'hjÚubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj×ubjÃ)�”}”(hhh]”hý)�”}”(hŒ0Nested Netlink attribute of type X with offset A”h]”hŒ0Nested Netlink attribute of type X with offset A”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M'hjñubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj×ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒmark”h]”hŒmark”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M(hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubjÃ)�”}”(hhh]”hý)�”}”(hŒ skb->mark”h]”hŒ skb->mark”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M(hj(ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒqueue”h]”hŒqueue”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M)hjHubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjEubjÃ)�”}”(hhh]”hý)�”}”(hŒskb->queue_mapping”h]”hŒskb->queue_mapping”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M)hj_ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjEubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒhatype”h]”hŒhatype”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M*hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj|ubjÃ)�”}”(hhh]”hý)�”}”(hŒskb->dev->type”h]”hŒskb->dev->type”…”�”•2[}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M*hj–ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj|ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒrxhash”h]”hŒrxhash”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M+hj¶ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj³ubjÃ)�”}”(hhh]”hý)�”}”(hŒ skb->hash”h]”hŒ skb->hash”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M+hjÍubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj³ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒcpu”h]”hŒcpu”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M,hjíubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjêubjÃ)�”}”(hhh]”hý)�”}”(hŒraw_smp_processor_id()”h]”hŒraw_smp_processor_id()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M,hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjêubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒvlan_tci”h]”hŒvlan_tci”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M-hj$ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj!ubjÃ)�”}”(hhh]”hý)�”}”(hŒskb_vlan_tag_get(skb)”h]”hŒskb_vlan_tag_get(skb)”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M-hj;ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj!ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ vlan_avail”h]”hŒ vlan_avail”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M.hj[ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjXubjÃ)�”}”(hhh]”hý)�”}”(hŒskb_vlan_tag_present(skb)”h]”hŒskb_vlan_tag_present(skb)”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M.hjrubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjXubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒ vlan_tpid”h]”hŒ vlan_tpid”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M/hj’ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj�ubjÃ)�”}”(hhh]”hý)�”}”(hŒskb->vlan_proto”h]”hŒskb->vlan_proto”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M/hj©ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubj¾)�”}”(hhh]”(jÃ)�”}”(hhh]”hý)�”}”(hŒrand”h]”hŒrand”…”�”}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M0hjÉubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÆubjÃ)�”}”(hhh]”hý)�”}”(hŒget_random_u32()”h]”hŒget_random_u32()”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M0hjàubah}”(h]”h ]”h"]”h$]”h&]”uh1jÂhjÆubeh}”(h]”h ]”h"]”h$]”h&]”uh1j½hjŠubeh}”(h]”h ]”h"]”h$]”h&]”uh1jþhj3ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j�hj0ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj,ubah}”(h]”h ]”h"]”h$]”h&]”uh1jâh³hÇh´Mhjgh²hubhý)�”}”(hŒKThese extensions can also be prefixed with '#'. Examples for low-level BPF:”h]”hŒOThese extensions can also be prefixed with ‘#’. Examples for low-level BPF:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M3hjgh²hubhý)�”}”(hŒ**ARP packets**::”h]”(hŒstrong”“”)�”}”(hŒ**ARP packets**”h]”hŒ ARP packets”…”�”}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hj$ubhŒ:”…”�”}”(hj$h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M6hjgh²hubjJ)�”}”(hŒ.ldh [12] jne #0x806, drop ret #-1 drop: ret #0”h]”hŒ.ldh [12] jne #0x806, drop ret #-1 drop: ret #0”…”�”}”hjBsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´M8hjgh²hubhý)�”}”(hŒ**IPv4 TCP packets**::”h]”(j))�”}”(hŒ**IPv4 TCP packets**”h]”hŒIPv4 TCP packets”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hjPubhŒ:”…”�”}”(hjPh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M=hjgh²hubjJ)�”}”(hŒEldh [12] jne #0x800, drop ldb [23] jneq #6, drop ret #-1 drop: ret #0”h]”hŒEldh [12] jne #0x800, drop ldb [23] jneq #6, drop ret #-1 drop: ret #0”…”�”}”hjlsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´M?hjgh²hubhý)�”}”(hŒ)**icmp random packet sampling, 1 in 4**::”h]”(j))�”}”(hŒ'**icmp random packet sampling, 1 in 4**”h]”hŒ#icmp random packet sampling, 1 in 4”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hjzubhŒ:”…”�”}”(hjzh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MFhjgh²hubjJ)�”}”(hŒldh [12] jne #0x800, drop ldb [23] jneq #1, drop # get a random uint32 number ld rand mod #4 jneq #1, drop ret #-1 drop: ret #0”h]”hŒldh [12] jne #0x800, drop ldb [23] jneq #1, drop # get a random uint32 number ld rand mod #4 jneq #1, drop ret #-1 drop: ret #0”…”�”}”hj–sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´MHhjgh²hubhý)�”}”(hŒ**SECCOMP filter example**::”h]”(j))�”}”(hŒ**SECCOMP filter example**”h]”hŒSECCOMP filter example”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hj¤ubhŒ:”…”�”}”(hj¤h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MShjgh²hubjJ)�”}”(hXÎld [4] /* offsetof(struct seccomp_data, arch) */ jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */ ld [0] /* offsetof(struct seccomp_data, nr) */ jeq #15, good /* __NR_rt_sigreturn */ jeq #231, good /* __NR_exit_group */ jeq #60, good /* __NR_exit */ jeq #0, good /* __NR_read */ jeq #1, good /* __NR_write */ jeq #5, good /* __NR_fstat */ jeq #9, good /* __NR_mmap */ jeq #14, good /* __NR_rt_sigprocmask */ jeq #13, good /* __NR_rt_sigaction */ jeq #35, good /* __NR_nanosleep */ bad: ret #0 /* SECCOMP_RET_KILL_THREAD */ good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */”h]”hXÎld [4] /* offsetof(struct seccomp_data, arch) */ jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */ ld [0] /* offsetof(struct seccomp_data, nr) */ jeq #15, good /* __NR_rt_sigreturn */ jeq #231, good /* __NR_exit_group */ jeq #60, good /* __NR_exit */ jeq #0, good /* __NR_read */ jeq #1, good /* __NR_write */ jeq #5, good /* __NR_fstat */ jeq #9, good /* __NR_mmap */ jeq #14, good /* __NR_rt_sigprocmask */ jeq #13, good /* __NR_rt_sigaction */ jeq #35, good /* __NR_nanosleep */ bad: ret #0 /* SECCOMP_RET_KILL_THREAD */ good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */”…”�”}”hjÀsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´MUhjgh²hubhý)�”}”(hŒ%Examples for low-level BPF extension:”h]”hŒ%Examples for low-level BPF extension:”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mehjgh²hubhý)�”}”(hŒ#**Packet for interface index 13**::”h]”(j))�”}”(hŒ!**Packet for interface index 13**”h]”hŒPacket for interface index 13”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hjÜubhŒ:”…”�”}”(hjÜh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mghjgh²hubjJ)�”}”(hŒ,ld ifidx jneq #13, drop ret #-1 drop: ret #0”h]”hŒ,ld ifidx jneq #13, drop ret #-1 drop: ret #0”…”�”}”hjøsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´Mihjgh²hubhý)�”}”(hŒ!**(Accelerated) VLAN w/ id 10**::”h]”(j))�”}”(hŒ**(Accelerated) VLAN w/ id 10**”h]”hŒ(Accelerated) VLAN w/ id 10”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j(hjubhŒ:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mnhjgh²hubjJ)�”}”(hŒ/ld vlan_tci jneq #10, drop ret #-1 drop: ret #0”h]”hŒ/ld vlan_tci jneq #10, drop ret #-1 drop: ret #0”…”�”}”hj"sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´Mphjgh²hubhý)�”}”(hŒMThe ARP filter shown above corresponds to the following sock_filter entries::”h]”hŒLThe ARP filter shown above corresponds to the following sock_filter entries:”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Muhjgh²hubjJ)�”}”(hŒw{ 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 1, 0x00000806 }, { 0x06, 0, 0, 0xffffffff }, { 0x06, 0, 0, 0000000000 },”h]”hŒw{ 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 1, 0x00000806 }, { 0x06, 0, 0, 0xffffffff }, { 0x06, 0, 0, 0000000000 },”…”�”}”hj>sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´Mxhjgh²hubeh}”(h]”Œbpf-engine-and-instruction-set”ah ]”h"]”Œbpf engine and instruction set”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K¸ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ JIT compiler”h]”hŒ JIT compiler”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjTh²hh³hÇh´M~ubhý)�”}”(hX;The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, ARM, ARM64, MIPS, RISC-V, s390, and ARC and can be enabled through CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each attached filter from user space or for internal kernel users if it has been previously enabled by root::”h]”hX:The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, ARM, ARM64, MIPS, RISC-V, s390, and ARC and can be enabled through CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each attached filter from user space or for internal kernel users if it has been previously enabled by root:”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M€hjTh²hubjJ)�”}”(hŒ*echo 1 > /proc/sys/net/core/bpf_jit_enable”h]”hŒ*echo 1 > /proc/sys/net/core/bpf_jit_enable”…”�”}”hjssbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´M†hjTh²hubhý)�”}”(hŒvFor JIT developers, doing audits etc, each compile run can output the generated opcode image into the kernel log via::”h]”hŒuFor JIT developers, doing audits etc, each compile run can output the generated opcode image into the kernel log via:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MˆhjTh²hubjJ)�”}”(hŒ*echo 2 > /proc/sys/net/core/bpf_jit_enable”h]”hŒ*echo 2 > /proc/sys/net/core/bpf_jit_enable”…”�”}”hj�sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´M‹hjTh²hubhý)�”}”(hŒExample output from dmesg::”h]”hŒExample output from dmesg:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M�hjTh²hubjJ)�”}”(hX¿[ 3389.935842] flen=6 proglen=70 pass=3 image=ffffffffa0069c8f [ 3389.935847] JIT code: 00000000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 68 [ 3389.935849] JIT code: 00000010: 44 2b 4f 6c 4c 8b 87 d8 00 00 00 be 0c 00 00 00 [ 3389.935850] JIT code: 00000020: e8 1d 94 ff e0 3d 00 08 00 00 75 16 be 17 00 00 [ 3389.935851] JIT code: 00000030: 00 e8 28 94 ff e0 83 f8 01 75 07 b8 ff ff 00 00 [ 3389.935852] JIT code: 00000040: eb 02 31 c0 c9 c3”h]”hX¿[ 3389.935842] flen=6 proglen=70 pass=3 image=ffffffffa0069c8f [ 3389.935847] JIT code: 00000000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 68 [ 3389.935849] JIT code: 00000010: 44 2b 4f 6c 4c 8b 87 d8 00 00 00 be 0c 00 00 00 [ 3389.935850] JIT code: 00000020: e8 1d 94 ff e0 3d 00 08 00 00 75 16 be 17 00 00 [ 3389.935851] JIT code: 00000030: 00 e8 28 94 ff e0 83 f8 01 75 07 b8 ff ff 00 00 [ 3389.935852] JIT code: 00000040: eb 02 31 c0 c9 c3”…”�”}”hj«sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jIh³hÇh´M�hjTh²hubhý)�”}”(hXvWhen CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1 and setting any other value than that will return in failure. This is even the case for setting bpf_jit_enable to 2, since dumping the final JIT image into the kernel log is discouraged and introspection through bpftool (under tools/bpf/bpftool/) is the generally recommended approach instead.”h]”hXvWhen CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1 and setting any other value than that will return in failure. This is even the case for setting bpf_jit_enable to 2, since dumping the final JIT image into the kernel log is discouraged and introspection through bpftool (under tools/bpf/bpftool/) is the generally recommended approach instead.”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M–hjTh²hubeh}”(h]”Œ jit-compiler”ah ]”h"]”Œ jit compiler”ah$]”h&]”uh1hÖhhØh²hh³hÇh´M~ubh×)�”}”(hhh]”(hÜ)�”}”(hŒBPF kernel internals”h]”hŒBPF kernel internals”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÏh²hh³hÇh´M�ubhý)�”}”(hXxInternally, for the kernel interpreter, a different instruction set format with similar underlying principles from BPF described in previous paragraphs is being used. However, the instruction set format is modelled closer to the underlying architecture to mimic native instruction sets, so that a better performance can be achieved (more details later). This new ISA is called eBPF. See the ../bpf/index.rst for details. (Note: eBPF which originates from [e]xtended BPF is not the same as BPF extensions! While eBPF is an ISA, BPF extensions date back to classic BPF's 'overloading' of BPF_LD | BPF_{B,H,W} | BPF_ABS instruction.)”h]”hX~Internally, for the kernel interpreter, a different instruction set format with similar underlying principles from BPF described in previous paragraphs is being used. However, the instruction set format is modelled closer to the underlying architecture to mimic native instruction sets, so that a better performance can be achieved (more details later). This new ISA is called eBPF. See the ../bpf/index.rst for details. (Note: eBPF which originates from [e]xtended BPF is not the same as BPF extensions! While eBPF is an ISA, BPF extensions date back to classic BPF’s ‘overloading’ of BPF_LD | BPF_{B,H,W} | BPF_ABS instruction.)”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MžhjÏh²hubhý)�”}”(hX5The new instruction set was originally designed with the possible goal in mind to write programs in "restricted C" and compile into eBPF with a optional GCC/LLVM backend, so that it can just-in-time map to modern 64-bit CPUs with minimal performance overhead over two steps, that is, C -> eBPF -> native code.”h]”hX9The new instruction set was originally designed with the possible goal in mind to write programs in “restricted Câ€� and compile into eBPF with a optional GCC/LLVM backend, so that it can just-in-time map to modern 64-bit CPUs with minimal performance overhead over two steps, that is, C -> eBPF -> native code.”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¨hjÏh²hubhý)�”}”(hXšCurrently, the new format is being used for running user BPF programs, which includes seccomp BPF, classic socket filters, cls_bpf traffic classifier, team driver's classifier for its load-balancing mode, netfilter's xt_bpf extension, PTP dissector/classifier, and much more. They are all internally converted by the kernel into the new instruction set representation and run in the eBPF interpreter. For in-kernel handlers, this all works transparently by using bpf_prog_create() for setting up the filter, resp. bpf_prog_destroy() for destroying it. The function bpf_prog_run(filter, ctx) transparently invokes eBPF interpreter or JITed code to run the filter. 'filter' is a pointer to struct bpf_prog that we got from bpf_prog_create(), and 'ctx' the given context (e.g. skb pointer). All constraints and restrictions from bpf_check_classic() apply before a conversion to the new layout is being done behind the scenes!”h]”hX¦Currently, the new format is being used for running user BPF programs, which includes seccomp BPF, classic socket filters, cls_bpf traffic classifier, team driver’s classifier for its load-balancing mode, netfilter’s xt_bpf extension, PTP dissector/classifier, and much more. They are all internally converted by the kernel into the new instruction set representation and run in the eBPF interpreter. For in-kernel handlers, this all works transparently by using bpf_prog_create() for setting up the filter, resp. bpf_prog_destroy() for destroying it. The function bpf_prog_run(filter, ctx) transparently invokes eBPF interpreter or JITed code to run the filter. ‘filter’ is a pointer to struct bpf_prog that we got from bpf_prog_create(), and ‘ctx’ the given context (e.g. skb pointer). All constraints and restrictions from bpf_check_classic() apply before a conversion to the new layout is being done behind the scenes!”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M­hjÏh²hubhý)�”}”(hŒéCurrently, the classic BPF format is being used for JITing on most 32-bit architectures, whereas x86-64, aarch64, s390x, powerpc64, sparc64, arm32, riscv64, riscv32, loongarch64, arc perform JIT compilation from eBPF instruction set.”h]”hŒéCurrently, the classic BPF format is being used for JITing on most 32-bit architectures, whereas x86-64, aarch64, s390x, powerpc64, sparc64, arm32, riscv64, riscv32, loongarch64, arc perform JIT compilation from eBPF instruction set.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M»hjÏh²hubeh}”(h]”Œbpf-kernel-internals”ah ]”h"]”Œbpf kernel internals”ah$]”h&]”uh1hÖhhØh²hh³hÇh´M�ubh×)�”}”(hhh]”(hÜ)�”}”(hŒTesting”h]”hŒTesting”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj h²hh³hÇh´MÁubhý)�”}”(hXQThe BPF selftests under tools/testing/selftests/bpf ship instruction tests in test_progs, see jit_insns, which runs the eBPF instructions over a range of operand magnitudes and signs, register combinations, memory offsets and jump offsets against the BPF interpreter or the JIT compiler, depending on the net.core.bpf_jit_enable setting.”h]”hXQThe BPF selftests under tools/testing/selftests/bpf ship instruction tests in test_progs, see jit_insns, which runs the eBPF instructions over a range of operand magnitudes and signs, register combinations, memory offsets and jump offsets against the BPF interpreter or the JIT compiler, depending on the net.core.bpf_jit_enable setting.”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÃhj h²hubeh}”(h]”Œtesting”ah ]”h"]”Œtesting”ah$]”h&]”uh1hÖhhØh²hh³hÇh´MÁubh×)�”}”(hhh]”(hÜ)�”}”(hŒMisc”h]”hŒMisc”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjGh²hh³hÇh´MÊubhý)�”}”(hŒdAlso trinity, the Linux syscall fuzzer, has built-in support for BPF and SECCOMP-BPF kernel fuzzing.”h]”hŒdAlso trinity, the Linux syscall fuzzer, has built-in support for BPF and SECCOMP-BPF kernel fuzzing.”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÌhjGh²hubeh}”(h]”Œmisc”ah ]”h"]”Œmisc”ah$]”h&]”uh1hÖhhØh²hh³hÇh´MÊubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Written by”h]”hŒ Written by”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjnh²hh³hÇh´MÐubhý)�”}”(hŒ®The document was written in the hope that it is found useful and in order to give potential BPF hackers or security auditors a better overview of the underlying architecture.”h]”hŒ®The document was written in the hope that it is found useful and in order to give potential BPF hackers or security auditors a better overview of the underlying architecture.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÒhjnh²hubjé)�”}”(hhh]”(jî)�”}”(hŒ Jay Schulist ”h]”hý)�”}”(hj’h]”(hŒJay Schulist <”…”�”}”(hj”h²hh³Nh´Nubj)�”}”(hŒjschlst@samba.org”h]”hŒjschlst@samba.org”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:jschlst@samba.org”uh1jhj”ubhŒ>”…”�”}”(hj”h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÖhj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhj�h²hh³hÇh´Nubjî)�”}”(hŒ&Daniel Borkmann ”h]”hý)�”}”(hj½h]”(hŒDaniel Borkmann <”…”�”}”(hj¿h²hh³Nh´Nubj)�”}”(hŒdaniel@iogearbox.net”h]”hŒdaniel@iogearbox.net”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:daniel@iogearbox.net”uh1jhj¿ubhŒ>”…”�”}”(hj¿h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M×hj»ubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhj�h²hh³hÇh´Nubjî)�”}”(hŒ#Alexei Starovoitov ”h]”hý)�”}”(hjèh]”(hŒAlexei Starovoitov <”…”�”}”(hjêh²hh³Nh´Nubj)�”}”(hŒast@kernel.org”h]”hŒast@kernel.org”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:ast@kernel.org”uh1jhjêubhŒ>”…”�”}”(hjêh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MØhjæubah}”(h]”h ]”h"]”h$]”h&]”uh1jíhj�h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j;Œ-”uh1jèh³hÇh´MÖhjnh²hubeh}”(h]”Œ written-by”ah ]”h"]”Œ written by”ah$]”h&]”uh1hÖhhØh²hh³hÇh´MÐubeh}”(h]”(Œ5linux-socket-filtering-aka-berkeley-packet-filter-bpf”hÕeh ]”h"]”(Œ7linux socket filtering aka berkeley packet filter (bpf)”Œnetworking-filter”eh$]”h&]”uh1hÖhhh²hh³hÇh´KŒexpect_referenced_by_name”}”j&hÊsŒexpect_referenced_by_id”}”hÕhÊsubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÛNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”jÂŒfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jOŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œ1”]”j©asŒrefids”}”hÕ]”hÊasŒnameids”}”(j&hÕj%j"jjj'j$jîj¸jˆj…jdjajQjNjÌjÉjjjDjAjkjhjjuŒ nametypes”}”(j&ˆj%‰j‰j'‰jîˆjˆ‰jd‰jQ‰j̉j‰jD‰jk‰j‰uh}”(hÕhØj"hØjhëj$jj³j©j¸jÈj…j*jaj‹jNjgjÉjTjjÏjAj jhjGjjnuŒ footnote_refs”}”j�]”j©asŒ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”jÈaŒ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j]Ks…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)�”}”(hhh]”hý)�”}”(hhh]”hŒ7Hyperlink target "networking-filter" is not referenced.”…”�”}”hj¼sbah}”(h]”h ]”h"]”h$]”h&]”uh1hühj¹ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÇŒline”Kuh1j·ubaŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.