From: Apple Date: Sat, 23 Jan 2010 01:03:33 +0000 (+0000) Subject: network_cmds-329.2.tar.gz X-Git-Tag: mac-os-x-1064^0 X-Git-Url: https://git.saurik.com/apple/network_cmds.git/commitdiff_plain/7f5b2e89a4f702a4180adf6481fd2153039ee5eb network_cmds-329.2.tar.gz --- diff --git a/ifconfig.tproj/ifconfig.8 b/ifconfig.tproj/ifconfig.8 index cba935e..1876828 100644 --- a/ifconfig.tproj/ifconfig.8 +++ b/ifconfig.tproj/ifconfig.8 @@ -38,6 +38,7 @@ .Nm .Op Fl L .Op Fl m +.Op Fl r .Ar interface .Op Cm create .Op Ar address_family @@ -54,6 +55,7 @@ .Op Fl L .Op Fl d .Op Fl m +.Op Fl r .Op Fl u .Op Fl v .Op Ar address_family @@ -66,6 +68,7 @@ .Op Fl L .Op Fl d .Op Fl m +.Op Fl r .Op Fl u .Op Fl v .Op Fl C @@ -895,6 +898,10 @@ flag may be used to list all of the interface cloners available on the system, with no additional information. Use of this flag is mutually exclusive with all other flags and commands. .Pp +The +.Fl r +flag may be used to show additional information related to the count of route references on the network interface. +.Pp For bridge interfaces, the list of addresses learned by the bridge is not shown when displaying information about all interfaces except when the .Fl v diff --git a/ifconfig.tproj/ifconfig.c b/ifconfig.tproj/ifconfig.c index a0d823c..1c50df3 100644 --- a/ifconfig.tproj/ifconfig.c +++ b/ifconfig.tproj/ifconfig.c @@ -95,6 +95,7 @@ int all; int bond_details = 0; int supmedia = 0; +int showrtref = 0; int printkeys = 0; /* Print keying material for interfaces. */ static int ifconfig(int argc, char *const *argv, int iscreate, @@ -161,7 +162,7 @@ main(int argc, char *argv[]) #ifndef __APPLE__ strlcpy(options, "adklmnuv", sizeof(options)); #else - strlcpy(options, "adlmuv", sizeof(options)); + strlcpy(options, "adlmruv", sizeof(options)); #endif for (p = opts; p != NULL; p = p->next) strlcat(options, p->opt, sizeof(options)); @@ -181,7 +182,7 @@ main(int argc, char *argv[]) printkeys++; break; #endif - case 'l': /* scan interface names only */ + case 'l': /* scan interface names only */ namesonly++; break; case 'm': /* show media choices in status */ @@ -192,7 +193,10 @@ main(int argc, char *argv[]) noload++; break; #endif - case 'u': /* restrict scan to "up" interfaces */ + case 'r': + showrtref++; + break; + case 'u': /* restrict scan to "up" interfaces */ uponly++; break; case 'v': @@ -212,8 +216,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - /* -l cannot be used with -a or -m or -b */ - if (namesonly && (all || supmedia || bond_details)) + /* -l cannot be used with -a or -r or -m or -b */ + if (namesonly && (all || supmedia || showrtref || bond_details)) usage(); /* nonsense.. */ @@ -829,6 +833,10 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl, printf(" metric %d", ifr.ifr_metric); if (ioctl(s, SIOCGIFMTU, &ifr) != -1) printf(" mtu %d", ifr.ifr_mtu); +#ifdef SIOCGIFGETRTREFCNT + if (showrtref && ioctl(s, SIOCGIFGETRTREFCNT, &ifr) != -1) + printf(" rtref %d", ifr.ifr_route_refcnt); +#endif putchar('\n'); #ifndef __APPLE__ diff --git a/ifconfig.tproj/ifvlan.c b/ifconfig.tproj/ifvlan.c index aeb8dad..eec3ef1 100644 --- a/ifconfig.tproj/ifvlan.c +++ b/ifconfig.tproj/ifvlan.c @@ -98,7 +98,7 @@ vlan_create(int s, struct ifreq *ifr) errx(1, "must specify a parent device for vlan create"); ifr->ifr_data = (caddr_t) ¶ms; } -#if SIOCIFCREATE2 +#ifdef SIOCIFCREATE2 if (ioctl(s, SIOCIFCREATE2, ifr) < 0) err(1, "SIOCIFCREATE2"); #else diff --git a/netstat.tproj/if.c b/netstat.tproj/if.c index e3f438e..18986be 100644 --- a/netstat.tproj/if.c +++ b/netstat.tproj/if.c @@ -459,6 +459,8 @@ struct iftot { u_int64_t ift_dr; /* drops */ u_int64_t ift_ib; /* input bytes */ u_int64_t ift_ob; /* output bytes */ + u_int64_t ift_obgp; /* output bg packets */ + u_int64_t ift_obgb; /* output bg bytes */ }; u_char signalled; /* set if alarm goes off "early" */ @@ -541,6 +543,8 @@ banner: "packets", "errs", "bytes", "packets", "errs", "bytes", "colls"); if (dflag) printf(" %5.5s", "drops"); + if (prioflag) + printf(" %10s %10s", "obgpkts", "obgbytes"); putchar('\n'); fflush(stdout); line = 0; @@ -566,6 +570,10 @@ loop: ifmd.ifmd_data.ifi_collisions - interesting->ift_co); if (dflag) printf(" %5llu", ifmd.ifmd_snd_drops - interesting->ift_dr); + if (prioflag) + printf(" %10llu %10llu", + ifmd.ifmd_filler[0] - interesting->ift_obgp, + ifmd.ifmd_filler[1] - interesting->ift_obgb); } interesting->ift_ip = ifmd.ifmd_data.ifi_ipackets; interesting->ift_ie = ifmd.ifmd_data.ifi_ierrors; @@ -575,6 +583,9 @@ loop: interesting->ift_ob = ifmd.ifmd_data.ifi_obytes; interesting->ift_co = ifmd.ifmd_data.ifi_collisions; interesting->ift_dr = ifmd.ifmd_snd_drops; + /* private counters */ + interesting->ift_obgp = ifmd.ifmd_filler[0]; + interesting->ift_obgb = ifmd.ifmd_filler[1]; } else { unsigned int latest_ifcount; @@ -609,6 +620,8 @@ loop: sum->ift_ob = 0; sum->ift_co = 0; sum->ift_dr = 0; + sum->ift_obgp = 0; + sum->ift_obgb = 0; for (i = 0; i < ifcount; i++) { struct ifmibdata *ifmd = ifmdall + i; @@ -620,6 +633,9 @@ loop: sum->ift_ob += ifmd->ifmd_data.ifi_obytes; sum->ift_co += ifmd->ifmd_data.ifi_collisions; sum->ift_dr += ifmd->ifmd_snd_drops; + /* private counters */ + sum->ift_obgp += ifmd->ifmd_filler[0]; + sum->ift_obgb += ifmd->ifmd_filler[1]; } if (!first) { printf("%10llu %5llu %10llu %10llu %5llu %10llu %5llu", @@ -632,6 +648,10 @@ loop: sum->ift_co - total->ift_co); if (dflag) printf(" %5llu", sum->ift_dr - total->ift_dr); + if (prioflag) + printf(" %10llu %10llu", + sum->ift_obgp - total->ift_obgp, + sum->ift_obgb - total->ift_obgb); } *total = *sum; } diff --git a/netstat.tproj/main.c b/netstat.tproj/main.c index 9d68607..102c933 100644 --- a/netstat.tproj/main.c +++ b/netstat.tproj/main.c @@ -275,7 +275,7 @@ int Aflag; /* show addresses of protocol control block */ int aflag; /* show all sockets (including servers) */ int bflag; /* show i/f total bytes in/out */ int dflag; /* show i/f dropped packets */ -#if defined(__APPLE__) && !TARGET_OS_EMBEDDED +#if defined(__APPLE__) int gflag; /* show group (multicast) routing or stats */ #endif int iflag; /* show interfaces */ @@ -284,6 +284,7 @@ int Lflag; /* show size of listen queues */ int mflag; /* show memory stats */ int nflag; /* show addresses numerically */ static int pflag; /* show given protocol */ +int prioflag; /* show packet priority statistics */ int rflag; /* show routing tables (or routing stats) */ int sflag; /* show protocol statistics */ int tflag; /* show i/f watchdog timers */ @@ -306,7 +307,7 @@ main(argc, argv) af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "Aabdf:gI:iLlmnp:rRstuWw:")) != -1) + while ((ch = getopt(argc, argv, "Aabdf:gI:iLlmnPp:rRstuWw:")) != -1) switch(ch) { case 'A': Aflag = 1; @@ -339,7 +340,7 @@ main(argc, argv) errx(1, "%s: unknown address family", optarg); } break; -#if defined(__APPLE__) && !TARGET_OS_EMBEDDED +#if defined(__APPLE__) case 'g': gflag = 1; break; @@ -368,6 +369,9 @@ main(argc, argv) case 'n': nflag = 1; break; + case 'P': + prioflag = 1; + break; case 'p': if ((tp = name2protox(optarg)) == NULL) { errx(1, @@ -430,8 +434,9 @@ main(argc, argv) routepr(nl[N_RTREE].n_value); exit(0); } -#if defined(__APPLE__) && !TARGET_OS_EMBEDDED +#if defined(__APPLE__) if (gflag) { +#if !TARGET_OS_EMBEDDED if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(); @@ -447,6 +452,7 @@ main(argc, argv) mroute6pr(); #endif } +#endif /* !TARGET_OS_EMBEDDED */ ifmalist_dump(); exit(0); } diff --git a/netstat.tproj/netstat.1 b/netstat.tproj/netstat.1 index 1b07b60..7fa01d2 100644 --- a/netstat.tproj/netstat.1 +++ b/netstat.tproj/netstat.1 @@ -306,6 +306,7 @@ D RTF_DYNAMIC Created dynamically (by redirect) G RTF_GATEWAY Destination requires forwarding by intermediary H RTF_HOST Host entry (net otherwise) I RTF_IFSCOPE Route is associated with an interface scope +i RTF_IFREF Route is holding a reference to the interface L RTF_LLINFO Valid protocol to link address translation M RTF_MODIFIED Modified dynamically (by redirect) m RTF_MULTICAST The route represents a multicast address diff --git a/netstat.tproj/netstat.h b/netstat.tproj/netstat.h index 9c25ee7..b53e5b0 100644 --- a/netstat.tproj/netstat.h +++ b/netstat.tproj/netstat.h @@ -80,6 +80,7 @@ extern int mflag; /* show memory stats */ extern int nflag; /* show addresses numerically */ extern int rflag; /* show routing tables (or routing stats) */ extern int sflag; /* show protocol statistics */ +extern int prioflag; /* show packet priority statistics */ extern int tflag; /* show i/f watchdog timers */ extern int Wflag; /* wide display */ diff --git a/netstat.tproj/route.c b/netstat.tproj/route.c index 576d51e..1e7befc 100644 --- a/netstat.tproj/route.c +++ b/netstat.tproj/route.c @@ -116,6 +116,7 @@ struct bits { { RTF_BLACKHOLE,'B' }, { RTF_BROADCAST,'b' }, { RTF_IFSCOPE, 'I' }, + { RTF_IFREF, 'i' }, { 0 } }; diff --git a/route.tproj/route.c b/route.tproj/route.c index f8850e6..b1960d7 100644 --- a/route.tproj/route.c +++ b/route.tproj/route.c @@ -1245,7 +1245,8 @@ char routeflags[] = "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010DELCLONE" "\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" "\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024b024" -"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\031IFSCOPE"; +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\031IFSCOPE\032CONDEMNED" +"\033IFREF"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" @@ -1298,6 +1299,8 @@ print_rtmsg(rtm, msglen) (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno); if (rtm->rtm_flags & RTF_IFSCOPE) (void) printf("ifscope %d, ", rtm->rtm_index); + if (rtm->rtm_flags & RTF_IFREF) + (void) printf("ifref, "); (void) printf("flags:"); bprintf(stdout, rtm->rtm_flags, routeflags); pmsg_common(rtm);