Skip to content

Commit 46d5024

Browse files
committed
Cleanup and minor edits
1 parent dd9f962 commit 46d5024

File tree

6 files changed

+49
-54
lines changed

6 files changed

+49
-54
lines changed

EXERCISE-3.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ONOS app that includes a pipeconf. The pipeconf-related files are the following:
121121
* [PipelinerImpl.java][PipelinerImpl.java]: An implementation of the `Pipeliner`
122122
driver behavior;
123123

124-
To build the ONOS app (including the pipeconf), In the second terminal window,
124+
To build the ONOS app (including the pipeconf), in the second terminal window,
125125
use the command:
126126

127127
```
@@ -164,8 +164,7 @@ information such as:
164164
* The ONOS driver to use for each device, `stratum-bmv2` in this case;
165165
* The pipeconf to use for each device, `org.onosproject.ngsdn-tutorial` in this
166166
case, as defined in [PipeconfLoader.java][PipeconfLoader.java];
167-
* Configuration specific to our custom app, such as the `myStationMac` or a flag
168-
to signal if a switch has to be considered a spine or not.
167+
* Configuration specific to our custom app (`fabricDeviceConfig`)
169168

170169
This file contains also information related to the IPv6 configuration associated
171170
to each switch interface. We will discuss this information in more details in
@@ -180,8 +179,6 @@ $ make netcfg
180179
This command will push the `netcfg.json` to ONOS, triggering discovery and
181180
configuration of the 4 switches.
182181

183-
FIXME: do log later, or deactivate lldp app for now to avoid clogging with error messages
184-
185182
Check the ONOS log (`make onos-log`), you should see messages like:
186183

187184
```
@@ -222,8 +219,8 @@ id=device:spine1, available=true, role=MASTER, type=SWITCH, driver=stratum-bmv2:
222219
id=device:spine2, available=true, role=MASTER, type=SWITCH, driver=stratum-bmv2:org.onosproject.ngsdn-tutorial
223220
```
224221

225-
Make sure you see `available=true` for all devices. That means ONOS is connected
226-
to the device and the pipeline configuration has been pushed.
222+
Make sure you see `available=true` for all devices. That means ONOS has a gRPC
223+
channel open to the device and the pipeline configuration has been pushed.
227224

228225

229226
#### Ports
@@ -292,10 +289,10 @@ deviceId=device:leaf1, groupCount=1
292289
"Group" is an ONOS northbound abstraction that is mapped internally to different
293290
types of P4Runtime entities. In this case you should see 1 group of type `CLONE`.
294291

295-
`CLONE` groups are mapped to a P4Runtime `CloneSessionEntry`, here used to clone
296-
packets to the controller via packet-in. Note that the `id=0x63` is the same as
297-
`#define CPU_CLONE_SESSION_ID 99` in the P4 program. This ID is hardcoded in the
298-
pipeconf code, as the group is created by
292+
`CLONE` groups are mapped to P4Runtime `CloneSessionEntry` entities, here used
293+
to clone packets to the controller via packet-in. Note that the `id=0x63` is the
294+
same as `#define CPU_CLONE_SESSION_ID 99` in the P4 program. This ID is
295+
hardcoded in the pipeconf code. The group is created by
299296
[PipelinerImpl.java][PipelinerImpl.java] in response to flow objectives mapped
300297
to the ACL table and requesting to clone packets such as NDP and ARP.
301298

EXERCISE-4.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Exercise 4: Enabling link discovery via P4Runtime packet I/O
22

3-
In this exercise, you will be asked to integrate the ONOS built-in link discovery
4-
service with your P4 program. ONOS performs link discovery by using controller
5-
packet-in/out. To make this work, you will need to apply simple changes to the
6-
starter P4 code, validate the P4 changes using PTF-based data plane unit tests,
7-
and finally, apply changes to the pipeconf Java implementation to enable ONOS's
8-
built-in apps use the packet-in/out support provided by your P4 implementation.
3+
In this exercise, you will be asked to integrate the ONOS built-in link
4+
discovery service with your P4 program. ONOS performs link discovery by using
5+
controller packet-in/out. To make this work, you will need to apply simple
6+
changes to the starter P4 code, validate the P4 changes using PTF-based data
7+
plane unit tests, and finally, apply changes to the pipeconf Java implementation
8+
to enable ONOS's built-in apps to use the packet-in/out support provided by your
9+
P4 implementation.
910

1011
## Controller packet I/O with P4Runtime
1112

@@ -50,13 +51,11 @@ The P4 starter code already provides support for the following capabilities:
5051

5152
* Parse the `cpu_out` header (if the ingress port is the CPU one)
5253
* Emit the `cpu_in` header as the first one in the deparser
53-
* Skip ingress pipeline processing for packet-outs and set the egress port to
54-
the one specified in the `cpu_out` header
5554
* Provide an ACL table with ternary match fields and an action to clone
5655
packets to the CPU port (used to generate a packet-ins)
5756

