Skip to content

Commit

Permalink
netlink: fix error handling
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wkozaczuk committed Jun 13, 2022
1 parent ad0c9d8 commit 508b73c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bsd/sys/compat/linux/linux_netlink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 508b73c

Please sign in to comment.