svn commit: r366842 - in head: sys/netinet sys/netinet6 usr.bin/netstat
Mark Johnston
markj at FreeBSD.org
Mon Oct 19 17:07:21 UTC 2020
Author: markj
Date: Mon Oct 19 17:07:19 2020
New Revision: 366842
URL: https://svnweb.freebsd.org/changeset/base/366842
Log:
icmp6: Count packets dropped due to an invalid hop limit
Pad the icmp6stat structure so that we can add more counters in the
future without breaking compatibility again, last done in r358620.
Annotate the rarely executed error paths with __predict_false while
here.
Reviewed by: bz, melifaro
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26578
Modified:
head/sys/netinet/icmp6.h
head/sys/netinet6/icmp6.c
head/sys/netinet6/nd6_nbr.c
head/sys/netinet6/nd6_rtr.c
head/usr.bin/netstat/inet6.c
Modified: head/sys/netinet/icmp6.h
==============================================================================
--- head/sys/netinet/icmp6.h Mon Oct 19 16:57:59 2020 (r366841)
+++ head/sys/netinet/icmp6.h Mon Oct 19 17:07:19 2020 (r366842)
@@ -639,6 +639,8 @@ struct icmp6stat {
uint64_t icp6s_overflowprfx; /* Too many prefixes. */
uint64_t icp6s_overflownndp; /* Too many neighbour entries. */
uint64_t icp6s_overflowredirect;/* Too many redirects. */
+ uint64_t icp6s_invlhlim; /* Invalid hop limit. */
+ uint64_t icp6s_spare[32];
};
#ifdef _KERNEL
Modified: head/sys/netinet6/icmp6.c
==============================================================================
--- head/sys/netinet6/icmp6.c Mon Oct 19 16:57:59 2020 (r366841)
+++ head/sys/netinet6/icmp6.c Mon Oct 19 17:07:19 2020 (r366842)
@@ -2261,7 +2261,8 @@ icmp6_redirect_input(struct mbuf *m, int off)
ip6_sprintf(ip6buf, &src6)));
goto bad;
}
- if (ip6->ip6_hlim != 255) {
+ if (__predict_false(ip6->ip6_hlim != 255)) {
+ ICMP6STAT_INC(icp6s_invlhlim);
nd6log((LOG_ERR,
"ICMP6 redirect sent from %s rejected; "
"hlim=%d (must be 255)\n",
Modified: head/sys/netinet6/nd6_nbr.c
==============================================================================
--- head/sys/netinet6/nd6_nbr.c Mon Oct 19 16:57:59 2020 (r366841)
+++ head/sys/netinet6/nd6_nbr.c Mon Oct 19 17:07:19 2020 (r366842)
@@ -136,7 +136,8 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
ifp = m->m_pkthdr.rcvif;
ip6 = mtod(m, struct ip6_hdr *);
- if (ip6->ip6_hlim != 255) {
+ if (__predict_false(ip6->ip6_hlim != 255)) {
+ ICMP6STAT_INC(icp6s_invlhlim);
nd6log((LOG_ERR,
"nd6_ns_input: invalid hlim (%d) from %s to %s on %s\n",
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
@@ -641,7 +642,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
ifp = m->m_pkthdr.rcvif;
ip6 = mtod(m, struct ip6_hdr *);
- if (ip6->ip6_hlim != 255) {
+ if (__predict_false(ip6->ip6_hlim != 255)) {
+ ICMP6STAT_INC(icp6s_invlhlim);
nd6log((LOG_ERR,
"nd6_na_input: invalid hlim (%d) from %s to %s on %s\n",
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c Mon Oct 19 16:57:59 2020 (r366841)
+++ head/sys/netinet6/nd6_rtr.c Mon Oct 19 17:07:19 2020 (r366842)
@@ -177,7 +177,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
/* Sanity checks */
ip6 = mtod(m, struct ip6_hdr *);
- if (ip6->ip6_hlim != 255) {
+ if (__predict_false(ip6->ip6_hlim != 255)) {
+ ICMP6STAT_INC(icp6s_invlhlim);
nd6log((LOG_ERR,
"%s: invalid hlim (%d) from %s to %s on %s\n", __func__,
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
@@ -376,7 +377,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
goto freeit;
ip6 = mtod(m, struct ip6_hdr *);
- if (ip6->ip6_hlim != 255) {
+ if (__predict_false(ip6->ip6_hlim != 255)) {
+ ICMP6STAT_INC(icp6s_invlhlim);
nd6log((LOG_ERR,
"%s: invalid hlim (%d) from %s to %s on %s\n", __func__,
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
Modified: head/usr.bin/netstat/inet6.c
==============================================================================
--- head/usr.bin/netstat/inet6.c Mon Oct 19 16:57:59 2020 (r366841)
+++ head/usr.bin/netstat/inet6.c Mon Oct 19 17:07:19 2020 (r366842)
@@ -1063,6 +1063,8 @@ icmp6_stats(u_long off, const char *name, int af1 __un
"{N:/neighbour entries overflow%s}\n");
p(icp6s_overflowredirect, "\t{:redirect-overflows/%ju} "
"{N:/redirect overflow%s}\n");
+ p(icp6s_invlhlim, "\t{:dropped-invalid-hop-limit/%ju} "
+ "{N:/message%s with invalid hop limit}\n");
xo_close_container("errors");
p(icp6s_pmtuchg, "\t{:path-mtu-changes/%ju} {N:/path MTU change%s}\n");
#undef p
More information about the svn-src-all
mailing list