Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jan 2025 23:49:11 GMT
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 810c122695d7 - main - netlink: use u_int as argument for ifnet_byindex()
Message-ID:  <202501292349.50TNnBvA007187@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=810c122695d72d277a07a2854172d6fd09fc9907

commit 810c122695d72d277a07a2854172d6fd09fc9907
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-01-29 17:05:57 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-01-29 23:48:55 +0000

    netlink: use u_int as argument for ifnet_byindex()
---
 sys/netlink/netlink_message_parser.c | 19 +++++++++++++------
 1 file 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501292349.50TNnBvA007187>