Skip to content

Commit 11514e2

Browse files
committed
Take solution from PTF tests and align P4 one with starter code
1 parent 7dfa686 commit 11514e2

File tree

10 files changed

+1354
-234
lines changed

10 files changed

+1354
-234
lines changed

p4src/main.p4

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,23 +426,23 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
426426

427427
// *** TODO EXERCISE 6 (IPV6 ROUTING)
428428
//
429-
// 1. Create table to handle IPv6 routing. Create a L2 my station table (hit
429+
// 1. Create a table to to handle NDP messages to resolve the MAC address of
430+
// switch. This table should:
431+
// - match on hdr.ndp.target_ipv6_addr (exact match)
432+
// - provide action "ndp_ns_to_na" (look in snippets.p4)
433+
// - default_action should be "NoAction"
434+
//
435+
// 2. Create table to handle IPv6 routing. Create a L2 my station table (hit
430436
// when Ethernet destination address is the switch address). This table
431437
// should not do anything to the packet (i.e., NoAction), but the control
432438
// block below should use the result (table.hit) to decide how to process
433439
// the packet.
434440
//
435-
// 2. Create a table for IPv6 routing. An action selector should be use to
441+
// 3. Create a table for IPv6 routing. An action selector should be use to
436442
// pick a next hop MAC address according to a hash of packet header
437443
// fields (IPv6 source/destination address and the flow label). Look in
438444
// snippets.p4 for an example of an action selector and table using it.
439445
//
440-
// 3. Create a table to to handle NDP messages to resolve the MAC address of
441-
// switch. This table should:
442-
// - match on hdr.ndp.target_ipv6_addr (exact match)
443-
// - provide action "ndp_ns_to_na" (look in snippets.p4)
444-
// - default_action should be "NoAction"
445-
//
446446
// You can name your tables whatever you like. You will need to fill
447447
// the name in elsewhere in this exercise.
448448

@@ -502,7 +502,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
502502
// controller:
503503
// 1. Set the packet egress port to that found in the cpu_out header
504504
// 2. Remove (set invalid) the cpu_out header
505-
// 3. Exit the pipeline here (no need to go through other tables)
505+
// 3. Exit the pipeline here (no need to go through other tables
506506
}
507507

508508
bool do_l3_l2 = true;

