]> git.proxmox.com Git - ovs.git/commitdiff
ofp-parse: Parse pipeline fields in OF1.5 packet-out
authorYi-Hung Wei <yihung.wei@gmail.com>
Mon, 15 May 2017 17:04:58 +0000 (10:04 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 31 May 2017 21:54:10 +0000 (14:54 -0700)
This patch adds support for parsing the pipeline match fields of
OpenFlow 1.5 packet-out messages. With this patch, we can use ovs-ofctl
to specify pipeline fileds for a packet-out message.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/ofp-parse.c
tests/ofproto-dpif.at
tests/ofproto.at
utilities/ovs-ofctl.8.in

index 7b0d23feb0c367216235f29c14c4ba2714cd29cd..afb8b40ccc4d838d6ee8a94c6bd0033b6e2d4b9f 100644 (file)
@@ -622,6 +622,7 @@ parse_ofp_packet_out_str__(struct ofputil_packet_out *po, char *string,
     *po = (struct ofputil_packet_out) {
         .buffer_id = UINT32_MAX,
     };
+    match_init_catchall(&po->flow_metadata);
     match_set_in_port(&po->flow_metadata, OFPP_CONTROLLER);
 
     act_str = extract_actions(string);
@@ -655,8 +656,22 @@ parse_ofp_packet_out_str__(struct ofputil_packet_out *po, char *string,
                 goto out;
             }
         } else {
-            error = xasprintf("unknown keyword %s", name);
-            goto out;
+            const struct mf_field *mf = mf_from_name(name);
+            if (!mf) {
+                error = xasprintf("unknown keyword %s", name);
+                goto out;
+            }
+
+            error = parse_field(mf, value, &po->flow_metadata,
+                                usable_protocols);
+            if (error) {
+                goto out;
+            }
+            if (!mf_is_pipeline_field(mf)) {
+                error = xasprintf("%s is not a valid pipeline field "
+                                  "for PACKET_OUT", name);
+                goto out;
+            }
         }
     }
 
index 1f6cd8422e041ab945c2d0c03100c830b8fd1ad3..743ac2ab34546ff3efafd688b1d11993e50a32c3 100644 (file)
@@ -731,6 +731,7 @@ AT_CHECK([tail -1 stdout], [0], [Datapath actions: 4,6,8,10,12,2
 ])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
 AT_SETUP([ofproto-dpif - push-pop])
 OVS_VSWITCHD_START
 add_of_ports br0 20 21 22 33 90
@@ -8368,6 +8369,50 @@ AT_CHECK([ovs-ofctl -O OpenFlow13 dump-tables br1 ], [0], [expout])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif packet-out pipeline match field (OpenFlow 1.5)])
+OVS_VSWITCHD_START
+
+AT_DATA([flows.txt], [dnl
+table=0,in_port=1 actions=controller
+table=0,tun_id=3 actions=controller
+table=0,metadata=5 actions=controller
+table=0,reg0=1,reg4=2,reg8=3,reg12=5 actions=controller
+table=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=0x01,tun_gbp_flags=0x03 actions=controller
+])
+AT_CHECK([ovs-ofctl -O OpenFlow15 add-flows br0 flows.txt])
+
+AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
+ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
+ovs-appctl -t ovs-ofctl ofctl/barrier
+ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
+AT_CAPTURE_FILE([monitor.log])
+
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=1 packet=0001020304050010203040501111 actions=table"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tunnel_id=3 packet=0001020304050010203040502222 actions=table"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,metadata=5 packet=0001020304050010203040503333 actions=table"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,reg0=1,reg4=2,reg8=3,reg12=5 packet=0001020304050010203040503333 actions=table"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=0x01,tun_gbp_flags=0x03 packet=0001020304050010203040503333 actions=table"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=2,tun_metadata33=3 packet=0001020304050010203040503333 actions=table"])
+
+ovs-appctl -t ovs-ofctl ofctl/barrier
+OVS_APP_EXIT_AND_WAIT([ovs-ofctl])
+
+AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
+OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 in_port=1 (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1111
+OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 tun_id=0x3,in_port=2 (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x2222
+OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 metadata=0x5,in_port=2 (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333
+OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 reg0=0x1,reg4=0x2,reg8=0x3,reg12=0x5,in_port=2 (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333
+OFPT_PACKET_IN (OF1.5): cookie=0x0 total_len=14 tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_gbp_id=1,tun_gbp_flags=0x3,in_port=2 (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x3333
+OFPT_BARRIER_REPLY (OF1.5):
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
 
 AT_SETUP([ofproto-dpif packet-out goto_table])
 OVS_VSWITCHD_START
index 5431f4e8d3c62043ebba5a12f318d28d2fc8cd80..6a4e26d98e7be7e32ac238f26b600d8ec0a6f225 100644 (file)
@@ -4078,6 +4078,35 @@ OFPT_BARRIER_REPLY (OF1.1):
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.5)])
+OVS_VSWITCHD_START
+
+# Start a monitor listening for packet-ins.
+AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
+ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
+ovs-appctl -t ovs-ofctl ofctl/barrier
+ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
+AT_CAPTURE_FILE([monitor.log])
+
+# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=none tun_id=0x11 metadata=0x22 packet=0001020304050010203040501234 actions=controller"])
+AT_CHECK([ovs-ofctl -O OpenFlow15 packet-out br0 "in_port=controller tun_id=0x11 metadata=0x33 packet=0001020304050010203040505678 actions=controller"])
+
+# Stop the monitor and check its output.
+ovs-appctl -t ovs-ofctl ofctl/barrier
+OVS_APP_EXIT_AND_WAIT([ovs-ofctl])
+
+AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
+OFPT_PACKET_IN (OF1.5): total_len=14 tun_id=0x11,metadata=0x22,in_port=ANY (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
+OFPT_PACKET_IN (OF1.5): total_len=14 tun_id=0x11,metadata=0x33,in_port=CONTROLLER (via packet_out) data_len=14 (unbuffered)
+vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
+OFPT_BARRIER_REPLY (OF1.5):
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 dnl This test checks that metadata and userdata are encoded in NXT_PACKET_IN2.
 AT_SETUP([ofproto - packet-out with metadata and userdata (NXT_PACKET_IN2)])
 OVS_VSWITCHD_START
index ed75b32a3808615c20c2d20594b1e33f73e835c9..6ebbc526c4bd66c2fc63c397cf7820a4cbde7829 100644 (file)
@@ -1920,6 +1920,11 @@ This can be any valid OpenFlow port number, or any of the \fBLOCAL\fR,
 .
 This field is required.
 
+.IP \fIpipeline_field\fR=\fIvalue\fR
+Optionally, user can specify a list of pipeline fields for a packet-out
+message. The supported pipeline fields includes \fBtunnel fields\fR and
+\fBregister fields\fR as defined in \fBovs\-fields\fR(7).
+
 .IP \fBpacket=\fIhex-string\fR
 The actual packet to send, expressed as a string of hexadecimal bytes.
 .