aboutsummaryrefslogtreecommitdiff
path: root/sbin/ping/ping.c
diff options
context:
space:
mode:
authorRichard Scheffenegger <rscheff@FreeBSD.org>2020-10-24 21:01:18 +0000
committerRichard Scheffenegger <rscheff@FreeBSD.org>2020-10-24 21:01:18 +0000
commit81a6f4c7ae69d0f3acf564418b3a38153df6f26d (patch)
tree610c7f70d26418a76932d9358e784f617a979372 /sbin/ping/ping.c
parentcb8e0678184c6b9f157c065b04fb3faf508289ed (diff)
downloadsrc-81a6f4c7ae69d0f3acf564418b3a38153df6f26d.tar.gz
src-81a6f4c7ae69d0f3acf564418b3a38153df6f26d.zip
Make use of IP_VLAN_PCP setsockopt in ping and ping6.
In order to validate the proper marking and use of a different ethernet priority class, add the new session-specific PCP feature to the ping/ping6 utilities. Reviewed by: mav, bcr Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D26627
Notes
Notes: svn path=/head/; revision=367021
Diffstat (limited to 'sbin/ping/ping.c')
-rw-r--r--sbin/ping/ping.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 0b0e7a9fdd34..688543deab24 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -155,6 +155,7 @@ static int options;
#define F_TIME 0x100000
#define F_SWEEP 0x200000
#define F_WAITTIME 0x400000
+#define F_IP_VLAN_PCP 0x800000
/*
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
@@ -247,7 +248,7 @@ main(int argc, char *const *argv)
u_long alarmtimeout;
long ltmp;
int almost_done, ch, df, hold, i, icmp_len, mib[4], preload;
- int ssend_errno, srecv_errno, tos, ttl;
+ int ssend_errno, srecv_errno, tos, ttl, pcp;
char ctrl[CMSG_SPACE(sizeof(struct timespec))];
char hnamebuf[MAXHOSTNAMELEN], snamebuf[MAXHOSTNAMELEN];
#ifdef IP_OPTIONS
@@ -295,11 +296,11 @@ main(int argc, char *const *argv)
err(EX_OSERR, "srecv socket");
}
- alarmtimeout = df = preload = tos = 0;
+ alarmtimeout = df = preload = tos = pcp = 0;
outpack = outpackhdr + sizeof(struct ip);
while ((ch = getopt(argc, argv,
- "Aac:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
+ "AaC:c:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
"P:"
@@ -314,6 +315,13 @@ main(int argc, char *const *argv)
case 'a':
options |= F_AUDIBLE;
break;
+ case 'C':
+ options |= F_IP_VLAN_PCP;
+ ltmp = strtol(optarg, &ep, 0);
+ if (*ep || ep == optarg || ltmp > 7 || ltmp < -1)
+ errx(EX_USAGE, "invalid PCP: `%s'", optarg);
+ pcp = ltmp;
+ break;
case 'c':
ltmp = strtol(optarg, &ep, 0);
if (*ep || ep == optarg || ltmp <= 0)
@@ -665,6 +673,10 @@ main(int argc, char *const *argv)
if (options & F_SO_DONTROUTE)
(void)setsockopt(ssend, SOL_SOCKET, SO_DONTROUTE, (char *)&hold,
sizeof(hold));
+ if (options & F_IP_VLAN_PCP) {
+ (void)setsockopt(ssend, IPPROTO_IP, IP_VLAN_PCP, (char *)&pcp,
+ sizeof(pcp));
+ }
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
if (options & F_POLICY) {
@@ -1762,11 +1774,11 @@ usage(void)
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: ping [-AaDdfHnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
+"usage: ping [-AaDdfHnoQqRrv] [-C pcp] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
" [-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m ttl]",
" " SECOPT " [-p pattern] [-S src_addr] [-s packetsize] [-t timeout]",
" [-W waittime] [-z tos] host",
-" ping [-AaDdfHLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]",
+" ping [-AaDdfHLnoQqRrv] [-C pcp] [-c count] [-I iface] [-i wait] [-l preload]",
" [-M mask | time] [-m ttl]" SECOPT " [-p pattern] [-S src_addr]",
" [-s packetsize] [-T ttl] [-t timeout] [-W waittime]",
" [-z tos] mcast-group");