diff options
author | Dan McDonald <danmcd@joyent.com> | 2021-03-26 12:11:36 -0400 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2021-03-26 12:11:38 -0400 |
commit | 47f932df82ca981aa929650baee08fb181c3eada (patch) | |
tree | 464dd9c9164bd0d9d3218af3303941105677ef8c /usr/src/cmd/cmd-inet/usr.sbin | |
parent | 0eb9f0cca48b7b34380838b2e9020d2d44e7a27c (diff) | |
parent | d4d62540c939a1f768b551ce50297d66799bd53e (diff) | |
download | illumos-joyent-47f932df82ca981aa929650baee08fb181c3eada.tar.gz |
[illumos-gate merge]
commit d4d62540c939a1f768b551ce50297d66799bd53e
13652 xargs: writing 1 byte into a region of size 0
commit 49950d9c675502476d8644b1e5bb1bf0d743f53b
13666 stackalign: add SPARC support
commit 373fc975de7796bc28f551ba20f2d72b529dfe48
13670 OmniOS openssl package renames
commit 3307fc5b1f2f4445f00811b556ab80d50467262a
13660 stackalign: cast between incompatible function types
commit 89af4c7b28b4436849bcbafbdebd243918ee0969
13661 printf builtin should ignore leading --
commit e49fc96399e3e599d5736b0968a49892988d60b3
13612 Convert ksh93.1 to mdoc
commit ff02f816914596a5b08ed3ef117ba39db27d217f
13656 pbchk: filter HTTP 401 responses
commit c063eb990f530561e469b3c1e4bb64230456c0da
2755 split ksh93 from core package
13460 ksh93 tests should be moved out of usr/demo
518 ksh documentation should be moved out of SUNWcsr
commit a7792e7bce645a8015cc7d0eda87b7a21f380874
13653 Failing to enable promiscuous mode should not be a fatal error in snoop(1M)
commit 8a37ae750765321f9d9de63763676fa7280d93da
13630 libpcidb could know about class codes
Conflicts:
usr/src/test/util-tests/tests/Makefile
usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h
usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c
Diffstat (limited to 'usr/src/cmd/cmd-inet/usr.sbin')
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c | 21 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h | 4 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c | 44 |
3 files changed, 40 insertions, 29 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c index 6abda78efc..c9b1eb848e 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c @@ -22,6 +22,8 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2021 Joyent, Inc. */ #include <stdio.h> @@ -79,6 +81,7 @@ int x_length = 0x7fffffff; FILE *namefile; boolean_t Pflg; boolean_t Iflg; +boolean_t fflg; boolean_t qflg; boolean_t rflg; #ifdef DEBUG @@ -228,7 +231,7 @@ main(int argc, char **argv) } (void) setvbuf(stdout, NULL, _IOLBF, BUFSIZ); - while ((c = getopt(argc, argv, "at:CPDSi:o:Nn:s:d:I:vVp:f:c:x:U?rqz:Z")) + while ((c = getopt(argc, argv, "at:CPDSi:o:Nn:s:d:I:vVp:fc:x:U?rqz:Z")) != EOF) { switch (c) { case 'a': @@ -306,21 +309,7 @@ main(int argc, char **argv) } break; case 'f': - (void) gethostname(self, MAXHOSTNAMELEN); - p = strchr(optarg, ':'); - if (p) { - *p = '\0'; - if (strcmp(optarg, self) == 0 || - strcmp(p+1, self) == 0) - (void) fprintf(stderr, - "Warning: cannot capture packets from %s\n", - self); - *p = ' '; - } else if (strcmp(optarg, self) == 0) - (void) fprintf(stderr, - "Warning: cannot capture packets from %s\n", - self); - argstr = optarg; + fflg = B_TRUE; break; case 'x': p = optarg; diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h index ff9099bbf9..19a8c25a87 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h @@ -24,7 +24,7 @@ * Use is subject to license terms. * * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright 2018 Joyent, Inc. + * Copyright 2021 Joyent, Inc. */ #ifndef _SNOOP_H @@ -349,7 +349,7 @@ extern char *prot_title; extern unsigned int encap_levels, total_encap_levels; extern int quitting; -extern boolean_t Iflg, Pflg, rflg; +extern boolean_t Iflg, Pflg, fflg, rflg; /* * Global error recovery routine: used to reset snoop variables after diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c index 8fbf3fc15f..5ce947b476 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2012 Milan Jurik. All rights reserved. + * Copyright 2021 Joyent, Inc. */ #include <stdio.h> @@ -178,8 +179,8 @@ void init_datalink(dlpi_handle_t dh, ulong_t snaplen, ulong_t chunksize, struct timeval *timeout, struct Pf_ext_packetfilt *fp) { - int retv; - int netfd; + int retv; + int netfd; retv = dlpi_bind(dh, DLPI_ANY_SAP, NULL); if (retv != DLPI_SUCCESS) @@ -200,22 +201,43 @@ init_datalink(dlpi_handle_t dh, ulong_t snaplen, ulong_t chunksize, (void) fprintf(stderr, "(promiscuous mode)\n"); retv = dlpi_promiscon(dh, DL_PROMISC_PHYS); if (retv != DLPI_SUCCESS) { - pr_errdlpi(dh, "promiscuous mode(physical) failed", - retv); + if (fflg) { + (void) fprintf(stderr, "Note: enabling " + "promiscuous mode (physical) failed; " + "packet capture may not be complete\n"); + } else { + pr_errdlpi(dh, + "promiscuous mode (physical) failed; " + "use -f to ignore", retv); + } } } else { (void) fprintf(stderr, "(non promiscuous)\n"); retv = dlpi_promiscon(dh, DL_PROMISC_MULTI); if (retv != DLPI_SUCCESS) { - pr_errdlpi(dh, "promiscuous mode(multicast) failed", - retv); + if (fflg) { + (void) fprintf(stderr, "Note: enabling " + "promiscuous mode (multicast) failed; " + "packet capture may not be complete\n"); + } else { + pr_errdlpi(dh, + "promiscuous mode (multicast) failed; " + "use -f to ignore", retv); + } } } retv = dlpi_promiscon(dh, DL_PROMISC_SAP); - if (retv != DLPI_SUCCESS) - pr_errdlpi(dh, "promiscuous mode(SAP) failed", retv); - + if (retv != DLPI_SUCCESS) { + if (fflg) { + (void) fprintf(stderr, "Note: enabling promiscuous " + "mode (SAP) failed; packet capture may not be " + "complete\n"); + } else { + pr_errdlpi(dh, "promiscuous mode (SAP) failed; " + "use -f to ignore", retv); + } + } netfd = dlpi_fd(dh); if (fp) { @@ -264,7 +286,7 @@ void net_read(dlpi_handle_t dh, size_t chunksize, int filter, void (*proc)(), int flags) { - int retval; + int retval; extern int count; size_t msglen; @@ -301,7 +323,7 @@ net_read(dlpi_handle_t dh, size_t chunksize, int filter, void (*proc)(), */ void corrupt(volatile char *pktp, volatile char *pstop, char *buf, - volatile char *bufstop) + volatile char *bufstop) { int c; int i; |