Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136918996
D26627.id77725.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D26627.id77725.diff
View Options
Index: sbin/ping/ping.8
===================================================================
--- sbin/ping/ping.8
+++ sbin/ping/ping.8
@@ -28,7 +28,7 @@
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd August 22, 2019
+.Dd October 1, 2020
.Dt PING 8
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl AaDdfHnoQqRrv
+.Op Fl C Ar pcp
.Op Fl c Ar count
.Op Fl G Ar sweepmaxsize
.Op Fl g Ar sweepminsize
@@ -57,6 +58,7 @@
.Ar host
.Nm
.Op Fl AaDdfHLnoQqRrv
+.Op Fl C Ar pcp
.Op Fl c Ar count
.Op Fl I Ar iface
.Op Fl i Ar wait
@@ -112,6 +114,9 @@
character in the output when any packet is received.
This option is ignored
if other format options are present.
+.It Fl C Ar pcp
+Add a 802.1p Ethernet Priority Code Point when sending a packet.
+0..7 use that specific PCP, -1 use the interface default PCP (or none).
.It Fl c Ar count
Stop after sending
(and receiving)
Index: sbin/ping/ping.c
===================================================================
--- sbin/ping/ping.c
+++ sbin/ping/ping.c
@@ -155,6 +155,7 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
{
(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");
Index: sbin/ping6/ping6.8
===================================================================
--- sbin/ping6/ping6.8
+++ sbin/ping6/ping6.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 10, 2020
+.Dd October 1, 2020
.Dt PING6 8
.Os
.Sh NAME
@@ -47,6 +47,9 @@
.Op Fl b Ar bufsiz
.Ek
.Bk -words
+.Op Fl C Ar pcp
+.Ek
+.Bk -words
.Op Fl c Ar count
.Ek
.Bk -words
@@ -144,6 +147,9 @@
.El
.It Fl b Ar bufsiz
Set socket buffer size.
+.It Fl C Ar pcp
+Add a 802.1p Ethernet Priority Code Point when sending a packet.
+0..7 use that specific PCP, -1 use the interface default PCP (or none).
.It Fl c Ar count
Stop after sending
(and receiving)
Index: sbin/ping6/ping6.c
===================================================================
--- sbin/ping6/ping6.c
+++ sbin/ping6/ping6.c
@@ -230,6 +230,7 @@
static u_int8_t nonce[8]; /* nonce field for node information */
static int hoplimit = -1; /* hoplimit */
static int tclass = -1; /* traffic class */
+static int pcp = -2; /* vlan priority code point */
static u_char *packet = NULL;
static cap_channel_t *capdns;
@@ -353,7 +354,7 @@
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
- "k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) {
+ "k:b:C:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'k':
@@ -413,6 +414,13 @@
"-b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported");
#endif
break;
+ case 'C': /* vlan priority code point */
+ pcp = strtol(optarg, &e, 10);
+ if (*optarg == '\0' || *e != '\0')
+ errx(1, "illegal vlan pcp %s", optarg);
+ if (7 < pcp || pcp < -1)
+ errx(1, "illegal vlan pcp -- %s", optarg);
+ break;
case 'c':
npackets = strtol(optarg, &e, 10);
if (npackets <= 0 || *optarg == '\0' || *e != '\0')
@@ -952,6 +960,12 @@
err(1, "setsockopt(IPV6_TCLASS)");
}
+ if (pcp != -2) {
+ if (setsockopt(ssend, IPPROTO_IPV6, IPV6_VLAN_PCP,
+ &pcp, sizeof(pcp)) == -1)
+ err(1, "setsockopt(IPV6_VLAN_PCP)");
+ }
+
if (argc > 1) { /* some intermediate addrs are specified */
int hops;
int rthdrlen;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 4:05 PM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25775809
Default Alt Text
D26627.id77725.diff (5 KB)
Attached To
Mode
D26627: Make use of IP_VLAN_PCP setsockopt in ping and ping6.
Attached
Detach File
Event Timeline
Log In to Comment