Fix netlink_process_msg() to propagate potential error
from netlink_senderr(). Normally netlink_senderr() should return
0 indicating that the error response was built successfully.
This patch tweaks the logic to make sure the error response
in such case is sent back as a NLMSG_ERROR reply accordingly
instead of making sendmsg() return error.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 bsd/sys/compat/linux/linux_netlink.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bsd/sys/compat/linux/linux_netlink.cc 
b/bsd/sys/compat/linux/linux_netlink.cc
index 82205d2b..180d81b5 100644
--- a/bsd/sys/compat/linux/linux_netlink.cc
+++ b/bsd/sys/compat/linux/linux_netlink.cc
@@ -830,7 +830,7 @@ netlink_process_getneigh_msg(struct socket *so, struct 
nlmsghdr *nlm)
        struct netlink_getneigh_lle_cbdata cbdata;
        int error;
 
-       if (nlm->nlmsg_len < sizeof (struct ndmsg)) {
+       if (nlm->nlmsg_len < NLMSG_LENGTH(sizeof (struct ndmsg))) {
                return EINVAL;
        }
 
@@ -892,7 +892,7 @@ netlink_process_msg(struct mbuf *m, struct socket *so)
 
 flush:
        if (error) {
-               netlink_senderr(so, nlm, error);
+               error = netlink_senderr(so, nlm, error);
        }
        if (m) {
                m_freem(m);
-- 
2.35.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20220604012837.214986-7-jwkozaczuk%40gmail.com.

Reply via email to