[ovs-dev] [of1.1 v5 1/5] ofp-msgs: New approach to encoding and decoding OpenFlow headers.

Ben Pfaff blp at nicira.com
Thu Jul 19 17:57:38 UTC 2012


On Thu, Jul 19, 2012 at 04:38:27PM +0900, Simon Horman wrote:
> On Thu, Jul 05, 2012 at 11:12:29PM -0700, Ben Pfaff wrote:
> > OpenFlow headers are not as uniform as they could be, with size, alignment,
> > and numbering changes from one version to another and across varieties
> > (e.g. ordinary messages vs. "stats" messages).  Until now the Open vSwitch
> > internal APIs haven't done a good job of abstracting those differences in
> > header formats.  This commit changes that; from this commit forward very
> > little code actually needs to understand the header format or numbering.
> > Instead, it can just encode or decode, or pull or put, the header using
> > a more abstract API using the ofpraw_, ofptype_, and other APIs in the
> > new ofp-msgs module.

...

> > @@ -2975,12 +2417,18 @@ ofputil_put_switch_features_port(const struct ofputil_phy_port *pp,
> >  /* Decodes the OpenFlow "port status" message in '*ops' into an abstract form
> >   * in '*ps'.  Returns 0 if successful, otherwise an OFPERR_* value. */
> >  enum ofperr
> > -ofputil_decode_port_status(const struct ofp_port_status *ops,
> > +ofputil_decode_port_status(const struct ofp_header *oh,
> >                             struct ofputil_port_status *ps)
> >  {
> > +    const struct ofp_port_status *ops;
> > +    enum ofpraw raw;
> >      struct ofpbuf b;
> >      int retval;
> >  
> > +    ofpbuf_use_const(&b, oh, ntohs(oh->length));
> > +    raw = ofpraw_pull_assert(&b);
> > +    ops = ofpbuf_pull(&b, sizeof *ops);
> > +
> >      if (ops->reason != OFPPR_ADD &&
> >          ops->reason != OFPPR_DELETE &&
> >          ops->reason != OFPPR_MODIFY) {
> 
> The variable raw seems to be unused in this function,
> perhaps it could be removed?

Thanks, I folded this in:

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index f3abff2..8b1ef26 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2421,12 +2421,11 @@ ofputil_decode_port_status(const struct ofp_header *oh,
                            struct ofputil_port_status *ps)
 {
     const struct ofp_port_status *ops;
-    enum ofpraw raw;
     struct ofpbuf b;
     int retval;
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
-    raw = ofpraw_pull_assert(&b);
+    ofpraw_pull_assert(&b);
     ops = ofpbuf_pull(&b, sizeof *ops);
 
     if (ops->reason != OFPPR_ADD &&



More information about the dev mailing list