[Bug 265718] ip_fragment() does not call IPSTAT() in one error case

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 08 Aug 2022 14:39:29 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265718

            Bug ID: 265718
           Summary: ip_fragment() does not call IPSTAT() in one error case
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: rozhuk.im@gmail.com

sys/netinet/ip_output.c

...
int
ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
    u_long if_hwassist_flags)
{
        int error = 0;
        int hlen = ip->ip_hl << 2;
        int len = (mtu - hlen) & ~7;    /* size of payload in each fragment */
        int off;
        struct mbuf *m0 = *m_frag;      /* the original packet          */
        int firstlen;
        struct mbuf **mnext;
        int nfrags;
        uint16_t ip_len, ip_off;

        ip_len = ntohs(ip->ip_len);
        ip_off = ntohs(ip->ip_off);

        if (ip_off & IP_DF) {   /* Fragmentation not allowed */
                IPSTAT_INC(ips_cantfrag);
                return EMSGSIZE;
        }

        /*
         * Must be able to put at least 8 bytes per fragment.
         */
        if (len < 8)
                return EMSGSIZE;

...

In all other error cases IPSTAT_INC() called before exit.
Without this stat more time required to debug.

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