diff options
author | Erik Nordmark <Erik.Nordmark@Sun.COM> | 2009-11-11 11:49:49 -0800 |
---|---|---|
committer | Erik Nordmark <Erik.Nordmark@Sun.COM> | 2009-11-11 11:49:49 -0800 |
commit | bd670b35a010421b6e1a5536c34453a827007c81 (patch) | |
tree | 97c2057b6771dd40411a12eb89d2db2e2b2cce31 /usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c | |
parent | b3388e4fc5f5c24c8a39fbe132a00b02dae5b717 (diff) | |
download | illumos-gate-bd670b35a010421b6e1a5536c34453a827007c81.tar.gz |
PSARC/2009/331 IP Datapath Refactoring
PSARC/2008/522 EOF of 2001/070 IPsec HW Acceleration support
PSARC/2009/495 netstat -r flags for blackhole and reject routes
PSARC 2009/496 EOF of XRESOLV
PSARC/2009/494 IP_DONTFRAG socket option
PSARC/2009/515 fragmentation controls for ping and traceroute
6798716 ip_newroute delenda est
6798739 ARP and IP are too separate
6807265 IPv4 ip2mac() support
6756382 Please remove Venus IPsec HWACCEL code
6880632 sendto/sendmsg never returns EHOSTUNREACH in Solaris
6748582 sendmsg() return OK, but doesn't send message using IPv4-mapped x IPv6 addr
1119790 TCP and path mtu discovery
4637227 should support equal-cost multi-path (ECMP)
5078568 getsockopt() for IPV6_PATHMTU on a non-connected socket should not succeed
6419648 "AR* contract private note" should be removed as part of ATM SW EOL
6274715 Arp could keep the old entry in the cache while it waits for an arp response
6605615 Remove duplicated TCP/IP opt_set/opt_get code; use conn_t
6874677 IP_TTL can be used to send with ttl zero
4034090 arp should not let you delete your own entry
6882140 Implement IP_DONTFRAG socket option
6883858 Implement ping -D option; traceroute -F should work for IPv6 and shared-IP zones
1119792 TCP/IP black hole detection is broken on receiver
4078796 Directed broadcast forwarding code has problems
4104337 restrict the IPPROTO_IP and IPPROTO_IPV6 options based on the socket family
4203747 Source address selection for source routed packets
4230259 pmtu is increased every ip_ire_pathmtu_interval timer value.
4300533 When sticky option ipv6_pktinfo set to bogus address subsequent connect time out
4471035 ire_delete_cache_gw is called through ire_walk unnecessarily
4514572 SO_DONTROUTE socket option doesn't work with IPv6
4524980 tcp_lookup_ipv4() should compare the ifindex against tcpb->tcpb_bound_if
4532714 machine fails to switch quickly among failed default routes
4634219 IPv6 path mtu discovery is broken when using routing header
4691581 udp broadcast handling causes too many replicas
4708405 mcast is broken on machines when all interfaces are IFF_POINTOPOINT
4770457 netstat/route: source address of interface routes pretends to be gateway address
4786974 use routing table to determine routes/interface for multicast
4792619 An ip_fanout_udp_ipc_v6() routine might lead to some simpler code
4816115 Nuke ipsec_out_use_global_policy
4862844 ipsec offload corner case
4867533 tcp_rq and tcp_wq are redundant
4868589 NCEs should be shared across an IPMP group
4872093 unplumbing an improper virtual interface panics in ip_newroute_get_dst_ill()
4901671 FireEngine needs some cleanup
4907617 IPsec identity latching should be done before sending SYN-ACK
4941461 scopeid and IPV6_PKTINFO with UDP/ICMP connect() does not work properly
4944981 ip does nothing with IP6I_NEXTHOP
4963353 IPv4 and IPv6 proto fanout codes could be brought closer
4963360 consider passing zoneid using ip6i_t instead of ipsec_out_t in NDP
4963734 new ip6_asp locking is used incorrectly in ip_newroute_v6()
5008315 IPv6 code passes ip6i_t to IPsec code instead of ip6_t
5009636 memory leak in ip_fanout_proto_v6()
5092337 tcp/udp option handling can use some cleanup
5035841 Solaris can fail to create a valid broadcast ire
5043747 ar_query_xmit: Could not find the ace
5051574 tcp_check_policy is missing some checks
6305037 full hardware checksum is discarded when there're more than 2 mblks in the chain
6311149 ip.c needs to be put through a woodchipper
4708860 Unable to reassemble CGTP fragmented multicast packets
6224628 Large IPv6 packets with IPsec protection sometimes have length mismatch.
6213243 Solaris does not currently support Dead Gateway Detection
5029091 duplicate code in IP's input path for TCP/UDP/SCTP
4674643 through IPv6 CGTP routes, the very first packet is sent only after a while
6207318 Multiple default routes do not round robin connections to routers.
4823410 IP has an inconsistent view of link mtu
5105520 adding interface route to down interface causes ifconfig hang
5105707 advanced sockets API introduced some dead code
6318399 IP option handling for icmp and udp is too complicated
6321434 Every dropped packet in IP should use ip_drop_packet()
6341693 ifconfig mtu should operate on the physical interface, not individual ipif's
6352430 The credentials attached to an mblk are not particularly useful
6357894 uninitialised ipp_hoplimit needs to be cleaned up.
6363568 ip_xmit_v6() may be missing IRE releases in error cases
6364828 ip_rput_forward needs a makeover
6384416 System panics when running as multicast forwarder using multicast tunnels
6402382 TX: UDP v6 slowpath is not modified to handle mac_exempt conns
6418413 assertion failed ipha->ipha_ident == 0||ipha->ipha_ident == 0xFFFF
6420916 assertion failures in ipv6 wput path
6430851 use of b_prev to store ifindex is not 100% safe
6446106 IPv6 packets stored in nce->nce_qd_mp will be sent with incorrect tcp/udp checksums
6453711 SCTP OOTB sent as if genetated by global zone
6465212 ARP/IP merge should remove ire_freemblk.esballoc
6490163 ip_input() could misbehave if the first mblk's size is not big enough
6496664 missing ipif_refrele leads to reference leak and deferred crash in ip_wput_ipsec_out_v6
6504856 memory leak in ip_fanout_proto_v6() when using link local outer tunnel addresses
6507765 IRE cache hash function performs badly
6510186 IP_FORWARD_PROG bit is easily overlooked
6514727 cgtp ipv6 failure on snv54
6528286 MULTIRT (CGTP) should offload checksum to hardware
6533904 SCTP: doesn't support traffic class for IPv6
6539415 TX: ipif source selection is flawed for unlabeled gateways
6539851 plumbed unworking nic blocks sending broadcast packets
6564468 non-solaris SCTP stack over rawip socket: netstat command counts rawipInData not rawipOutDatagrams
6568511 ipIfStatsOutDiscards not bumped when discarding an ipsec packet on the wrong NIC
6584162 tcp_g_q_inactive() makes incorrect use of taskq_dispatch()
6603974 round-robin default with many interfaces causes infinite temporary IRE thrashing
6611750 ilm_lookup_ill_index_v4 was born an orphan
6618423 ip_wput_frag_mdt sends out packets that void pfhooks
6620964 IRE max bucket count calculations performed in ip_ire_init() are flawed
6626266 various _broadcasts seem redundant
6638182 IP_PKTINFO + SO_DONTROUTE + CIPSO IP option == panic
6647710 IPv6 possible DoS vulnerability
6657357 nce should be kmem_cache alloc'ed from an nce_cache.
6685131 ilg_add -> conn_ilg_alloc interacting with conn_ilg[] walkers can cause panic.
6730298 adding 0.0.0.0 key with mask != 0 causes 'route delete default' to fail
6730976 vni and ipv6 doesn't quite work.
6740956 assertion failed: mp->b_next == 0L && mp->b_prev == 0L in nce_queue_mp_common()
6748515 BUMP_MIB() is occasionally done on the wrong ill
6753250 ip_output_v6() `notv6' error path has an errant ill_refrele()
6756411 NULL-pointer dereference in ip_wput_local()
6769582 IP must forward packet returned from FW-HOOK
6781525 bogus usesrc usage leads directly to panic
6422839 System paniced in ip_multicast_loopback due to NULL pointer dereference
6785521 initial IPv6 DAD solicitation is dropped in ip_newroute_ipif_v6()
6787370 ipnet devices not seeing forwarded IP packets on outgoing interface
6791187 ip*dbg() calls in ip_output_options() claim to originate from ip_wput()
6794047 nce_fp_mp prevents sharing of NCEs across an IPMP group
6797926 many unnecessary ip0dbg() in ip_rput_data_v6
6846919 Packet queued for ND gets sent in the clear.
6856591 ping doesn't send packets with DF set
6861113 arp module has incorrect dependency path for hook module
6865664 IPV6_NEXTHOP does not work with TCP socket
6874681 No ICMP time exceeded when a router receives packet with ttl = 0
6880977 ip_wput_ire() uses over 1k of stack
6595433 IPsec performance could be significantly better when calling hw crypto provider synchronously
6848397 ifconfig down of an interface can hang.
6849602 IPV6_PATHMTU size issue for UDP
6885359 Add compile-time option for testing pure IPsec overhead
6889268 Odd loopback source address selection with IPMP
6895420 assertion failed: connp->conn_helper_info == NULL
6851189 Routing-related panic occurred during reboot on T2000 system running snv_117
6896174 Post-async-encryption, AH+ESP packets may have misinitialized ipha/ip6
6896687 iptun presents IPv6 with an MTU < 1280
6897006 assertion failed: ipif->ipif_id != 0 in ip_sioctl_slifzone_restart
Diffstat (limited to 'usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c')
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c | 378 |
1 files changed, 269 insertions, 109 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c index 96bcec530c..1919d21356 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c +++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c @@ -196,6 +196,7 @@ static void ire_report(const mib_item_t *item); static void tcp_report(const mib_item_t *item); static void udp_report(const mib_item_t *item); static void group_report(mib_item_t *item); +static void dce_report(mib_item_t *item); static void print_ip_stats(mib2_ip_t *ip); static void print_icmp_stats(mib2_icmp_t *icmp); static void print_ip6_stats(mib2_ipv6IfStatsEntry_t *ip6); @@ -236,7 +237,7 @@ static void fatal(int errcode, char *str1, ...); static boolean_t Aflag = B_FALSE; /* All sockets/ifs/rtng-tbls */ -static boolean_t Dflag = B_FALSE; /* Debug Info */ +static boolean_t Dflag = B_FALSE; /* DCE info */ static boolean_t Iflag = B_FALSE; /* IP Traffic Interfaces */ static boolean_t Mflag = B_FALSE; /* STREAMS Memory Statistics */ static boolean_t Nflag = B_FALSE; /* Numeric Network Addresses */ @@ -248,6 +249,7 @@ static boolean_t Pflag = B_FALSE; /* Net to Media Tables */ static boolean_t Gflag = B_FALSE; /* Multicast group membership */ static boolean_t MMflag = B_FALSE; /* Multicast routing table */ static boolean_t DHCPflag = B_FALSE; /* DHCP statistics */ +static boolean_t Xflag = B_FALSE; /* Debug Info */ static int v4compat = 0; /* Compatible printing format for status */ @@ -276,6 +278,8 @@ static int ipv6NetToMediaEntrySize; static int ipv6MemberEntrySize; static int ipv6GroupSourceEntrySize; +static int ipDestEntrySize; + static int transportMLPSize; static int tcpConnEntrySize; static int tcp6ConnEntrySize; @@ -298,7 +302,7 @@ static m_label_t *zone_security_label = NULL; /* Flags on routes */ #define FLF_A 0x00000001 -#define FLF_B 0x00000002 +#define FLF_b 0x00000002 #define FLF_D 0x00000004 #define FLF_G 0x00000008 #define FLF_H 0x00000010 @@ -306,7 +310,12 @@ static m_label_t *zone_security_label = NULL; #define FLF_U 0x00000040 #define FLF_M 0x00000080 #define FLF_S 0x00000100 -static const char flag_list[] = "ABDGHLUMS"; +#define FLF_C 0x00000200 /* IRE_IF_CLONE */ +#define FLF_I 0x00000400 /* RTF_INDIRECT */ +#define FLF_R 0x00000800 /* RTF_REJECT */ +#define FLF_B 0x00001000 /* RTF_BLACKHOLE */ + +static const char flag_list[] = "AbDGHLUMSCIRB"; typedef struct filter_rule filter_t; @@ -379,14 +388,15 @@ main(int argc, char **argv) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - while ((c = getopt(argc, argv, "adimnrspMgvf:P:I:DRT:")) != -1) { + while ((c = getopt(argc, argv, "adimnrspMgvxf:P:I:DRT:")) != -1) { switch ((char)c) { case 'a': /* all connections */ Aflag = B_TRUE; break; - case 'd': /* turn on debugging */ + case 'd': /* DCE info */ Dflag = B_TRUE; + IFLAGMOD(Iflag_only, 1, 0); /* see macro def'n */ break; case 'i': /* interface (ill/ipif report) */ @@ -438,6 +448,10 @@ main(int argc, char **argv) IFLAGMOD(Iflag_only, 1, 0); /* see macro def'n */ break; + case 'x': /* turn on debugging */ + Xflag = B_TRUE; + break; + case 'f': process_filter(optarg); break; @@ -603,7 +617,7 @@ main(int argc, char **argv) mib_item_destroy(&previtem); } - if (!(Iflag || Rflag || Sflag || Mflag || + if (!(Dflag || Iflag || Rflag || Sflag || Mflag || MMflag || Pflag || Gflag || DHCPflag)) { if (protocol_selected(IPPROTO_UDP)) udp_report(item); @@ -634,12 +648,14 @@ main(int argc, char **argv) if (family_selected(AF_INET6)) ndp_report(item); } + if (Dflag) + dce_report(item); mib_item_destroy(&curritem); } /* netstat: AF_UNIX behaviour */ if (family_selected(AF_UNIX) && - (!(Iflag || Rflag || Sflag || Mflag || + (!(Dflag || Iflag || Rflag || Sflag || Mflag || MMflag || Pflag || Gflag))) unixpr(kc); (void) kstat_close(kc); @@ -729,7 +745,7 @@ mibget(int sd) * us information concerning IRE_MARK_TESTHIDDEN routes. */ req = (struct opthdr *)&tor[1]; - req->level = EXPER_IP_AND_TESTHIDDEN; + req->level = EXPER_IP_AND_ALL_IRES; req->name = 0; req->len = 0; @@ -755,7 +771,7 @@ mibget(int sd) getcode = getmsg(sd, &ctlbuf, (struct strbuf *)0, &flags); if (getcode == -1) { perror("mibget getmsg(ctl) failed"); - if (Dflag) { + if (Xflag) { (void) fputs("# level name len\n", stderr); i = 0; @@ -774,7 +790,7 @@ mibget(int sd) toa->PRIM_type == T_OPTMGMT_ACK && toa->MGMT_flags == T_SUCCESS && req->len == 0) { - if (Dflag) + if (Xflag) (void) printf("mibget getmsg() %d returned " "EOD (level %ld, name %ld)\n", j, req->level, req->name); @@ -826,7 +842,7 @@ mibget(int sd) last_item->valp = malloc((int)req->len); if (last_item->valp == NULL) goto error_exit; - if (Dflag) + if (Xflag) (void) printf("msg %d: group = %4d mib_id = %5d" "length = %d\n", j, last_item->group, last_item->mib_id, @@ -1754,6 +1770,7 @@ mib_get_constants(mib_item_t *item) ipGroupSourceEntrySize = ip->ipGroupSourceEntrySize; ipRouteAttributeSize = ip->ipRouteAttributeSize; transportMLPSize = ip->transportMLPSize; + ipDestEntrySize = ip->ipDestEntrySize; assert(IS_P2ALIGNED(ipAddrEntrySize, sizeof (mib2_ipAddrEntry_t *))); assert(IS_P2ALIGNED(ipRouteEntrySize, @@ -1850,7 +1867,7 @@ mib_get_constants(mib_item_t *item) } } /* 'for' loop 1 ends */ - if (Dflag) { + if (Xflag) { (void) puts("mib_get_constants:"); (void) printf("\tipv6IfStatsEntrySize %d\n", ipv6IfStatsEntrySize); @@ -1872,6 +1889,7 @@ mib_get_constants(mib_item_t *item) ipv6MemberEntrySize); (void) printf("\tipv6IfIcmpEntrySize %d\n", ipv6IfIcmpEntrySize); + (void) printf("\tipDestEntrySize %d\n", ipDestEntrySize); (void) printf("\ttransportMLPSize %d\n", transportMLPSize); (void) printf("\ttcpConnEntrySize %d\n", tcpConnEntrySize); (void) printf("\ttcp6ConnEntrySize %d\n", tcp6ConnEntrySize); @@ -1895,7 +1913,7 @@ stat_report(mib_item_t *item) /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -2542,7 +2560,7 @@ mrt_stat_report(mib_item_t *curritem) for (tempitem = curritem; tempitem; tempitem = tempitem->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -2603,7 +2621,7 @@ if_report(mib_item_t *item, char *matchname, /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -2632,7 +2650,7 @@ if_report(mib_item_t *item, char *matchname, boolean_t first = B_TRUE; uint32_t new_ifindex; - if (Dflag) + if (Xflag) (void) printf("if_report: %d items\n", (item->length) / sizeof (mib2_ipAddrEntry_t)); @@ -2944,7 +2962,7 @@ if_report(mib_item_t *item, char *matchname, boolean_t first = B_TRUE; uint32_t new_ifindex; - if (Dflag) + if (Xflag) (void) printf("if_report: %d items\n", (item->length) / sizeof (mib2_ipv6AddrEntry_t)); @@ -3287,10 +3305,10 @@ if_report_ip4(mib2_ipAddrEntry_t *ap, (void) pr_netaddr(ap->ipAdEntAddr, ap->ipAdEntNetMask, abuf, sizeof (abuf)); - (void) printf("%-13s %-14s %-6llu %-5s %-6llu " + (void) printf("%-13s %-14s %-6llu %-5s %-6s " "%-5s %-6s %-6llu\n", abuf, pr_addr(ap->ipAdEntAddr, dstbuf, sizeof (dstbuf)), - statptr->ipackets, "N/A", statptr->opackets, "N/A", "N/A", + statptr->ipackets, "N/A", "N/A", "N/A", "N/A", 0LL); } } @@ -3337,11 +3355,10 @@ if_report_ip6(mib2_ipv6AddrEntry_t *ap6, else (void) pr_prefix6(&ap6->ipv6AddrAddress, ap6->ipv6AddrPfxLength, abuf, sizeof (abuf)); - (void) printf("%-27s %-27s %-6llu %-5s %-6llu %-5s %-6s\n", + (void) printf("%-27s %-27s %-6llu %-5s %-6s %-5s %-6s\n", abuf, pr_addr6(&ap6->ipv6AddrAddress, dstbuf, sizeof (dstbuf)), - statptr->ipackets, "N/A", - statptr->opackets, "N/A", "N/A"); + statptr->ipackets, "N/A", "N/A", "N/A", "N/A"); } } @@ -3490,7 +3507,7 @@ group_report(mib_item_t *item) /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -3501,12 +3518,12 @@ group_report(mib_item_t *item) switch (item->mib_id) { case EXPER_IP_GROUP_MEMBERSHIP: v4grp = item; - if (Dflag) + if (Xflag) (void) printf("item is v4grp info\n"); break; case EXPER_IP_GROUP_SOURCES: v4src = item; - if (Dflag) + if (Xflag) (void) printf("item is v4src info\n"); break; default: @@ -3518,12 +3535,12 @@ group_report(mib_item_t *item) switch (item->mib_id) { case EXPER_IP6_GROUP_MEMBERSHIP: v6grp = item; - if (Dflag) + if (Xflag) (void) printf("item is v6grp info\n"); break; case EXPER_IP6_GROUP_SOURCES: v6src = item; - if (Dflag) + if (Xflag) (void) printf("item is v6src info\n"); break; default: @@ -3533,7 +3550,7 @@ group_report(mib_item_t *item) } if (family_selected(AF_INET) && v4grp != NULL) { - if (Dflag) + if (Xflag) (void) printf("%u records for ipGroupMember:\n", v4grp->length / sizeof (ip_member_t)); @@ -3564,7 +3581,7 @@ group_report(mib_item_t *item) if (!Vflag || v4src == NULL) continue; - if (Dflag) + if (Xflag) (void) printf("scanning %u ipGroupSource " "records...\n", v4src->length/sizeof (ip_grpsrc_t)); @@ -3609,7 +3626,7 @@ group_report(mib_item_t *item) } if (family_selected(AF_INET6) && v6grp != NULL) { - if (Dflag) + if (Xflag) (void) printf("%u records for ipv6GroupMember:\n", v6grp->length / sizeof (ipv6_member_t)); @@ -3638,7 +3655,7 @@ group_report(mib_item_t *item) if (!Vflag || v6src == NULL) continue; - if (Dflag) + if (Xflag) (void) printf("scanning %u ipv6GroupSource " "records...\n", v6src->length/sizeof (ipv6_grpsrc_t)); @@ -3683,6 +3700,126 @@ group_report(mib_item_t *item) (void) fflush(stdout); } +/* --------------------- DCE_REPORT (netstat -d) ------------------------- */ + +#define FLBUFSIZE 8 + +/* Assumes flbuf is at least 5 characters; callers use FLBUFSIZE */ +static char * +dceflags2str(uint32_t flags, char *flbuf) +{ + char *str = flbuf; + + if (flags & DCEF_DEFAULT) + *str++ = 'D'; + if (flags & DCEF_PMTU) + *str++ = 'P'; + if (flags & DCEF_UINFO) + *str++ = 'U'; + if (flags & DCEF_TOO_SMALL_PMTU) + *str++ = 'S'; + *str++ = '\0'; + return (flbuf); +} + +static void +dce_report(mib_item_t *item) +{ + mib_item_t *v4dce = NULL; + mib_item_t *v6dce = NULL; + int jtemp = 0; + char ifname[LIFNAMSIZ + 1]; + char abuf[MAXHOSTNAMELEN + 1]; + char flbuf[FLBUFSIZE]; + boolean_t first; + dest_cache_entry_t *dce; + + /* 'for' loop 1: */ + for (; item; item = item->next_item) { + if (Xflag) { + (void) printf("\n--- Entry %d ---\n", ++jtemp); + (void) printf("Group = %d, mib_id = %d, " + "length = %d, valp = 0x%p\n", + item->group, item->mib_id, item->length, + item->valp); + } + if (item->group == MIB2_IP && family_selected(AF_INET) && + item->mib_id == EXPER_IP_DCE) { + v4dce = item; + if (Xflag) + (void) printf("item is v4dce info\n"); + } + if (item->group == MIB2_IP6 && family_selected(AF_INET6) && + item->mib_id == EXPER_IP_DCE) { + v6dce = item; + if (Xflag) + (void) printf("item is v6dce info\n"); + } + } + + if (family_selected(AF_INET) && v4dce != NULL) { + if (Xflag) + (void) printf("%u records for DestCacheEntry:\n", + v4dce->length / ipDestEntrySize); + + first = B_TRUE; + for (dce = (dest_cache_entry_t *)v4dce->valp; + (char *)dce < (char *)v4dce->valp + v4dce->length; + /* LINTED: (note 1) */ + dce = (dest_cache_entry_t *)((char *)dce + + ipDestEntrySize)) { + if (first) { + (void) putchar('\n'); + (void) puts("Destination Cache Entries: IPv4"); + (void) puts( + "Address PMTU Age Flags"); + (void) puts( + "-------------------- ------ ----- -----"); + first = B_FALSE; + } + + (void) printf("%-20s %6u %5u %-5s\n", + pr_addr(dce->DestIpv4Address, abuf, sizeof (abuf)), + dce->DestPmtu, dce->DestAge, + dceflags2str(dce->DestFlags, flbuf)); + } + } + + if (family_selected(AF_INET6) && v6dce != NULL) { + if (Xflag) + (void) printf("%u records for DestCacheEntry:\n", + v6dce->length / ipDestEntrySize); + + first = B_TRUE; + for (dce = (dest_cache_entry_t *)v6dce->valp; + (char *)dce < (char *)v6dce->valp + v6dce->length; + /* LINTED: (note 1) */ + dce = (dest_cache_entry_t *)((char *)dce + + ipDestEntrySize)) { + if (first) { + (void) putchar('\n'); + (void) puts("Destination Cache Entries: IPv6"); + (void) puts( + "Address PMTU " + " Age Flags If "); + (void) puts( + "--------------------------- ------ " + "----- ----- ---"); + first = B_FALSE; + } + + (void) printf("%-27s %6u %5u %-5s %s\n", + pr_addr6(&dce->DestIpv6Address, abuf, + sizeof (abuf)), + dce->DestPmtu, dce->DestAge, + dceflags2str(dce->DestFlags, flbuf), + dce->DestIfindex == 0 ? "" : + ifindex2str(dce->DestIfindex, ifname)); + } + } + (void) fflush(stdout); +} + /* --------------------- ARP_REPORT (netstat -p) -------------------------- */ static void @@ -3703,7 +3840,7 @@ arp_report(mib_item_t *item) /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -3713,7 +3850,7 @@ arp_report(mib_item_t *item) if (!(item->group == MIB2_IP && item->mib_id == MIB2_IP_MEDIA)) continue; /* 'for' loop 1 */ - if (Dflag) + if (Xflag) (void) printf("%u records for " "ipNetToMediaEntryTable:\n", item->length/sizeof (mib2_ipNetToMediaEntry_t)); @@ -3798,7 +3935,7 @@ ndp_report(mib_item_t *item) /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -3973,7 +4110,7 @@ ire_report(const mib_item_t *item) v4a = v4_attrs; v6a = v6_attrs; for (; item != NULL; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -3991,7 +4128,7 @@ ire_report(const mib_item_t *item) else if (item->group == MIB2_IP6 && !family_selected(AF_INET6)) continue; /* 'for' loop 1 */ - if (Dflag) { + if (Xflag) { if (item->group == MIB2_IP) { (void) printf("%u records for " "ipRouteEntryTable:\n", @@ -4161,29 +4298,29 @@ form_v4_route_flags(const mib2_ipRouteEntry_t *rp, char *flags) flag_b = FLF_U; (void) strcpy(flags, "U"); - if (rp->ipRouteInfo.re_ire_type == IRE_DEFAULT || - rp->ipRouteInfo.re_ire_type == IRE_PREFIX || - rp->ipRouteInfo.re_ire_type == IRE_HOST || - rp->ipRouteInfo.re_ire_type == IRE_HOST_REDIRECT) { + /* RTF_INDIRECT wins over RTF_GATEWAY - don't display both */ + if (rp->ipRouteInfo.re_flags & RTF_INDIRECT) { + (void) strcat(flags, "I"); + flag_b |= FLF_I; + } else if (rp->ipRouteInfo.re_ire_type & IRE_OFFLINK) { (void) strcat(flags, "G"); flag_b |= FLF_G; } - if (rp->ipRouteMask == IP_HOST_MASK) { + /* IRE_IF_CLONE wins over RTF_HOST - don't display both */ + if (rp->ipRouteInfo.re_ire_type & IRE_IF_CLONE) { + (void) strcat(flags, "C"); + flag_b |= FLF_C; + } else if (rp->ipRouteMask == IP_HOST_MASK) { (void) strcat(flags, "H"); flag_b |= FLF_H; } - if (rp->ipRouteInfo.re_ire_type == IRE_HOST_REDIRECT) { + if (rp->ipRouteInfo.re_flags & RTF_DYNAMIC) { (void) strcat(flags, "D"); flag_b |= FLF_D; } - if (rp->ipRouteInfo.re_ire_type == IRE_CACHE) { - /* Address resolution */ - (void) strcat(flags, "A"); - flag_b |= FLF_A; - } if (rp->ipRouteInfo.re_ire_type == IRE_BROADCAST) { /* Broadcast */ - (void) strcat(flags, "B"); - flag_b |= FLF_B; + (void) strcat(flags, "b"); + flag_b |= FLF_b; } if (rp->ipRouteInfo.re_ire_type == IRE_LOCAL) { /* Local */ (void) strcat(flags, "L"); @@ -4197,6 +4334,14 @@ form_v4_route_flags(const mib2_ipRouteEntry_t *rp, char *flags) (void) strcat(flags, "S"); /* Setsrc */ flag_b |= FLF_S; } + if (rp->ipRouteInfo.re_flags & RTF_REJECT) { + (void) strcat(flags, "R"); + flag_b |= FLF_R; + } + if (rp->ipRouteInfo.re_flags & RTF_BLACKHOLE) { + (void) strcat(flags, "B"); + flag_b |= FLF_B; + } return (flag_b); } @@ -4205,9 +4350,9 @@ static const char ire_hdr_v4[] = static const char ire_hdr_v4_compat[] = "\n%s Table:\n"; static const char ire_hdr_v4_verbose[] = -" Destination Mask Gateway Device Mxfrg " -"Rtt Ref Flg Out In/Fwd %s\n" -"-------------------- --------------- -------------------- ------ ----- " +" Destination Mask Gateway Device " +" MTU Ref Flg Out In/Fwd %s\n" +"-------------------- --------------- -------------------- ------ " "----- --- --- ----- ------ %s\n"; static const char ire_hdr_v4_normal[] = @@ -4226,8 +4371,10 @@ ire_report_item_v4(const mib2_ipRouteEntry_t *rp, boolean_t first, char flags[10]; /* RTF_ flags */ uint_t flag_b; - if (!(Aflag || (rp->ipRouteInfo.re_ire_type != IRE_CACHE && + if (!(Aflag || (rp->ipRouteInfo.re_ire_type != IRE_IF_CLONE && rp->ipRouteInfo.re_ire_type != IRE_BROADCAST && + rp->ipRouteInfo.re_ire_type != IRE_MULTICAST && + rp->ipRouteInfo.re_ire_type != IRE_NOROUTE && rp->ipRouteInfo.re_ire_type != IRE_LOCAL))) { return (first); } @@ -4253,15 +4400,13 @@ ire_report_item_v4(const mib2_ipRouteEntry_t *rp, boolean_t first, dstbuf, sizeof (dstbuf)); } if (Vflag) { - (void) printf("%-20s %-15s %-20s %-6s %5u%c %4u %3u " + (void) printf("%-20s %-15s %-20s %-6s %5u %3u " "%-4s%6u %6u %s\n", dstbuf, pr_mask(rp->ipRouteMask, maskbuf, sizeof (maskbuf)), pr_addrnz(rp->ipRouteNextHop, gwbuf, sizeof (gwbuf)), octetstr(&rp->ipRouteIfIndex, 'a', ifname, sizeof (ifname)), rp->ipRouteInfo.re_max_frag, - rp->ipRouteInfo.re_frag_flag ? '*' : ' ', - rp->ipRouteInfo.re_rtt, rp->ipRouteInfo.re_ref, flags, rp->ipRouteInfo.re_obpkt, @@ -4391,58 +4536,39 @@ ire_filter_match_v6(const mib2_ipv6RouteEntry_t *rp6, uint_t flag_b) return (B_TRUE); } -static const char ire_hdr_v6[] = -"\n%s Table: IPv6\n"; -static const char ire_hdr_v6_verbose[] = -" Destination/Mask Gateway If PMTU Rtt " -"Ref Flags Out In/Fwd %s\n" -"--------------------------- --------------------------- ----- ------ ----- " -"--- ----- ------ ------ %s\n"; -static const char ire_hdr_v6_normal[] = -" Destination/Mask Gateway Flags Ref Use " -" If %s\n" -"--------------------------- --------------------------- ----- --- ------- " -"----- %s\n"; - -static boolean_t -ire_report_item_v6(const mib2_ipv6RouteEntry_t *rp6, boolean_t first, - const sec_attr_list_t *attrs) +/* + * Given an IPv6 MIB2 route entry, form the list of flags for the + * route. + */ +static uint_t +form_v6_route_flags(const mib2_ipv6RouteEntry_t *rp6, char *flags) { - char dstbuf[MAXHOSTNAMELEN + 1]; - char gwbuf[MAXHOSTNAMELEN + 1]; - char ifname[LIFNAMSIZ + 1]; - char flags[10]; /* RTF_ flags */ - uint_t flag_b; - - if (!(Aflag || (rp6->ipv6RouteInfo.re_ire_type != IRE_CACHE && - rp6->ipv6RouteInfo.re_ire_type != IRE_LOCAL))) { - return (first); - } + uint_t flag_b; flag_b = FLF_U; (void) strcpy(flags, "U"); - if (rp6->ipv6RouteInfo.re_ire_type == IRE_DEFAULT || - rp6->ipv6RouteInfo.re_ire_type == IRE_PREFIX || - rp6->ipv6RouteInfo.re_ire_type == IRE_HOST || - rp6->ipv6RouteInfo.re_ire_type == IRE_HOST_REDIRECT) { + /* RTF_INDIRECT wins over RTF_GATEWAY - don't display both */ + if (rp6->ipv6RouteInfo.re_flags & RTF_INDIRECT) { + (void) strcat(flags, "I"); + flag_b |= FLF_I; + } else if (rp6->ipv6RouteInfo.re_ire_type & IRE_OFFLINK) { (void) strcat(flags, "G"); flag_b |= FLF_G; } - if (rp6->ipv6RoutePfxLength == IPV6_ABITS) { + /* IRE_IF_CLONE wins over RTF_HOST - don't display both */ + if (rp6->ipv6RouteInfo.re_ire_type & IRE_IF_CLONE) { + (void) strcat(flags, "C"); + flag_b |= FLF_C; + } else if (rp6->ipv6RoutePfxLength == IPV6_ABITS) { (void) strcat(flags, "H"); flag_b |= FLF_H; } - if (rp6->ipv6RouteInfo.re_ire_type == IRE_HOST_REDIRECT) { + if (rp6->ipv6RouteInfo.re_flags & RTF_DYNAMIC) { (void) strcat(flags, "D"); flag_b |= FLF_D; } - if (rp6->ipv6RouteInfo.re_ire_type == IRE_CACHE) { - /* Address resolution */ - (void) strcat(flags, "A"); - flag_b |= FLF_A; - } if (rp6->ipv6RouteInfo.re_ire_type == IRE_LOCAL) { /* Local */ (void) strcat(flags, "L"); flag_b |= FLF_L; @@ -4455,6 +4581,48 @@ ire_report_item_v6(const mib2_ipv6RouteEntry_t *rp6, boolean_t first, (void) strcat(flags, "S"); /* Setsrc */ flag_b |= FLF_S; } + if (rp6->ipv6RouteInfo.re_flags & RTF_REJECT) { + (void) strcat(flags, "R"); + flag_b |= FLF_R; + } + if (rp6->ipv6RouteInfo.re_flags & RTF_BLACKHOLE) { + (void) strcat(flags, "B"); + flag_b |= FLF_B; + } + return (flag_b); +} + +static const char ire_hdr_v6[] = +"\n%s Table: IPv6\n"; +static const char ire_hdr_v6_verbose[] = +" Destination/Mask Gateway If MTU " +"Ref Flags Out In/Fwd %s\n" +"--------------------------- --------------------------- ----- ----- " +"--- ----- ------ ------ %s\n"; +static const char ire_hdr_v6_normal[] = +" Destination/Mask Gateway Flags Ref Use " +" If %s\n" +"--------------------------- --------------------------- ----- --- ------- " +"----- %s\n"; + +static boolean_t +ire_report_item_v6(const mib2_ipv6RouteEntry_t *rp6, boolean_t first, + const sec_attr_list_t *attrs) +{ + char dstbuf[MAXHOSTNAMELEN + 1]; + char gwbuf[MAXHOSTNAMELEN + 1]; + char ifname[LIFNAMSIZ + 1]; + char flags[10]; /* RTF_ flags */ + uint_t flag_b; + + if (!(Aflag || (rp6->ipv6RouteInfo.re_ire_type != IRE_IF_CLONE && + rp6->ipv6RouteInfo.re_ire_type != IRE_MULTICAST && + rp6->ipv6RouteInfo.re_ire_type != IRE_NOROUTE && + rp6->ipv6RouteInfo.re_ire_type != IRE_LOCAL))) { + return (first); + } + + flag_b = form_v6_route_flags(rp6, flags); if (!ire_filter_match_v6(rp6, flag_b)) return (first); @@ -4468,7 +4636,7 @@ ire_report_item_v6(const mib2_ipv6RouteEntry_t *rp6, boolean_t first, } if (Vflag) { - (void) printf("%-27s %-27s %-5s %5u%c %5u %3u " + (void) printf("%-27s %-27s %-5s %5u %3u " "%-5s %6u %6u %s\n", pr_prefix6(&rp6->ipv6RouteDest, rp6->ipv6RoutePfxLength, dstbuf, sizeof (dstbuf)), @@ -4478,8 +4646,6 @@ ire_report_item_v6(const mib2_ipv6RouteEntry_t *rp6, boolean_t first, octetstr(&rp6->ipv6RouteIfIndex, 'a', ifname, sizeof (ifname)), rp6->ipv6RouteInfo.re_max_frag, - rp6->ipv6RouteInfo.re_frag_flag ? '*' : ' ', - rp6->ipv6RouteInfo.re_rtt, rp6->ipv6RouteInfo.re_ref, flags, rp6->ipv6RouteInfo.re_obpkt, @@ -4617,7 +4783,7 @@ tcp_report(const mib_item_t *item) v4a = v4_attrs; v6a = v6_attrs; for (; item != NULL; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -4841,7 +5007,7 @@ udp_report(const mib_item_t *item) v6a = v6_attrs; /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -4916,10 +5082,7 @@ udp_report_item_v4(const mib2_udpEntry_t *ude, boolean_t first, "", miudp_state(ude->udpEntryInfo.ue_state, attr)); - /* - * UDP sockets don't have remote attributes, so there's no need to - * print them here. - */ + print_transport_label(attr); return (first); } @@ -4956,10 +5119,7 @@ udp_report_item_v6(const mib2_udp6Entry_t *ude6, boolean_t first, miudp_state(ude6->udp6EntryInfo.ue_state, attr), ifnamep == NULL ? "" : ifnamep); - /* - * UDP sockets don't have remote attributes, so there's no need to - * print them here. - */ + print_transport_label(attr); return (first); } @@ -5321,7 +5481,7 @@ mrt_report(mib_item_t *item) /* 'for' loop 1: */ for (; item; item = item->next_item) { - if (Dflag) { + if (Xflag) { (void) printf("\n--- Entry %d ---\n", ++jtemp); (void) printf("Group = %d, mib_id = %d, " "length = %d, valp = 0x%p\n", @@ -5334,7 +5494,7 @@ mrt_report(mib_item_t *item) switch (item->mib_id) { case EXPER_DVMRP_VIF: - if (Dflag) + if (Xflag) (void) printf("%u records for ipVifTable:\n", item->length/sizeof (struct vifctl)); if (item->length/sizeof (struct vifctl) == 0) { @@ -5377,7 +5537,7 @@ mrt_report(mib_item_t *item) break; case EXPER_DVMRP_MRT: - if (Dflag) + if (Xflag) (void) printf("%u records for ipMfcTable:\n", item->length/sizeof (struct vifctl)); if (item->length/sizeof (struct vifctl) == 0) { |