[ovs-dev] [PATCH 10/41] ofp-util: Allow decoding of Open Flow 1.1 and 1.2 Packet Out Messages
Simon Horman
horms at verge.net.au
Tue Aug 7 21:49:45 UTC 2012
Signed-off-by: Simon Horman <horms at verge.net.au>
---
v10
* No change
v9
* No change
v8
* Return error value returned by ofputil_port_from_ofp11()
rather than OFPERR_OFPBMC_BAD_VALUE.
- This fix, from v3, disappeared somewhere along the way
* Add ofp-print test for Open Flow 1.2
- I'm not sure how to generate an Open Flow 1.1 message at this point
v7
* Manual rebase
v6
* No change
v5
* No change
v4
* No change
v3
* Manual rebase
* Correct title: This patch relates to Packet Out not Packet In
* Use OFPT_PACKET_OUT instead of OFPT11_PACKET_OUT, it seems
easier to use a single code and differentiate using the version
in the ofp_header
* Return error value returned by ofputil_port_from_ofp11()
rather than OFPERR_OFPBMC_BAD_VALUE.
v2
* No change
---
lib/ofp-util.c | 19 ++++++++++++++++++-
tests/ofp-print.at | 13 ++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 1972b25..10b4555 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2157,7 +2157,24 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po,
ofpbuf_use_const(&b, oh, ntohs(oh->length));
raw = ofpraw_pull_assert(&b);
- if (raw == OFPRAW_OFPT10_PACKET_OUT) {
+ if (raw == OFPRAW_OFPT11_PACKET_OUT) {
+ enum ofperr error;
+ const struct ofp11_packet_out *opo = ofpbuf_pull(&b, sizeof *opo);
+
+ po->buffer_id = ntohl(opo->buffer_id);
+ error = ofputil_port_from_ofp11(opo->in_port, &po->in_port);
+ if (error) {
+ return error;
+ }
+
+ error = ofpacts_pull_openflow11_actions(&b, ntohs(opo->actions_len),
+ ofpacts);
+ if (error) {
+ return error;
+ }
+
+ bad_in_port_err = OFPERR_OFPBMC_BAD_VALUE;
+ } else if (raw == OFPRAW_OFPT10_PACKET_OUT) {
enum ofperr error;
const struct ofp_packet_out *opo = ofpbuf_pull(&b, sizeof *opo);
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 2c4e6c5..842869c 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -406,7 +406,7 @@ OFPT_PORT_STATUS (OF1.1) (xid=0x0): MOD: 3(eth0): addr:50:54:00:00:00:01
])
AT_CLEANUP
-AT_SETUP([OFPT_PACKET_OUT])
+AT_SETUP([OFPT_PACKET_OUT - OF1.0])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
01 0d 00 54 00 00 00 00 00 00 01 14 00 01 00 08 \
@@ -420,6 +420,17 @@ OFPT_PACKET_OUT (xid=0x0): in_port=1 actions=output:3 buffer=0x00000114
])
AT_CLEANUP
+AT_SETUP([OFPT_PACKET_OUT - OF1.1])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 0d 00 28 88 58 df c5 ff ff ff 00 ff ff ff fe \
+00 10 00 00 00 00 00 00 00 00 00 10 ff ff ff fb \
+05 dc 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPT_PACKET_OUT (OF1.2) (xid=0x8858dfc5): in_port=LOCAL actions=FLOOD buffer=0xffffff00
+])
+AT_CLEANUP
+
# The flow is formatted with cls_rule_format() for the low-verbosity case.
AT_SETUP([OFPT_FLOW_MOD - OF1.0 - low verbosity])
AT_KEYWORDS([ofp-print])
--
1.7.10.2.484.gcd07cc5
More information about the dev
mailing list