From owner-dev-commits-src-all@freebsd.org Wed Aug 18 17:08:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7909A652E73; Wed, 18 Aug 2021 17:08:55 +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 4GqZ9z333Kz4ktC; Wed, 18 Aug 2021 17:08:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4D01015294; Wed, 18 Aug 2021 17:08:55 +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 17IH8tkn064614; Wed, 18 Aug 2021 17:08:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17IH8trx064613; Wed, 18 Aug 2021 17:08:55 GMT (envelope-from git) Date: Wed, 18 Aug 2021 17:08:55 GMT Message-Id: <202108181708.17IH8trx064613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: bb250fae9e9e - main - gre: simplify RSS ifdefs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb250fae9e9e278b681cf3a71ced718700ecf74c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 17:08:55 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=bb250fae9e9e278b681cf3a71ced718700ecf74c commit bb250fae9e9e278b681cf3a71ced718700ecf74c Author: Franco Fichtner AuthorDate: 2021-08-18 17:05:29 +0000 Commit: Kevin Bowling CommitDate: 2021-08-18 17:05:29 +0000 gre: simplify RSS ifdefs Use the early break to avoid else definitions. When RSS gains a runtime option previous constructs would duplicate and convolute the existing code. While here init flowid and skip magic numbers and late default assignment. Reviewed by: melifaro, kbowling Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31584 --- sys/net/if_gre.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index aa3e4062b060..19014f9fd3de 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -643,46 +643,37 @@ gre_setseqn(struct grehdr *gh, uint32_t seq) static uint32_t gre_flowid(struct gre_softc *sc, struct mbuf *m, uint32_t af) { - uint32_t flowid; + uint32_t flowid = 0; if ((sc->gre_options & GRE_UDPENCAP) == 0 || sc->gre_port != 0) - return (0); -#ifndef RSS - switch (af) { -#ifdef INET - case AF_INET: - flowid = mtod(m, struct ip *)->ip_src.s_addr ^ - mtod(m, struct ip *)->ip_dst.s_addr; - break; -#endif -#ifdef INET6 - case AF_INET6: - flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ - mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; - break; -#endif - default: - flowid = 0; - } -#else /* RSS */ + return (flowid); switch (af) { #ifdef INET case AF_INET: +#ifdef RSS flowid = rss_hash_ip4_2tuple(mtod(m, struct ip *)->ip_src, mtod(m, struct ip *)->ip_dst); break; +#endif + flowid = mtod(m, struct ip *)->ip_src.s_addr ^ + mtod(m, struct ip *)->ip_dst.s_addr; + break; #endif #ifdef INET6 case AF_INET6: +#ifdef RSS flowid = rss_hash_ip6_2tuple( &mtod(m, struct ip6_hdr *)->ip6_src, &mtod(m, struct ip6_hdr *)->ip6_dst); break; +#endif + flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ + mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; + break; #endif default: - flowid = 0; + break; } -#endif return (flowid); }