git: 412a609da482 - stable/13 - gre: simplify RSS ifdefs

Kevin Bowling kbowling at FreeBSD.org
Wed Aug 25 23:52:50 UTC 2021


The branch stable/13 has been updated by kbowling (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=412a609da4821f52865bbd2b81a4493a3586aca0

commit 412a609da4821f52865bbd2b81a4493a3586aca0
Author:     Franco Fichtner <franco at opnsense.org>
AuthorDate: 2021-08-18 17:05:29 +0000
Commit:     Kevin Bowling <kbowling at FreeBSD.org>
CommitDate: 2021-08-25 23:52:35 +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 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);
 }
 


More information about the dev-commits-src-all mailing list