Git Product home page Git Product logo

xdp-test-suite-xdp-filter's Introduction

XDP test harness

A test harness that can be used to test the implementation of XDP and XDP programs.

Quick start

Run # ./run_netns.sh "client test_xdp_filter" . File run_netns.sh starts the tests in separate network namespace. File xdp_filter-exec.sh circumvents xdp-filter looking for the XDP program’s file only in active directory.

Requirements

Python 3.5, bcc, Pyroute2, Scapy

Usage

Running

To start the test suite, start ./run.py as a superuser. There are three commands that can be used:

client

Start a client, running tests using network interfaces to process packets by XDP program. One can further specify which tests to run, using unittest’s format. That is modules, classes and methods separated by dots, for example ./run.py client test_general.ReturnValuesBasic.

bptr

Similar to the client command, but uses the BPF_PROG_TEST_RUN syscall command instead of a server to process packets by an XDP program.

server

Starts a server, used by client command to send packets.

Configuration

Configuration of interfaces to be used for testing is done in the config.py file. In the configuration file there are two variables:

local_server_ctx

A variable specifying the interface of the server, used for testing, and the interface of the server used for communication with a client.

local_server_ctx = ContextServer(
    ContextLocal("enp0s31f6"),
    ContextCommunication("192.168.0.106", 6555),
)

remote_server_ctxs

List of contexts specifying one physical testing interface and one virtual testing interface. Elements of the list are either ContextClient objects, for physical interfaces, or objects created by new_virtual_ctx function, for virtual interfaces.

remote_server_ctxs = ContextClientList([
    ContextClient(
	  ContextLocal("enp0s31f6", xdp_mode=XDPFlag.SKB_MODE),
	  ContextCommunication("192.168.0.107", 6555)
    ),
    new_virtual_ctx(
	  ContextLocal("a_to_b", xdp_mode=XDPFlag.DRV_MODE),
	  ContextCommunication("192.168.1.1"),
	  "test_b",
	  ContextLocal("b_to_a", xdp_mode=XDPFlag.DRV_MODE),
	  ContextCommunication("192.168.1.2", 6000),
    ),
])

Creating new tests

To create a new test, create a class inheriting from XDPCase. This class should be located in a file named with a test_ prefix and placed in the tests folder. Each method of this class, that should be run while testing, has to be named with a test_ prefix.

Each test should either call both load_bpf and attach_xdp methods in this order, before calling send_packets, or be decorated with usingCustomLoader and attach own XDP program to the interface. After attaching attaching an XDP program, calling send_packets, returns a SendResult object, containing lists of packets that arrived to each interface engaged in testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.