This document provides an example of a DNS filter implementation on top of NVIDIA® BlueField® DPU.
Domain name system (DNS) translates domain names to IP addresses so browsers can load internet resources. Each device connected to the internet has a unique IP address which other machines use to find the device.
The DNS process includes several steps:
- Once a user tries to log into a website using a browser, the user's device creates a DNS query and sends it to a DNS resolver.
- The DNS resolver queries the DNS domain to get an IP address by searching its cache or sending the request to another DNS server.
- Once a match is found, the DNS resolver returns the correct IP matching the DNS domain.
- The user can log into the required website using the correct IP.
DNS filter is used to offload DNS requests from the host to the BlueField DPU Arm which allows reducing CPU overhead as Arm allows further DNS processing to be done (e.g., allowlisting, logging, filtering, etc).
The DNS filter application is designed to run as a "bump-on-the-wire" on the BlueField-2 DPU instance. The DPU intercepts the traffic coming (ingress traffic) from the wire and either passes it to the Arm or forwards it to the egress port using hairpin. The decision is made by traffic classification.
The DNS filter runs on top of DOCA FLOW to classify DNS requests.
- Ingress packet types are identified using pipes which encapsulate flow rule matching patterns and actions.
- The DNS filter application builds two pipes for each port (DNS pipe and hairpin pipe). Every pipe includes exactly one entry.
- The DNS pipe matches only DNS traffic and FORWARDS it to the Arm. The hairpin pipe matches every packet (no misses). The DNS pipe serves as a root pipe and the hairpin pipe serves as a FORWARDING miss component to the DNS pipe. Therefore, every received packet is checked first against the DNS pipe, and if there is a match then it is forwarded to the Arm. Otherwise (miss case), it is forwarded to the hairpin pipe and then is matched.
- Parse application argument.
- Initialize arg parser resources.
- Register DOCA general flags.
- Parsing DPDK flags and calling
- DPDK initialization.
- Initialize DPDK ports, including mempool allocation.
- Initialize hairpin queues if needed.
- Binds hairpin queues of each port to its peer port.
- DNS filter initialization.
- DOCA flow and DOCA flow port initialization.
- Creates hairpin pipe for both ports. This pipe includes one entry that matches every type of packet (no misses) and forwards it to the egress port through hairpin.
- Creates DNS pipe, that serves as a root pipe, for both ports. The built pipe has one entry for matching DNS traffic and forwarding it to Arm. In addition, the hairpin pipe serves for a FORWARDING if the DNS entry does not match (i.e., for each non-DNS packet, packets are hairpined).
- Processing packets.
- All received packets on Arm are DNS packets, while non-DNS packets are forwarded to the egress port using hairpin allowing DNS packets to be filtered.
- DNS filter destroy.
- Frees all allocated resources.
- Please refer to the DOCA Installation Guide for details on how to install BlueField related software.
- The DNS filter example binary is located under /opt/mellanox/doca/examples/dns_filter/bin/doca_dns_filter. To re-build the application:
cd /opt/mellanox/doca/examples/dns_filter/src meson /tmp/build ninja -C /tmp/build
doca_dns_filterwill be created under /tmp/build.
- The build process depends on the
PKG_CONFIG_PATHenvironment variable to locate the DPDK libraries. If the variable was accidently corrupted, and the build fails, run the following command:
- For Ubuntu:
- For CentOS:
- For Ubuntu:
- Pre-run setup. The DNS filter example is based on DPDK libraries. Therefore, the user is required to provide DPDK flags, and allocate huge pages. Run:
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
- To run the application:
Usage: doca_dns_filter [DPDK Flags] -- [DOCA Flags] DOCA Flags: -h, --help Print a help synopsis -l, --log-level Set the log level for the app <CRITICAL=0, DEBUG=4>
/opt/mellanox/doca/examples/dns_filter/bin/doca_dns_filter -a auxiliary:mlx5_core.sf.4 -a auxiliary:mlx5_core.sf.5 -- -l 3
Or using a JSON file:
doca_dns_filter --json [json_file]
/opt/mellanox/doca/examples/dns_filter/bin/doca_dns_filter --json /root/dns_filter_params.json
Sub-Functions must be enabled according to Scalable Function Setup Guide.Note:
-a auxiliary:mlx5_core.sf.4 -a auxiliary:mlx5_core.sf.5are necessary for proper usage of the application. Modifying these flags results in unexpected behavior as only two ports are supported. The SF numbers are is arbitrary and configurable. For additional information on available flags for DPDK, use
For information on available flags for the application, use
/opt/mellanox/doca/examples/dns_filter/bin/doca_dns_filter -- -h
Refer to NVIDIA DOCA Arg Parser User Guide for more information.
|Flag Type||Short Flag||Long Flag/JSON Key||Description||JSON Content|
|DPDK flags||a||devices||Add a PCIe device into the list of devices to probe.||
|General flags||l||log-level||Sets the log level for the application:
|h||help||Print a help synopsis||N/A|
/opt/mellanox/doca/examples/dns_filter/sbin/doca_dns_filter -a 03:00.3 -a 03:00.4 -c 0xff -- -l 4
Refer to section "Running DOCA Application on Host" in NVIDIA DOCA Virtual Functions User Guide.
For instructions on running the gRPC application server on the BlueField, refer to NVIDIA DOCA gRPC Infrastructure User Guide.
To run the Python client of the gRPC-enabled application:
./doca_dns_filter_gRPC_client.py -d/--debug <server address[:server port]>
This section details the steps necessary for running the DNS filter application on NVIDIA converged accelerator. The DNS-filter application running on the converged accelerator has the same logic as described in previous sections of this page. However, instead of processing the DNS packets in the Arm, the packets are copied to the GPU memory for further processing. To make use of the GPU's capabilities, several steps must be taken.
- Refer to the DOCA Installation Guide for instructions on installing NVIDIA driver for CUDA and a CUDA-repo on your setup.
- Create sub-functions and configure the OVS according to Scalable Function Setup Guide.
- The meson version must at at least be 0.59.1 in order for meson to identify the CUDA compiler. To set up the right meson version:
- Download the
*.tarfile of the right meson version (0.59.01) from this link.
- Copy the
*.tarfile onto the BlueField.
- Untar the file:
tar -xzf meson-0.59.1.tar.gz
This untars it to the current directory. After untarring the file, a Python script called
meson.pyis extracted under
<path-to-current directory>/meson-0.59.1. Use this Python script instead of the installed meson version in the system. Going forward, this section refers to "path to the current directory" just as "path" when using meson.
- Download the
Since there is no pre-compiled DNS filter application binary provided that uses the GPU support, you must compile it and run it. All the sources needed for building, compiling, and running the application with GPU support are found under
truein the application's
meson_options.txtfile found at
- Setup CUDA path:
export CPATH=/usr/local/cuda/targets/sbsa-linux/include:$CPATH export LD_LIBRARY_PATH=/usr/local/cuda/targets/sbsa-linux/lib:$LD_LIBRARY_PATH export PATH=/usr/local/cuda/bin:/usr/local/cuda-11.4/bin:$PATH
- To build the application, run:
<path>/meson-0.59.1/meson.py /tmp/build ninja -C /tmp/build
doca_dns_filteris created under
If CUDA-11.4 is installed, the version of CUDA in the meson file must be modified to match it (11.4).
- The DNS filter example is a DPDK application. Therefore, the user is required to provide DPDK flags and allocate huge pages. Run:
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
- To run the application, follow the steps in Running Application on BlueField.
This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation nor any of its direct or indirect subsidiaries and affiliates (collectively: “NVIDIA”) make no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assume no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality.
NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document.
NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk.
NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs.
No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA.
Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices.
THIS DOCUMENT AND ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, “MATERIALS”) ARE BEING PROVIDED “AS IS.” NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Notwithstanding any damages that customer might incur for any reason whatsoever, NVIDIA’s aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms of Sale for the product.
NVIDIA, the NVIDIA logo, and Mellanox are trademarks and/or registered trademarks of Mellanox Technologies Ltd. and/or NVIDIA Corporation in the U.S. and in other countries. The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world¬wide basis. Other company and product names may be trademarks of the respective companies with which they are associated.
© 2022 NVIDIA Corporation & affiliates. All rights reserved.