CobbLiu
CobbLiu

Reputation: 457

How can I use DPDK to write a DNS server?

I want to write a high performance DNS server using Intel DPDK. How can I use Intel DPDK to process TCP packets effectively?

Sure, implement a net stack on DPDK is the solution. But it's too complicated.

As DNS server handles much more UDP queries than TCP queries, I intend to use DPDK to handle UDP queries and use linux net stack to handle TCP queries.
How can I do this on a single machine?

Upvotes: 2

Views: 3403

Answers (2)

Abhishek
Abhishek

Reputation: 283

What Gabe has suggested is correct -- However there is a better way to achieve what you really want. You need to use a bifurcated driver.

The problem with using a KNI as suggested by Gabe is this:

Its your software in user space that will decide what it needs to retain (UDP) and what all needs to be routed via a network stack (TCP). You will then pass them to the kernel via DPDK software rings that would consume CPU and memory cycles.

There will be a memory copy between your mbuf and the kernel socket buffer which will affect your KNI performance.

Also note that if you handle UDP in your user space then you need to construct the L2 header before pushing the packet out. This means that you also perhaps need to trap all ARP packets so that you can build your ARP cache, as you will need that to construct the L2 header.

Upvotes: 2

Gabe
Gabe

Reputation: 897

Look at the KNI documentation and Kernel NIC Interface example in the DPDK.

After allocating your KNI device, in you main DPDK polling loop you will pull packets off of the NIC. You'll have to parse the header yourself, or you could get fancy and set up multiple RX queues and then use RSS 5-tuple filters to send UDP packets to your processing queue, and the rest to the default queue.

Anyway, regardless of the method chosen, if it is a UDP packet you can handle it your self (like you requested); otherwise, you will queue the packet on to the KNI thread. You will also need the other half of the KNI interface as well, where you poll packets off of the KNI thread, and send it out the interface.

This is exactly the way we do it in our application where we still want a linux networking stack for all operations other than our specific traffic.

Upvotes: 1

Related Questions