On 1/20/25 09:14, Frode Nordahl wrote:
> 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?
>
> 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.
Best regards, Ilya Maximets.
>
> Fixes: 91fc51106cfe ("route-table: Support parsing multipath routes.")
> Signed-off-by: Frode Nordahl <[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