On Tue, Jan 21, 2025 at 1:43 PM Ilya Maximets <[email protected]> wrote:
>
> On 1/20/25 14:43, Frode Nordahl wrote:
>
> (accidentally replied to v1 before, copying here)
>
> > While our use of the buffer produced by ofpbuf_use_data() currently
> > does not lead to any memory allocations, somebody might introduce
> > that in the future.
>
> Sounds strange to change the buffer while parsing it. Is there intention
> to do so or this is just a precaution?
Just a precaution. After Eelco highlighted the coverity scan result, I
revisited the whole set with more vigilance and found this.
> >
> > The documentation for ofpbuf_use_data advises to always make a
> > call to ofpbuf_uninit(), let's adhere to that.
>
> We should use ofpbuf_use_const() instead if modification is not anticipated.
> It will assert on attempt to modify/reallocate the buffer, and we'll not
> need to uninitialize it.
Thank you for pointing that out, I somehow moved away from
ofpbuf_use_const() during development, but I see that slipping it back
in now works just fine. Will send a reroll with that as a fix
instead.
--
Frode Nordahl
> Best regards, Ilya Maximets.
>
> >
> > Fixes: 91fc51106cfe ("route-table: Support parsing multipath routes.")
> > Signed-off-by: Frode Nordahl <[email protected]>
> > Acked-by: Eelco Chaudron <[email protected]>
> > ---
> > lib/route-table.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/lib/route-table.c b/lib/route-table.c
> > index fbda4c41d..b7964522f 100644
> > --- a/lib/route-table.c
> > +++ b/lib/route-table.c
> > @@ -419,15 +419,18 @@ route_table_parse__(struct ofpbuf *buf, size_t ofs,
> > if (!mp_rtnh) {
> > VLOG_DBG_RL(&rl, "got short message while parsing "
> > "multipath attribute");
> > + ofpbuf_uninit(&mp_buf);
> > goto error_out;
> > }
> >
> > if (!route_table_parse__(&mp_buf, 0, nlmsg, rtm, mp_rtnh,
> > &mp_change)) {
> > + ofpbuf_uninit(&mp_buf);
> > goto error_out;
> > }
> > ovs_list_push_back_all(&change->rd.nexthops,
> > &mp_change.rd.nexthops);
> > + ofpbuf_uninit(&mp_buf);
> > }
> > }
> > if (!attrs[RTA_OIF] && !attrs[RTA_GATEWAY]
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev