svn commit: r347338 - stable/12/sys/netinet

Alexander Motin mav at FreeBSD.org
Wed May 8 15:23:46 UTC 2019


Author: mav
Date: Wed May  8 15:23:45 2019
New Revision: 347338
URL: https://svnweb.freebsd.org/changeset/base/347338

Log:
  MFC r346898: ip multicast debug: fix strings vs defines
  
  Turning on multicast debug made multicast failure worse
  because the strings and #define values no longer matched
  up.  Fix them, and make sure they stay matched-up.

Modified:
  stable/12/sys/netinet/in_mcast.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/in_mcast.c
==============================================================================
--- stable/12/sys/netinet/in_mcast.c	Wed May  8 15:22:27 2019	(r347337)
+++ stable/12/sys/netinet/in_mcast.c	Wed May  8 15:23:45 2019	(r347338)
@@ -3054,7 +3054,14 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS)
 
 #if defined(KTR) && (KTR_COMPILE & KTR_IGMPV3)
 
-static const char *inm_modestrs[] = { "un", "in", "ex" };
+static const char *inm_modestrs[] = {
+	[MCAST_UNDEFINED] = "un",
+	[MCAST_INCLUDE] = "in",
+	[MCAST_EXCLUDE] = "ex",
+};
+_Static_assert(MCAST_UNDEFINED == 0 &&
+	       MCAST_EXCLUDE + 1 == nitems(inm_modestrs),
+	       "inm_modestrs: no longer matches #defines");
 
 static const char *
 inm_mode_str(const int mode)
@@ -3066,16 +3073,20 @@ inm_mode_str(const int mode)
 }
 
 static const char *inm_statestrs[] = {
-	"not-member",
-	"silent",
-	"idle",
-	"lazy",
-	"sleeping",
-	"awakening",
-	"query-pending",
-	"sg-query-pending",
-	"leaving"
+	[IGMP_NOT_MEMBER] = "not-member",
+	[IGMP_SILENT_MEMBER] = "silent",
+	[IGMP_REPORTING_MEMBER] = "reporting",
+	[IGMP_IDLE_MEMBER] = "idle",
+	[IGMP_LAZY_MEMBER] = "lazy",
+	[IGMP_SLEEPING_MEMBER] = "sleeping",
+	[IGMP_AWAKENING_MEMBER] = "awakening",
+	[IGMP_G_QUERY_PENDING_MEMBER] = "query-pending",
+	[IGMP_SG_QUERY_PENDING_MEMBER] = "sg-query-pending",
+	[IGMP_LEAVING_MEMBER] = "leaving",
 };
+_Static_assert(IGMP_NOT_MEMBER == 0 &&
+	       IGMP_LEAVING_MEMBER + 1 == nitems(inm_statestrs),
+	       "inm_statetrs: no longer matches #defines");
 
 static const char *
 inm_state_str(const int state)


More information about the svn-src-all mailing list