On Wed, Jan 29, 2014 at 09:12:43PM +0900, FUJITA Tomonori wrote:
> On Wed, 29 Jan 2014 15:13:46 +0900
> FUJITA Tomonori <[email protected]> wrote:
> 
> > On Wed, 29 Jan 2014 12:05:49 +0900
> > Simon Horman <[email protected]> wrote:
> > 
> > > Prior to this patch the code serialises an OFPMatch as:
> > > 
> > >    "OFPMatch": {
> > >       "oxm_fields": {
> > >          "arp_op": 1,
> > >          ...
> > >       }
> > >    }
> > > 
> > > But the parser fails, complaining that "oxm_fields" is an unknown field 
> > > name.
> > > 
> > > Resolve this by using the same JSON format as OF1.3:
> > > 
> > >    "OFPMatch": {
> > >       "length": 329,
> > >       "oxm_fields": [
> > >          {
> > >             "OXMTlv": {
> > >                "field": "in_port",
> > >                "mask": null,
> > >                "value": 84281096
> > >             }
> > >          },
> > >          ...
> > >       }
> > >    }
> > > 
> > > Signed-off-by: Simon Horman <[email protected]>
> > > ---
> > >  ryu/ofproto/ofproto_v1_4_parser.py | 27 +++++++++++++++++++++++++++
> > >  1 file changed, 27 insertions(+)
> > > 
> > > diff --git a/ryu/ofproto/ofproto_v1_4_parser.py 
> > > b/ryu/ofproto/ofproto_v1_4_parser.py
> > > index 616e0f5..980f201 100644
> > > --- a/ryu/ofproto/ofproto_v1_4_parser.py
> > > +++ b/ryu/ofproto/ofproto_v1_4_parser.py
> > > @@ -478,6 +478,33 @@ class OFPMatch(StringifyMixin):
> > >      def stringify_attrs(self):
> > >          yield "oxm_fields", dict(self._fields2)
> > >  
> > > +    def to_jsondict(self):
> > > +        """
> > > +        Returns a dict expressing the flow match.
> > > +        """
> > > +        body = {"oxm_fields": [ofproto.oxm_to_jsondict(k, uv) for k, uv
> > > +                               in self._fields2],
> > > +                "length": self.length,
> > > +                "type": self.type}
> > > +        return {self.__class__.__name__: body}
> > > +
> > > +    @classmethod
> > > +    def from_jsondict(cls, dict_):
> > > +        """
> > > +        Returns an object which is generated from a dict.
> > > +
> > > +        Exception raises:
> > > +        KeyError -- Unknown match field is defined in dict
> > > +        """
> > > +        fields = [ofproto.oxm_from_jsondict(f) for f
> > > +                  in dict_['oxm_fields']]
> > > +        o = OFPMatch()
> > > +        # XXX old api compat
> > > +        # serialize and parse to fill OFPMatch.fields
> > > +        buf = bytearray()
> > > +        o.serialize(buf, 0)
> > > +        return OFPMatch.parser(str(buf), 0)
> > 
> > Looks like from_jsondict() is broken. fields is not used to create
> > OFPmatch object. Here's a fix. We can avoid calling parser since we
> > dropped the old API.
> > 
> > =
> > >From 36d15083685a342a7cff635ba3fb677a2d857bc8 Mon Sep 17 00:00:00 2001
> > From: FUJITA Tomonori <[email protected]>
> > Date: Wed, 29 Jan 2014 15:09:06 +0900
> > Subject: [PATCH] of14: fix OFPMatch from_jsondict method
> > 
> > Signed-off-by: FUJITA Tomonori <[email protected]>
> > ---
> >  ryu/ofproto/ofproto_v1_4_parser.py | 7 +------
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> > 
> > diff --git a/ryu/ofproto/ofproto_v1_4_parser.py 
> > b/ryu/ofproto/ofproto_v1_4_parser.py
> > index c067bb3..4a4a0d8 100644
> > --- a/ryu/ofproto/ofproto_v1_4_parser.py
> > +++ b/ryu/ofproto/ofproto_v1_4_parser.py
> > @@ -738,12 +738,7 @@ class OFPMatch(StringifyMixin):
> >          """
> >          fields = [ofproto.oxm_from_jsondict(f) for f
> >                    in dict_['oxm_fields']]
> > -        o = OFPMatch()
> > -        # XXX old api compat
> > -        # serialize and parse to fill OFPMatch.fields
> > -        buf = bytearray()
> > -        o.serialize(buf, 0)
> > -        return OFPMatch.parser(str(buf), 0)
> > +        return OFPMatch(**dict(fields))
> 
> Oops, somehow I misunderstood that you ack'ed this and merged.

No problem.

I make a quick check and this seems to work.
I'll test it more thoroughly as I increase the OF1.4 coverage.

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to