58-
One piece is missing to provide complete packet-in support, and you have to modify
59-
the P4 program to implement it:
57+
Something is missing to provide complete packet-in/out support, and you have to
58+
modify the P4 program to implement it:
6059

6160
1. Open `p4src/main.p4`;
6261
2. Look for the implementation of the egress pipeline (`control EgressPipeImpl`);
@@ -230,8 +229,8 @@ Link stats are derived by ONOS by periodically obtaining the port counters for
230229
each device. ONOS internally uses gNMI to read port information, including
231230
counters.
232231

233-
In this case, you should see ~1 packet/s, as that's the rate of packet-outs
234-
generated by the `lldpprovider` app.
232+
In this case, you should see approx 1 packet/s, as that's the rate of
233+
packet-outs generated by the `lldpprovider` app.
235234

236235
## Congratulations!
237236

EXERCISE-5.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ are used to provide interface configuration to ONOS.
2727
### Our P4 implementation of L2 bridging
2828

2929
The starter P4 code already defines tables to forward packets based on the
30-
Ethernet address, precisely, two distinct tables to handle two different types
30+
Ethernet address, precisely, two distinct tables, to handle two different types
3131
of L2 entries:
3232

3333
1. Unicast entries: which will be filled in by the control plane when the
@@ -36,30 +36,29 @@ of L2 entries:
3636
(NS) messages to all host-facing ports;
3737

3838
For (2), unlike ARP messages in IPv4, which are broadcasted to Ethernet
39-
destination address FF:FF:FF:FF:FF:FF, NDP messages are sent to special
40-
Ethernet addresses specified by RFC2464. These addresses are prefixed
41-
with 33:33 and the last four octets are the last four octets of the IPv6
42-
destination multicast address. The most straightforward way of matching
43-
on such IPv6 broadcast/multicast packets, without digging in the details
44-
of RFC2464, is to use a ternary match on `33:33:**:**:**:**`, where `*` means
45-
"don't care".
39+
destination address FF:FF:FF:FF:FF:FF, NDP messages are sent to special Ethernet
40+
addresses specified by RFC2464. These addresses are prefixed with 33:33 and the
41+
last four octets are the last four octets of the IPv6 destination multicast
42+
address. The most straightforward way of matching on such IPv6
43+
broadcast/multicast packets, without digging in the details of RFC2464, is to
44+
use a ternary match on `33:33:**:**:**:**`, where `*` means "don't care".
4645

4746
For this reason, our solution defines two tables. One that matches in an exact
4847
fashion `l2_exact_table` (easier to scale on switch ASIC memory) and one that
4948
uses ternary matching `l2_ternary_table` (which requires more expensive TCAM
5049
memories, usually much smaller).
5150

5251
These tables are applied to packets in an order defined in the `apply` block
53-
area of the ingress pipeline (`IngressPipeImpl`):
52+
of the ingress pipeline (`IngressPipeImpl`):
5453

5554
```
5655
if (!l2_exact_table.apply().hit) {
5756
l2_ternary_table.apply();
5857
}
5958
```
6059

61-
The ternary table has lower priority and is applied only if a matching entry is
62-
not found in the exact one.
60+
The ternary table has lower priority and it's applied only if a matching entry
61+
is not found in the exact one.
6362

6463
**Note**: To keep things simple, we won't be using VLANs to segment our L2
6564
domains. As such, when matching packets in the `l2_ternary_table`, these will be

EXERCISE-6.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The first step will be to add new tables to `main.p4`.
9090
We already provide ways to handle NDP NS and NA exchanged by hosts connected to
9191
the same subnet (see `l2_ternary_table`). However, for hosts, the Linux
9292
networking stack takes care of generating a NDP NA reply. For the switches in
93-
our fabric, there's no Linux networking stack associated to it.
93+
our fabric, there's no traditional networking stack associated to it.
9494

9595
There are multiple solutions to this problem:
9696

@@ -106,7 +106,7 @@ There are multiple solutions to this problem:
106106
option. You can decide to go with a different one, but you should keep in mind
107107
that there will be less starter code for you to re-use.
108108

109-
The idea is simple, NDP NA packets have the same header structure as NDP NS
109+
The idea is simple: NDP NA packets have the same header structure as NDP NS
110110
ones. They are both ICMPv6 packets with different header field values, such as
111111
different ICMPv6 type, different Ethernet addresses etc. A switch that knows the
112112
MAC address of a given IPv6 target address found in an NDP NS request, can
@@ -117,13 +117,13 @@ To implement P4-based generation of NDP NA messages, look in
117117
`ndp_ns_to_na` to transform an NDP NS packet into an NDP NA one. Your task is to
118118
implement a table that uses such action.
119119

