Skip to content

Commit 50f397b

Browse files
authored
clean-up trailing whitespace (p4lang#453)
These changes have been mostly auto-generated with: find . -type f -print0 | xargs -0 perl -pi -e 's/ +$//' Signed-off-by: Radostin Stoyanov <[email protected]>
1 parent 071b89a commit 50f397b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+275
-275
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ you get started with P4 programming, organized into several modules:
3131
* [Firewall](./exercises/firewall)
3232
* [Link Monitoring](./exercises/link_monitor)
3333

34-
## Presentation
34+
## Presentation
3535

3636
The slides are available [online](http://bit.ly/p4d2-2018-spring) and
3737
in the P4_tutorial.pdf in the tutorial directory.
@@ -46,7 +46,7 @@ The documentation for P4_16 and P4Runtime is available [here](https://p4.org/spe
4646
All excercises in this repository use the v1model architecture, the documentation for which is available at:
4747
1. The BMv2 Simple Switch target document accessible [here](https://github.com/p4lang/behavioral-model/blob/master/docs/simple_switch.md) talks mainly about the v1model architecture.
4848
2. The include file `v1model.p4` has extensive comments and can be accessed [here](https://github.com/p4lang/p4c/blob/master/p4include/v1model.p4).
49-
49+
5050
## Obtaining required software
5151

5252
If you are starting this tutorial at one of the proctored tutorial events,

exercises/basic/basic.p4

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ parser MyParser(packet_in packet,
6262
************ C H E C K S U M V E R I F I C A T I O N *************
6363
*************************************************************************/
6464

65-
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
65+
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
6666
apply { }
6767
}
6868

@@ -77,11 +77,11 @@ control MyIngress(inout headers hdr,
7777
action drop() {
7878
mark_to_drop(standard_metadata);
7979
}
80-
80+
8181
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
8282
/* TODO: fill out code in action body */
8383
}
84-
84+
8585
table ipv4_lpm {
8686
key = {
8787
hdr.ipv4.dstAddr: lpm;
@@ -94,7 +94,7 @@ control MyIngress(inout headers hdr,
9494
size = 1024;
9595
default_action = NoAction();
9696
}
97-
97+
9898
apply {
9999
/* TODO: fix ingress control logic
100100
* - ipv4_lpm should be applied only when IPv4 header is valid
@@ -119,10 +119,10 @@ control MyEgress(inout headers hdr,
119119

120120
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
121121
apply {
122-
update_checksum(
123-
hdr.ipv4.isValid(),
122+
update_checksum(
123+
hdr.ipv4.isValid(),
124124
{ hdr.ipv4.version,
125-
hdr.ipv4.ihl,
125+
hdr.ipv4.ihl,
126126
hdr.ipv4.diffserv,
127127
hdr.ipv4.totalLen,
128128
hdr.ipv4.identification,

exercises/basic/solution/basic.p4

+7-7
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ parser MyParser(packet_in packet,
7474
************ C H E C K S U M V E R I F I C A T I O N *************
7575
*************************************************************************/
7676

77-
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
77+
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
7878
apply { }
7979
}
8080

@@ -89,14 +89,14 @@ control MyIngress(inout headers hdr,
8989
action drop() {
9090
mark_to_drop(standard_metadata);
9191
}
92-
92+
9393
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
9494
standard_metadata.egress_spec = port;
9595
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
9696
hdr.ethernet.dstAddr = dstAddr;
9797
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
9898
}
99-
99+
100100
table ipv4_lpm {
101101
key = {
102102
hdr.ipv4.dstAddr: lpm;
@@ -109,7 +109,7 @@ control MyIngress(inout headers hdr,
109109
size = 1024;
110110
default_action = drop();
111111
}
112-
112+
113113
apply {
114114
if (hdr.ipv4.isValid()) {
115115
ipv4_lpm.apply();
@@ -133,10 +133,10 @@ control MyEgress(inout headers hdr,
133133

134134
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
135135
apply {
136-
update_checksum(
137-
hdr.ipv4.isValid(),
136+
update_checksum(
137+
hdr.ipv4.isValid(),
138138
{ hdr.ipv4.version,
139-
hdr.ipv4.ihl,
139+
hdr.ipv4.ihl,
140140
hdr.ipv4.diffserv,
141141
hdr.ipv4.totalLen,
142142
hdr.ipv4.identification,

exercises/basic/triangle-topo/topology.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"s3": { "runtime_json" : "triangle-topo/s3-runtime.json" }
1717
},
1818
"links": [
19-
["h1", "s1-p1"], ["s1-p2", "s2-p2"], ["s1-p3", "s3-p2"],
19+
["h1", "s1-p1"], ["s1-p2", "s2-p2"], ["s1-p3", "s3-p2"],
2020
["s3-p3", "s2-p3"], ["h2", "s2-p1"], ["h3", "s3-p1"]
2121
]
2222
}

exercises/basic_tunnel/basic_tunnel.p4

+6-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ parser MyParser(packet_in packet,
8686
************ C H E C K S U M V E R I F I C A T I O N *************
8787
*************************************************************************/
8888

89-
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
89+
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
9090
apply { }
9191
}
9292

@@ -101,14 +101,14 @@ control MyIngress(inout headers hdr,
101101
action drop() {
102102
mark_to_drop(standard_metadata);
103103
}
104-
104+
105105
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
106106
standard_metadata.egress_spec = port;
107107
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
108108
hdr.ethernet.dstAddr = dstAddr;
109109
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
110110
}
111-
111+
112112
table ipv4_lpm {
113113
key = {
114114
hdr.ipv4.dstAddr: lpm;
@@ -153,10 +153,10 @@ control MyEgress(inout headers hdr,
153153

154154
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
155155
apply {
156-
update_checksum(
157-
hdr.ipv4.isValid(),
156+
update_checksum(
157+
hdr.ipv4.isValid(),
158158
{ hdr.ipv4.version,
159-
hdr.ipv4.ihl,
159+
hdr.ipv4.ihl,
160160
hdr.ipv4.diffserv,
161161
hdr.ipv4.totalLen,
162162
hdr.ipv4.identification,

exercises/basic_tunnel/solution/basic_tunnel.p4

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ parser MyParser(packet_in packet,
9090
************ C H E C K S U M V E R I F I C A T I O N *************
9191
*************************************************************************/
9292

93-
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
93+
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
9494
apply { }
9595
}
9696

@@ -105,14 +105,14 @@ control MyIngress(inout headers hdr,
105105
action drop() {
106106
mark_to_drop(standard_metadata);
107107
}
108-
108+
109109
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
110110
standard_metadata.egress_spec = port;
111111
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
112112
hdr.ethernet.dstAddr = dstAddr;
113113
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
114114
}
115-
115+
116116
table ipv4_lpm {
117117
key = {
118118
hdr.ipv4.dstAddr: lpm;
@@ -125,7 +125,7 @@ control MyIngress(inout headers hdr,
125125
size = 1024;
126126
default_action = drop();
127127
}
128-
128+
129129
action myTunnel_forward(egressSpec_t port) {
130130
standard_metadata.egress_spec = port;
131131
}
@@ -171,10 +171,10 @@ control MyEgress(inout headers hdr,
171171

172172
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
173173
apply {
174-
update_checksum(
175-
hdr.ipv4.isValid(),
174+
update_checksum(
175+
hdr.ipv4.isValid(),
176176
{ hdr.ipv4.version,
177-
hdr.ipv4.ihl,
177+
hdr.ipv4.ihl,
178178
hdr.ipv4.diffserv,
179179
hdr.ipv4.totalLen,
180180
hdr.ipv4.identification,

exercises/calc/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ switch in Mininet to test its behavior.
2323
```
2424
This will:
2525
* compile `calc.p4`, and
26-
26+
2727
* start a Mininet instance with one switches (`s1`) connected to
2828
two hosts (`h1`, `h2`).
2929
* The hosts are assigned IPs of `10.0.1.1` and `10.0.1.2`.
@@ -33,8 +33,8 @@ you to test your calculator. You can run the driver program directly
3333
from the Mininet command prompt:
3434

3535
```
36-
mininet> h1 python calc.py
37-
>
36+
mininet> h1 python calc.py
37+
>
3838
```
3939

4040
3. The driver program will provide a new prompt, at which you can type
@@ -70,7 +70,7 @@ We will use the following header format:
7070
+----------------+----------------+----------------+---------------+
7171
| Result |
7272
+----------------+----------------+----------------+---------------+
73-
73+
7474

7575
- P is an ASCII Letter 'P' (0x50)
7676
- 4 is an ASCII Letter '4' (0x34)
@@ -81,7 +81,7 @@ We will use the following header format:
8181
- '&' (0x26) Result = OperandA & OperandB
8282
- '|' (0x7c) Result = OperandA | OperandB
8383
- '^' (0x5e) Result = OperandA ^ OperandB
84-
84+
8585

8686
We will assume that the calculator header is carried over Ethernet,
8787
and we will use the Ethernet type 0x1234 to indicate the presence of

exercises/calc/calc.p4

+19-19
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
* '|' (0x7c) Result = OperandA | OperandB
3030
* '^' (0x5e) Result = OperandA ^ OperandB
3131
*
32-
* The device receives a packet, performs the requested operation, fills in the
33-
* result and sends the packet back out of the same port it came in on, while
32+
* The device receives a packet, performs the requested operation, fills in the
33+
* result and sends the packet back out of the same port it came in on, while
3434
* swapping the source and destination addresses.
3535
*
3636
* If an unknown operation is specified or the header is not valid, the packet
37-
* is dropped
37+
* is dropped
3838
*/
3939

4040
#include <core.p4>
@@ -45,7 +45,7 @@
4545
*/
4646

4747
/*
48-
* Standard Ethernet header
48+
* Standard Ethernet header
4949
*/
5050
header ethernet_t {
5151
bit<48> dstAddr;
@@ -54,7 +54,7 @@ header ethernet_t {
5454
}
5555

5656
/*
57-
* This is a custom protocol header for the calculator. We'll use
57+
* This is a custom protocol header for the calculator. We'll use
5858
* etherType 0x1234 for it (see parser)
5959
*/
6060
const bit<16> P4CALC_ETYPE = 0x1234;
@@ -86,12 +86,12 @@ struct headers {
8686
}
8787

8888
/*
89-
* All metadata, globally used in the program, also needs to be assembled
90-
* into a single struct. As in the case of the headers, we only need to
89+
* All metadata, globally used in the program, also needs to be assembled
90+
* into a single struct. As in the case of the headers, we only need to
9191
* declare the type, but there is no need to instantiate it,
9292
* because it is done "by the architecture", i.e. outside of P4 functions
9393
*/
94-
94+
9595
struct metadata {
9696
/* In our case it is empty */
9797
}
@@ -102,18 +102,18 @@ struct metadata {
102102
parser MyParser(packet_in packet,
103103
out headers hdr,
104104
inout metadata meta,
105-
inout standard_metadata_t standard_metadata) {
105+
inout standard_metadata_t standard_metadata) {
106106
state start {
107107
packet.extract(hdr.ethernet);
108108
transition select(hdr.ethernet.etherType) {
109109
P4CALC_ETYPE : check_p4calc;
110110
default : accept;
111111
}
112112
}
113-
113+
114114
state check_p4calc {
115115
/* TODO: just uncomment the following parse block */
116-
/*
116+
/*
117117
transition select(packet.lookahead<p4calc_t>().p,
118118
packet.lookahead<p4calc_t>().four,
119119
packet.lookahead<p4calc_t>().ver) {
@@ -122,7 +122,7 @@ parser MyParser(packet_in packet,
122122
}
123123
*/
124124
}
125-
125+
126126
state parse_p4calc {
127127
packet.extract(hdr.p4calc);
128128
transition accept;
@@ -151,21 +151,21 @@ control MyIngress(inout headers hdr,
151151
* - Send the packet back to the port it came from
152152
by saving standard_metadata.ingress_port into
153153
standard_metadata.egress_spec
154-
*/
154+
*/
155155
}
156-
156+
157157
action operation_add() {
158158
/* TODO call send_back with operand_a + operand_b */
159159
}
160-
160+
161161
action operation_sub() {
162162
/* TODO call send_back with operand_a - operand_b */
163163
}
164-
164+
165165
action operation_and() {
166166
/* TODO call send_back with operand_a & operand_b */
167167
}
168-
168+
169169
action operation_or() {
170170
/* TODO call send_back with operand_a | operand_b */
171171
}
@@ -177,7 +177,7 @@ control MyIngress(inout headers hdr,
177177
action operation_drop() {
178178
mark_to_drop(standard_metadata);
179179
}
180-
180+
181181
table calculate {
182182
key = {
183183
hdr.p4calc.op : exact;
@@ -199,7 +199,7 @@ control MyIngress(inout headers hdr,
199199
P4CALC_CARET: operation_xor();
200200
}
201201
}
202-
202+
203203
apply {
204204
if (hdr.p4calc.isValid()) {
205205
calculate.apply();

0 commit comments

Comments
 (0)