ptf/tests/bridging.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ def testPacket(self, pkt):
8080
# qualified name of tables, match fields, and actions.
8181
# ---- START SOLUTION ----
8282
self.insert(self.helper.build_table_entry(
83-
table_name="IngressPipeImpl.l2_ternary_table",
83+
table_name="MODIFY ME",
8484
match_fields={
8585
# Ternary match.
86-
"hdr.ethernet.dst_addr": (
86+
"MODIFY ME": (
8787
"FF:FF:FF:FF:FF:FF",
8888
"FF:FF:FF:FF:FF:FF")
8989
},
90-
action_name="IngressPipeImpl.set_multicast_group",
90+
action_name="MODIFY ME",
9191
action_params={
92-
"gid": mcast_group_id
92+
"MODIFY ME": mcast_group_id
9393
},
9494
priority=DEFAULT_PRIORITY
9595
))
@@ -101,14 +101,14 @@ def testPacket(self, pkt):
101101
# qualified name of tables, match fields, and actions.
102102
# ---- START SOLUTION ----
103103
self.insert(self.helper.build_table_entry(
104-
table_name="IngressPipeImpl.l2_ternary_table",
104+
table_name="MODIFY ME",
105105
match_fields={
106106
# Ternary match (value, mask)
107-
"hdr.ethernet.dst_addr": (
107+
"MODIFY ME": (
108108
"33:33:00:00:00:00",
109109
"FF:FF:00:00:00:00")
110110
},
111-
action_name="IngressPipeImpl.set_multicast_group",
111+
action_name="MODIFY ME",
112112
action_params={
113113
"gid": mcast_group_id
114114
},
@@ -196,14 +196,14 @@ def testPacket(self, pkt):
196196
# qualified name of tables, match fields, and actions.
197197
# ---- START SOLUTION ----
198198
self.insert(self.helper.build_table_entry(
199-
table_name="IngressPipeImpl.l2_exact_table",
199+
table_name="MODIFY ME",
200200
match_fields={
201201
# Exact match.
202-
"hdr.ethernet.dst_addr": pkt[Ether].dst
202+
"MODIFY ME": pkt[Ether].dst
203203
},
204-
action_name="IngressPipeImpl.set_egress_port",
204+
action_name="MODIFY ME",
205205
action_params={
206-
"port_num": self.port2
206+
"MODIFY ME": self.port2
207207
}
208208
))
209209
# ---- END SOLUTION ----
@@ -273,14 +273,14 @@ def testPacket(self, pkt):
273273
# qualified name of tables, match fields, and actions.
274274
# ---- START SOLUTION ----
275275
self.insert(self.helper.build_table_entry(
276-
table_name="IngressPipeImpl.l2_exact_table",
276+
table_name="MODIFY ME",
277277
match_fields={
278278
# Exact match.
279-
"hdr.ethernet.dst_addr": pkt[Ether].dst
279+
"MODIFY ME": pkt[Ether].dst
280280
},
281-
action_name="IngressPipeImpl.set_egress_port",
281+
action_name="MODIFY ME",
282282
action_params={
283-
"port_num": self.port2
283+
"MODIFY ME": self.port2
284284
}
285285
))
286286
# ---- END SOLUTION ----
@@ -294,14 +294,14 @@ def testPacket(self, pkt):
294294
# qualified name of tables, match fields, and actions.
295295
# ---- START SOLUTION ----
296296
self.insert(self.helper.build_table_entry(
297-
table_name="IngressPipeImpl.l2_exact_table",
297+
table_name="MODIFY ME",
298298
match_fields={
299299
# Exact match.
300-
"hdr.ethernet.dst_addr": pkt2[Ether].dst
300+
"MODIFY ME": pkt2[Ether].dst
301301
},
302-
action_name="IngressPipeImpl.set_egress_port",
302+
action_name="MODIFY ME",
303303
action_params={
304-
"port_num": self.port1
304+
"MODIFY ME": self.port1
305305
}
306306
))
307307
# ---- END SOLUTION ----

ptf/tests/packetio.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def testPacket(self, pkt):
6767
packet_out_msg = self.helper.build_packet_out(
6868
payload=str(pkt),
6969
metadata={
70-
"egress_port": outport,
70+
"MODIFY ME": outport,
7171
"_pad": 0
7272
})
7373
# ---- END SOLUTION ----
@@ -110,12 +110,12 @@ def testPacket(self, pkt):
110110
# clone_to_cpu action.
111111
# ---- START SOLUTION ----
112112
self.insert(self.helper.build_table_entry(
113-
table_name="IngressPipeImpl.acl_table",
113+
table_name="MODIFY ME",
114114
match_fields={
115115
# Ternary match.
116-
"hdr.ethernet.ether_type": (eth_type, 0xffff)
116+
"MODIFY ME": (eth_type, 0xffff)
117117
},
118-
action_name="IngressPipeImpl.clone_to_cpu",
118+
action_name="MODIFY ME",
119119
priority=DEFAULT_PRIORITY
120120
))
121121
# ---- END SOLUTION ----
@@ -128,7 +128,7 @@ def testPacket(self, pkt):
128128
exp_packet_in_msg = self.helper.build_packet_in(
129129
payload=str(pkt),
130130
metadata={
131-
"ingress_port": inport,
131+
"MODIFY ME": inport,
132132
"_pad": 0
133133
})
134134
# ---- END SOLUTION ----

ptf/tests/routing.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def testPacket(self, pkt):
6464
# qualified name of tables, match fields, and actions.
6565
# ---- START SOLUTION ----
6666
self.insert(self.helper.build_table_entry(
67-
table_name="IngressPipeImpl.my_station_table",
67+
table_name="MODIFY ME",
6868
match_fields={
6969
# Exact match.
70-
"hdr.ethernet.dst_addr": pkt[Ether].dst
70+
"MODIFY ME": pkt[Ether].dst
7171
},
7272
action_name="NoAction"
7373
))
@@ -79,25 +79,25 @@ def testPacket(self, pkt):
7979
# qualified name of tables, match fields, and actions.
8080
# ---- START SOLUTION ----
8181
self.insert(self.helper.build_act_prof_group(
82-
act_prof_name="IngressPipeImpl.ecmp_selector",
82+
act_prof_name="MODIFY ME",
8383
group_id=1,
8484
actions=[
8585
# List of tuples (action name, action param dict)
86-
("IngressPipeImpl.set_next_hop", {"dmac": next_hop_mac}),
86+
("MODIFY ME", {"MODIFY ME": next_hop_mac}),
8787
]
8888
))
8989
# ---- END SOLUTION ----
9090

91-
# Insert L3 entry to app pkt's IPv6 dst addr to group
91+
# Insert L3 routing entry to map pkt's IPv6 dst addr to group
9292
# *** TODO EXERCISE 6
9393
# Modify names to match content of P4Info file (look for the fully
9494
# qualified name of tables, match fields, and actions.
9595
# ---- START SOLUTION ----
9696
self.insert(self.helper.build_table_entry(
97-
table_name="IngressPipeImpl.routing_v6_table",
97+
table_name="MODIFY ME",
9898
match_fields={
9999
# LPM match (value, prefix)
100-
"hdr.ipv6.dst_addr": (pkt[IPv6].dst, 128)
100+
"MODIFY ME": (pkt[IPv6].dst, 128)
101101
},
102102
group_id=1
103103
))
@@ -109,14 +109,14 @@ def testPacket(self, pkt):
109109
# qualified name of tables, match fields, and actions.
110110
# ---- START SOLUTION ----
111111
self.insert(self.helper.build_table_entry(
112-
table_name="IngressPipeImpl.l2_exact_table",
112+
table_name="MODIFY ME",
113113
match_fields={
114114
# Exact match
115-
"hdr.ethernet.dst_addr": next_hop_mac
115+
"MODIFY ME": next_hop_mac
116116
},
117-
action_name="IngressPipeImpl.set_egress_port",
117+
action_name="MODIFY ME",
118118
action_params={
119-
"port_num": self.port2
119+
"MODIFY ME": self.port2
120120
}
121121
))
122122
# ---- END SOLUTION ----
@@ -143,18 +143,23 @@ def runTest(self):
143143
target_mac = SWITCH1_MAC
144144

145145
# Insert entry to transform NDP NA packets for the given target address
146-
# (match), to NDP NA packets with the given target MAC address (action)
146+
# (match), to NDP NA packets with the given target MAC address (action
147+
# *** TODO EXERCISE 6
148+
# Modify names to match content of P4Info file (look for the fully
149+
# qualified name of tables, match fields, and actions.
150+
# ---- START SOLUTION ----
147151
self.insert(self.helper.build_table_entry(
148-
table_name="IngressPipeImpl.ndp_reply_table",
152+
table_name="MODIFY ME",
149153
match_fields={
150154
# Exact match.
151-
"hdr.ndp.target_ipv6_addr": switch_ip
155+
"MODIFY ME": switch_ip
152156
},
153-
action_name="IngressPipeImpl.ndp_ns_to_na",
157+
action_name="MODIFY ME",
154158
action_params={
155-
"target_mac": target_mac
159+
"MODIFY ME": target_mac
156160
}
157161
))
162+
# ---- END SOLUTION ----
158163

159164
# NDP Neighbor Solicitation packet
160165
pkt = genNdpNsPkt(target_ip=switch_ip)

0 commit comments

Comments
 (0)