HomeFreeBSD

mbuf_tags: use explicitly sized type for 'type' parameter

Description

mbuf_tags: use explicitly sized type for 'type' parameter

Functions manipulating mbuf tags are using an int type for passing the
'type' parameter, but the internal tag storage is using a 16bit
integer to store it. This leads to the following code:

t = m_tag_alloc(...,0xffffffff,...,...);
m_tag_prepend(m, t);
r = m_tag_locate(m ,...,0xffffffff, NULL);

Returning r == NULL because m_tag_locate doesn't truncate the type
parameter when doing the match. This is unexpected because the type of
the 'type' parameter is int, and the caller doesn't need to know about
the internal truncations.

Fix this by making the 'type' parameter of type uint16_t in order to
match the size of its internal storage and make it obvious to the
caller the actual size of the parameter.

While there also use uint uniformly replacing the existing u_int
instances.

Reviewed by: kp, donner, glebius
Differential revision: https://reviews.freebsd.org/D33680

Details

Provenance
roygerAuthored on Dec 28 2021, 8:13 AM
Reviewer
kp
Differential Revision
D33680: mbuf_tags: use explicitly sized type for 'type' parameter
Parents
rGb99651c52fa5: cxgbe(4): Fix panic on driver detach after a partially failed attach.
Branches
Unknown
Tags
Unknown