platform/netlink: move generic code in _netlink_recv_handle()

This also applies to genl messages. Move the code.
This commit is contained in:
Thomas Haller
2022-06-21 22:36:35 +02:00
parent b1abd3ebdd
commit 88df542b6b

View File

@@ -4140,8 +4140,7 @@ nmp_object_new_from_nl(NMPlatform *platform,
{
const struct nlmsghdr *msghdr;
if (msg->nm_protocol != NETLINK_ROUTE)
return NULL;
nm_assert(msg->nm_protocol == NETLINK_ROUTE);
msghdr = msg->nm_nlh;
@@ -9317,9 +9316,6 @@ continue_reading:
/* FIXME: implement */
}
switch (netlink_protocol) {
case NETLINK_ROUTE:
{
seq_result = WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN;
if (msg.nm_nlh->nlmsg_type == NLMSG_DONE) {
@@ -9376,8 +9372,7 @@ continue_reading:
}
/* Error message reported back from kernel. */
_LOGD(
"netlink: recvmsg: error message from kernel: %s (%d)%s%s%s for request %d",
_LOGD("netlink: recvmsg: error message from kernel: %s (%d)%s%s%s for request %d",
nm_strerror_native(errsv),
errsv,
NM_PRINT_FMT_QUOTED(extack_msg, " \"", extack_msg, "\"", ""),
@@ -9388,6 +9383,11 @@ continue_reading:
} else
process_valid_msg = TRUE;
switch (netlink_protocol) {
default:
nm_assert_not_reached();
/* fall-through */
case NETLINK_ROUTE:
/* check whether the seq number is different from before, and
* whether the previous number (@nlh_seq_last_seen) is a pending
* refresh-all request. In that case, the pending request is thereby
@@ -9410,9 +9410,6 @@ continue_reading:
event_seq_check(platform, seq_number, seq_result, extack_msg);
break;
}
default:
nm_assert_not_reached();
}
if (abort_parsing)
goto stop;
@@ -9425,6 +9422,7 @@ continue_reading:
/* Multipart message not yet complete, continue reading */
goto continue_reading;
}
stop:
if (!handle_events) {
/* when we don't handle events, we want to drain all messages from the socket