Message ID | 20231003055630.117963-1-amusil@redhat.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [ovs-dev,1/2] ofp-prop: Add helper for parsing and storing of ovs_u128. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
On Tue, Oct 03, 2023 at 07:56:29AM +0200, Ales Musil wrote: > Add helper methods that allow us to store and parse the > ovs_u128 type. > > Signed-off-by: Ales Musil <amusil@redhat.com> Acked-by: Simon Horman <horms@ovn.org>
On 10/3/23 07:56, Ales Musil wrote: > Add helper methods that allow us to store and parse the > ovs_u128 type. > > Signed-off-by: Ales Musil <amusil@redhat.com> > --- > include/openvswitch/ofp-prop.h | 3 +++ > lib/ofp-prop.c | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 33 insertions(+) > > diff --git a/include/openvswitch/ofp-prop.h b/include/openvswitch/ofp-prop.h > index e676f8dc0..14a451ea0 100644 > --- a/include/openvswitch/ofp-prop.h > +++ b/include/openvswitch/ofp-prop.h > @@ -88,6 +88,7 @@ enum ofperr ofpprop_parse_u8(const struct ofpbuf *, uint8_t *value); > enum ofperr ofpprop_parse_u16(const struct ofpbuf *, uint16_t *value); > enum ofperr ofpprop_parse_u32(const struct ofpbuf *, uint32_t *value); > enum ofperr ofpprop_parse_u64(const struct ofpbuf *, uint64_t *value); > +enum ofperr ofpprop_parse_u128(const struct ofpbuf *, ovs_u128 *value); Hi, Ales. You're adding both be and le versions of 'put' function, but only le version of 'parse'. Should ofpprop_parse_be128 be also implemented? Seems inconsistent. Best regards, Ilya Maximets.
On Tue, Oct 3, 2023 at 3:01 PM Ilya Maximets <i.maximets@ovn.org> wrote: > > On 10/3/23 07:56, Ales Musil wrote: > > Add helper methods that allow us to store and parse the > > ovs_u128 type. > > > > Signed-off-by: Ales Musil <amusil@redhat.com> > > --- > > include/openvswitch/ofp-prop.h | 3 +++ > > lib/ofp-prop.c | 30 ++++++++++++++++++++++++++++++ > > 2 files changed, 33 insertions(+) > > > > diff --git a/include/openvswitch/ofp-prop.h b/include/openvswitch/ofp-prop.h > > index e676f8dc0..14a451ea0 100644 > > --- a/include/openvswitch/ofp-prop.h > > +++ b/include/openvswitch/ofp-prop.h > > @@ -88,6 +88,7 @@ enum ofperr ofpprop_parse_u8(const struct ofpbuf *, uint8_t *value); > > enum ofperr ofpprop_parse_u16(const struct ofpbuf *, uint16_t *value); > > enum ofperr ofpprop_parse_u32(const struct ofpbuf *, uint32_t *value); > > enum ofperr ofpprop_parse_u64(const struct ofpbuf *, uint64_t *value); > > +enum ofperr ofpprop_parse_u128(const struct ofpbuf *, ovs_u128 *value); > > Hi, Ales. You're adding both be and le versions of 'put' function, but only > le version of 'parse'. Should ofpprop_parse_be128 be also implemented? > Seems inconsistent. > > Best regards, Ilya Maximets. > You are right, I have missed that there is also parse_b64 etc. I'll fix that in v2. Thanks, Ales
diff --git a/include/openvswitch/ofp-prop.h b/include/openvswitch/ofp-prop.h index e676f8dc0..14a451ea0 100644 --- a/include/openvswitch/ofp-prop.h +++ b/include/openvswitch/ofp-prop.h @@ -88,6 +88,7 @@ enum ofperr ofpprop_parse_u8(const struct ofpbuf *, uint8_t *value); enum ofperr ofpprop_parse_u16(const struct ofpbuf *, uint16_t *value); enum ofperr ofpprop_parse_u32(const struct ofpbuf *, uint32_t *value); enum ofperr ofpprop_parse_u64(const struct ofpbuf *, uint64_t *value); +enum ofperr ofpprop_parse_u128(const struct ofpbuf *, ovs_u128 *value); enum ofperr ofpprop_parse_uuid(const struct ofpbuf *, struct uuid *); enum ofperr ofpprop_parse_nested(const struct ofpbuf *, struct ofpbuf *); @@ -98,10 +99,12 @@ void *ofpprop_put_zeros(struct ofpbuf *, uint64_t type, size_t len); void ofpprop_put_be16(struct ofpbuf *, uint64_t type, ovs_be16 value); void ofpprop_put_be32(struct ofpbuf *, uint64_t type, ovs_be32 value); void ofpprop_put_be64(struct ofpbuf *, uint64_t type, ovs_be64 value); +void ofpprop_put_be128(struct ofpbuf *, uint64_t type, ovs_be128 value); void ofpprop_put_u8(struct ofpbuf *, uint64_t type, uint8_t value); void ofpprop_put_u16(struct ofpbuf *, uint64_t type, uint16_t value); void ofpprop_put_u32(struct ofpbuf *, uint64_t type, uint32_t value); void ofpprop_put_u64(struct ofpbuf *, uint64_t type, uint64_t value); +void ofpprop_put_u128(struct ofpbuf *, uint64_t type, ovs_u128 value); void ofpprop_put_bitmap(struct ofpbuf *, uint64_t type, uint64_t bitmap); void ofpprop_put_flag(struct ofpbuf *, uint64_t type); void ofpprop_put_uuid(struct ofpbuf *, uint64_t type, const struct uuid *); diff --git a/lib/ofp-prop.c b/lib/ofp-prop.c index 8b2d8a85a..6884456ad 100644 --- a/lib/ofp-prop.c +++ b/lib/ofp-prop.c @@ -250,6 +250,20 @@ ofpprop_parse_u64(const struct ofpbuf *property, uint64_t *value) return 0; } +/* Attempts to parse 'property' as a property containing a 128-bit value. If + * successful, stores the value into '*value' and returns 0; otherwise returns + * an OpenFlow error. */ +enum ofperr +ofpprop_parse_u128(const struct ofpbuf *property, ovs_u128 *value) +{ + ovs_be128 *p = property->msg; + if (ofpbuf_msgsize(property) != sizeof *p) { + return OFPERR_OFPBPC_BAD_LEN; + } + *value = ntoh128(*p); + return 0; +} + /* Attempts to parse 'property' as a property containing a UUID. If * successful, stores the value into '*uuid' and returns 0; otherwise returns * an OpenFlow error. */ @@ -351,6 +365,15 @@ ofpprop_put_be64(struct ofpbuf *msg, uint64_t type, ovs_be64 value) ofpprop_end(msg, start); } +/* Adds a property with the given 'type' and 128-bit 'value' to 'msg'. */ +void +ofpprop_put_be128(struct ofpbuf *msg, uint64_t type, ovs_be128 value) +{ + size_t start = ofpprop_start(msg, type); + ofpbuf_put(msg, &value, sizeof value); + ofpprop_end(msg, start); +} + /* Adds a property with the given 'type' and 8-bit 'value' to 'msg'. */ void ofpprop_put_u8(struct ofpbuf *msg, uint64_t type, uint8_t value) @@ -381,6 +404,13 @@ ofpprop_put_u64(struct ofpbuf *msg, uint64_t type, uint64_t value) ofpprop_put_be64(msg, type, htonll(value)); } +/* Adds a property with the given 'type' and 64-bit 'value' to 'msg'. */ +void +ofpprop_put_u128(struct ofpbuf *msg, uint64_t type, ovs_u128 value) +{ + ofpprop_put_be128(msg, type, hton128(value)); +} + /* Appends a property to 'msg' whose type is 'type' and whose contents is a * series of property headers, one for each 1-bit in 'bitmap'. */ void
Add helper methods that allow us to store and parse the ovs_u128 type. Signed-off-by: Ales Musil <amusil@redhat.com> --- include/openvswitch/ofp-prop.h | 3 +++ lib/ofp-prop.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)