From nobody Wed Jan 11 10:39:56 2023 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 4NsPMK2NYxz2r1Lx; Wed, 11 Jan 2023 10:39:57 +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 4NsPMK1RDZz3P03; Wed, 11 Jan 2023 10:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673433597; 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=Oz631472ZmBZN+zso7GD0YsNTWbdOeCMgQ9Fz6UJlHc=; b=e0Y1Mvlk7oJYzPjCgpgFqhyjh6UqIEsDtNJSNUoPT8f11WM0zvEB70f4ECGaOIOmm92rx3 VACtNTLjMTtWu/yrTcRAcZ3A2mYo/9Akms1UXTGLXfxVE/sCMqPTUX96TE+CVXct92G2+L VWPj1vHVP/eVwmuq3MdxfLMwzQgwtSTQ7Js6WOadna9noj5wM4KXMEsEqcP/SglsPtzWFn 3UtpvbbJe+Fl7eBRNh7OL/B6Est2UhWazhXNVGcNCXRYYPn3HZb3mepscrTEZhatS+IUJq 4LJs/BS0fD/yWBI0KqF8AD/ZYdK1gdFf2xoFm/ZdW39VQqL9lBPgUAqS+pjQQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673433597; 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=Oz631472ZmBZN+zso7GD0YsNTWbdOeCMgQ9Fz6UJlHc=; b=KlaRqgFf7AddBygCQcL9BqrH+vwERsB7acE6t8f96/kI/zGWkYPVoExMxtBSE0n2APBQVX WXMre7G3CljVPP/kohc+4lsJi+LjwP1WxW6bKsiFBucn8x3wN80kRy6VQ4kmSX48qwnlla pQH53vagM9k0Jvw/QOuImrOtRSjj/ppT/OxvQ0BmtOlxhWqF4/dWvHBLOLQ49gY6vDQhXG 8EOqx/pzYdsoOF7sMwVX5rEJ//Qf130OP7cqz0nPmXS+lFDDGfGBLIgQMr4Z5G9UJs9Yo5 0ifcWut9VvjTW1b6a22Pp2fBeFaUJaCe8JxuNS2Vbqqk1ePDE6MURXnqevsh4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673433597; a=rsa-sha256; cv=none; b=woYWnbxQu2LtmxhwqwItStnzxkdun5unvqk3QDmTyJVMGW02e7cwtn7tm+WJai/b2dG01d owza+0KdCdW/1XmXGQn2qqpK6hcsdX1i7TVcgNzKjzPBRAWVWpaZEeZbEsBlrL1lvurS1x SrYx118osuBZ2z3RoLVETs6dA0q6al3FPAvaeYrflnjn1q01xGhYcZ27aJ9vQpryXNFd6v Y5HFsU8YCsPCEXFxKhN3Zolre9RUK4A+27HhBrLh556TNsQUQIFhHvSWZYP1he3/MPU6z2 1X0IDTbFf/nJhZWHgknKcYA4n761nDV8ekSB/iJ0z3clYUt0pTwDhAjtdBY97A== 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 4NsPMK0S7HzlGy; Wed, 11 Jan 2023 10:39:57 +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 30BAduqO068051; Wed, 11 Jan 2023 10:39:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30BAdu6c068050; Wed, 11 Jan 2023 10:39:56 GMT (envelope-from git) Date: Wed, 11 Jan 2023 10:39:56 GMT Message-Id: <202301111039.30BAdu6c068050@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: faa7d6c2f94a - stable/13 - if_vxlan(4): Correct the statistic for output bytes 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: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: faa7d6c2f94aee09cdc92142d51a0b2eb12b3239 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=faa7d6c2f94aee09cdc92142d51a0b2eb12b3239 commit faa7d6c2f94aee09cdc92142d51a0b2eb12b3239 Author: Zhenlei Huang AuthorDate: 2022-10-07 11:37:12 +0000 Commit: Zhenlei Huang CommitDate: 2023-01-11 10:35:59 +0000 if_vxlan(4): Correct the statistic for output bytes The vxlan interface encapsulates the Ethernet frame by prepending IP/UDP and vxlan headers. For statistics, only the payload, i.e. the encapsulated (inner) frame should be counted. Event: Aberdeen Hackathon 2022 Reviewed by: kp Approved by: kp (mentor) Differential Revision: https://reviews.freebsd.org/D36855 (cherry picked from commit de1ea2d5171ec53acd69f93821b9507267ee44b7) --- sys/net/if_vxlan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index f8e8c413ea62..7ea480899d7d 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2501,7 +2501,7 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, struct ip *ip; struct in_addr srcaddr, dstaddr; uint16_t srcport, dstport; - int len, mcast, error; + int plen, mcast, error; struct route route, *ro; struct sockaddr_in *sin; uint32_t csum_flags; @@ -2514,6 +2514,7 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, dstaddr = fvxlsa->in4.sin_addr; dstport = fvxlsa->in4.sin_port; + plen = m->m_pkthdr.len; M_PREPEND(m, sizeof(struct ip) + sizeof(struct vxlanudphdr), M_NOWAIT); if (m == NULL) { @@ -2521,11 +2522,9 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, return (ENOBUFS); } - len = m->m_pkthdr.len; - ip = mtod(m, struct ip *); ip->ip_tos = 0; - ip->ip_len = htons(len); + ip->ip_len = htons(m->m_pkthdr.len); ip->ip_off = 0; ip->ip_ttl = sc->vxl_ttl; ip->ip_p = IPPROTO_UDP; @@ -2591,7 +2590,7 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, error = ip_output(m, NULL, ro, 0, sc->vxl_im4o, NULL); if (error == 0) { if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - if_inc_counter(ifp, IFCOUNTER_OBYTES, len); + if_inc_counter(ifp, IFCOUNTER_OBYTES, plen); if (mcast != 0) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); } else @@ -2613,7 +2612,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, struct ip6_hdr *ip6; const struct in6_addr *srcaddr, *dstaddr; uint16_t srcport, dstport; - int len, mcast, error; + int plen, mcast, error; struct route_in6 route, *ro; struct sockaddr_in6 *sin6; uint32_t csum_flags; @@ -2626,6 +2625,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, dstaddr = &fvxlsa->in6.sin6_addr; dstport = fvxlsa->in6.sin6_port; + plen = m->m_pkthdr.len; M_PREPEND(m, sizeof(struct ip6_hdr) + sizeof(struct vxlanudphdr), M_NOWAIT); if (m == NULL) { @@ -2633,8 +2633,6 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, return (ENOBUFS); } - len = m->m_pkthdr.len; - ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_flow = 0; /* BMV: Keep in forwarding entry? */ ip6->ip6_vfc = IPV6_VERSION; @@ -2709,7 +2707,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, error = ip6_output(m, NULL, ro, 0, sc->vxl_im6o, NULL, NULL); if (error == 0) { if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - if_inc_counter(ifp, IFCOUNTER_OBYTES, len); + if_inc_counter(ifp, IFCOUNTER_OBYTES, plen); if (mcast != 0) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); } else