Message ID | 20170718223244.28449-1-joe@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Tue, Jul 18, 2017 at 03:32:43PM -0700, Joe Stringer wrote: > Rather than open-coding access to netlink attribute pointers in > put_exclude_packet_type(), make use of the netlink attribute helpers. > This simplifies the following bugfix. > > Signed-off-by: Joe Stringer <joe@ovn.org> > --- > lib/dpif-netlink.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c > index 562f6134c3a5..63ef3de5c7d1 100644 > --- a/lib/dpif-netlink.c > +++ b/lib/dpif-netlink.c > @@ -3452,13 +3452,13 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type, > size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data; > size_t second_chunk_size = data_len - first_chunk_size > - packet_type_len; > - uint8_t *first_attr = NULL; > struct nlattr *next_attr = nl_attr_next(packet_type); > + size_t ofs; > > - first_attr = nl_msg_put_unspec_uninit(buf, type, > - data_len - packet_type_len); > - memcpy(first_attr, data, first_chunk_size); > - memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size); > + ofs = nl_msg_start_nested(buf, type); > + nl_msg_put(buf, data, first_chunk_size); > + nl_msg_put(buf, next_attr, second_chunk_size); > + nl_msg_end_nested(buf, ofs); > } else { > nl_msg_put_unspec(buf, type, data, data_len); > } > -- > 2.11.1 > Acked-by: Eric Garver <e@erig.me>
On 19 July 2017 at 08:54, Eric Garver <e@erig.me> wrote: > On Tue, Jul 18, 2017 at 03:32:43PM -0700, Joe Stringer wrote: >> Rather than open-coding access to netlink attribute pointers in >> put_exclude_packet_type(), make use of the netlink attribute helpers. >> This simplifies the following bugfix. >> >> Signed-off-by: Joe Stringer <joe@ovn.org> >> --- >> lib/dpif-netlink.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c >> index 562f6134c3a5..63ef3de5c7d1 100644 >> --- a/lib/dpif-netlink.c >> +++ b/lib/dpif-netlink.c >> @@ -3452,13 +3452,13 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type, >> size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data; >> size_t second_chunk_size = data_len - first_chunk_size >> - packet_type_len; >> - uint8_t *first_attr = NULL; >> struct nlattr *next_attr = nl_attr_next(packet_type); >> + size_t ofs; >> >> - first_attr = nl_msg_put_unspec_uninit(buf, type, >> - data_len - packet_type_len); >> - memcpy(first_attr, data, first_chunk_size); >> - memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size); >> + ofs = nl_msg_start_nested(buf, type); >> + nl_msg_put(buf, data, first_chunk_size); >> + nl_msg_put(buf, next_attr, second_chunk_size); >> + nl_msg_end_nested(buf, ofs); >> } else { >> nl_msg_put_unspec(buf, type, data, data_len); >> } >> -- >> 2.11.1 >> > > Acked-by: Eric Garver <e@erig.me> Thanks, applied to master.
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 562f6134c3a5..63ef3de5c7d1 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -3452,13 +3452,13 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type, size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data; size_t second_chunk_size = data_len - first_chunk_size - packet_type_len; - uint8_t *first_attr = NULL; struct nlattr *next_attr = nl_attr_next(packet_type); + size_t ofs; - first_attr = nl_msg_put_unspec_uninit(buf, type, - data_len - packet_type_len); - memcpy(first_attr, data, first_chunk_size); - memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size); + ofs = nl_msg_start_nested(buf, type); + nl_msg_put(buf, data, first_chunk_size); + nl_msg_put(buf, next_attr, second_chunk_size); + nl_msg_end_nested(buf, ofs); } else { nl_msg_put_unspec(buf, type, data, data_len); }
Rather than open-coding access to netlink attribute pointers in put_exclude_packet_type(), make use of the netlink attribute helpers. This simplifies the following bugfix. Signed-off-by: Joe Stringer <joe@ovn.org> --- lib/dpif-netlink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)