Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Aug 2021 00:03:17 GMT
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 5e2076065c8b - stable/12 - gre: simplify RSS ifdefs
Message-ID:  <202108260003.17Q03HK7004137@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kbowling (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=5e2076065c8b7dc60db1a856e1acdf2d8070400e

commit 5e2076065c8b7dc60db1a856e1acdf2d8070400e
Author:     Franco Fichtner <franco@opnsense.org>
AuthorDate: 2021-08-18 17:05:29 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2021-08-26 00:01:53 +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
    
    (cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c)
---
 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 cb0e83d10537..462a2ecdc680 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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108260003.17Q03HK7004137>