From nobody Fri Oct 7 11:46:10 2022 X-Original-To: dev-commits-src-main@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 4MkRN30YNJz4V8rp; Fri, 7 Oct 2022 11:46:11 +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 4MkRN305q8z3hfx; Fri, 7 Oct 2022 11:46:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665143171; 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=6H7sAUOQRHJKNiX8a8fyk3scqY56iscJpdBrrQqbMPo=; b=AYIRkV+HfyzXP+0SoAXMOVbHrq+ebHTZEvN2LQFjkdkATKZ9mQmyGSl+4xKXfz2qTfZIo8 5Xv6jxbQjAkKmZb+MShKh4gbJOr+zZEBO/z7GRN1RayyQmgFKWeXCQpK1/yn0H9cF0s/7L jM99mZQugHDV3uMsgEM+bC5SGuqGfcGiyd72VJ/DIcrQduEJzavMkgc6lxF1W43z8qFhJZ exPldc3rkQa0bbYjg20PyDwi3dGOI2SQGsONMSiiqtOfwkPKuLxlR22aOo7vY7ZN8kq8BF WFdnMEq/OGhOZdBiGILyvaMf5vMFYEefCWRSp2Ic0wGOMAKIS42bB2qMB6BnEQ== 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 4MkRN26Gjdzb8D; Fri, 7 Oct 2022 11:46:10 +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 297BkA2C074074; Fri, 7 Oct 2022 11:46:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 297BkARu074073; Fri, 7 Oct 2022 11:46:10 GMT (envelope-from git) Date: Fri, 7 Oct 2022 11:46:10 GMT Message-Id: <202210071146.297BkARu074073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: de1ea2d5171e - main - if_vxlan(4): Correct the statistic for output bytes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: de1ea2d5171ec53acd69f93821b9507267ee44b7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665143171; 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=6H7sAUOQRHJKNiX8a8fyk3scqY56iscJpdBrrQqbMPo=; b=pvEBeq9krxSnBJhySiRMJ12UeUwNE4eU7bsBOiQtHcH51wRnXfkTGUV4hH55Q73bAraU8b C8m5qvgVL7HgfYKuZl5E4pVCfkesHVpPVtF02YhuqfdKes5bHv3PT7QNLX8kWbN/YZU8mo XFY2SjVEfFUMuAOdTwp7BEabBacQEbQOeVGmnBcr3IhNQH0VnvsUsm17oNum+JM9mJ2N7V K28/0ZvsLTG1NBqVK8WB/wAgueJuXkxm2OGrKNuKWTAGKwO9TIDvGSQ0gIf5mhh7DKy9f9 XPClc7NX5sW793/ZXMfPoXeK8Dyrquu3ujmsIqdqIXMRluuPQUwTX7p6CirVtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665143171; a=rsa-sha256; cv=none; b=StPYCCUt/9NMlhrRmtRZo8rbJioDwURESNWKSZxVV5Lvc7N+Ic1Lk3Jf/1iEma+4Hj6cw+ 6T6fpg3YfUUZ6/eVgkCLAc+guVbnHYr+gIG5DUIFWVv3YiqBPkc7SvJf5H19FNKZPMFxzs 4rLlNu4otOOra+Gh6GHt1GTAr37OJaBBlNePWlOw1GMDGYgZZ20dM7QSnKITmbIS9BwBI2 3e9ZXscBevjHsNiMv4w7UZq+oEUhyq4wmFmORCDT8Nye3Cpb+o1W09ZdEuZNHwedVFTQtL s6aQV4792/6i/VJwTz67AZQIDSnlKf6hN6+WiQicgvifk5DF8Wpusm1QQBf/BQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=de1ea2d5171ec53acd69f93821b9507267ee44b7 commit de1ea2d5171ec53acd69f93821b9507267ee44b7 Author: Zhenlei Huang AuthorDate: 2022-10-07 11:37:12 +0000 Commit: Kristof Provost CommitDate: 2022-10-07 11:45:16 +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 Differential Revision: https://reviews.freebsd.org/D36855 --- 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 500eb520cd1b..27ad2ec08335 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2504,7 +2504,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; @@ -2517,6 +2517,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) { @@ -2524,11 +2525,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; @@ -2594,7 +2593,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 @@ -2616,7 +2615,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; @@ -2629,6 +2628,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) { @@ -2636,8 +2636,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; @@ -2712,7 +2710,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