120-
This table should define a mapping between the interface IPv6 addresses
121-
provided in [netcfg.json](mininet/netcfg.json) and the `myStationMac` associated
122-
to each switch (also defined in netcfg.json). When an NDP
123-
NS packet is received, asking to resolve one of such IPv6 addresses, the
124-
`ndp_ns_to_na` action should be invoked with the given `myStationMac` as
125-
parameter. The ONOS app will be responsible of inserting entries in this table
126-
according to the content of netcfg.json.
120+
This table should define a mapping between the interface IPv6 addresses provided
121+
in [netcfg.json](mininet/netcfg.json) and the `myStationMac` associated to each
122+
switch (also defined in netcfg.json). When an NDP NS packet is received, asking
123+
to resolve one of such IPv6 addresses, the `ndp_ns_to_na` action should be
124+
invoked with the given `myStationMac` as parameter. The ONOS app will be
125+
responsible of inserting entries in this table according to the content of
126+
netcfg.json.
127127

128128
The ONOS app already provides a component
129129
[NdpReplyComponent.java](app/src/main/java/org/p4/p4d2/tutorial/NdpReplyComponent.java)

app/src/main/java/org/onosproject/ngsdn/tutorial/L2BridgingComponent.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private void insertMulticastGroup(DeviceId deviceId) {
180180
}
181181

182182
log.info("Adding L2 multicast group with {} ports on {}...",
183-
ports.size(), deviceId);
183+
ports.size(), deviceId);
184184

185185
// Forge group object.
186186
final GroupDescription multicastGroup = Utils.buildMulticastGroup(
@@ -191,7 +191,7 @@ private void insertMulticastGroup(DeviceId deviceId) {
191191
}
192192

193193
/**
194-
* Insert flow rules matching matching ethernet destination
194+
* Insert flow rules matching ethernet destination
195195
* broadcast/multicast addresses (e.g. ARP requests, NDP Neighbor
196196
* Solicitation, etc.). Such packets should be processed by the multicast
197197
* group created before.
@@ -313,7 +313,7 @@ private void insertUnmatchedBridgingFlowRule(DeviceId deviceId) {
313313
private void learnHost(Host host, DeviceId deviceId, PortNumber port) {
314314

315315
log.info("Adding L2 unicast rule on {} for host {} (port {})...",
316-
deviceId, host.id(), port);
316+
deviceId, host.id(), port);
317317

318318
// *** TODO EXERCISE 5
319319
// Modify P4Runtime entity names to match content of P4Info file (look
@@ -324,7 +324,7 @@ private void learnHost(Host host, DeviceId deviceId, PortNumber port) {
324324
final MacAddress hostMac = host.mac();
325325
final PiCriterion hostMacCriterion = PiCriterion.builder()
326326
.matchExact(PiMatchFieldId.of("MODIFY ME"),
327-
hostMac.toBytes())
327+
hostMac.toBytes())
328328
.build();
329329

330330
// Action: set output port
@@ -425,7 +425,7 @@ public void event(HostEvent event) {
425425

426426
mainComponent.getExecutorService().execute(() -> {
427427
log.info("{} event! host={}, deviceId={}, port={}",
428-
event.type(), host.id(), deviceId, port);
428+
event.type(), host.id(), deviceId, port);
429429

430430
learnHost(host, deviceId, port);
431431
});
@@ -500,7 +500,7 @@ private void setUpAllDevices() {
500500
// For all hosts connected to this device...
501501
hostService.getConnectedHosts(device.id()).forEach(
502502
host -> learnHost(host, host.location().deviceId(),
503-
host.location().port()));
503+
host.location().port()));
504504
}
505505
});
506506
}

solution/app/src/main/java/org/onosproject/ngsdn/tutorial/L2BridgingComponent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void insertMulticastGroup(DeviceId deviceId) {
191191
}
192192

193193
/**
194-
* Insert flow rules matching matching ethernet destination
194+
* Insert flow rules matching ethernet destination
195195
* broadcast/multicast addresses (e.g. ARP requests, NDP Neighbor
196196
* Solicitation, etc.). Such packets should be processed by the multicast
197197
* group created before.
@@ -273,10 +273,10 @@ private void insertUnmatchedBridgingFlowRule(DeviceId deviceId) {
273273
// Match unmatched traffic - Match ternary **:**:**:**:**:**
274274
final PiCriterion unmatchedTrafficCriterion = PiCriterion.builder()
275275
.matchTernary(
276-
PiMatchFieldId.of("hdr.ethernet.dst_addr"),
277-
MacAddress.valueOf("00:00:00:00:00:00").toBytes(),
278-
MacAddress.valueOf("00:00:00:00:00:00").toBytes())
279-
.build();
276+
PiMatchFieldId.of("hdr.ethernet.dst_addr"),
277+
MacAddress.valueOf("00:00:00:00:00:00").toBytes(),
278+
MacAddress.valueOf("00:00:00:00:00:00").toBytes())
279+
.build();
280280

281281
// Action: set multicast group id
282282
final PiAction setMcastGroupAction = PiAction.builder()

0 commit comments

Comments
 (0)