The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=53807a8a27dc5e80d6564aee61b7fe2aeaf99768

commit 53807a8a27dc5e80d6564aee61b7fe2aeaf99768
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2022-10-04 03:53:04 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2022-10-04 03:53:04 +0000

    netinet*: use sparse C99 initializer for inetctlerrmap
    
    and mark those PRC_* codes, that are used.  The rest are dead code.
    This is not a functional change, but illustrative to make easier
    review of following changes.
---
 sys/netinet/ip_input.c   | 20 ++++++++++++++------
 sys/netinet6/ip6_input.c | 21 ++++++++++++++-------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 952b14943780..145c4464b855 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -873,13 +873,21 @@ ipproto_unregister(uint8_t proto)
                return (ENOENT);
 }
 
+/* (x) - issued by icmp_input() */
 u_char inetctlerrmap[PRC_NCMDS] = {
-       0,              0,              0,              0,
-       0,              EMSGSIZE,       EHOSTDOWN,      EHOSTUNREACH,
-       EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
-       EMSGSIZE,       EHOSTUNREACH,   0,              0,
-       0,              0,              EHOSTUNREACH,   0,
-       ENOPROTOOPT,    ECONNREFUSED
+       [PRC_MSGSIZE] = EMSGSIZE,                       /* (x) */
+       [PRC_HOSTDEAD] = EHOSTDOWN,
+       [PRC_HOSTUNREACH] = EHOSTUNREACH,
+       [PRC_UNREACH_NET] = EHOSTUNREACH,               /* (x) */
+       [PRC_UNREACH_HOST] = EHOSTUNREACH,
+       [PRC_UNREACH_PROTOCOL] = ECONNREFUSED,          /* (x) */
+       [PRC_UNREACH_PORT] = ECONNREFUSED,              /* (x) */
+       [12] = EMSGSIZE,
+       [PRC_UNREACH_SRCFAIL] = EHOSTUNREACH,
+       [PRC_TIMXCEED_INTRANS] = EHOSTUNREACH,          /* (x) */
+       [PRC_TIMXCEED_REASS] = 0,                       /* (x) */
+       [PRC_PARAMPROB] = ENOPROTOOPT,                  /* (x) */
+       [PRC_UNREACH_ADMIN_PROHIB] = ECONNREFUSED,      /* (x) */
 };
 
 /*
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 31a3170475cb..7bee7425421f 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1710,13 +1710,20 @@ ip6_lasthdr(const struct mbuf *m, int off, int proto, 
int *nxtp)
 
 /*
  * System control for IP6
+ * (x) - issued by icmp6_input()
  */
-
 u_char inet6ctlerrmap[PRC_NCMDS] = {
-       0,              0,              0,              0,
-       0,              EMSGSIZE,       EHOSTDOWN,      EHOSTUNREACH,
-       EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
-       EMSGSIZE,       EHOSTUNREACH,   0,              0,
-       0,              0,              EHOSTUNREACH,   0,
-       ENOPROTOOPT,    ECONNREFUSED
+       [PRC_MSGSIZE]   = EMSGSIZE,                     /* (x) */
+       [PRC_HOSTDEAD]  = EHOSTDOWN,
+       [PRC_HOSTUNREACH] = EHOSTUNREACH,
+       [PRC_UNREACH_NET] = EHOSTUNREACH,               /* (x) */
+       [PRC_UNREACH_HOST] = EHOSTUNREACH,
+       [PRC_UNREACH_PROTOCOL] = ECONNREFUSED,          /* (x) */
+       [PRC_UNREACH_PORT] = ECONNREFUSED,              /* (x) */
+       [12] = EMSGSIZE,
+       [PRC_UNREACH_SRCFAIL] = EHOSTUNREACH,
+       [PRC_TIMXCEED_INTRANS] = EHOSTUNREACH,          /* (x) */
+       [PRC_TIMXCEED_REASS] = 0,                       /* (x) */
+       [PRC_PARAMPROB] = ENOPROTOOPT,                  /* (x) */
+       [PRC_UNREACH_ADMIN_PROHIB] = ECONNREFUSED,      /* (x) */
 };

Reply via email to