aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2025-01-29 17:05:57 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2025-01-29 23:48:55 +0000
commit810c122695d72d277a07a2854172d6fd09fc9907 (patch)
tree44a7c7fdb7393698dcc08f62f40b784156461a43
parent8b094a9801edcd4010d3fb8dc85cf2cec598abfc (diff)
netlink: use u_int as argument for ifnet_byindex()
-rw-r--r--sys/netlink/netlink_message_parser.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/netlink/netlink_message_parser.c b/sys/netlink/netlink_message_parser.c
index 368cb43cf496..4a35440c50e0 100644
--- a/sys/netlink/netlink_message_parser.c
+++ b/sys/netlink/netlink_message_parser.c
@@ -420,12 +420,15 @@ static int
nlattr_get_ifp_internal(struct nlattr *nla, struct nl_pstate *npt,
void *target, bool zero_ok)
{
+ struct ifnet *ifp;
+ u_int ifindex;
+
if (__predict_false(NLA_DATA_LEN(nla) != sizeof(uint32_t))) {
NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint32",
nla->nla_type, NLA_DATA_LEN(nla));
return (EINVAL);
}
- uint32_t ifindex = *((const uint32_t *)NLA_DATA_CONST(nla));
+ ifindex = *((const u_int *)NLA_DATA_CONST(nla));
if (ifindex == 0 && zero_ok) {
*((struct ifnet **)target) = NULL;
@@ -434,7 +437,7 @@ nlattr_get_ifp_internal(struct nlattr *nla, struct nl_pstate *npt,
NET_EPOCH_ASSERT();
- struct ifnet *ifp = ifnet_byindex(ifindex);
+ ifp = ifnet_byindex(ifindex);
if (__predict_false(ifp == NULL)) {
NLMSG_REPORT_ERR_MSG(npt, "nla type %d: ifindex %u invalid",
nla->nla_type, ifindex);
@@ -562,11 +565,13 @@ nlattr_get_nested_ptr(struct nlattr *nla, struct nl_pstate *npt,
int
nlf_get_ifp(void *src, struct nl_pstate *npt, void *target)
{
- int ifindex = *((const int *)src);
+ struct ifnet *ifp;
+ u_int ifindex;
NET_EPOCH_ASSERT();
- struct ifnet *ifp = ifnet_byindex(ifindex);
+ ifindex = *((const u_int *)src);
+ ifp = ifnet_byindex(ifindex);
if (ifp == NULL) {
NL_LOG(LOG_DEBUG, "ifindex %u invalid", ifindex);
return (ENOENT);
@@ -579,11 +584,13 @@ nlf_get_ifp(void *src, struct nl_pstate *npt, void *target)
int
nlf_get_ifpz(void *src, struct nl_pstate *npt, void *target)
{
- int ifindex = *((const int *)src);
+ struct ifnet *ifp;
+ u_int ifindex;
NET_EPOCH_ASSERT();
- struct ifnet *ifp = ifnet_byindex(ifindex);
+ ifindex = *((const u_int *)src);
+ ifp = ifnet_byindex(ifindex);
if (ifindex != 0 && ifp == NULL) {
NL_LOG(LOG_DEBUG, "ifindex %u invalid", ifindex);
return (ENOENT);