From nobody Thu Sep 15 02:23:00 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MSgwP0Wx9z4crVq; Thu, 15 Sep 2022 02:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MSgwN6tBXz46Sr; Thu, 15 Sep 2022 02:23:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663208581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8Wc/R/LfqB03Ja5c+2xA+DTCPOoDH+6y8hG8udV/3wM=; b=HiKg77x8VnD2avAc8ANL7q1iGD0cKknIovRBDjvGNs1Opfk/c7l6Ab9fiawy/hLrxfRFKH ijPrYgDbip4162uxF8xAUx3WIRefz0jJ8Tzz8JHSWmKhaK79XDr7qLAtd4Gq8Wt54OeQZ6 Af109OJqRuj6FZju+y+jk4vlfHhklbY6khY4Nxj32qOQhspZtAgV9qz/P0VB2gN7H/cWVB XqUuMhk/hnXvYzMKfi412cx+6XjpflMhKlpxoBOJfE3lOydRyDFEnkte3LW5KoplA4w4GW Ks9C+9SrgnddZtkkPUxkM1ZSJBTCOWIJB7hrJfd1EB8TQVNKzR2RrX2Ewha1HQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MSgwN5v6MzsNT; Thu, 15 Sep 2022 02:23:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28F2N0Lv091370; Thu, 15 Sep 2022 02:23:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28F2N0W2091369; Thu, 15 Sep 2022 02:23:00 GMT (envelope-from git) Date: Thu, 15 Sep 2022 02:23:00 GMT Message-Id: <202209150223.28F2N0W2091369@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: da6715bbb125 - main - ip_output: always increase "cantfrag" stat if ip_fragment() fails List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da6715bbb125ebe5d3ca7fd7656e8409b2d31921 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663208581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8Wc/R/LfqB03Ja5c+2xA+DTCPOoDH+6y8hG8udV/3wM=; b=yogT7AaLty/R+kO5X/QknNg1zXeLhy0wzL1ND4kxKSx5/mXBuGdZwnw0GfAufblsVSwTxp c1QFRu0fQErKLWHB85E2A1JazxO+2e4isMWYkze95lD4MMpG2Msan2wJmZiI8ANPfDqrbU bEr9C14wZrsWIGwOlitqHYIfR5Mngz66w3uLZK/s9+eVX4X3MziWsz5JWYJSq2Rh5rZwNl dlSk03lRIW3XfhXXfsMPFSR6EQPCE3X8O+X3tLxVdWK1+xwveidP8Wr2lBLfcvkzpdPUgh RW+pOBph11+g5yw+P7+xRdt3ox+xqtRjVbgZBULotTfC9h7SICpOLYIvHfGApQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663208581; a=rsa-sha256; cv=none; b=nmAaYcDvZiWImOMdKuYLW0EUipoElkzaAt+gmPU5N6xT1tzNIaG/Zab3XVAUDBiE8nyhaP Ks9u0+3rNLu4KT49yS+6fnV0+hinVO9TeUEjjLbSXGvXF6HAqxcoe9UmTKpOIIFACdy0Cu 3mg1EUvq0xZhFK8h1gvJG8Zpzt0W6Vy739/3es5RsocCZNc/WAx3NIioQW0Hsa5Ve3d4vZ Kf1x00Fu8Wj7qXO+6ItWjRPK43LIvi2HBhbsmKyCOjFzrooHi7qj58IMtaT+r6V7+Ppb/B pxdIzudadMesiXidWJnzdsby0S3XBtCTtwxZexaXXOCsU2MWppPQg19fRn8b5Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=da6715bbb125ebe5d3ca7fd7656e8409b2d31921 commit da6715bbb125ebe5d3ca7fd7656e8409b2d31921 Author: Gleb Smirnoff AuthorDate: 2022-09-15 02:22:40 +0000 Commit: Gleb Smirnoff CommitDate: 2022-09-15 02:22:40 +0000 ip_output: always increase "cantfrag" stat if ip_fragment() fails While here, join two unlikely cases into one if clause. Submitted by: Ivan Rozhuk PR: 265718 Reviewed by: mjg, melifaro Differential revision: https://reviews.freebsd.org/D36584 --- sys/netinet/ip_output.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index db39663e508e..375db580296e 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -868,16 +868,14 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu, 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. + * Packet shall not have "Don't Fragment" flag and have at least 8 + * bytes of payload. */ - if (len < 8) - return EMSGSIZE; + if (__predict_false((ip_off & IP_DF) || len < 8)) { + IPSTAT_INC(ips_cantfrag); + return (EMSGSIZE); + } /* * If the interface will not calculate checksums on