Skip to contentSkip to conversation

ila: ilarouter bpf code for tc and xdp

RFC PATCH In review Alexei Starovoitov 2 participants 4 messages Sep 23, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ila: ilarouter bpf code for tc and xdp

From: Aaron Yue <[email protected]>

Jesper,

here is old email and cover letter that didn't make it to the list due to vger outage (I guess).
The verifier patch that Aaron is talking about has landed long ago.

The dataplane of ILA router is very short and simple.
Control plane is very different matter. It's not ready for prime time yet.

----------

This patch contains the tc and xdp implementation of kernelspace bpf code. It requires userspace to insert to the ILA bpf maps, in tc's case, the precomputed ILA mappings, and in xdp's case, both the precomputed ILA mappings and the MAC address.

The xdp bpf code also requires a verifier patch to allow direct map access from the packet (will be patched in by Alexei).

Aaron Yue (2):
samples/bpf: ilarouter for tc
samples/bpf: ilarouter for xdp

 samples/bpf/Makefile        |   2 +
 samples/bpf/ila.h           |  80 ++++++++++++++++++++++++++++
 samples/bpf/ilarouter_tc.c  | 124 ++++++++++++++++++++++++++++++++++++++++++++
 samples/bpf/ilarouter_xdp.c |  88 +++++++++++++++++++++++++++++++
 samples/bpf/inet_helper.h   |  38 ++++++++++++++
 5 files changed, 332 insertions(+)
 create mode 100644 samples/bpf/ila.h
 create mode 100644 samples/bpf/ilarouter_tc.c
 create mode 100644 samples/bpf/ilarouter_xdp.c
 create mode 100644 samples/bpf/inet_helper.h
Signature · 1 line
2.8.0.rc2
#1 lore raw

RFC PATCH 1/2 samples/bpf: ilarouter for tc

From: Aaron Yue <[email protected]>

From: Aaron Yue <[email protected]>

Requires a userspace program to insert ila mappings to the ila map.

---
 samples/bpf/Makefile       |   1 +
 samples/bpf/ila.h          |  80 +++++++++++++++++++++++++++++
 samples/bpf/ilarouter_tc.c | 124 +++++++++++++++++++++++++++++++++++++++++++++
 samples/bpf/inet_helper.h  |  38 ++++++++++++++
 4 files changed, 243 insertions(+)
 create mode 100644 samples/bpf/ila.h
 create mode 100644 samples/bpf/ilarouter_tc.c
 create mode 100644 samples/bpf/inet_helper.h
samples/bpf/Makefile +1 -0
index 90ebf7d..15e19bb 100644
@@ -74,6 +74,7 @@ always += parse_varlen.o parse_simple.o parse_ldabs.o
 always += test_cgrp2_tc_kern.o
 always += xdp1_kern.o
 always += xdp2_kern.o
+always += ilarouter_tc.o
 
 HOSTCFLAGS += -I$(objtree)/usr/include
 
samples/bpf/ila.h new file +80 -0

80 lines not on this page · raw message

samples/bpf/ilarouter_tc.c new file +124 -0

124 lines not on this page · raw message

samples/bpf/inet_helper.h new file +38 -0
new file mode 100644
index 0000000..d5fc281
@@ -0,0 +1,38 @@
+#ifndef __INET_HELPER_H
+#define __INET_HELPER_H
+
+#include <linux/inet.h>
+
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+#define _htonl(A) __builtin_bswap32(A)
+#elif defined(__BIG_ENDIAN_BITFIELD)
+#define _htonl(A) (A)
+#else
+#error "Fix asm/byteorder.h"
+#endif
+
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+#define _ntohl(A) __builtin_bswap32(A)
+#elif defined(__BIG_ENDIAN_BITFIELD)
+#define _ntohl(A) (A)
+#else
+#error "Fix asm/byteorder.h"
+#endif
+
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+#define _htonll(A) __builtin_bswap64(A)
+#elif defined(__BIG_ENDIAN_BITFIELD)
+#define _htonll(A) (A)
+#else
+#error "Fix asm/byteorder.h"
+#endif
+
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+#define _ntohll(A) __builtin_bswap64(A)
+#elif defined(__BIG_ENDIAN_BITFIELD)
+#define _ntohll(A) (A)
+#else
+#error "Fix asm/byteorder.h"
+#endif
+
+#endif
Signature · 1 line
2.8.0.rc2
#2 lore raw

RFC PATCH 2/2 samples/bpf: ilarouter for xdp

In reply to Alexei Starovoitov

From: Aaron Yue <[email protected]>

From: Aaron Yue <[email protected]>

Requires a userspace program to insert ila mappings and mac addresses to the ila map. Needs a verifier patch to directly allow access to the pkt from the bpf map.

---
 samples/bpf/Makefile        |  1 +
 samples/bpf/ilarouter_xdp.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
 create mode 100644 samples/bpf/ilarouter_xdp.c
samples/bpf/Makefile +1 -0
index 15e19bb..827e6e8 100644
@@ -75,6 +75,7 @@ always += test_cgrp2_tc_kern.o
 always += xdp1_kern.o
 always += xdp2_kern.o
 always += ilarouter_tc.o
+always += ilarouter_xdp.o
 
 HOSTCFLAGS += -I$(objtree)/usr/include
 
samples/bpf/ilarouter_xdp.c new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.8.0.rc2
#3 lore raw
In reply to Alexei Starovoitov
Quoted 9 lines · On Fri, 23 Sep 2016 10:16:33 -0700 Alexei Starovoitov <[email protected]> wrote:

From: Aaron Yue <[email protected]>

Jesper,

here is old email and cover letter that didn't make it to the list due to vger outage (I guess).
The verifier patch that Aaron is talking about has landed long ago.

The dataplane of ILA router is very short and simple.

Yes, looks very simple indeed! Cool! :-)

Quoted 26 lines

Control plane is very different matter. It's not ready for prime time yet.

----------

This patch contains the tc and xdp implementation of kernelspace bpf code. It requires userspace to insert to the ILA bpf maps, in tc's case, the precomputed ILA mappings, and in xdp's case, both the precomputed ILA mappings and the MAC address.

The xdp bpf code also requires a verifier patch to allow direct map access from the packet (will be patched in by Alexei).

Aaron Yue (2):
samples/bpf: ilarouter for tc
samples/bpf: ilarouter for xdp

 samples/bpf/Makefile        |   2 +
 samples/bpf/ila.h           |  80 ++++++++++++++++++++++++++++
 samples/bpf/ilarouter_tc.c  | 124 ++++++++++++++++++++++++++++++++++++++++++++
 samples/bpf/ilarouter_xdp.c |  88 +++++++++++++++++++++++++++++++
 samples/bpf/inet_helper.h   |  38 ++++++++++++++
 5 files changed, 332 insertions(+)
 create mode 100644 samples/bpf/ila.h
 create mode 100644 samples/bpf/ilarouter_tc.c
 create mode 100644 samples/bpf/ilarouter_xdp.c
 create mode 100644 samples/bpf/inet_helper.h
Signature · 5 lines
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer