create P4 basis + smaller updates

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2019-02-21 23:19:17 +01:00
parent 7f904bdcef
commit b6bd281c3a
8 changed files with 151 additions and 3 deletions

9
doc/.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
*.pdf
plan.tex
*.aux
*.glo
*.lof
*.log
*.lot
*.out
*.toc

Binary file not shown.

View file

@ -104,10 +104,22 @@ user@T:~# iptables -t mangle -A PREROUTING \
**** Cisco (?) **** Cisco (?)
*** P4 based implementation *** P4 based implementation
TBD TBD
**** Static mappings **** General
- need table - IPv6 subnet 2001:db8::/32
- need tcp & udp translation - IPv6 hosts are in 2001:db8:6::/64
- IPv6 default router (::/0) is 2001:db8:6::42/64
- IPv4 mapped Internet "NAT64 prefix" 2001:db8:4444::/96 (should
go into a table)
- IPv4 hosts are in 10.0.4.0/24
- IPv6 in IPv4 mapped hosts are in 10.0.6.0/24
- IPv4 default router = 10.0.0.42
**** Static mappings
- likely need table(s)
- need tcp & udp translation
***** Hosts
****** Left side: IPv6
****** Right side: IPv4
**** Requirements **** Requirements
- -
*** Performance comparison *** Performance comparison

37
p4app/static-mapping.sh Normal file
View file

@ -0,0 +1,37 @@
#!/bin/sh
set -x
# cleanup
for i in 1 2 3 4; do
mx h$i "ip addr flush dev $dev"
done
# host 1/2+42 need NDP for reaching themselves
for i in 1 2; do
dev="h$i-eth0"
# add and enable ipv6
mx h$i "sysctl net.ipv6.conf.{lo,h$i-eth0}.disable_ipv6=0"
mx h$i "ip addr add 2001:db8:6::$i/64 dev $dev"
mx h$i "ip -6 route add default via 2001:db8:6::42"
# add neighbors
for j in 1 2 42; do
mx h$i "ip -6 neigh add 2001:db8:6::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
done
done
# host 3/4 need ARP, also need access to .42 (virtual IP)
for i in 3 4; do
dev="h$i-eth0"
mx h$i "ip addr add 10.0.0.$i/24 dev $dev"
# add arp
for j in 1 2 42; do
mx h$i "ip neigh add 10.0.0.${j} dev $dev lladdr 00:00:0a:00:00:${j}"
done
done
for i in 1 2 3 4; do
mx h$i "ip neigh show"
done

28
p4src/checksums.p4 Normal file
View file

@ -0,0 +1,28 @@
/* -*- P4_16 -*- */
#ifndef CHECKSUMS_P4
#define CHECKSUMS_P4
#include <core.p4>
#include <v1model.p4>
#include "headers.p4"
/*************************************************************************
************* C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
/*************************************************************************
************** C H E C K S U M C O M P U T A T I O N **************
*************************************************************************/
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
apply {
}
}
#endif

View file

@ -14,6 +14,7 @@ typedef bit<9> port_t;
const bit<16> TYPE_IPV4 = 0x0800; const bit<16> TYPE_IPV4 = 0x0800;
const bit<16> TYPE_IPV6 = 0x86DD; const bit<16> TYPE_IPV6 = 0x86DD;
const bit<8> TYPE_TCP = 6; const bit<8> TYPE_TCP = 6;
const bit<8> TCP_SEQ_LEN = 4;
header ethernet_t { header ethernet_t {

12
p4src/settings.p4 Normal file
View file

@ -0,0 +1,12 @@
/* -*- P4_16 -*- */
/* table sizes, register widths, and such */
#ifndef SETTINGS_P4
#define SETTINGS_P4
#include <core.p4>
#include <v1model.p4>
#define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42
#endif

49
p4src/static-mapping.p4 Normal file
View file

@ -0,0 +1,49 @@
/* -*- P4_16 -*- */
#include <core.p4>
#include <v1model.p4>
#include "headers.p4"
#include "parsers.p4"
#include "checksums.p4"
#include "settings.p4"
/*************************************************************************
************** I N G R E S S P R O C E S S I N G *******************
*************************************************************************/
control MyIngress(inout headers hdr,
inout metadata meta,
inout standard_metadata_t standard_metadata) {
apply {
}
}
/*************************************************************************
**************** E G R E S S P R O C E S S I N G *******************
*************************************************************************/
control MyEgress(inout headers hdr,
inout metadata meta,
inout standard_metadata_t standard_metadata) {
apply {
/* set tcp header valid after modifying it -- keep this in mind*/
// hdr.tcp.setValid();
}
}
/*************************************************************************
*********************** S W I T C H *******************************
*************************************************************************/
V1Switch(
MyParser(),
MyVerifyChecksum(),
MyIngress(),
MyEgress(),
MyComputeChecksum(),
MyDeparser()
) main;