From: Gavin Li <gav...@nvidia.com> Linux kernel netlink module added NLA_F_NESTED flag checking for nested netlink messages in 5.2. A nested message without the flag set will be treated as malformated one. The check is optional and is controlled by message policy. To avoid this, add NLA_F_NESTED explicitly for all nested netlink messages with a new function nl_msg_start_nested_with_flag().
Signed-off-by: Gavin Li <gav...@nvidia.com> Reviewed-by: Roi Dayan <r...@nvidia.com> Reviewed-by: Simon Horman <simon.hor...@corigine.com> Acked-by: Eelco Chaudron <echau...@redhat.com> --- lib/netlink.c | 9 +++++++++ lib/netlink.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/netlink.c b/lib/netlink.c index 6215282d6fbe..1e8d5a8ec57d 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -523,6 +523,15 @@ nl_msg_start_nested(struct ofpbuf *msg, uint16_t type) return offset; } +/* Adds the header for nested Netlink attributes to 'msg', with the specified + * 'type', and returns the header's offset within 'msg'. It's similar to + * nl_msg_start_nested() and uses NLA_F_NESTED flag mandatorily. */ +size_t +nl_msg_start_nested_with_flag(struct ofpbuf *msg, uint16_t type) +{ + return nl_msg_start_nested(msg, type | NLA_F_NESTED); +} + /* Finalizes a nested Netlink attribute in 'msg'. 'offset' should be the value * returned by nl_msg_start_nested(). */ void diff --git a/lib/netlink.h b/lib/netlink.h index e9050c31bacd..008604aa60d1 100644 --- a/lib/netlink.h +++ b/lib/netlink.h @@ -81,6 +81,7 @@ void nl_msg_put_string__(struct ofpbuf *, uint16_t type, const char *value, void nl_msg_put_string(struct ofpbuf *, uint16_t type, const char *value); size_t nl_msg_start_nested(struct ofpbuf *, uint16_t type); +size_t nl_msg_start_nested_with_flag(struct ofpbuf *, uint16_t type); void nl_msg_end_nested(struct ofpbuf *, size_t offset); void nl_msg_cancel_nested(struct ofpbuf *, size_t offset); bool nl_msg_end_non_empty_nested(struct ofpbuf *, size_t offset); -- 2.38.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev