platform: cleanup event_handler_recvmsg() (inline verify_source())
This commit is contained in:
@@ -3281,17 +3281,16 @@ next:
|
|||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
event_seq_check (struct nl_msg *msg, gpointer user_data)
|
event_seq_check (NMPlatform *platform, struct nl_msg *msg)
|
||||||
{
|
{
|
||||||
NMPlatform *platform = NM_PLATFORM (user_data);
|
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
struct nlmsghdr *hdr;
|
struct nlmsghdr *hdr;
|
||||||
|
|
||||||
hdr = nlmsg_hdr (msg);
|
hdr = nlmsg_hdr (msg);
|
||||||
|
|
||||||
if (hdr->nlmsg_seq == 0)
|
if (hdr->nlmsg_seq == 0)
|
||||||
return NL_OK;
|
return;
|
||||||
|
|
||||||
priv->nlh_seq_last = hdr->nlmsg_seq;
|
priv->nlh_seq_last = hdr->nlmsg_seq;
|
||||||
|
|
||||||
@@ -3303,8 +3302,6 @@ event_seq_check (struct nl_msg *msg, gpointer user_data)
|
|||||||
priv->nlh_seq_expect = 0;
|
priv->nlh_seq_expect = 0;
|
||||||
} else
|
} else
|
||||||
_LOGt ("sequence-number: seq %u received (wait for %u)", hdr->nlmsg_seq, priv->nlh_seq_last);
|
_LOGt ("sequence-number: seq %u received (wait for %u)", hdr->nlmsg_seq, priv->nlh_seq_last);
|
||||||
|
|
||||||
return NL_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -5398,22 +5395,6 @@ event_handler (GIOChannel *channel,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define NL_CB_CALL(cmd) \
|
|
||||||
do { \
|
|
||||||
err = (cmd); \
|
|
||||||
switch (err) { \
|
|
||||||
case NL_OK: \
|
|
||||||
err = 0; \
|
|
||||||
break; \
|
|
||||||
case NL_SKIP: \
|
|
||||||
goto skip; \
|
|
||||||
case NL_STOP: \
|
|
||||||
goto stop; \
|
|
||||||
default: \
|
|
||||||
goto out; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* copied from libnl3's recvmsgs() */
|
/* copied from libnl3's recvmsgs() */
|
||||||
static int
|
static int
|
||||||
event_handler_recvmsgs (NMPlatform *platform)
|
event_handler_recvmsgs (NMPlatform *platform)
|
||||||
@@ -5450,15 +5431,20 @@ continue_reading:
|
|||||||
|
|
||||||
nlmsg_set_proto (msg, NETLINK_ROUTE);
|
nlmsg_set_proto (msg, NETLINK_ROUTE);
|
||||||
nlmsg_set_src (msg, &nla);
|
nlmsg_set_src (msg, &nla);
|
||||||
|
nrecv++;
|
||||||
|
|
||||||
|
if (!creds || creds->pid) {
|
||||||
|
if (creds)
|
||||||
|
_LOGW ("netlink: received non-kernel message (pid %d)", creds->pid);
|
||||||
|
else
|
||||||
|
_LOGW ("netlink: received message without credentials");
|
||||||
|
goto stop;
|
||||||
|
}
|
||||||
|
|
||||||
if (creds)
|
if (creds)
|
||||||
nlmsg_set_creds (msg, creds);
|
nlmsg_set_creds (msg, creds);
|
||||||
|
|
||||||
nrecv++;
|
event_seq_check (platform, msg);
|
||||||
|
|
||||||
/* NL_CB_MSG_IN */
|
|
||||||
NL_CB_CALL (verify_source (msg, platform));
|
|
||||||
|
|
||||||
NL_CB_CALL (event_seq_check (msg, platform));
|
|
||||||
|
|
||||||
if (hdr->nlmsg_flags & NLM_F_MULTI)
|
if (hdr->nlmsg_flags & NLM_F_MULTI)
|
||||||
multipart = 1;
|
multipart = 1;
|
||||||
|
Reference in New Issue
Block a user