From 119f267938e994bc8053f380231ace79176728c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Soul=C3=A9?= Date: Fri, 22 Sep 2017 09:32:00 -0700 Subject: [PATCH] Fix for issue 32. (#33) * This commit includes example tutorials and solutions for P4D2 2017. - Added example P4 programs for ipv4_forwarding, mri, arp, calc - Added python code to invoke compiler, start bmv2, run mininet - Added solutions to above programs - Added README files that describe exercises * Fix for issue #32. The text had said the name of the action should be ipv4_forward, when it should have been set_dst_info. --- P4D2_2017/exercises/arp/README.md | 4 ++-- P4D2_2017/exercises/arp/arp.p4 | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/P4D2_2017/exercises/arp/README.md b/P4D2_2017/exercises/arp/README.md index 1a71dac..1160e3d 100644 --- a/P4D2_2017/exercises/arp/README.md +++ b/P4D2_2017/exercises/arp/README.md @@ -117,11 +117,11 @@ well as a hard-coded MAC address for the switch. 1. An action for `drop`. - 1. An action (named `ipv4_forward`) to store information in the metadata + 1. An action (named `set_dst_info`) to store information in the metadata structure, rather than immediately writing to the packet header. 1. A table (named `ipv4_lpm`) that will match on the destination IP address - and invoke the `ipv4_forward` action. + and invoke the `set_dst_info` action. 1. An action to send an ICMP reply. diff --git a/P4D2_2017/exercises/arp/arp.p4 b/P4D2_2017/exercises/arp/arp.p4 index 5c80530..0193407 100644 --- a/P4D2_2017/exercises/arp/arp.p4 +++ b/P4D2_2017/exercises/arp/arp.p4 @@ -173,10 +173,21 @@ control MyIngress( /* TODO: Define actions and tables here */ + + action set_dst_info(mac_addr_t mac_da, + mac_addr_t mac_sa, + port_id_t egress_port) + { + /* + * TODO: add logic to store mac addresses and + * egress ports in meta data + */ + } + table ipv4_lpm { key = { meta.dst_ipv4 : lpm; } - actions = { /* TODO: add actions */ drop; } + actions = { set_dst_info; drop; } default_action = drop(); }