Skip to content

Commit 508b73c

Browse files
committed
netlink: fix error handling
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]>
1 parent ad0c9d8 commit 508b73c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bsd/sys/compat/linux/linux_netlink.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ netlink_process_getneigh_msg(struct socket *so, struct nlmsghdr *nlm)
830830
struct netlink_getneigh_lle_cbdata cbdata;
831831
int error;
832832

833-
if (nlm->nlmsg_len < sizeof (struct ndmsg)) {
833+
if (nlm->nlmsg_len < NLMSG_LENGTH(sizeof (struct ndmsg))) {
834834
return EINVAL;
835835
}
836836

@@ -892,7 +892,7 @@ netlink_process_msg(struct mbuf *m, struct socket *so)
892892

893893
flush:
894894
if (error) {
895-
netlink_senderr(so, nlm, error);
895+
error = netlink_senderr(so, nlm, error);
896896
}
897897
if (m) {
898898
m_freem(m);

0 commit comments

Comments
 (0)