Add a sysctl, net.inet.icmp.tstamprepl, which can be used to disable replies

to ICMP Timestamp packets.

PR:		193689
Submitted by:	Anthony Cornehl <accornehl@gmail.com>
MFC after:	3 weeks
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Mark Johnston 2014-10-01 18:07:34 +00:00
parent 98286ba5f4
commit 00cb6bef99
2 changed files with 11 additions and 1 deletions

View File

@ -28,7 +28,7 @@
.\" @(#)icmp.4 8.1 (Berkeley) 6/5/93 .\" @(#)icmp.4 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd February 9, 2007 .Dd September 30, 2014
.Dt ICMP 4 .Dt ICMP 4
.Os .Os
.Sh NAME .Sh NAME
@ -216,6 +216,10 @@ instead of the possibly different return path.
Number of bytes from original packet to quote in ICMP reply. Number of bytes from original packet to quote in ICMP reply.
This number is internally enforced to be at least 8 bytes (per RFC792) This number is internally enforced to be at least 8 bytes (per RFC792)
and at most the maximal space left in the ICMP reply mbuf. and at most the maximal space left in the ICMP reply mbuf.
.It Va tstamprepl
.Pq Vt boolean
Enable/disable replies to ICMP Timestamp packets.
Defaults to true.
.El .El
.Sh ERRORS .Sh ERRORS
A socket operation may fail with one of the following errors returned: A socket operation may fail with one of the following errors returned:

View File

@ -149,6 +149,10 @@ SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, bmcastecho, CTLFLAG_RW,
&VNET_NAME(icmpbmcastecho), 0, &VNET_NAME(icmpbmcastecho), 0,
""); "");
static VNET_DEFINE(int, icmptstamprepl) = 1;
#define V_icmptstamprepl VNET(icmptstamprepl)
SYSCTL_INT(_net_inet_icmp, OID_AUTO, tstamprepl, CTLFLAG_RW,
&VNET_NAME(icmptstamprepl), 0, "Respond to ICMP Timestamp packets");
#ifdef ICMPPRINTFS #ifdef ICMPPRINTFS
int icmpprintfs = 0; int icmpprintfs = 0;
@ -545,6 +549,8 @@ icmp_input(struct mbuf **mp, int *offp, int proto)
goto reflect; goto reflect;
case ICMP_TSTAMP: case ICMP_TSTAMP:
if (V_icmptstamprepl == 0)
break;
if (!V_icmpbmcastecho if (!V_icmpbmcastecho
&& (m->m_flags & (M_MCAST | M_BCAST)) != 0) { && (m->m_flags & (M_MCAST | M_BCAST)) != 0) {
ICMPSTAT_INC(icps_bmcasttstamp); ICMPSTAT_INC(icps_bmcasttstamp);