Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 2024 22:44:49 +0000
From:      bugzilla-noreply@freebsd.org
To:        net@FreeBSD.org
Subject:   [Bug 276363] if_wg: Fix bug in calculate_padding() for the 'p_mtu = 0' case
Message-ID:  <bug-276363-7501-3mogODO1lE@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-276363-7501@https.bugs.freebsd.org/bugzilla/>
References:  <bug-276363-7501@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276363

Kyle Evans <kevans@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kevans@freebsd.org

--- Comment #2 from Kyle Evans <kevans@freebsd.org> ---
(In reply to Aaron LI from comment #1)

I would perhaps reorganize it slightly at that point:

static inline unsigned int=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20
calculate_padding(struct wg_packet *pkt)=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
{=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
        unsigned int padded_size, last_unit =3D pkt->p_mbuf->m_pkthdr.len;=
=20=20=20=20=20=20=20=20

        padded_size =3D (last_unit + (WG_PKT_PADDING - 1)) & ~(WG_PKT_PADDI=
NG -
1);

        if (__predict_true(pkt->p_mtu !=3D 0)) {=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                if (__predict_false(last_unit > pkt->p_mtu))=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                        last_unit %=3D pkt->p_mtu;=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20

                if (pkt->p_mtu < padded_size)=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                        padded_size =3D pkt->p_mtu;=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
        }=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20

        return (padded_size - last_unit);=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20
}

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276363-7501-3mogODO1lE>