Repository: Netronome/bpf-samples Branch: master Commit: a7dd7d8c3863 Files: 24 Total size: 99.6 KB Directory structure: gitextract_pfkymjau/ ├── .gitignore ├── .gitmodules ├── COPYING ├── README.rst ├── headers/ │ ├── bpf_endian.h │ ├── bpf_helpers.h │ ├── jhash.h │ └── perf-sys.h ├── l4lb/ │ ├── Makefile │ ├── README.rst │ ├── bpftool_utils.py │ ├── destination_samples/ │ │ ├── 128_destinations.csv │ │ ├── 256_destinations.csv │ │ ├── 32_destinations.csv │ │ └── 512_destinations.csv │ ├── l4lb_map.py │ ├── l4lb_stats.py │ └── l4lb_xdp.c └── programmable_rss/ ├── Makefile ├── README.rst ├── rss_common.h ├── rss_kern.c ├── rss_user.c └── traffic_IPIP.pcap ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.ll *.o *.pyc *.swp rss xdpdump tmp_bpftool.txt ================================================ FILE: .gitmodules ================================================ [submodule "libbpf"] path = libbpf url = https://github.com/libbpf/libbpf.git ================================================ FILE: COPYING ================================================ The BSD 2-Clause License Copyright (C) 2018 Netronome Systems, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ================================================ FILE: README.rst ================================================ .. SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) XDP Demo Apps ============= Testing XDP, on software and on hardware ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This repository contains eBPF XDP demo applications. Most demos can be run on XDP compatible drivers or hardware. Each subdirectory provides instructions for loading the programs in “driver” and/or in “offload” mode. “Driver mode” loads the XDP program into the kernel where the processing is carried out by the host CPU, whilst “offloaded XDP” allows for the program to be run on hardware, such as with the Netronome Agilio® CX SmartNIC. To enable XDP offload on a Agilio CX, please refer to `Netronome eBPF user guides`_. .. _Netronome eBPF user guides: https://help.netronome.com/support/solutions/folders/36000172266 List of available demos ~~~~~~~~~~~~~~~~~~~~~~~ The sources for each demo are located in a specific subdirectory. ======================== =============== Application Kernel Required ======================== =============== `Layer 4 Load Balancer`_ 4.17 `Programmable RSS`_ 4.18 `xdpdump`_ 4.18 ======================== =============== .. _Layer 4 Load Balancer: l4lb/ .. _Programmable RSS: programmable_rss/ .. _xdpdump: xdpdump/ libbpf ~~~~~~ The ``libbpf`` directory is a git submodule and contains libraries required for compiling the samples. To obtain the submodule content, the following git clone command is required: git clone --recurse-submodules https://github.com/Netronome/bpf-samples.git Notes ~~~~~ - These applications are prototypes and are not suitable for production use. ================================================ FILE: headers/bpf_endian.h ================================================ /* SPDX-License-Identifier: GPL-2.0 */ /* Copied from $(LINUX)/tools/testing/selftests/bpf/bpf_endian.h */ #ifndef __BPF_ENDIAN__ #define __BPF_ENDIAN__ #include /* LLVM's BPF target selects the endianness of the CPU * it compiles on, or the user specifies (bpfel/bpfeb), * respectively. The used __BYTE_ORDER__ is defined by * the compiler, we cannot rely on __BYTE_ORDER from * libc headers, since it doesn't reflect the actual * requested byte order. * * Note, LLVM's BPF target has different __builtin_bswapX() * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE * in bpfel and bpfeb case, which means below, that we map * to cpu_to_be16(). We could use it unconditionally in BPF * case, but better not rely on it, so that this header here * can be used from application and BPF program side, which * use different targets. */ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define __bpf_ntohs(x)__builtin_bswap16(x) # define __bpf_htons(x)__builtin_bswap16(x) # define __bpf_constant_ntohs(x)___constant_swab16(x) # define __bpf_constant_htons(x)___constant_swab16(x) # define __bpf_ntohl(x)__builtin_bswap32(x) # define __bpf_htonl(x)__builtin_bswap32(x) # define __bpf_constant_ntohl(x)___constant_swab32(x) # define __bpf_constant_htonl(x)___constant_swab32(x) #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define __bpf_ntohs(x)(x) # define __bpf_htons(x)(x) # define __bpf_constant_ntohs(x)(x) # define __bpf_constant_htons(x)(x) # define __bpf_ntohl(x)(x) # define __bpf_htonl(x)(x) # define __bpf_constant_ntohl(x)(x) # define __bpf_constant_htonl(x)(x) #else # error "Fix your compiler's __BYTE_ORDER__?!" #endif #define bpf_htons(x)\ (__builtin_constant_p(x) ?\ __bpf_constant_htons(x) : __bpf_htons(x)) #define bpf_ntohs(x)\ (__builtin_constant_p(x) ?\ __bpf_constant_ntohs(x) : __bpf_ntohs(x)) #define bpf_htonl(x)\ (__builtin_constant_p(x) ?\ __bpf_constant_htonl(x) : __bpf_htonl(x)) #define bpf_ntohl(x)\ (__builtin_constant_p(x) ?\ __bpf_constant_ntohl(x) : __bpf_ntohl(x)) #endif /* __BPF_ENDIAN__ */ ================================================ FILE: headers/bpf_helpers.h ================================================ /* SPDX-License-Identifier: GPL-2.0 */ /* Copied from $(LINUX)/tools/testing/selftests/bpf/bpf_helpers.h */ #ifndef __BPF_HELPERS_H #define __BPF_HELPERS_H /* helper macro to place programs, maps, license in * different sections in elf_bpf file. Section names * are interpreted by elf_bpf loader */ #define SEC(NAME) __attribute__((section(NAME), used)) /* helper functions called from eBPF programs written in C */ static void *(*bpf_map_lookup_elem)(void *map, void *key) = (void *) BPF_FUNC_map_lookup_elem; static int (*bpf_map_update_elem)(void *map, void *key, void *value, unsigned long long flags) = (void *) BPF_FUNC_map_update_elem; static int (*bpf_map_delete_elem)(void *map, void *key) = (void *) BPF_FUNC_map_delete_elem; static int (*bpf_probe_read)(void *dst, int size, void *unsafe_ptr) = (void *) BPF_FUNC_probe_read; static unsigned long long (*bpf_ktime_get_ns)(void) = (void *) BPF_FUNC_ktime_get_ns; static int (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = (void *) BPF_FUNC_trace_printk; static void (*bpf_tail_call)(void *ctx, void *map, int index) = (void *) BPF_FUNC_tail_call; static unsigned long long (*bpf_get_smp_processor_id)(void) = (void *) BPF_FUNC_get_smp_processor_id; static unsigned long long (*bpf_get_current_pid_tgid)(void) = (void *) BPF_FUNC_get_current_pid_tgid; static unsigned long long (*bpf_get_current_uid_gid)(void) = (void *) BPF_FUNC_get_current_uid_gid; static int (*bpf_get_current_comm)(void *buf, int buf_size) = (void *) BPF_FUNC_get_current_comm; static unsigned long long (*bpf_perf_event_read)(void *map, unsigned long long flags) = (void *) BPF_FUNC_perf_event_read; static int (*bpf_clone_redirect)(void *ctx, int ifindex, int flags) = (void *) BPF_FUNC_clone_redirect; static int (*bpf_redirect)(int ifindex, int flags) = (void *) BPF_FUNC_redirect; static int (*bpf_perf_event_output)(void *ctx, void *map, unsigned long long flags, void *data, int size) = (void *) BPF_FUNC_perf_event_output; static int (*bpf_get_stackid)(void *ctx, void *map, int flags) = (void *) BPF_FUNC_get_stackid; static int (*bpf_probe_write_user)(void *dst, void *src, int size) = (void *) BPF_FUNC_probe_write_user; static int (*bpf_current_task_under_cgroup)(void *map, int index) = (void *) BPF_FUNC_current_task_under_cgroup; static int (*bpf_skb_get_tunnel_key)(void *ctx, void *key, int size, int flags) = (void *) BPF_FUNC_skb_get_tunnel_key; static int (*bpf_skb_set_tunnel_key)(void *ctx, void *key, int size, int flags) = (void *) BPF_FUNC_skb_set_tunnel_key; static int (*bpf_skb_get_tunnel_opt)(void *ctx, void *md, int size) = (void *) BPF_FUNC_skb_get_tunnel_opt; static int (*bpf_skb_set_tunnel_opt)(void *ctx, void *md, int size) = (void *) BPF_FUNC_skb_set_tunnel_opt; static unsigned long long (*bpf_get_prandom_u32)(void) = (void *) BPF_FUNC_get_prandom_u32; static int (*bpf_xdp_adjust_head)(void *ctx, int offset) = (void *) BPF_FUNC_xdp_adjust_head; /* llvm builtin functions that eBPF C program may use to * emit BPF_LD_ABS and BPF_LD_IND instructions */ struct sk_buff; unsigned long long load_byte(void *skb, unsigned long long off) asm("llvm.bpf.load.byte"); unsigned long long load_half(void *skb, unsigned long long off) asm("llvm.bpf.load.half"); unsigned long long load_word(void *skb, unsigned long long off) asm("llvm.bpf.load.word"); /* a helper structure used by eBPF C program * to describe map attributes to elf_bpf loader */ struct bpf_map_def { unsigned int type; unsigned int key_size; unsigned int value_size; unsigned int max_entries; unsigned int map_flags; unsigned int inner_map_idx; }; static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) = (void *) BPF_FUNC_skb_load_bytes; static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) = (void *) BPF_FUNC_skb_store_bytes; static int (*bpf_l3_csum_replace)(void *ctx, int off, int from, int to, int flags) = (void *) BPF_FUNC_l3_csum_replace; static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, int to, int flags) = (void *) BPF_FUNC_l4_csum_replace; static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) = (void *) BPF_FUNC_skb_under_cgroup; static int (*bpf_skb_change_head)(void *, int len, int flags) = (void *) BPF_FUNC_skb_change_head; #if defined(__x86_64__) #define PT_REGS_PARM1(x) ((x)->di) #define PT_REGS_PARM2(x) ((x)->si) #define PT_REGS_PARM3(x) ((x)->dx) #define PT_REGS_PARM4(x) ((x)->cx) #define PT_REGS_PARM5(x) ((x)->r8) #define PT_REGS_RET(x) ((x)->sp) #define PT_REGS_FP(x) ((x)->bp) #define PT_REGS_RC(x) ((x)->ax) #define PT_REGS_SP(x) ((x)->sp) #define PT_REGS_IP(x) ((x)->ip) #elif defined(__s390x__) #define PT_REGS_PARM1(x) ((x)->gprs[2]) #define PT_REGS_PARM2(x) ((x)->gprs[3]) #define PT_REGS_PARM3(x) ((x)->gprs[4]) #define PT_REGS_PARM4(x) ((x)->gprs[5]) #define PT_REGS_PARM5(x) ((x)->gprs[6]) #define PT_REGS_RET(x) ((x)->gprs[14]) #define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */ #define PT_REGS_RC(x) ((x)->gprs[2]) #define PT_REGS_SP(x) ((x)->gprs[15]) #define PT_REGS_IP(x) ((x)->psw.addr) #elif defined(__aarch64__) #define PT_REGS_PARM1(x) ((x)->regs[0]) #define PT_REGS_PARM2(x) ((x)->regs[1]) #define PT_REGS_PARM3(x) ((x)->regs[2]) #define PT_REGS_PARM4(x) ((x)->regs[3]) #define PT_REGS_PARM5(x) ((x)->regs[4]) #define PT_REGS_RET(x) ((x)->regs[30]) #define PT_REGS_FP(x) ((x)->regs[29]) /* Works only with CONFIG_FRAME_POINTER */ #define PT_REGS_RC(x) ((x)->regs[0]) #define PT_REGS_SP(x) ((x)->sp) #define PT_REGS_IP(x) ((x)->pc) #elif defined(__powerpc__) #define PT_REGS_PARM1(x) ((x)->gpr[3]) #define PT_REGS_PARM2(x) ((x)->gpr[4]) #define PT_REGS_PARM3(x) ((x)->gpr[5]) #define PT_REGS_PARM4(x) ((x)->gpr[6]) #define PT_REGS_PARM5(x) ((x)->gpr[7]) #define PT_REGS_RC(x) ((x)->gpr[3]) #define PT_REGS_SP(x) ((x)->sp) #define PT_REGS_IP(x) ((x)->nip) #elif defined(__sparc__) #define PT_REGS_PARM1(x) ((x)->u_regs[UREG_I0]) #define PT_REGS_PARM2(x) ((x)->u_regs[UREG_I1]) #define PT_REGS_PARM3(x) ((x)->u_regs[UREG_I2]) #define PT_REGS_PARM4(x) ((x)->u_regs[UREG_I3]) #define PT_REGS_PARM5(x) ((x)->u_regs[UREG_I4]) #define PT_REGS_RET(x) ((x)->u_regs[UREG_I7]) #define PT_REGS_RC(x) ((x)->u_regs[UREG_I0]) #define PT_REGS_SP(x) ((x)->u_regs[UREG_FP]) #if defined(__arch64__) #define PT_REGS_IP(x) ((x)->tpc) #else #define PT_REGS_IP(x) ((x)->pc) #endif #endif #ifdef __powerpc__ #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; }) #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP #elif defined(__sparc__) #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = PT_REGS_RET(ctx); }) #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP #else #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ \ bpf_probe_read(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx)); }) #define BPF_KRETPROBE_READ_RET_IP(ip, ctx) ({ \ bpf_probe_read(&(ip), sizeof(ip), \ (void *)(PT_REGS_FP(ctx) + sizeof(ip))); }) #endif #endif ================================================ FILE: headers/jhash.h ================================================ #ifndef _LINUX_JHASH_H #define _LINUX_JHASH_H /* Copied from $(LINUX)/include/linux/jhash.h (kernel 4.18) */ /* jhash.h: Jenkins hash support. * * Copyright (C) 2006. Bob Jenkins (bob_jenkins@burtleburtle.net) * * http://burtleburtle.net/bob/hash/ * * These are the credits from Bob's sources: * * lookup3.c, by Bob Jenkins, May 2006, Public Domain. * * These are functions for producing 32-bit hashes for hash table lookup. * hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() * are externally useful functions. Routines to test the hash are included * if SELF_TEST is defined. You can use this free for any purpose. It's in * the public domain. It has no warranty. * * Copyright (C) 2009-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) */ static inline __u32 rol32(__u32 word, unsigned int shift) { return (word << shift) | (word >> ((-shift) & 31)); } /* copy paste of jhash from kernel sources (include/linux/jhash.h) to make sure * LLVM can compile it into valid sequence of BPF instructions */ #define __jhash_mix(a, b, c) \ { \ a -= c; a ^= rol32(c, 4); c += b; \ b -= a; b ^= rol32(a, 6); a += c; \ c -= b; c ^= rol32(b, 8); b += a; \ a -= c; a ^= rol32(c, 16); c += b; \ b -= a; b ^= rol32(a, 19); a += c; \ c -= b; c ^= rol32(b, 4); b += a; \ } #define __jhash_final(a, b, c) \ { \ c ^= b; c -= rol32(b, 14); \ a ^= c; a -= rol32(c, 11); \ b ^= a; b -= rol32(a, 25); \ c ^= b; c -= rol32(b, 16); \ a ^= c; a -= rol32(c, 4); \ b ^= a; b -= rol32(a, 14); \ c ^= b; c -= rol32(b, 24); \ } #define JHASH_INITVAL 0xdeadbeef typedef unsigned int u32; /* jhash - hash an arbitrary key * @k: sequence of bytes as key * @length: the length of the key * @initval: the previous hash, or an arbitray value * * The generic version, hashes an arbitrary sequence of bytes. * No alignment or length assumptions are made about the input key. * * Returns the hash value of the key. The result depends on endianness. */ static inline u32 jhash(const void *key, u32 length, u32 initval) { u32 a, b, c; const unsigned char *k = key; /* Set up the internal state */ a = b = c = JHASH_INITVAL + length + initval; /* All but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += *(u32 *)(k); b += *(u32 *)(k + 4); c += *(u32 *)(k + 8); __jhash_mix(a, b, c); length -= 12; k += 12; } /* Last block: affect all 32 bits of (c) */ switch (length) { case 12: c += (u32)k[11]<<24; /* fall through */ case 11: c += (u32)k[10]<<16; /* fall through */ case 10: c += (u32)k[9]<<8; /* fall through */ case 9: c += k[8]; /* fall through */ case 8: b += (u32)k[7]<<24; /* fall through */ case 7: b += (u32)k[6]<<16; /* fall through */ case 6: b += (u32)k[5]<<8; /* fall through */ case 5: b += k[4]; /* fall through */ case 4: a += (u32)k[3]<<24; /* fall through */ case 3: a += (u32)k[2]<<16; /* fall through */ case 2: a += (u32)k[1]<<8; /* fall through */ case 1: a += k[0]; __jhash_final(a, b, c); case 0: /* Nothing left to add */ break; } return c; } /* jhash2 - hash an array of u32's * @k: the key which must be an array of u32's * @length: the number of u32's in the key * @initval: the previous hash, or an arbitray value * * Returns the hash value of the key. */ static inline u32 jhash2(const u32 *k, u32 length, u32 initval) { u32 a, b, c; /* Set up the internal state */ a = b = c = JHASH_INITVAL + (length<<2) + initval; /* Handle most of the key */ while (length > 3) { a += k[0]; b += k[1]; c += k[2]; __jhash_mix(a, b, c); length -= 3; k += 3; } /* Handle the last 3 u32's */ switch (length) { case 3: c += k[2]; /* fall through */ case 2: b += k[1]; /* fall through */ case 1: a += k[0]; __jhash_final(a, b, c); case 0: /* Nothing left to add */ break; } return c; } /* __jhash_nwords - hash exactly 3, 2 or 1 word(s) */ static inline u32 __jhash_nwords(u32 a, u32 b, u32 c, u32 initval) { a += initval; b += initval; c += initval; __jhash_final(a, b, c); return c; } static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) { return __jhash_nwords(a, b, c, initval + JHASH_INITVAL + (3 << 2)); } static inline u32 jhash_2words(u32 a, u32 b, u32 initval) { return __jhash_nwords(a, b, 0, initval + JHASH_INITVAL + (2 << 2)); } static inline u32 jhash_1word(u32 a, u32 initval) { return __jhash_nwords(a, 0, 0, initval + JHASH_INITVAL + (1 << 2)); } #endif /* _LINUX_JHASH_H */ ================================================ FILE: headers/perf-sys.h ================================================ /* SPDX-License-Identifier: GPL-2.0 */ /* Copied from $(LINUX)/tools/perf/perf-sys.h (kernel 4.18) */ #ifndef _PERF_SYS_H #define _PERF_SYS_H #include #include #include #include #include /* * remove the following headers to allow for userspace program compilation * #include * #include */ #ifdef __powerpc__ #define CPUINFO_PROC {"cpu"} #endif #ifdef __s390__ #define CPUINFO_PROC {"vendor_id"} #endif #ifdef __sh__ #define CPUINFO_PROC {"cpu type"} #endif #ifdef __hppa__ #define CPUINFO_PROC {"cpu"} #endif #ifdef __sparc__ #define CPUINFO_PROC {"cpu"} #endif #ifdef __alpha__ #define CPUINFO_PROC {"cpu model"} #endif #ifdef __arm__ #define CPUINFO_PROC {"model name", "Processor"} #endif #ifdef __mips__ #define CPUINFO_PROC {"cpu model"} #endif #ifdef __arc__ #define CPUINFO_PROC {"Processor"} #endif #ifdef __xtensa__ #define CPUINFO_PROC {"core ID"} #endif #ifndef CPUINFO_PROC #define CPUINFO_PROC { "model name", } #endif static inline int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) { int fd; fd = syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags); #ifdef HAVE_ATTR_TEST if (unlikely(test_attr__enabled)) test_attr__open(attr, pid, cpu, fd, group_fd, flags); #endif return fd; } #endif /* _PERF_SYS_H */ ================================================ FILE: l4lb/Makefile ================================================ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) LLVM_VERSION ?= LLVM := $(shell clang$(LLVM_VERSION) --version) CLANG_FLAGS ?= -W -Wall \ -Wno-compare-distinct-pointer-types SRCS=$(wildcard *.c) OBJS=$(patsubst %.c,%.o,$(SRCS)) Q ?= @ INCLUDE_DIRS ?= -I../headers/ %.o: %.c @echo "\tLLVM CC $@" $(Q) clang$(LLVM_VERSION) $(INCLUDE_DIRS) -O2 -emit-llvm -c $< $(CLANG_FLAGS) -o $(patsubst %.o,%.llvm,$@) $(Q) llc$(LLVM_VERSION) -march=bpf -filetype=obj -o $@ $(patsubst %.o,%.llvm,$@) $(Q) rm $(patsubst %.o,%.llvm,$@) ifeq ($(LLVM),) all: $(warning Install LLVM to compile BPF sources) else all: $(OBJS) endif clean: rm -f *.llvm rm -f *.o .PHONY: all clean ================================================ FILE: l4lb/README.rst ================================================ Layer 4 Load Balancer Demo ========================== This program will demonstrate how a XDP load balancer can be used to distribute incoming traffic by hashing the layer 3 and layer 4 headers. The XDP program, will process incoming network packets and compute a hash based on the sender IP address, along with the TCP or UDP network ports. This hash value is subsequently used as the key for a eBPF map. The eBPF map is filled with the available servers to which the XDP program can redirect the packet to. The XDP program will extend and insert an outer IP header with this map data. After processing, the program will subsequently send the packet back out of the network interface to the destination server. The map fill and stats scripts are written in python and utilize bpftool to showcase how a program can be deployed using iproute2 and bpftool utilities. Minimum Requirements for Demo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Linux kernel 4.17 - iproute2 v4.16.0 (a.k.a ss180402) - clang / LLVM 4.0 - bpftool - Python 3 - Agilio® eBPF firmware (only for HW offload) - July 2018 (available from `Netronome's support website`_) .. _Netronome's support website: https://help.netronome.com/ Loading the Demo ~~~~~~~~~~~~~~~~ To compile the XDP program :: $ make The program can be loaded using iproute2 using the following commands XDP driver mode :: # ip link set dev { DEV } xdpdrv obj l4lb_xdp.o sec xdp XDP offload :: # ip link set dev { DEV } xdpoffload obj l4lb_xdp.o sec xdp The load balancer map can be filled with the l4lb_map.py script. Note that sample files with lists of destinations are provided under `destination_samples/`_ :: # ./l4lb_map.py -i { DEV } -f { file containing destinations } Traffic statistics may be seen using the l4lb_stats.py script :: # ./l4lb_stats.py -i { DEV } .. _destination_samples/: destination_samples/ Traffic Generation ~~~~~~~~~~~~~~~~~~ Traffic can be generated using a variety of tools. A command is shown below which utilises the hping3 utility to generate the traffic. The command should be run on a different host connected to the server running the eBPF l4lb program. In this example the traffic generator uses interface ens0 and is transmitting traffic to IP address 10.0.0.4 :: hping3 10.0.0.4 --rand-source -i ens0 --flood Example ~~~~~~~ To demo the program on offload mode on interface ens4np0, with 32 destinations :: # ip link set dev ens4np0 xdpoffload obj l4lb_xdp.o sec xdp Note: 12 bytes struct bpf_elf_map fixup performed due to size mismatch! # ./l4lb_map.py -i ens4np0 -f destination_samples/32_destinations.csv Loading file with 32 destinations # ./l4lb_stats.py -i ens4np0 == Load balancer outbound statistics [Offload] == 1 10.0.0.57 1,029,744 pkts/s 1,186,266,224 bits/s 2 10.0.125.19 1,031,841 pkts/s 1,188,681,760 bits/s 3 10.0.129.60 1,033,649 pkts/s 1,190,763,984 bits/s 4 10.0.14.88 1,031,274 pkts/s 1,188,028,704 bits/s 5 10.0.143.99 1,032,110 pkts/s 1,188,991,816 bits/s 6 10.0.159.176 1,031,466 pkts/s 1,188,249,616 bits/s 7 10.0.16.109 1,031,213 pkts/s 1,187,957,968 bits/s 8 10.0.161.129 1,031,025 pkts/s 1,187,740,928 bits/s 9 10.0.175.130 1,032,664 pkts/s 1,189,629,368 bits/s 10 10.0.178.75 1,032,625 pkts/s 1,189,584,800 bits/s 11 10.0.181.34 1,031,332 pkts/s 1,188,094,584 bits/s 12 10.0.185.52 1,033,361 pkts/s 1,190,432,608 bits/s 13 10.0.192.32 1,032,855 pkts/s 1,189,849,312 bits/s 14 10.0.199.54 1,032,126 pkts/s 1,189,009,256 bits/s 15 10.0.214.65 1,032,921 pkts/s 1,189,925,864 bits/s 16 10.0.23.41 1,033,084 pkts/s 1,190,112,864 bits/s 17 10.0.234.48 1,031,888 pkts/s 1,188,735,048 bits/s 18 10.0.24.77 1,031,594 pkts/s 1,188,396,896 bits/s 19 10.0.244.158 1,031,127 pkts/s 1,187,859,136 bits/s 20 10.0.31.144 1,032,068 pkts/s 1,188,942,400 bits/s 21 10.0.32.134 1,031,787 pkts/s 1,188,619,744 bits/s 22 10.0.32.35 1,031,222 pkts/s 1,187,968,624 bits/s 23 10.0.50.179 1,031,597 pkts/s 1,188,400,768 bits/s 24 10.0.56.49 1,032,840 pkts/s 1,189,831,872 bits/s 25 10.0.63.10 1,031,564 pkts/s 1,188,362,008 bits/s 26 10.0.75.126 1,032,512 pkts/s 1,189,454,960 bits/s 27 10.0.75.197 1,030,993 pkts/s 1,187,705,080 bits/s 28 10.0.75.209 1,033,445 pkts/s 1,190,529,504 bits/s 29 10.0.89.127 1,033,593 pkts/s 1,190,700,032 bits/s 30 10.0.90.135 1,031,819 pkts/s 1,188,655,600 bits/s 31 10.0.90.214 1,032,841 pkts/s 1,189,832,848 bits/s 32 10.0.92.11 1,032,581 pkts/s 1,189,534,416 bits/s [Totals] 33,026,761 pkts/s 38,046,848,592 bits/s Note: This example was produced with a high performance traffic generator, lower rates are expected with hping3. Removing the Demo ~~~~~~~~~~~~~~~~ XDP driver mode :: # ip link set dev { DEV } xdpdrv off XDP offload :: # ip link set dev { DEV } xdpoffload off ================================================ FILE: l4lb/bpftool_utils.py ================================================ #!/usr/bin/env python3 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) # Copyright (c) 2018 Netronome Systems, Inc. import json import subprocess import struct import sys def check_output_json(cmd): return json.loads(subprocess.check_output(cmd, shell=True).decode("utf-8")) def get_xdp_prog(interface): cmd_iplink = 'ip -j link show %s' % interface iplink = check_output_json(cmd_iplink) return iplink[0]['xdp']['prog']['id'] def get_map_ids(interface): prog_id = get_xdp_prog(interface) cmd_progshow = 'bpftool prog show id %d -p' % prog_id prog_info = check_output_json(cmd_progshow) maps = check_output_json('bpftool map -p') map_ids = [] for m in maps: if m['id'] in prog_info['map_ids']: map_ids.append(m['id']) return map_ids def get_map_entries(map_id): cmd_mapshow = 'bpftool map show id %s -p' % map_id map_info = check_output_json(cmd_mapshow) return map_info['max_entries'] def get_map_dev(map_id): cmd_mapshow = 'bpftool map show id %s -p' % map_id map_info = check_output_json(cmd_mapshow) if "dev" in map_info: return "Offload" else: return "Driver" def dump_map(map_id): cmd_map = 'bpftool map dump id %s -p' % map_id return check_output_json(cmd_map) def hex_list_to_int(hex_list): hex_str = ''.join([byte.replace('0x', '') for byte in hex_list]) return (int.from_bytes(bytes.fromhex(hex_str), byteorder='little')) ================================================ FILE: l4lb/destination_samples/128_destinations.csv ================================================ 10.0.88.205, 00:15:4d:58:cd:73 10.0.18.70, 00:15:4d:12:46:fd 10.0.195.112, 00:15:4d:c3:70:25 10.0.78.90, 00:15:4d:4e:5a:71 10.0.163.40, 00:15:4d:a3:28:8f 10.0.73.36, 00:15:4d:49:24:22 10.0.84.187, 00:15:4d:54:bb:24 10.0.91.5, 00:15:4d:5b:05:c4 10.0.94.163, 00:15:4d:5e:a3:8f 10.0.107.139, 00:15:4d:6b:8b:b3 10.0.62.8, 00:15:4d:3e:08:5b 10.0.167.5, 00:15:4d:a7:05:6a 10.0.95.82, 00:15:4d:5f:52:15 10.0.103.166, 00:15:4d:67:a6:1b 10.0.130.78, 00:15:4d:82:4e:d3 10.0.160.22, 00:15:4d:a0:16:15 10.0.26.39, 00:15:4d:1a:27:ba 10.0.28.178, 00:15:4d:1c:b2:a7 10.0.61.219, 00:15:4d:3d:db:e1 10.0.136.80, 00:15:4d:88:50:7b 10.0.143.131, 00:15:4d:8f:83:43 10.0.59.23, 00:15:4d:3b:17:ce 10.0.33.220, 00:15:4d:21:dc:45 10.0.115.238, 00:15:4d:73:ee:78 10.0.94.5, 00:15:4d:5e:05:7d 10.0.169.254, 00:15:4d:a9:fe:fa 10.0.67.201, 00:15:4d:43:c9:a2 10.0.179.40, 00:15:4d:b3:28:64 10.0.178.157, 00:15:4d:b2:9d:bd 10.0.234.135, 00:15:4d:ea:87:f6 10.0.215.81, 00:15:4d:d7:51:a3 10.0.204.92, 00:15:4d:cc:5c:6a 10.0.2.126, 00:15:4d:02:7e:0c 10.0.233.124, 00:15:4d:e9:7c:fe 10.0.249.99, 00:15:4d:f9:63:14 10.0.74.62, 00:15:4d:4a:3e:e6 10.0.240.222, 00:15:4d:f0:de:c9 10.0.215.184, 00:15:4d:d7:b8:59 10.0.126.211, 00:15:4d:7e:d3:f9 10.0.75.224, 00:15:4d:4b:e0:83 10.0.63.180, 00:15:4d:3f:b4:33 10.0.146.203, 00:15:4d:92:cb:70 10.0.49.18, 00:15:4d:31:12:b6 10.0.103.246, 00:15:4d:67:f6:73 10.0.213.88, 00:15:4d:d5:58:5f 10.0.237.180, 00:15:4d:ed:b4:c0 10.0.5.222, 00:15:4d:05:de:6e 10.0.200.90, 00:15:4d:c8:5a:c3 10.0.98.151, 00:15:4d:62:97:bd 10.0.24.54, 00:15:4d:18:36:45 10.0.26.187, 00:15:4d:1a:bb:a2 10.0.125.254, 00:15:4d:7d:fe:92 10.0.197.161, 00:15:4d:c5:a1:b9 10.0.140.219, 00:15:4d:8c:db:aa 10.0.150.216, 00:15:4d:96:d8:f2 10.0.244.207, 00:15:4d:f4:cf:c6 10.0.111.29, 00:15:4d:6f:1d:0c 10.0.118.29, 00:15:4d:76:1d:e1 10.0.166.72, 00:15:4d:a6:48:9e 10.0.186.225, 00:15:4d:ba:e1:46 10.0.165.164, 00:15:4d:a5:a4:59 10.0.155.148, 00:15:4d:9b:94:ab 10.0.27.97, 00:15:4d:1b:61:8e 10.0.94.250, 00:15:4d:5e:fa:53 10.0.251.119, 00:15:4d:fb:77:83 10.0.53.117, 00:15:4d:35:75:1b 10.0.50.29, 00:15:4d:32:1d:df 10.0.221.217, 00:15:4d:dd:d9:48 10.0.43.49, 00:15:4d:2b:31:ea 10.0.46.83, 00:15:4d:2e:53:44 10.0.84.51, 00:15:4d:54:33:c9 10.0.79.91, 00:15:4d:4f:5b:03 10.0.50.159, 00:15:4d:32:9f:76 10.0.108.221, 00:15:4d:6c:dd:54 10.0.113.222, 00:15:4d:71:de:39 10.0.9.3, 00:15:4d:09:03:6b 10.0.39.182, 00:15:4d:27:b6:f1 10.0.240.28, 00:15:4d:f0:1c:56 10.0.234.128, 00:15:4d:ea:80:e7 10.0.188.84, 00:15:4d:bc:54:34 10.0.107.88, 00:15:4d:6b:58:28 10.0.124.246, 00:15:4d:7c:f6:20 10.0.12.20, 00:15:4d:0c:14:4e 10.0.224.183, 00:15:4d:e0:b7:e4 10.0.34.66, 00:15:4d:22:42:97 10.0.67.128, 00:15:4d:43:80:1e 10.0.63.198, 00:15:4d:3f:c6:84 10.0.11.128, 00:15:4d:0b:80:0b 10.0.241.166, 00:15:4d:f1:a6:f5 10.0.250.72, 00:15:4d:fa:48:73 10.0.22.29, 00:15:4d:16:1d:bc 10.0.181.193, 00:15:4d:b5:c1:87 10.0.92.78, 00:15:4d:5c:4e:ee 10.0.95.136, 00:15:4d:5f:88:a9 10.0.90.99, 00:15:4d:5a:63:f8 10.0.148.153, 00:15:4d:94:99:c9 10.0.93.121, 00:15:4d:5d:79:0f 10.0.163.157, 00:15:4d:a3:9d:50 10.0.95.55, 00:15:4d:5f:37:1f 10.0.32.37, 00:15:4d:20:25:1f 10.0.10.129, 00:15:4d:0a:81:6b 10.0.125.0, 00:15:4d:7d:00:64 10.0.90.54, 00:15:4d:5a:36:2b 10.0.90.92, 00:15:4d:5a:5c:65 10.0.186.52, 00:15:4d:ba:34:12 10.0.226.220, 00:15:4d:e2:dc:37 10.0.11.231, 00:15:4d:0b:e7:73 10.0.158.164, 00:15:4d:9e:a4:23 10.0.56.200, 00:15:4d:38:c8:90 10.0.201.210, 00:15:4d:c9:d2:e0 10.0.107.116, 00:15:4d:6b:74:3c 10.0.117.250, 00:15:4d:75:fa:30 10.0.57.172, 00:15:4d:39:ac:b7 10.0.222.139, 00:15:4d:de:8b:19 10.0.13.222, 00:15:4d:0d:de:06 10.0.179.42, 00:15:4d:b3:2a:66 10.0.223.214, 00:15:4d:df:d6:9c 10.0.238.67, 00:15:4d:ee:43:df 10.0.234.248, 00:15:4d:ea:f8:48 10.0.106.113, 00:15:4d:6a:71:a6 10.0.2.228, 00:15:4d:02:e4:81 10.0.48.179, 00:15:4d:30:b3:bb 10.0.179.135, 00:15:4d:b3:87:64 10.0.249.63, 00:15:4d:f9:3f:8b 10.0.27.194, 00:15:4d:1b:c2:14 10.0.68.55, 00:15:4d:44:37:d0 10.0.20.7, 00:15:4d:14:07:8c 10.0.134.42, 00:15:4d:86:2a:97 ================================================ FILE: l4lb/destination_samples/256_destinations.csv ================================================ 10.0.128.192, 00:15:4d:80:c0:f1 10.0.96.178, 00:15:4d:60:b2:77 10.0.239.127, 00:15:4d:ef:7f:12 10.0.211.136, 00:15:4d:d3:88:b0 10.0.55.164, 00:15:4d:37:a4:34 10.0.189.181, 00:15:4d:bd:b5:ed 10.0.87.208, 00:15:4d:57:d0:d4 10.0.32.185, 00:15:4d:20:b9:ed 10.0.166.207, 00:15:4d:a6:cf:c8 10.0.11.243, 00:15:4d:0b:f3:7e 10.0.88.196, 00:15:4d:58:c4:cf 10.0.154.213, 00:15:4d:9a:d5:10 10.0.7.163, 00:15:4d:07:a3:86 10.0.160.228, 00:15:4d:a0:e4:f4 10.0.76.250, 00:15:4d:4c:fa:38 10.0.46.174, 00:15:4d:2e:ae:cf 10.0.40.103, 00:15:4d:28:67:72 10.0.198.22, 00:15:4d:c6:16:72 10.0.25.200, 00:15:4d:19:c8:7f 10.0.219.121, 00:15:4d:db:79:67 10.0.202.8, 00:15:4d:ca:08:12 10.0.177.221, 00:15:4d:b1:dd:4f 10.0.146.225, 00:15:4d:92:e1:87 10.0.33.182, 00:15:4d:21:b6:67 10.0.5.40, 00:15:4d:05:28:96 10.0.167.116, 00:15:4d:a7:74:86 10.0.72.188, 00:15:4d:48:bc:c9 10.0.20.135, 00:15:4d:14:87:73 10.0.82.123, 00:15:4d:52:7b:7e 10.0.244.235, 00:15:4d:f4:eb:a1 10.0.6.154, 00:15:4d:06:9a:6b 10.0.69.98, 00:15:4d:45:62:19 10.0.54.169, 00:15:4d:36:a9:0d 10.0.0.14, 00:15:4d:00:0e:71 10.0.45.244, 00:15:4d:2d:f4:5c 10.0.109.138, 00:15:4d:6d:8a:a0 10.0.38.41, 00:15:4d:26:29:bb 10.0.158.7, 00:15:4d:9e:07:f7 10.0.43.23, 00:15:4d:2b:17:60 10.0.124.78, 00:15:4d:7c:4e:30 10.0.139.197, 00:15:4d:8b:c5:1d 10.0.144.16, 00:15:4d:90:10:89 10.0.187.199, 00:15:4d:bb:c7:65 10.0.72.66, 00:15:4d:48:42:bd 10.0.68.224, 00:15:4d:44:e0:04 10.0.138.44, 00:15:4d:8a:2c:e4 10.0.214.119, 00:15:4d:d6:77:80 10.0.126.135, 00:15:4d:7e:87:5c 10.0.232.141, 00:15:4d:e8:8d:13 10.0.192.72, 00:15:4d:c0:48:e7 10.0.223.209, 00:15:4d:df:d1:6b 10.0.10.140, 00:15:4d:0a:8c:04 10.0.152.163, 00:15:4d:98:a3:df 10.0.230.94, 00:15:4d:e6:5e:95 10.0.82.48, 00:15:4d:52:30:ec 10.0.217.198, 00:15:4d:d9:c6:35 10.0.11.61, 00:15:4d:0b:3d:f8 10.0.206.111, 00:15:4d:ce:6f:82 10.0.192.56, 00:15:4d:c0:38:91 10.0.33.205, 00:15:4d:21:cd:7d 10.0.232.230, 00:15:4d:e8:e6:07 10.0.71.148, 00:15:4d:47:94:60 10.0.172.38, 00:15:4d:ac:26:83 10.0.81.78, 00:15:4d:51:4e:d1 10.0.52.216, 00:15:4d:34:d8:20 10.0.102.62, 00:15:4d:66:3e:8e 10.0.102.83, 00:15:4d:66:53:aa 10.0.131.31, 00:15:4d:83:1f:26 10.0.87.161, 00:15:4d:57:a1:2d 10.0.63.138, 00:15:4d:3f:8a:99 10.0.151.7, 00:15:4d:97:07:16 10.0.194.195, 00:15:4d:c2:c3:9a 10.0.53.62, 00:15:4d:35:3e:79 10.0.253.245, 00:15:4d:fd:f5:5f 10.0.47.229, 00:15:4d:2f:e5:cb 10.0.209.139, 00:15:4d:d1:8b:44 10.0.24.212, 00:15:4d:18:d4:78 10.0.130.236, 00:15:4d:82:ec:da 10.0.168.214, 00:15:4d:a8:d6:15 10.0.92.44, 00:15:4d:5c:2c:dc 10.0.237.23, 00:15:4d:ed:17:80 10.0.232.87, 00:15:4d:e8:57:ad 10.0.14.93, 00:15:4d:0e:5d:34 10.0.32.144, 00:15:4d:20:90:34 10.0.137.63, 00:15:4d:89:3f:61 10.0.198.84, 00:15:4d:c6:54:4f 10.0.233.119, 00:15:4d:e9:77:a5 10.0.102.71, 00:15:4d:66:47:58 10.0.52.238, 00:15:4d:34:ee:2d 10.0.22.167, 00:15:4d:16:a7:8c 10.0.66.62, 00:15:4d:42:3e:57 10.0.228.217, 00:15:4d:e4:d9:4b 10.0.187.180, 00:15:4d:bb:b4:49 10.0.127.118, 00:15:4d:7f:9e:0a 10.0.249.242, 00:15:4d:f9:f2:ac 10.0.91.117, 00:15:4d:5b:75:67 10.0.113.105, 00:15:4d:71:69:b0 10.0.122.65, 00:15:4d:7a:41:b9 10.0.128.99, 00:15:4d:80:63:15 10.0.120.15, 00:15:4d:78:0f:6b 10.0.193.21, 00:15:4d:c1:15:7d 10.0.238.226, 00:15:4d:ee:e2:b6 10.0.15.155, 00:15:4d:0f:9b:92 10.0.70.112, 00:15:4d:46:70:85 10.0.183.249, 00:15:4d:b7:f9:3f 10.0.19.39, 00:15:4d:13:27:e0 10.0.192.234, 00:15:4d:c0:ea:40 10.0.2.130, 00:15:4d:02:82:17 10.0.213.214, 00:15:4d:d5:d6:be 10.0.221.60, 00:15:4d:dd:3c:bd 10.0.124.225, 00:15:4d:7c:e1:75 10.0.17.29, 00:15:4d:11:1d:01 10.0.27.105, 00:15:4d:1b:69:6a 10.0.57.226, 00:15:4d:39:e2:7e 10.0.217.250, 00:15:4d:d9:fa:5c 10.0.111.82, 00:15:4d:6f:52:cd 10.0.126.126, 00:15:4d:7e:7e:34 10.0.20.130, 00:15:4d:14:82:17 10.0.87.156, 00:15:4d:57:9c:a1 10.0.207.63, 00:15:4d:cf:3f:c0 10.0.121.65, 00:15:4d:79:41:c4 10.0.149.155, 00:15:4d:95:9b:c4 10.0.19.174, 00:15:4d:13:ae:27 10.0.132.129, 00:15:4d:84:81:f6 10.0.92.248, 00:15:4d:5c:f8:8a 10.0.28.5, 00:15:4d:1c:05:8d 10.0.140.124, 00:15:4d:8c:7c:89 10.0.6.6, 00:15:4d:06:06:3c 10.0.70.136, 00:15:4d:46:88:67 10.0.203.195, 00:15:4d:cb:c3:95 10.0.230.202, 00:15:4d:e6:ca:c9 10.0.90.47, 00:15:4d:5a:2f:96 10.0.89.179, 00:15:4d:59:b3:b8 10.0.161.13, 00:15:4d:a1:0d:a7 10.0.0.208, 00:15:4d:00:d0:89 10.0.155.69, 00:15:4d:9b:45:b5 10.0.165.214, 00:15:4d:a5:d6:c1 10.0.35.186, 00:15:4d:23:ba:49 10.0.97.127, 00:15:4d:61:7f:76 10.0.136.252, 00:15:4d:88:fc:75 10.0.96.125, 00:15:4d:60:7d:0c 10.0.121.36, 00:15:4d:79:24:6f 10.0.37.187, 00:15:4d:25:bb:b5 10.0.4.6, 00:15:4d:04:06:b3 10.0.245.164, 00:15:4d:f5:a4:64 10.0.239.210, 00:15:4d:ef:d2:2e 10.0.55.27, 00:15:4d:37:1b:28 10.0.86.174, 00:15:4d:56:ae:79 10.0.134.50, 00:15:4d:86:32:e0 10.0.101.204, 00:15:4d:65:cc:83 10.0.237.57, 00:15:4d:ed:39:4f 10.0.57.209, 00:15:4d:39:d1:ce 10.0.146.250, 00:15:4d:92:fa:a3 10.0.119.232, 00:15:4d:77:e8:9d 10.0.85.15, 00:15:4d:55:0f:19 10.0.180.61, 00:15:4d:b4:3d:7a 10.0.146.83, 00:15:4d:92:53:ca 10.0.166.74, 00:15:4d:a6:4a:91 10.0.216.47, 00:15:4d:d8:2f:aa 10.0.168.1, 00:15:4d:a8:01:cf 10.0.230.23, 00:15:4d:e6:17:31 10.0.160.173, 00:15:4d:a0:ad:cf 10.0.199.92, 00:15:4d:c7:5c:0d 10.0.172.117, 00:15:4d:ac:75:7b 10.0.222.145, 00:15:4d:de:91:d4 10.0.202.187, 00:15:4d:ca:bb:8d 10.0.58.144, 00:15:4d:3a:90:55 10.0.127.158, 00:15:4d:7f:9e:a2 10.0.103.252, 00:15:4d:67:fc:c9 10.0.236.159, 00:15:4d:ec:9f:9c 10.0.21.75, 00:15:4d:15:4b:4a 10.0.84.174, 00:15:4d:54:ae:89 10.0.237.211, 00:15:4d:ed:d3:97 10.0.42.215, 00:15:4d:2a:d7:a2 10.0.161.77, 00:15:4d:a1:4d:15 10.0.200.22, 00:15:4d:c8:16:c9 10.0.225.119, 00:15:4d:e1:77:cc 10.0.191.81, 00:15:4d:bf:51:be 10.0.216.179, 00:15:4d:d8:b3:29 10.0.93.76, 00:15:4d:5d:4c:6f 10.0.169.90, 00:15:4d:a9:5a:85 10.0.64.189, 00:15:4d:40:bd:3d 10.0.91.155, 00:15:4d:5b:9b:67 10.0.78.130, 00:15:4d:4e:82:5d 10.0.33.95, 00:15:4d:21:5f:fd 10.0.126.140, 00:15:4d:7e:8c:3b 10.0.21.67, 00:15:4d:15:43:7b 10.0.221.142, 00:15:4d:dd:8e:2c 10.0.169.5, 00:15:4d:a9:05:67 10.0.167.45, 00:15:4d:a7:2d:78 10.0.160.190, 00:15:4d:a0:be:7a 10.0.234.5, 00:15:4d:ea:05:4e 10.0.84.135, 00:15:4d:54:87:50 10.0.184.95, 00:15:4d:b8:5f:bb 10.0.165.206, 00:15:4d:a5:ce:43 10.0.199.194, 00:15:4d:c7:c2:25 10.0.27.212, 00:15:4d:1b:d4:4b 10.0.200.251, 00:15:4d:c8:fb:a3 10.0.205.148, 00:15:4d:cd:94:b6 10.0.1.126, 00:15:4d:01:7e:4b 10.0.3.62, 00:15:4d:03:3e:37 10.0.218.217, 00:15:4d:da:d9:7b 10.0.198.133, 00:15:4d:c6:85:49 10.0.16.236, 00:15:4d:10:ec:30 10.0.234.222, 00:15:4d:ea:de:b2 10.0.253.132, 00:15:4d:fd:84:f5 10.0.132.30, 00:15:4d:84:1e:9f 10.0.143.171, 00:15:4d:8f:ab:03 10.0.71.83, 00:15:4d:47:53:c6 10.0.58.71, 00:15:4d:3a:47:46 10.0.233.90, 00:15:4d:e9:5a:5d 10.0.189.106, 00:15:4d:bd:6a:0c 10.0.121.16, 00:15:4d:79:10:78 10.0.128.90, 00:15:4d:80:5a:c9 10.0.58.48, 00:15:4d:3a:30:bc 10.0.57.73, 00:15:4d:39:49:c5 10.0.108.135, 00:15:4d:6c:87:c0 10.0.196.63, 00:15:4d:c4:3f:82 10.0.1.107, 00:15:4d:01:6b:50 10.0.57.28, 00:15:4d:39:1c:b4 10.0.188.212, 00:15:4d:bc:d4:d1 10.0.165.35, 00:15:4d:a5:23:77 10.0.25.98, 00:15:4d:19:62:c1 10.0.189.132, 00:15:4d:bd:84:84 10.0.104.132, 00:15:4d:68:84:bd 10.0.86.48, 00:15:4d:56:30:10 10.0.21.186, 00:15:4d:15:ba:d5 10.0.169.205, 00:15:4d:a9:cd:5c 10.0.163.38, 00:15:4d:a3:26:65 10.0.46.226, 00:15:4d:2e:e2:00 10.0.77.208, 00:15:4d:4d:d0:96 10.0.103.157, 00:15:4d:67:9d:de 10.0.168.42, 00:15:4d:a8:2a:e9 10.0.28.203, 00:15:4d:1c:cb:17 10.0.169.159, 00:15:4d:a9:9f:f2 10.0.83.227, 00:15:4d:53:e3:4a 10.0.102.227, 00:15:4d:66:e3:37 10.0.177.228, 00:15:4d:b1:e4:d5 10.0.150.123, 00:15:4d:96:7b:ec 10.0.178.155, 00:15:4d:b2:9b:84 10.0.136.160, 00:15:4d:88:a0:fe 10.0.124.147, 00:15:4d:7c:93:b8 10.0.252.201, 00:15:4d:fc:c9:be 10.0.126.29, 00:15:4d:7e:1d:0c 10.0.146.116, 00:15:4d:92:74:22 10.0.164.177, 00:15:4d:a4:b1:ef 10.0.114.234, 00:15:4d:72:ea:83 10.0.226.20, 00:15:4d:e2:14:c4 10.0.28.135, 00:15:4d:1c:87:54 10.0.182.104, 00:15:4d:b6:68:7b 10.0.101.8, 00:15:4d:65:08:af 10.0.86.119, 00:15:4d:56:77:4a 10.0.159.173, 00:15:4d:9f:ad:ee 10.0.153.183, 00:15:4d:99:b7:ac 10.0.91.173, 00:15:4d:5b:ad:04 10.0.230.48, 00:15:4d:e6:30:86 ================================================ FILE: l4lb/destination_samples/32_destinations.csv ================================================ 10.0.89.127, 00:15:4d:59:7f:ad 10.0.214.65, 00:15:4d:d6:41:bd 10.0.178.75, 00:15:4d:b2:4b:c8 10.0.24.77, 00:15:4d:18:4d:d8 10.0.199.54, 00:15:4d:c7:36:9f 10.0.234.48, 00:15:4d:ea:30:28 10.0.175.130, 00:15:4d:af:82:8c 10.0.244.158, 00:15:4d:f4:9e:b3 10.0.185.52, 00:15:4d:b9:34:6d 10.0.159.176, 00:15:4d:9f:b0:37 10.0.125.19, 00:15:4d:7d:13:9f 10.0.56.49, 00:15:4d:38:31:6f 10.0.75.197, 00:15:4d:4b:c5:1f 10.0.75.209, 00:15:4d:4b:d1:a9 10.0.92.11, 00:15:4d:5c:0b:d3 10.0.31.144, 00:15:4d:1f:90:cb 10.0.32.134, 00:15:4d:20:86:6c 10.0.50.179, 00:15:4d:32:b3:09 10.0.0.57, 00:15:4d:00:39:c4 10.0.16.109, 00:15:4d:10:6d:cf 10.0.192.32, 00:15:4d:c0:20:d2 10.0.90.135, 00:15:4d:5a:87:1e 10.0.75.126, 00:15:4d:4b:7e:c4 10.0.63.10, 00:15:4d:3f:0a:ae 10.0.161.129, 00:15:4d:a1:81:9f 10.0.129.60, 00:15:4d:81:3c:5e 10.0.143.99, 00:15:4d:8f:63:5c 10.0.32.35, 00:15:4d:20:23:a7 10.0.14.88, 00:15:4d:0e:58:7a 10.0.23.41, 00:15:4d:17:29:ae 10.0.90.214, 00:15:4d:5a:d6:d0 10.0.181.34, 00:15:4d:b5:22:c3 ================================================ FILE: l4lb/destination_samples/512_destinations.csv ================================================ 10.0.212.70, 00:15:4d:d4:46:8f 10.0.47.219, 00:15:4d:2f:db:39 10.0.68.55, 00:15:4d:44:37:3d 10.0.214.11, 00:15:4d:d6:0b:f3 10.0.160.168, 00:15:4d:a0:a8:b0 10.0.106.197, 00:15:4d:6a:c5:04 10.0.250.85, 00:15:4d:fa:55:37 10.0.207.173, 00:15:4d:cf:ad:f0 10.0.56.197, 00:15:4d:38:c5:8a 10.0.226.152, 00:15:4d:e2:98:e1 10.0.58.44, 00:15:4d:3a:2c:f5 10.0.229.45, 00:15:4d:e5:2d:0d 10.0.187.142, 00:15:4d:bb:8e:64 10.0.24.34, 00:15:4d:18:22:4f 10.0.166.54, 00:15:4d:a6:36:ae 10.0.93.206, 00:15:4d:5d:ce:db 10.0.231.249, 00:15:4d:e7:f9:1f 10.0.65.76, 00:15:4d:41:4c:26 10.0.15.234, 00:15:4d:0f:ea:c3 10.0.230.55, 00:15:4d:e6:37:15 10.0.136.86, 00:15:4d:88:56:03 10.0.148.53, 00:15:4d:94:35:2f 10.0.183.116, 00:15:4d:b7:74:16 10.0.180.50, 00:15:4d:b4:32:33 10.0.254.80, 00:15:4d:fe:50:28 10.0.233.102, 00:15:4d:e9:66:26 10.0.102.227, 00:15:4d:66:e3:67 10.0.113.54, 00:15:4d:71:36:c4 10.0.40.225, 00:15:4d:2b:e1:86 10.0.88.87, 00:15:4d:58:57:67 10.0.175.163, 00:15:4d:af:a3:e5 10.0.9.218, 00:15:4d:09:da:d5 10.0.40.86, 00:15:4d:28:56:cf 10.0.75.65, 00:15:4d:4b:41:df 10.0.250.93, 00:15:4d:fa:5d:c8 10.0.56.38, 00:15:4d:38:26:4c 10.0.206.8, 00:15:4d:ce:08:a6 10.0.196.245, 00:15:4d:c4:f5:0d 10.0.186.51, 00:15:4d:ba:33:9e 10.0.145.16, 00:15:4d:91:10:4e 10.0.186.6, 00:15:4d:ba:06:41 10.0.72.74, 00:15:4d:48:4a:95 10.0.88.233, 00:15:4d:58:e9:40 10.0.170.57, 00:15:4d:aa:39:19 10.0.174.71, 00:15:4d:ae:47:83 10.0.205.107, 00:15:4d:cd:6b:ca 10.0.167.246, 00:15:4d:a7:f6:ed 10.0.174.232, 00:15:4d:ae:e8:2b 10.0.168.32, 00:15:4d:a8:20:53 10.0.224.43, 00:15:4d:e0:2b:c7 10.0.93.164, 00:15:4d:5d:a4:8f 10.0.158.161, 00:15:4d:9e:a1:32 10.0.181.253, 00:15:4d:b5:fd:fc 10.0.207.193, 00:15:4d:cf:c1:d1 10.0.156.0, 00:15:4d:9c:00:95 10.0.120.164, 00:15:4d:78:a6:04 10.0.165.105, 00:15:4d:a5:69:9d 10.0.145.130, 00:15:4d:91:82:26 10.0.171.20, 00:15:4d:ab:14:9f 10.0.68.20, 00:15:4d:44:14:bd 10.0.82.179, 00:15:4d:52:b3:32 10.0.248.39, 00:15:4d:f8:27:2d 10.0.168.14, 00:15:4d:a8:0e:66 10.0.195.102, 00:15:4d:c3:66:c8 10.0.165.167, 00:15:4d:a5:a7:39 10.0.176.113, 00:15:4d:b0:71:f8 10.0.120.227, 00:15:4d:78:e3:0b 10.0.219.90, 00:15:4d:db:5a:7e 10.0.178.140, 00:15:4d:b2:8c:40 10.0.59.79, 00:15:4d:3b:4f:44 10.0.158.189, 00:15:4d:9e:bd:d3 10.0.40.70, 00:15:4d:28:46:34 10.0.225.152, 00:15:4d:e1:98:a9 10.0.36.165, 00:15:4d:24:a5:82 10.0.94.93, 00:15:4d:5e:5d:15 10.0.83.128, 00:15:4d:53:80:4f 10.0.76.13, 00:15:4d:4c:0d:ec 10.0.118.86, 00:15:4d:76:56:f4 10.0.176.235, 00:15:4d:b0:eb:75 10.0.188.233, 00:15:4d:bc:e9:d8 10.0.202.241, 00:15:4d:ca:f1:ee 10.0.37.168, 00:15:4d:25:a8:1f 10.0.195.176, 00:15:4d:c3:b0:59 10.0.65.57, 00:15:4d:41:39:f6 10.0.221.4, 00:15:4d:dd:04:44 10.0.44.138, 00:15:4d:2c:8a:39 10.0.142.65, 00:15:4d:8e:41:43 10.0.88.84, 00:15:4d:58:54:bd 10.0.163.174, 00:15:4d:a3:ae:5a 10.0.199.94, 00:15:4d:c7:5e:9e 10.0.219.201, 00:15:4d:db:c9:3e 10.0.26.231, 00:15:4d:1a:e7:12 10.0.43.225, 00:15:4d:2b:e1:73 10.0.160.35, 00:15:4d:a0:23:fe 10.0.92.199, 00:15:4d:5c:c7:9d 10.0.120.114, 00:15:4d:78:72:46 10.0.253.62, 00:15:4d:fd:3e:dd 10.0.135.200, 00:15:4d:87:c8:4e 10.0.92.114, 00:15:4d:5c:72:8e 10.0.219.222, 00:15:4d:db:de:92 10.0.154.138, 00:15:4d:9a:8a:b3 10.0.167.68, 00:15:4d:a7:44:8a 10.0.231.143, 00:15:4d:e7:8f:c3 10.0.237.28, 00:15:4d:ed:1c:eb 10.0.226.243, 00:15:4d:e2:f3:60 10.0.8.3, 00:15:4d:08:03:b8 10.0.52.35, 00:15:4d:34:23:c0 10.0.175.212, 00:15:4d:af:d4:84 10.0.184.67, 00:15:4d:b8:43:33 10.0.147.13, 00:15:4d:93:0d:36 10.0.222.50, 00:15:4d:de:32:69 10.0.1.222, 00:15:4d:01:de:bb 10.0.74.63, 00:15:4d:4a:3f:bd 10.0.194.127, 00:15:4d:c2:7f:b4 10.0.99.66, 00:15:4d:63:42:df 10.0.10.74, 00:15:4d:0a:4a:b7 10.0.253.143, 00:15:4d:fd:8f:b1 10.0.44.2, 00:15:4d:2c:02:cd 10.0.3.250, 00:15:4d:03:fe:13 10.0.114.169, 00:15:4d:72:a9:1c 10.0.133.177, 00:15:4d:85:b1:2b 10.0.189.77, 00:15:4d:bd:4d:fd 10.0.239.11, 00:15:4d:ef:0b:8a 10.0.203.91, 00:15:4d:cb:5b:f9 10.0.185.3, 00:15:4d:b9:03:55 10.0.251.239, 00:15:4d:fb:ef:fb 10.0.236.208, 00:15:4d:ec:d0:7a 10.0.231.78, 00:15:4d:e7:4e:a1 10.0.185.48, 00:15:4d:b9:30:88 10.0.62.14, 00:15:4d:3e:0e:fa 10.0.14.18, 00:15:4d:0e:12:8e 10.0.206.174, 00:15:4d:ce:ae:6b 10.0.26.17, 00:15:4d:1a:11:62 10.0.77.101, 00:15:4d:4d:65:d6 10.0.112.140, 00:15:4d:70:8c:4a 10.0.219.48, 00:15:4d:db:30:19 10.0.132.137, 00:15:4d:84:89:13 10.0.19.129, 00:15:4d:13:81:39 10.0.190.195, 00:15:4d:be:c3:2e 10.0.123.113, 00:15:4d:7b:71:ae 10.0.113.176, 00:15:4d:71:b0:24 10.0.171.218, 00:15:4d:ab:da:de 10.0.120.166, 00:15:4d:78:a6:6c 10.0.76.254, 00:15:4d:4c:fe:5e 10.0.38.73, 00:15:4d:26:49:c5 10.0.86.85, 00:15:4d:56:55:52 10.0.19.189, 00:15:4d:13:bd:8f 10.0.55.21, 00:15:4d:37:15:13 10.0.99.239, 00:15:4d:63:ef:a5 10.0.191.51, 00:15:4d:bf:33:f8 10.0.249.221, 00:15:4d:f9:dd:40 10.0.239.35, 00:15:4d:ef:23:52 10.0.247.191, 00:15:4d:f7:bf:05 10.0.5.139, 00:15:4d:05:8b:3c 10.0.16.140, 00:15:4d:10:8c:a6 10.0.247.85, 00:15:4d:f7:55:53 10.0.202.235, 00:15:4d:ca:eb:a7 10.0.8.55, 00:15:4d:08:37:37 10.0.127.137, 00:15:4d:7f:89:ce 10.0.0.223, 00:15:4d:00:df:1e 10.0.89.25, 00:15:4d:59:19:fe 10.0.132.108, 00:15:4d:84:6c:a3 10.0.5.225, 00:15:4d:05:e1:ed 10.0.58.29, 00:15:4d:3a:1d:1e 10.0.8.205, 00:15:4d:08:cd:d4 10.0.105.65, 00:15:4d:69:41:4c 10.0.219.15, 00:15:4d:db:0f:c7 10.0.102.77, 00:15:4d:66:4d:90 10.0.97.50, 00:15:4d:61:32:35 10.0.167.214, 00:15:4d:a7:d6:29 10.0.13.176, 00:15:4d:0d:b0:f6 10.0.124.183, 00:15:4d:7c:b7:be 10.0.75.32, 00:15:4d:4b:20:8f 10.0.144.206, 00:15:4d:90:ce:cc 10.0.135.178, 00:15:4d:87:b2:3a 10.0.53.31, 00:15:4d:35:1f:c8 10.0.123.205, 00:15:4d:7b:cd:17 10.0.220.17, 00:15:4d:dc:11:b8 10.0.109.84, 00:15:4d:6d:54:d0 10.0.71.210, 00:15:4d:47:d2:ec 10.0.93.37, 00:15:4d:5d:25:1c 10.0.19.124, 00:15:4d:13:7c:b4 10.0.169.14, 00:15:4d:a9:0e:39 10.0.145.187, 00:15:4d:91:bb:dd 10.0.102.249, 00:15:4d:66:f9:ed 10.0.237.106, 00:15:4d:ed:6a:5b 10.0.55.84, 00:15:4d:37:54:a7 10.0.188.122, 00:15:4d:bc:7a:82 10.0.232.114, 00:15:4d:e8:72:f6 10.0.242.119, 00:15:4d:f2:77:4f 10.0.160.140, 00:15:4d:a0:8c:91 10.0.118.103, 00:15:4d:76:67:a3 10.0.22.206, 00:15:4d:16:ce:39 10.0.109.90, 00:15:4d:6d:5a:6c 10.0.142.196, 00:15:4d:8e:c4:65 10.0.35.181, 00:15:4d:23:b5:f0 10.0.99.62, 00:15:4d:63:3e:fc 10.0.32.79, 00:15:4d:20:4f:e7 10.0.189.14, 00:15:4d:bd:0e:0f 10.0.40.158, 00:15:4d:28:9e:6e 10.0.12.166, 00:15:4d:0c:a6:b5 10.0.25.39, 00:15:4d:19:27:5a 10.0.161.44, 00:15:4d:a1:2c:b6 10.0.89.203, 00:15:4d:59:cb:b2 10.0.67.183, 00:15:4d:43:b7:2c 10.0.110.191, 00:15:4d:6e:bf:80 10.0.81.247, 00:15:4d:51:f7:d1 10.0.77.229, 00:15:4d:4d:e5:57 10.0.178.19, 00:15:4d:b2:13:ae 10.0.204.89, 00:15:4d:cc:59:0f 10.0.30.0, 00:15:4d:1e:00:7b 10.0.148.51, 00:15:4d:94:33:4d 10.0.213.43, 00:15:4d:d5:2b:56 10.0.105.225, 00:15:4d:69:e1:31 10.0.150.197, 00:15:4d:96:c5:41 10.0.2.69, 00:15:4d:02:45:eb 10.0.0.135, 00:15:4d:00:87:4f 10.0.85.113, 00:15:4d:55:71:e1 10.0.132.23, 00:15:4d:84:17:28 10.0.14.185, 00:15:4d:0e:b9:f3 10.0.89.21, 00:15:4d:59:15:57 10.0.99.52, 00:15:4d:63:34:70 10.0.43.173, 00:15:4d:2b:ad:22 10.0.122.212, 00:15:4d:7a:d4:fd 10.0.106.106, 00:15:4d:6a:6a:f5 10.0.86.91, 00:15:4d:56:5b:cb 10.0.217.233, 00:15:4d:d9:e9:d0 10.0.195.226, 00:15:4d:c3:e2:58 10.0.79.46, 00:15:4d:4f:2e:6a 10.0.85.18, 00:15:4d:55:12:8c 10.0.213.194, 00:15:4d:d5:c2:76 10.0.4.188, 00:15:4d:04:bc:5a 10.0.237.180, 00:15:4d:ed:b4:1b 10.0.252.132, 00:15:4d:fc:84:34 10.0.128.254, 00:15:4d:80:fe:42 10.0.228.232, 00:15:4d:e4:e8:d2 10.0.168.106, 00:15:4d:a8:6a:83 10.0.40.6, 00:15:4d:28:06:67 10.0.196.226, 00:15:4d:c4:e2:96 10.0.170.161, 00:15:4d:aa:a1:7f 10.0.40.189, 00:15:4d:28:bd:48 10.0.53.194, 00:15:4d:35:c2:db 10.0.87.236, 00:15:4d:57:ec:33 10.0.44.224, 00:15:4d:2c:e0:db 10.0.207.53, 00:15:4d:cf:35:7b 10.0.68.76, 00:15:4d:44:4c:b2 10.0.132.145, 00:15:4d:84:91:4a 10.0.25.139, 00:15:4d:19:8b:2b 10.0.67.154, 00:15:4d:43:9a:6e 10.0.103.66, 00:15:4d:67:42:66 10.0.39.134, 00:15:4d:27:86:4f 10.0.43.223, 00:15:4d:2b:df:ce 10.0.198.164, 00:15:4d:c6:a4:ba 10.0.177.27, 00:15:4d:b1:1b:88 10.0.251.73, 00:15:4d:fb:49:c7 10.0.186.213, 00:15:4d:ba:d5:a7 10.0.34.102, 00:15:4d:22:66:b4 10.0.135.108, 00:15:4d:87:6c:5c 10.0.98.20, 00:15:4d:62:14:aa 10.0.113.179, 00:15:4d:71:b3:7b 10.0.110.135, 00:15:4d:6e:87:01 10.0.131.15, 00:15:4d:83:0f:ea 10.0.3.254, 00:15:4d:03:fe:57 10.0.168.63, 00:15:4d:a8:3f:17 10.0.124.178, 00:15:4d:7c:b2:dd 10.0.185.87, 00:15:4d:b9:57:97 10.0.112.208, 00:15:4d:70:d0:ad 10.0.113.94, 00:15:4d:71:5e:af 10.0.129.153, 00:15:4d:81:99:5b 10.0.48.197, 00:15:4d:30:c5:c4 10.0.25.15, 00:15:4d:19:0f:62 10.0.54.242, 00:15:4d:36:f2:19 10.0.251.68, 00:15:4d:fb:44:da 10.0.167.196, 00:15:4d:a7:c4:5a 10.0.105.214, 00:15:4d:69:d6:b1 10.0.100.134, 00:15:4d:64:86:8d 10.0.228.199, 00:15:4d:e4:c7:09 10.0.82.46, 00:15:4d:52:2e:83 10.0.58.164, 00:15:4d:3a:a4:05 10.0.60.204, 00:15:4d:3c:cc:cd 10.0.171.150, 00:15:4d:ab:96:af 10.0.182.61, 00:15:4d:b6:3d:33 10.0.100.183, 00:15:4d:64:b7:ad 10.0.239.85, 00:15:4d:ef:55:53 10.0.53.14, 00:15:4d:35:0e:14 10.0.56.113, 00:15:4d:38:71:c8 10.0.100.143, 00:15:4d:64:8f:54 10.0.243.248, 00:15:4d:f3:f8:02 10.0.92.90, 00:15:4d:5c:5a:1c 10.0.51.144, 00:15:4d:33:90:44 10.0.79.214, 00:15:4d:4f:d6:7f 10.0.151.85, 00:15:4d:97:55:a6 10.0.207.40, 00:15:4d:cf:28:28 10.0.103.109, 00:15:4d:67:6d:15 10.0.9.131, 00:15:4d:09:83:6b 10.0.50.245, 00:15:4d:32:f5:bf 10.0.81.211, 00:15:4d:51:d3:81 10.0.185.21, 00:15:4d:b9:15:26 10.0.83.173, 00:15:4d:53:ad:71 10.0.72.140, 00:15:4d:48:8c:1c 10.0.79.150, 00:15:4d:4f:96:0d 10.0.158.190, 00:15:4d:9e:be:4d 10.0.180.72, 00:15:4d:b4:48:9d 10.0.23.181, 00:15:4d:17:b5:0b 10.0.1.232, 00:15:4d:01:e8:1b 10.0.153.111, 00:15:4d:99:6f:31 10.0.218.135, 00:15:4d:da:87:06 10.0.253.85, 00:15:4d:fd:55:49 10.0.143.64, 00:15:4d:8f:40:05 10.0.16.146, 00:15:4d:10:92:ca 10.0.16.16, 00:15:4d:10:10:8a 10.0.79.100, 00:15:4d:4f:64:e3 10.0.44.54, 00:15:4d:2c:36:6a 10.0.191.185, 00:15:4d:bf:b9:83 10.0.245.194, 00:15:4d:f5:c2:a2 10.0.168.84, 00:15:4d:a8:54:14 10.0.103.162, 00:15:4d:67:a2:2b 10.0.96.176, 00:15:4d:60:b0:8d 10.0.135.33, 00:15:4d:87:21:52 10.0.192.144, 00:15:4d:c0:90:53 10.0.122.33, 00:15:4d:7a:21:38 10.0.220.42, 00:15:4d:dc:2a:52 10.0.137.134, 00:15:4d:89:86:94 10.0.3.129, 00:15:4d:03:81:ea 10.0.125.118, 00:15:4d:7d:76:9d 10.0.86.111, 00:15:4d:56:6f:6c 10.0.62.129, 00:15:4d:3e:81:68 10.0.65.218, 00:15:4d:41:da:7e 10.0.122.65, 00:15:4d:7a:41:0b 10.0.91.117, 00:15:4d:5b:75:a1 10.0.79.140, 00:15:4d:4f:8c:a4 10.0.161.205, 00:15:4d:a1:cd:15 10.0.110.186, 00:15:4d:6e:ba:66 10.0.107.6, 00:15:4d:6b:06:79 10.0.249.132, 00:15:4d:f9:84:ec 10.0.42.84, 00:15:4d:2a:54:10 10.0.210.142, 00:15:4d:d2:8e:0c 10.0.205.123, 00:15:4d:cd:7b:a4 10.0.12.122, 00:15:4d:0c:7a:d2 10.0.149.177, 00:15:4d:95:b1:51 10.0.167.49, 00:15:4d:a7:31:62 10.0.6.59, 00:15:4d:06:3b:33 10.0.63.239, 00:15:4d:3f:ef:40 10.0.128.241, 00:15:4d:80:f1:be 10.0.52.202, 00:15:4d:34:ca:06 10.0.240.205, 00:15:4d:f0:cd:42 10.0.228.221, 00:15:4d:e4:dd:f6 10.0.234.90, 00:15:4d:ea:5a:09 10.0.81.203, 00:15:4d:51:cb:12 10.0.170.147, 00:15:4d:aa:93:b7 10.0.223.175, 00:15:4d:df:af:86 10.0.246.221, 00:15:4d:f6:dd:70 10.0.196.31, 00:15:4d:c4:1f:32 10.0.1.40, 00:15:4d:01:28:48 10.0.97.220, 00:15:4d:61:dc:28 10.0.248.112, 00:15:4d:f8:70:d0 10.0.87.205, 00:15:4d:57:cd:e1 10.0.160.95, 00:15:4d:a0:5f:bc 10.0.185.69, 00:15:4d:b9:45:3f 10.0.204.194, 00:15:4d:cc:c2:76 10.0.48.123, 00:15:4d:30:7b:5e 10.0.103.27, 00:15:4d:67:1b:51 10.0.29.131, 00:15:4d:1d:83:79 10.0.39.185, 00:15:4d:27:b9:50 10.0.74.136, 00:15:4d:4a:88:17 10.0.173.112, 00:15:4d:ad:70:19 10.0.88.173, 00:15:4d:58:ad:5e 10.0.203.15, 00:15:4d:cb:0f:ae 10.0.11.122, 00:15:4d:0b:7a:41 10.0.148.58, 00:15:4d:94:3a:1c 10.0.236.123, 00:15:4d:ec:7b:99 10.0.101.95, 00:15:4d:65:5f:b3 10.0.185.218, 00:15:4d:b9:da:24 10.0.8.59, 00:15:4d:08:3b:88 10.0.172.55, 00:15:4d:ac:37:96 10.0.184.32, 00:15:4d:b8:20:a2 10.0.191.221, 00:15:4d:bf:dd:05 10.0.207.182, 00:15:4d:cf:b6:a4 10.0.115.120, 00:15:4d:73:78:62 10.0.46.33, 00:15:4d:2e:21:24 10.0.200.39, 00:15:4d:c8:27:89 10.0.41.185, 00:15:4d:29:b9:f4 10.0.83.242, 00:15:4d:53:f2:95 10.0.132.80, 00:15:4d:84:50:8a 10.0.16.221, 00:15:4d:10:dd:11 10.0.105.98, 00:15:4d:69:62:aa 10.0.205.125, 00:15:4d:cd:7d:a1 10.0.82.144, 00:15:4d:52:90:36 10.0.135.51, 00:15:4d:87:33:76 10.0.206.129, 00:15:4d:ce:81:fe 10.0.159.156, 00:15:4d:9f:9c:e1 10.0.152.36, 00:15:4d:98:24:a5 10.0.133.111, 00:15:4d:85:6f:b1 10.0.156.207, 00:15:4d:9c:cf:90 10.0.14.145, 00:15:4d:0e:91:c4 10.0.106.49, 00:15:4d:6a:31:55 10.0.10.184, 00:15:4d:0a:b8:89 10.0.68.115, 00:15:4d:44:73:7e 10.0.195.89, 00:15:4d:c3:59:34 10.0.43.111, 00:15:4d:2b:6f:09 10.0.73.101, 00:15:4d:49:65:84 10.0.179.181, 00:15:4d:b3:b5:a5 10.0.211.149, 00:15:4d:d3:95:af 10.0.40.212, 00:15:4d:28:d4:71 10.0.203.64, 00:15:4d:cb:40:eb 10.0.212.158, 00:15:4d:d4:9e:a6 10.0.173.114, 00:15:4d:ad:72:93 10.0.252.163, 00:15:4d:fc:a3:aa 10.0.250.41, 00:15:4d:fa:29:0e 10.0.247.142, 00:15:4d:f7:8e:60 10.0.27.73, 00:15:4d:1b:49:48 10.0.76.231, 00:15:4d:4c:e7:7e 10.0.124.124, 00:15:4d:7c:7c:73 10.0.86.88, 00:15:4d:56:58:e3 10.0.18.175, 00:15:4d:12:af:78 10.0.157.82, 00:15:4d:9d:52:5b 10.0.149.16, 00:15:4d:95:10:d7 10.0.183.176, 00:15:4d:b7:b0:83 10.0.192.110, 00:15:4d:c0:6e:70 10.0.139.55, 00:15:4d:8b:37:c3 10.0.206.27, 00:15:4d:ce:1b:a9 10.0.248.152, 00:15:4d:f8:98:06 10.0.118.176, 00:15:4d:76:b0:74 10.0.246.88, 00:15:4d:f6:58:25 10.0.161.3, 00:15:4d:a1:03:d3 10.0.132.208, 00:15:4d:84:d0:d5 10.0.100.185, 00:15:4d:64:b9:28 10.0.51.191, 00:15:4d:33:bf:a2 10.0.15.149, 00:15:4d:0f:95:8d 10.0.196.197, 00:15:4d:c4:c5:0d 10.0.171.170, 00:15:4d:ab:aa:e7 10.0.59.69, 00:15:4d:3b:45:64 10.0.52.141, 00:15:4d:34:8d:7b 10.0.129.164, 00:15:4d:81:a4:98 10.0.0.98, 00:15:4d:00:62:0c 10.0.222.19, 00:15:4d:de:13:08 10.0.164.29, 00:15:4d:a4:1d:7b 10.0.86.26, 00:15:4d:56:1a:11 10.0.127.171, 00:15:4d:7f:ab:bb 10.0.114.10, 00:15:4d:72:0a:85 10.0.55.123, 00:15:4d:37:7b:f3 10.0.89.92, 00:15:4d:59:5c:d6 10.0.31.168, 00:15:4d:1f:a8:be 10.0.138.99, 00:15:4d:8a:63:91 10.0.4.32, 00:15:4d:04:20:81 10.0.149.72, 00:15:4d:95:48:2f 10.0.213.222, 00:15:4d:d5:de:95 10.0.30.251, 00:15:4d:1e:fb:23 10.0.60.103, 00:15:4d:3c:67:11 10.0.137.88, 00:15:4d:89:58:2d 10.0.86.16, 00:15:4d:56:10:15 10.0.164.119, 00:15:4d:a4:77:07 10.0.44.89, 00:15:4d:2c:59:1a 10.0.149.205, 00:15:4d:95:cd:61 10.0.148.1, 00:15:4d:94:01:47 10.0.147.115, 00:15:4d:93:73:9a 10.0.254.89, 00:15:4d:fe:59:3c 10.0.165.84, 00:15:4d:a5:54:4b 10.0.238.19, 00:15:4d:ee:13:a2 10.0.148.122, 00:15:4d:94:7a:b7 10.0.9.51, 00:15:4d:09:33:55 10.0.2.202, 00:15:4d:02:ca:eb 10.0.253.117, 00:15:4d:fd:75:72 10.0.55.186, 00:15:4d:37:ba:77 10.0.166.31, 00:15:4d:a6:1f:9d 10.0.89.164, 00:15:4d:59:a4:07 10.0.117.157, 00:15:4d:75:9d:23 10.0.87.226, 00:15:4d:57:e2:21 10.0.56.68, 00:15:4d:38:44:5e 10.0.153.26, 00:15:4d:99:1a:d3 10.0.39.103, 00:15:4d:27:67:15 10.0.124.144, 00:15:4d:7c:90:f5 10.0.96.17, 00:15:4d:60:11:c5 10.0.195.128, 00:15:4d:c3:80:ae 10.0.104.150, 00:15:4d:68:96:7e 10.0.156.200, 00:15:4d:9c:c8:96 10.0.204.190, 00:15:4d:cc:be:1f 10.0.86.105, 00:15:4d:56:69:0f 10.0.213.5, 00:15:4d:d5:05:45 10.0.62.172, 00:15:4d:3e:ac:77 10.0.129.232, 00:15:4d:81:e8:7a 10.0.176.5, 00:15:4d:b0:05:48 10.0.190.93, 00:15:4d:be:5d:60 10.0.19.112, 00:15:4d:13:70:bd 10.0.184.232, 00:15:4d:b8:e8:26 10.0.98.248, 00:15:4d:62:f8:e2 10.0.69.84, 00:15:4d:45:54:e2 10.0.92.106, 00:15:4d:5c:6a:d7 10.0.47.188, 00:15:4d:2f:bc:54 10.0.218.82, 00:15:4d:da:52:57 10.0.132.60, 00:15:4d:84:3c:c8 10.0.71.181, 00:15:4d:47:b5:b6 10.0.187.5, 00:15:4d:bb:05:fa 10.0.194.25, 00:15:4d:c2:19:7c 10.0.92.6, 00:15:4d:5c:06:ea 10.0.198.249, 00:15:4d:c6:f9:57 10.0.187.141, 00:15:4d:bb:8d:58 10.0.180.111, 00:15:4d:b4:6f:e5 10.0.23.1, 00:15:4d:17:01:9f 10.0.84.243, 00:15:4d:54:f3:3f 10.0.241.172, 00:15:4d:f1:ac:6b 10.0.227.128, 00:15:4d:e3:80:0b 10.0.110.106, 00:15:4d:6e:6a:7f 10.0.95.143, 00:15:4d:5f:8f:85 10.0.46.63, 00:15:4d:2e:3f:59 10.0.176.140, 00:15:4d:b0:8c:7d 10.0.195.155, 00:15:4d:c3:9b:6b 10.0.214.76, 00:15:4d:d6:4c:93 10.0.6.174, 00:15:4d:06:ae:5a 10.0.58.186, 00:15:4d:3a:ba:88 10.0.169.249, 00:15:4d:a9:f9:e6 10.0.187.211, 00:15:4d:bb:d3:2c ================================================ FILE: l4lb/l4lb_map.py ================================================ #!/usr/bin/env python3 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) # Copyright (c) 2018 Netronome Systems, Inc. import argparse import csv import json import os import subprocess from bpftool_utils import * parser = argparse.ArgumentParser(description="Initialize load balancer map") parser.add_argument('-i', '--interface', action='store', required=True, help='xdp network interface') parser.add_argument('-f', '--file', action='store', required=True, help='Input file containing destination data') parser.add_argument('-s', '--saddr', action='store', required=False, type=str, default='10.0.0.1', help='source ip for outgoing packets') args = parser.parse_args() tmpfile = 'tmp_bpftool.txt' # batch map updates into a file for bpftool stats_zero = '00 00 00 00 00 00 00 00' # initialize stats to (u64) zero interface = args.interface try: map_id = str(get_map_ids(interface)[0]) max_dest = get_map_entries(map_id) # map size as defined by xdp program except: print("Error finding map for dev: %s" % interface) sys.exit(1) try: dest_file = open(args.file, 'r') dest_hosts = list(csv.reader(dest_file)) dest_count = len(dest_hosts) except: print("Error reading file") sys.exit(1) if dest_count > max_dest: print("Warning: only the first %d destinations will be used" % max_dest) else: print("Loading file with %d destinations" % dest_count) batchfile = open(tmpfile, 'w') # iterate through data in input file, if it contains less values than max_dest # map will be filled as round robin for key in range (0, max_dest): target_id = key % dest_count # bpftool requires data as individual bytes keyval1 = str(key & 0xFF) keyval2 = str(key >> 8) saddr = args.saddr.split('.') # source IP for egress packets daddr = dest_hosts[target_id][0].split('.') # IP of the target server dmac_hex = dest_hosts[target_id][1].split(':') # MAC of the target server dmac = [str(int(byte, 16)) for byte in dmac_hex] # convert hex to integers # Fill in map using struct iptnl_info arrangement as specified in l4lb_xdp.c COMMAND = (['map update id', map_id, 'key', keyval1, keyval2, '00 00', 'value', saddr[0], saddr[1], saddr[2], saddr[3], daddr[0], daddr[1], daddr[2], daddr[3], stats_zero, stats_zero, dmac[0], dmac[1], dmac[2], dmac[3], dmac[4], dmac[5], '00 00 \n']) COMMAND = ' '.join(COMMAND) batchfile.write(COMMAND) batchfile.close() subprocess.check_output('bpftool batch file %s' % tmpfile, shell=True) ================================================ FILE: l4lb/l4lb_stats.py ================================================ #!/usr/bin/env python3 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) # Copyright (c) 2018 Netronome Systems, Inc. import argparse import json import os import subprocess import sys import time from bpftool_utils import * parser = argparse.ArgumentParser(description="Display load balancer statistics") parser.add_argument('-i', '--interface', action='store', required=True, help='xdp network interface') args = parser.parse_args() interface = args.interface prev = {} while True: n = 1 pkt_tot = 0 bit_tot = 0 values = {} clock = time.time() # obtain map values try: map_id = get_map_ids(interface)[0] map_vals = dump_map(map_id) xdp_type = get_map_dev(map_id) except: print("Error accessing eBPF map") time.sleep(1) continue # get totals for each destination ip for record in map_vals: # obtain values from map from positions defined by struct iptnl_info dest_ip = [int(byte, 16) for byte in record['value'][4:8]] bw = hex_list_to_int(record['value'][8:16]) pkt = hex_list_to_int(record['value'][16:24]) ip = '%s.%s.%s.%s' % (dest_ip[0], dest_ip[1], dest_ip[2], dest_ip[3]) if ip in values: values[ip][0] += pkt values[ip][1] += bw else: values[ip] = [pkt, bw] os.system("clear") pr = ("== Load balancer outbound statistics [%s] ==\n\n" % xdp_type) # Calculate network rate using diff from previous sample for key in sorted(values): bitrate = 0 pktrate = 0 if key in prev: sample_period = clock - prev[key][2] pktrate = int((values[key][0] - prev[key][0]) / sample_period) bitrate = int((values[key][1] - prev[key][1]) / sample_period) * 8 prev[key] = [values[key][0], values[key][1], clock] if pktrate >= 0: # on map refill stats are reset causes neg stats pr += ("{:4d}\t{:15s}\t{:12,} pkts/s\t{:15,} bits/s\n" .format(n, key, pktrate, bitrate)) pkt_tot += pktrate bit_tot += bitrate n += 1 pr += "\n[Totals]\t\t{:12,} pkts/s\t{:15,} bits/s".format(pkt_tot, bit_tot) print(pr) time.sleep(max(0, 1 - (time.time() - clock))) ================================================ FILE: l4lb/l4lb_xdp.c ================================================ // SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) // Copyright (c) 2018 Netronome Systems, Inc. #include #include #include #include #include #include #include #include #include #include #include #include "bpf_endian.h" #include "bpf_helpers.h" #include "jhash.h" #define MAX_SERVERS 512 /* 0x3FFF mask to check for fragment offset field */ #define IP_FRAGMENTED 65343 struct pkt_meta { __be32 src; __be32 dst; union { __u32 ports; __u16 port16[2]; }; }; struct dest_info { __u32 saddr; __u32 daddr; __u64 bytes; __u64 pkts; __u8 dmac[6]; }; struct bpf_map_def SEC("maps") servers = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(__u32), .value_size = sizeof(struct dest_info), .max_entries = MAX_SERVERS, }; static __always_inline struct dest_info *hash_get_dest(struct pkt_meta *pkt) { __u32 key; struct dest_info *tnl; /* hash packet source ip with both ports to obtain a destination */ key = jhash_2words(pkt->src, pkt->ports, MAX_SERVERS) % MAX_SERVERS; /* get destination's network details from map */ tnl = bpf_map_lookup_elem(&servers, &key); if (!tnl) { /* if entry does not exist, fallback to key 0 */ key = 0; tnl = bpf_map_lookup_elem(&servers, &key); } return tnl; } static __always_inline bool parse_udp(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct udphdr *udp; udp = data + off; if (udp + 1 > data_end) return false; pkt->port16[0] = udp->source; pkt->port16[1] = udp->dest; return true; } static __always_inline bool parse_tcp(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct tcphdr *tcp; tcp = data + off; if (tcp + 1 > data_end) return false; pkt->port16[0] = tcp->source; pkt->port16[1] = tcp->dest; return true; } static __always_inline void set_ethhdr(struct ethhdr *new_eth, const struct ethhdr *old_eth, const struct dest_info *tnl, __be16 h_proto) { memcpy(new_eth->h_source, old_eth->h_dest, sizeof(new_eth->h_source)); memcpy(new_eth->h_dest, tnl->dmac, sizeof(new_eth->h_dest)); new_eth->h_proto = h_proto; } static __always_inline int process_packet(struct xdp_md *ctx, __u64 off) { void *data_end = (void *)(long)ctx->data_end; void *data = (void *)(long)ctx->data; struct pkt_meta pkt = {}; struct ethhdr *new_eth; struct ethhdr *old_eth; struct dest_info *tnl; struct iphdr iph_tnl; struct iphdr *iph; __u16 *next_iph_u16; __u16 pkt_size; __u16 payload_len; __u8 protocol; u32 csum = 0; iph = data + off; if (iph + 1 > data_end) return XDP_DROP; if (iph->ihl != 5) return XDP_DROP; protocol = iph->protocol; payload_len = bpf_ntohs(iph->tot_len); off += sizeof(struct iphdr); /* do not support fragmented packets as L4 headers may be missing */ if (iph->frag_off & IP_FRAGMENTED) return XDP_DROP; pkt.src = iph->saddr; pkt.dst = iph->daddr; /* obtain port numbers for UDP and TCP traffic */ if (protocol == IPPROTO_TCP) { if (!parse_tcp(data, off, data_end, &pkt)) return XDP_DROP; } else if (protocol == IPPROTO_UDP) { if (!parse_udp(data, off, data_end, &pkt)) return XDP_DROP; } else { return XDP_PASS; } /* allocate a destination using packet hash and map lookup */ tnl = hash_get_dest(&pkt); if (!tnl) return XDP_DROP; /* extend the packet for ip header encapsulation */ if (bpf_xdp_adjust_head(ctx, 0 - (int)sizeof(struct iphdr))) return XDP_DROP; data = (void *)(long)ctx->data; data_end = (void *)(long)ctx->data_end; /* relocate ethernet header to start of packet and set MACs */ new_eth = data; old_eth = data + sizeof(*iph); if (new_eth + 1 > data_end || old_eth + 1 > data_end || iph + 1 > data_end) return XDP_DROP; set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); /* create an additional ip header for encapsulation */ iph_tnl.version = 4; iph_tnl.ihl = sizeof(*iph) >> 2; iph_tnl.frag_off = 0; iph_tnl.protocol = IPPROTO_IPIP; iph_tnl.check = 0; iph_tnl.id = 0; iph_tnl.tos = 0; iph_tnl.tot_len = bpf_htons(payload_len + sizeof(*iph)); iph_tnl.daddr = tnl->daddr; iph_tnl.saddr = tnl->saddr; iph_tnl.ttl = 8; /* calculate ip header checksum */ next_iph_u16 = (__u16 *)&iph_tnl; #pragma clang loop unroll(full) for (int i = 0; i < (int)sizeof(*iph) >> 1; i++) csum += *next_iph_u16++; iph_tnl.check = ~((csum & 0xffff) + (csum >> 16)); iph = data + sizeof(*new_eth); *iph = iph_tnl; /* increment map counters */ pkt_size = (__u16)(data_end - data); /* payload size excl L2 crc */ __sync_fetch_and_add(&tnl->pkts, 1); __sync_fetch_and_add(&tnl->bytes, pkt_size); return XDP_TX; } SEC("xdp") int loadbal(struct xdp_md *ctx) { void *data_end = (void *)(long)ctx->data_end; void *data = (void *)(long)ctx->data; struct ethhdr *eth = data; __u32 eth_proto; __u32 nh_off; nh_off = sizeof(struct ethhdr); if (data + nh_off > data_end) return XDP_DROP; eth_proto = eth->h_proto; /* demo program only accepts ipv4 packets */ if (eth_proto == bpf_htons(ETH_P_IP)) return process_packet(ctx, nh_off); else return XDP_PASS; } ================================================ FILE: programmable_rss/Makefile ================================================ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) TARGET := rss LLC ?= llc CLANG ?= clang CC ?= gcc LIBBPF_DIR = ../libbpf/src/ XDP_C = ${TARGET:=_kern.c} XDP_OBJ = ${XDP_C:.c=.o} USER_C = ${TARGET:=_user.c} USER_OBJ = ${USER_C:.c=.o} OBJECT_LIBBPF = $(LIBBPF_DIR)/libbpf.a CFLAGS ?= -I$(LIBBPF_DIR)/root/usr/include/ CFLAGS += -I../headers/ LDFLAGS ?= -L$(LIBBPF_DIR) LIBS = -lbpf -lelf all: llvm-check $(TARGET) $(XDP_OBJ) .PHONY: clean $(CLANG) $(LLC) clean: cd $(LIBBPF_DIR) && $(MAKE) clean; rm -f $(TARGET) rm -f $(XDP_OBJ) rm -f $(USER_OBJ) rm -f *.ll llvm-check: $(CLANG) $(LLC) @for TOOL in $^ ; do \ if [ ! $$(command -v $${TOOL} 2>/dev/null) ]; then \ echo "*** ERROR: Cannot find tool $${TOOL}" ;\ exit 1; \ else true; fi; \ done $(OBJECT_LIBBPF): @if [ ! -d $(LIBBPF_DIR) ]; then \ echo "Error: Need libbpf submodule"; \ echo "May need to run git submodule update --init"; \ exit 1; \ else \ cd $(LIBBPF_DIR) && $(MAKE) all; \ mkdir -p root; DESTDIR=root $(MAKE) install_headers; \ fi $(TARGET): %: %_user.c $(OBJECT_LIBBPF) Makefile $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(XDP_OBJ): %.o: %.c $(CLANG) -S \ -D __BPF_TRACING__ \ $(CFLAGS) \ -Wall \ -Wno-unused-value -Wno-pointer-sign \ -Wno-compare-distinct-pointer-types \ -Werror \ -O2 -emit-llvm -c -g $< $(LLC) -march=bpf -filetype=obj -o $@ ${@:.o=.ll} ================================================ FILE: programmable_rss/README.rst ================================================ Programmable RSS Demo ===================== Overview of RSS ~~~~~~~~~~~~~~~ Receive Side Scaling (RSS) is utilised in modern network cards to distribute network traffic between the host CPUs through the use of multiple queues [1]_. A hash function is applied to the packet headers (commonly the 4 tuple) to generate a hash for the flow. This hash value is subsequently used as the index to an indirection table which designates the destination RSS queue. Symmetric RSS is a RSS implementation where packets in both direction of a flow map to the same queue, i.e. for a connection between hosts A and B, both packets sent by A and by B will be placed on the same queue. This is useful for IDS/Firewalls monitoring traffic flows, by ensuring CPU state access locality across all packets of the flow one can minimise cache bouncing and achieve higher performance. Custom header RSS (or Encapsulated RSS) allows users to benefit from RSS even if they are using custom headers or uncommon encapsulations. Default RSS implementations are only able to parse common protocols. With programmable RSS users can include any field of the headers in RSS calculation. Users can also parse any encapsulation protocol they have in their networks. This is beneficial to overlay and trunk networks, where the outer IP header is relatively static resulting in a badly distributed RSS. The inner IP header addresses can have more variance hence a better RSS distribution. The RSS algorithms available on network cards are commonly closed source or fixed in hardware. In Linux kernel 4.18, the capability of programming the RX RSS through eBPF was introduced. Demo App ~~~~~~~~ This program will demonstrate how XDP offload can be utilised to provide user programmable RSS. As this is a demo, it showcases multiple RSS capabilities, however a deployment would likely only implement one of these RSS options. The demo allows for incoming packets to be distributed to - a single queue, chosen by the user through a userspace utility - distributed queues using a hash algorithm - distributed queues using a Symmetric RSS hash algorithm - distributed queues using a hash algorithm against the IPinIP inner headers This demo shows support for simple IPinIP encapsulation because it's easy to set up and test, but UDP encapsulations (VXLAN, Geneve, FOU, GUE, etc.), NSH, QUIC or any other protocol can easily be implemented. Minimum Requirements for Demo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This program requires a XDP offload compatible SmartNIC. It cannot be run in driver mode. - Linux kernel 4.18 - clang / LLVM 4.0 - libelf-dev (Ubuntu) / elfutils-devel (Fedora) - Agilio® eBPF firmware for HW offload - July 2018 (available from `Netronome's support website`_) .. _Netronome's support website: https://help.netronome.com/ Loading the Demo ~~~~~~~~~~~~~~~~ The program is compiled using an included libbpf. To compile the user space and XDP programs :: $ make To load the program :: # ./rss -i INTERFACE Traffic Generation ~~~~~~~~~~~~~~~~~~ Traffic can be generated using a variety of tools, but for ease of use a pcap file has been supplied (traffic_IPIP.pcap). This traffic can be replayed using the following instructions. For the host running the eBPF program, ensure promiscuous mode is enabled to allow for all packets to be received. This is required as the destination MAC address set within the pcap file has been set for another host :: # ip link set dev ens4np0 promisc on On the traffic generator, use tcpreplay to retransmit the test traffic :: # tcpreplay -i ens0 -l 500 traffic_IPIP.pcap Examples ~~~~~~~~ The following examples will utilise the interface ens4np0 which has 8 queues set within ethtool. All examples are run against the same IPinIP traffic :: # ethtool -L ens4np0 combined 8 rx 0 tx 0 Sending all traffic to queue 5 :: # ./rss -i ens4np0 -q 5 ------------------------------------------------- RSS Queue 0: 0 RSS Queue 1: 0 RSS Queue 2: 0 RSS Queue 3: 0 RSS Queue 4: 0 RSS Queue 5: 804,081 RSS Queue 6: 0 RSS Queue 7: 0 Distributing traffic using jhash algorithm :: # ./rss -i ens4np0 -j ------------------------------------------------- RSS Queue 0: 0 RSS Queue 1: 0 RSS Queue 2: 0 RSS Queue 3: 0 RSS Queue 4: 0 RSS Queue 5: 402,400 RSS Queue 6: 402,400 RSS Queue 7: 0 Distributing traffic using jhash algorithm with Symmetric RSS :: # ./rss -i ens4np0 -j -s ------------------------------------------------- RSS Queue 0: 0 RSS Queue 1: 0 RSS Queue 2: 0 RSS Queue 3: 0 RSS Queue 4: 0 RSS Queue 5: 0 RSS Queue 6: 804,797 RSS Queue 7: 0 Distributing traffic using jhash algorithm with encapsulated IPs :: # ./rss -i ens4np0 -j -e ------------------------------------------------- RSS Queue 0: 72,449 RSS Queue 1: 104,648 RSS Queue 2: 120,747 RSS Queue 3: 128,797 RSS Queue 4: 64,398 RSS Queue 5: 128,792 RSS Queue 6: 72,447 RSS Queue 7: 112,693 Distributing traffic using jhash algorithm with encapsulated IPs on 4 queues :: # ./rss -i ens4np0 -j -e -m 4 ------------------------------------------------- RSS Queue 0: 136,820 RSS Queue 1: 233,403 RSS Queue 2: 193,158 RSS Queue 3: 241,450 Removing the Demo ~~~~~~~~~~~~~~~~~ The XDP program will automatically be unloaded on exiting the rss program .. [1] https://www.kernel.org/doc/Documentation/networking/scaling.txt ================================================ FILE: programmable_rss/rss_common.h ================================================ // SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) // Copyright (c) 2018 Netronome Systems, Inc. #define MAX_RSS_QUEUES 64 enum { QUEUE_STATIC = 0, QUEUE_HASH, QUEUE_SYMMETRIC, QUEUE_ENCAP, }; struct queue_select_ctrl { __u8 select_mode; __u8 queue_static; }; struct indirect_queue { __u32 packet_cnt; __u8 queue_num; }; ================================================ FILE: programmable_rss/rss_kern.c ================================================ // SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) // Copyright (c) 2018 Netronome Systems, Inc. #include #include #include #include #include #include #include #include #include #include #include "bpf_endian.h" #include "bpf_helpers.h" #include "jhash.h" #include "rss_common.h" struct pkt_meta { __be32 src; __be32 dst; __be32 srcv6[4]; __be32 dstv6[4]; union { __u32 ports; __u16 port16[2]; }; __u8 protocol; }; struct bpf_map_def SEC("maps") ctrl_map = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(__u32), .value_size = sizeof(struct queue_select_ctrl), .max_entries = 1, }; struct bpf_map_def SEC("maps") indirect_map = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(__u32), .value_size = sizeof(struct indirect_queue), .max_entries = MAX_RSS_QUEUES, }; static __always_inline __u32 hash_tuples(struct pkt_meta *pkt, bool is_ip6) { __u32 a; __u32 b; /* hash packet ip and ports to obtain a key for rss indirection tbl */ if (is_ip6) { a = jhash2(pkt->srcv6, 4, 0xc55); b = jhash2(pkt->dstv6, 4, 0x1234); return jhash_3words(a, b, pkt->ports, 0xeb0f); } else { return jhash_3words(pkt->src, pkt->dst, pkt->ports, 0xeb0f); } } static __always_inline bool parse_udp(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct udphdr *udp; udp = data + off; if (udp + 1 > data_end) return false; pkt->port16[0] = udp->source; pkt->port16[1] = udp->dest; return true; } static __always_inline bool parse_tcp(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct tcphdr *tcp; tcp = data + off; if (tcp + 1 > data_end) return false; pkt->port16[0] = tcp->source; pkt->port16[1] = tcp->dest; return true; } static __always_inline bool parse_ip4(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct iphdr *iph; iph = data + off; if (iph + 1 > data_end) return false; if (iph->ihl != 5) return false; pkt->src = iph->saddr; pkt->dst = iph->daddr; pkt->protocol = iph->protocol; return true; } static __always_inline bool parse_ip6(void *data, __u64 off, void *data_end, struct pkt_meta *pkt) { struct ipv6hdr *ip6h; ip6h = data + off; if (ip6h + 1 > data_end) return false; memcpy(pkt->srcv6, ip6h->saddr.s6_addr32, 16); memcpy(pkt->dstv6, ip6h->daddr.s6_addr32, 16); pkt->protocol = ip6h->nexthdr; return true; } static __always_inline void sort_tuple(struct pkt_meta *pkt, bool is_ip6) { __be32 temp_ipv6[4]; __be32 temp_ip; __u16 temp_port; __u64 tot_dst; __u64 tot_src; /* sort tuple to ensure consistency for both flow directions */ if (is_ip6) { tot_src = pkt->srcv6[0] + pkt->srcv6[1] + pkt->srcv6[2] + pkt->srcv6[3]; tot_dst = pkt->dstv6[0] + pkt->dstv6[1] + pkt->dstv6[2] + pkt->dstv6[3]; if (tot_src < tot_dst) { memcpy(temp_ipv6, pkt->srcv6, 16); memcpy(pkt->srcv6, pkt->dstv6, 16); memcpy(pkt->dstv6, temp_ipv6, 16); } } else { if (pkt->src < pkt->dst) { temp_ip = pkt->src; pkt->src = pkt->dst; pkt->dst = temp_ip; } } if (pkt->port16[0] < pkt->port16[1]) { temp_port = pkt->port16[0]; pkt->port16[0] = pkt->port16[1]; pkt->port16[1] = temp_port; } } SEC("xdp") int process_packet(struct xdp_md *ctx) { void *data_end = (void *)(long)ctx->data_end; void *data = (void *)(long)ctx->data; struct queue_select_ctrl *queue_ctrl; struct indirect_queue *dest_q; struct ethhdr *eth = data; struct pkt_meta pkt = {}; bool symmetric = false; bool use_encap = false; bool is_ip6 = false; bool jhash = false; __u32 eth_proto; __u32 hash; __u32 key; __u32 off; /* determine hashing mode using map lookup */ key = 0; queue_ctrl = bpf_map_lookup_elem(&ctrl_map, &key); if (!queue_ctrl) return XDP_PASS; switch (queue_ctrl->select_mode) { case QUEUE_STATIC: jhash = false; key = queue_ctrl->queue_static; break; case QUEUE_HASH: jhash = true; break; case QUEUE_SYMMETRIC: jhash = true; symmetric = true; break; case QUEUE_ENCAP: jhash = true; use_encap = true; break; default: return XDP_PASS; } /* parse packet for IP Addresses and Ports */ off = sizeof(struct ethhdr); if (data + off > data_end) return XDP_PASS; eth_proto = eth->h_proto; if (eth_proto == bpf_htons(ETH_P_IP)) { if (!parse_ip4(data, off, data_end, &pkt)) return XDP_PASS; off += sizeof(struct iphdr); } else if (eth_proto == bpf_htons(ETH_P_IPV6)) { if (!parse_ip6(data, off, data_end, &pkt)) return XDP_PASS; is_ip6 = true; off += sizeof(struct ipv6hdr); } else { return XDP_PASS; } /* if IPinIP packet allow for second IP header */ if (pkt.protocol == IPPROTO_IPIP) { if (use_encap) { if (!parse_ip4(data, off, data_end, &pkt)) return XDP_PASS; is_ip6 = false; } off += sizeof(struct iphdr); } else if (pkt.protocol == IPPROTO_IPV6) { if (use_encap) { if (!parse_ip6(data, off, data_end, &pkt)) return XDP_PASS; is_ip6 = true; } off += sizeof(struct ipv6hdr); } if (data + off > data_end) return XDP_PASS; /* obtain port numbers for UDP and TCP traffic */ if (pkt.protocol == IPPROTO_TCP) { if (!parse_tcp(data, off, data_end, &pkt)) return XDP_PASS; } else if (pkt.protocol == IPPROTO_UDP) { if (!parse_udp(data, off, data_end, &pkt)) return XDP_PASS; } else { pkt.ports = 0; } if (symmetric) sort_tuple(&pkt, is_ip6); if (jhash) { /* set map lookup key using 4 tuple hash */ hash = hash_tuples(&pkt, is_ip6); key = hash % MAX_RSS_QUEUES; } /* HW cannot perform modulus on varying values so use indirection tbl */ dest_q = bpf_map_lookup_elem(&indirect_map, &key); if (!dest_q) return XDP_PASS; ctx->rx_queue_index = dest_q->queue_num; /* increment queue packet counter */ __sync_fetch_and_add(&dest_q->packet_cnt, 1); return XDP_PASS; } ================================================ FILE: programmable_rss/rss_user.c ================================================ // SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) // Copyright (c) 2018 Netronome Systems, Inc. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "rss_common.h" static int ifindex; static __u32 xdp_flags; static void unload_prog(int sig) { bpf_set_link_xdp_fd(ifindex, -1, xdp_flags); printf("unloading xdp program...\n"); exit(0); } static int get_interface_rx_channels(int ifindex) { struct ethtool_channels cmd; struct ifreq req; int socketfd; socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (socketfd == -1) return -1; /* get interface name */ req.ifr_ifindex = ifindex; if (ioctl(socketfd, SIOCGIFNAME, &req) == -1) return -1; /* get ethtool channels */ req.ifr_data = (void *)&cmd; cmd.cmd = ETHTOOL_GCHANNELS; if (ioctl(socketfd, SIOCETHTOOL, &req) == -1) return -1; return cmd.combined_count + cmd.rx_count; } static int poll_stats(int indirect_map_fd, int queues_enabled, int poll_secs) { struct indirect_queue indirect_lookup; int values[queues_enabled]; int prev[queues_enabled]; struct timespec t1, t2; double time_taken; long queue_rate; int queue; int i; /* initialize arrays */ memset(prev, 0, sizeof(prev)); memset(values, 0, sizeof(prev)); /* use thousand separators in printf */ setlocale(LC_NUMERIC, "en_US"); clock_gettime(CLOCK_MONOTONIC_RAW, &t1); while (true) { printf("-------------------------------------------------\n\n"); for (i = 0; i < MAX_RSS_QUEUES; i++) { if (bpf_map_lookup_elem(indirect_map_fd, &i, &indirect_lookup) != 0) { printf("Err lookup failed\n"); return 0; } queue = indirect_lookup.queue_num; values[queue] += indirect_lookup.packet_cnt; } clock_gettime(CLOCK_MONOTONIC_RAW, &t2); /* calc sample period to allow rate to be obtained */ time_taken = (t2.tv_sec + 1.0e-9 * t2.tv_nsec) - (t1.tv_sec + 1.0e-9 * t1.tv_nsec); for (i = 0; i < queues_enabled; i++) { queue_rate = (values[i] - prev[i]) / time_taken; printf("RSS Queue %d: %'ld\n", i, queue_rate); prev[i] = values[i]; values[i] = 0; } t1 = t2; usleep(poll_secs * 1000 * 1000); } } static void usage(const char *prog) { fprintf(stderr, "%s -i interface [OPTS]\n\n" "OPTS:\n" " -q QUEUE send all traffic to single queue\n" " -j jhash incoming IP and ports\n" " -s jhash with Symmetric RSS\n" " -e jhash Encapsulated IPinIP headers\n" " -m QUEUES set maximum number of queues for jhash\n", prog); } int main(int argc, char **argv) { struct bpf_prog_load_attr prog_load_attr = { .prog_type = BPF_PROG_TYPE_XDP, .file = "rss_kern.o", }; struct indirect_queue indirect_rec = {}; struct queue_select_ctrl mapctrl; struct bpf_map *indirect_map; struct bpf_map *ctrl_map; struct bpf_object *obj; int queues_enabled = 0; int indirect_map_fd; int ethtool_queues; int ctrl_map_fd; int prog_fd; int key; int opt; int i; mapctrl.select_mode = QUEUE_HASH; xdp_flags = XDP_FLAGS_HW_MODE; /* set HW offload flag */ if (optind == argc) { usage(basename(argv[0])); return -1; } while ((opt = getopt(argc, argv, "hi:q:jsem:")) != -1) { switch (opt) { case 'h': usage(basename(argv[0])); return 0; case 'i': ifindex = if_nametoindex(optarg); break; case 'q': mapctrl.select_mode = QUEUE_STATIC; mapctrl.queue_static = atoi(optarg); break; case 'j': mapctrl.select_mode = QUEUE_HASH; break; case 's': mapctrl.select_mode = QUEUE_SYMMETRIC; break; case 'e': mapctrl.select_mode = QUEUE_ENCAP; break; case 'm': queues_enabled = atoi(optarg); break; default: printf("incorrect usage\n"); usage(basename(argv[0])); return -1; } } if (ifindex == 0) { printf("Err: Invalid interface\n"); return -1; } prog_load_attr.ifindex = ifindex; /* set offload dev ifindex */ ethtool_queues = get_interface_rx_channels(ifindex); if (ethtool_queues < 1) { printf("Err: Cannot obtain number of NIC channels\n"); return -1; } if (queues_enabled == 0) /* if no user defined max queue limit */ queues_enabled = ethtool_queues; if (queues_enabled > ethtool_queues) { printf("Err: Queues enabled exceeds netdev queues\n"); printf("Ethtool queues: %d\n", ethtool_queues); return -1; } if (mapctrl.select_mode == QUEUE_STATIC) { if (mapctrl.queue_static >= queues_enabled) { printf("Err: Queue selected exceeds queues enabled\n"); printf("Netdev queues enabled: %d\n", queues_enabled); return -1; } } /* use libbpf to load program */ if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd)) { printf("Err: Cannot load file\n"); return -1; } if (prog_fd < 1) { printf("Error creating prog_fd\n"); return -1; } signal(SIGINT, unload_prog); signal(SIGTERM, unload_prog); /* use libbpf to link program to interface with corresponding flags */ if (bpf_set_link_xdp_fd(ifindex, prog_fd, xdp_flags) < 0) { printf("Error linking fd to xdp with offload flags\n"); return -1; } ctrl_map = bpf_object__find_map_by_name(obj, "ctrl_map"); ctrl_map_fd = bpf_map__fd(ctrl_map); indirect_map = bpf_object__find_map_by_name(obj, "indirect_map"); indirect_map_fd = bpf_map__fd(indirect_map); if (!(ctrl_map_fd >= 0 && indirect_map_fd >= 0)) { printf("Err: Cannot find maps\n"); return -1; } /* fill ctrl map with hash mode queues */ key = 0; if (bpf_map_update_elem(ctrl_map_fd, &key, &mapctrl, BPF_ANY) != 0) { printf("Err: Map update\n"); return -1; } /* fill indirection map round robin using modulus */ for (i = 0; i < MAX_RSS_QUEUES; i++) { indirect_rec.queue_num = i % queues_enabled; if (bpf_map_update_elem(indirect_map_fd, &i, &indirect_rec, BPF_ANY) != 0) { printf("Err: Map update failed\n"); return -1; } } poll_stats(indirect_map_fd, queues_enabled, 1); return 0; }