summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cmd-inet
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/cmd-inet')
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c378
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/in.mpathd/mpd_main.c2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSUNP.c9
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c18
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ping/ping.c51
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/route.c47
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.c20
7 files changed, 367 insertions, 158 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) {
diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/mpd_main.c b/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/mpd_main.c
index 28416c4d7f..c0621996d3 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/mpd_main.c
+++ b/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/mpd_main.c
@@ -2875,7 +2875,7 @@ mibwalk(void (*proc)(mib_item_t *))
* 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;
diff --git a/usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSUNP.c b/usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSUNP.c
index b76341e303..2cea11b454 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSUNP.c
+++ b/usr/src/cmd/cmd-inet/usr.lib/mdnsd/mDNSUNP.c
@@ -407,6 +407,15 @@ select_src_ifi_info_solaris(int sockfd, int numifs,
if (ifflags & (IFF_NOXMIT | IFF_NOLOCAL | IFF_PRIVATE))
continue;
+ /* A DHCP client will have IFF_UP set yet the address is zero. Ignore */
+ if (lifr->lifr_addr.ss_family == AF_INET) {
+ struct sockaddr_in *sinptr;
+
+ sinptr = (struct sockaddr_in *) &lifr->lifr_addr;
+ if (sinptr->sin_addr.s_addr == INADDR_ANY)
+ continue;
+ }
+
if (*best_lifr != NULL) {
/*
* Check if we found a better interface by checking
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c
index 506b15a307..868f9ab5e2 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c
@@ -3541,18 +3541,6 @@ ifplumb(const char *linkname, const char *ifname, boolean_t genppa, int af)
Perror2_exit("I_PUSH", IP_MOD_NAME);
/*
- * Push the ARP module onto the interface stream. IP uses
- * this to send resolution requests up to ARP. We need to
- * do this before the SLIFNAME ioctl is sent down because
- * the interface becomes publicly known as soon as the SLIFNAME
- * ioctl completes. Thus some other process trying to bring up
- * the interface after SLIFNAME but before we have pushed ARP
- * could hang. We pop the module again later if it is not needed.
- */
- if (ioctl(ip_fd, I_PUSH, ARP_MOD_NAME) == -1)
- Perror2_exit("I_PUSH", ARP_MOD_NAME);
-
- /*
* Prepare to set IFF_IPV4/IFF_IPV6 flags as part of SIOCSLIFNAME.
* (At this point in time the kernel also allows an override of the
* IFF_CANTCHANGE flags.)
@@ -3679,12 +3667,6 @@ ifplumb(const char *linkname, const char *ifname, boolean_t genppa, int af)
(void) putchar('\n');
}
- /* Check if arp is not actually needed */
- if (lifr.lifr_flags & (IFF_NOARP|IFF_IPV6)) {
- if (ioctl(ip_fd, I_POP, 0) == -1)
- Perror2_exit("I_POP", ARP_MOD_NAME);
- }
-
/*
* Open "/dev/udp" for use as a multiplexor to PLINK the
* interface stream under. We use "/dev/udp" instead of "/dev/ip"
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ping/ping.c b/usr/src/cmd/cmd-inet/usr.sbin/ping/ping.c
index 2a4ff60d57..d851dce613 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ping/ping.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ping/ping.c
@@ -159,6 +159,7 @@ static int moptions; /* multicast options */
int npackets; /* number of packets to send */
static ushort_t tos; /* type-of-service value */
static int hoplimit = -1; /* time-to-live value */
+static int dontfrag; /* IP*_DONTFRAG */
static int timeout = TIMEOUT; /* timeout value (sec) for probes */
static struct if_entry out_if; /* interface argument */
int ident; /* ID for this ping run */
@@ -268,7 +269,7 @@ main(int argc, char *argv[])
setbuf(stdout, (char *)0);
while ((c = getopt(argc, argv,
- "abA:c:dF:G:g:I:i:LlnN:P:p:rRSsTt:UvX:x:Y0123?")) != -1) {
+ "abA:c:dDF:G:g:I:i:LlnN:P:p:rRSsTt:UvX:x:Y0123?")) != -1) {
switch ((char)c) {
case 'A':
if (strcmp(optarg, "inet") == 0) {
@@ -301,6 +302,10 @@ main(int argc, char *argv[])
options |= SO_DEBUG;
break;
+ case 'D':
+ dontfrag = 1;
+ break;
+
case 'b':
bypass = _B_TRUE;
break;
@@ -1303,8 +1308,6 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
}
}
- if (nexthop != NULL && !use_udp)
- set_nexthop(family, ai_nexthop, recv_sock);
/*
* We always receive on raw icmp socket. But the sending socket can be
* raw icmp or udp, depending on the use of -U flag.
@@ -1332,9 +1335,6 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
}
}
- if (nexthop != NULL)
- set_nexthop(family, ai_nexthop, send_sock);
-
/*
* In order to distinguish replies to our UDP probes from
* other pings', we need to know our source port number.
@@ -1368,6 +1368,9 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
send_sock = recv_sock;
}
+ if (nexthop != NULL)
+ set_nexthop(family, ai_nexthop, send_sock);
+
int_op = 48 * 1024;
if (int_op < datalen)
int_op = datalen;
@@ -1431,6 +1434,7 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
if (moptions & MULTICAST_TTL) {
char_op = hoplimit;
+ /* Applies to unicast and multicast. */
if (family == AF_INET) {
if (setsockopt(send_sock, IPPROTO_IP, IP_MULTICAST_TTL,
(char *)&char_op, sizeof (char)) == -1) {
@@ -1454,7 +1458,10 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
*/
}
- /* did the user specify an interface? */
+ /*
+ * did the user specify an interface?
+ * Applies to unicast, broadcast and multicast.
+ */
if (moptions & MULTICAST_IF) {
struct ifaddrlist *al = NULL; /* interface list */
struct ifaddrlist *my_if;
@@ -1496,6 +1503,8 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
}
if (family == AF_INET) {
+ struct in_pktinfo pktinfo;
+
if (setsockopt(send_sock, IPPROTO_IP, IP_MULTICAST_IF,
(char *)&my_if->addr.addr,
sizeof (struct in_addr)) == -1) {
@@ -1504,6 +1513,15 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
strerror(errno));
exit(EXIT_FAILURE);
}
+ bzero(&pktinfo, sizeof (pktinfo));
+ pktinfo.ipi_ifindex = my_if->index;
+ if (setsockopt(send_sock, IPPROTO_IP, IP_PKTINFO,
+ (char *)&pktinfo, sizeof (pktinfo)) == -1) {
+ Fprintf(stderr, "%s: setsockopt "
+ "IP_PKTINFO %s\n", progname,
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
} else {
/*
* the outgoing interface is set in set_ancillary_data()
@@ -1525,6 +1543,23 @@ setup_socket(int family, int *send_sockp, int *recv_sockp, int *if_index,
}
}
+ /* We enable or disable to not depend on the kernel default */
+ if (family == AF_INET) {
+ if (setsockopt(send_sock, IPPROTO_IP, IP_DONTFRAG,
+ (char *)&dontfrag, sizeof (dontfrag)) == -1) {
+ Fprintf(stderr, "%s: setsockopt IP_DONTFRAG %s\n",
+ progname, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ if (setsockopt(send_sock, IPPROTO_IPV6, IPV6_DONTFRAG,
+ (char *)&dontfrag, sizeof (dontfrag)) == -1) {
+ Fprintf(stderr, "%s: setsockopt IPV6_DONTFRAG %s\n",
+ progname, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* receiving IPv6 extension headers in verbose mode */
if (verbose && family == AF_INET6) {
if (setsockopt(recv_sock, IPPROTO_IPV6, IPV6_RECVHOPOPTS,
@@ -2336,7 +2371,7 @@ usage(char *cmdname)
Fprintf(stderr, "usage: %s host [timeout]\n", cmdname);
Fprintf(stderr,
/* CSTYLED */
-"usage: %s -s [-l | U] [abdLnRrv] [-A addr_family] [-c traffic_class]\n\t"
+"usage: %s -s [-l | U] [abdDLnRrv] [-A addr_family] [-c traffic_class]\n\t"
"[-g gateway [-g gateway ...]] [-N nexthop] [-F flow_label] [-I interval]\n\t"
"[-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]\n",
cmdname);
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/route.c b/usr/src/cmd/cmd-inet/usr.sbin/route.c
index b4b16d6755..aedef45409 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/route.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/route.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -45,8 +45,6 @@
* @(#)linkaddr.c 8.1 (Berkeley) 6/4/93
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/param.h>
#include <sys/file.h>
#include <sys/socket.h>
@@ -175,6 +173,8 @@ static struct keytab {
{"show", K_SHOW},
#define K_SECATTR 43
{"secattr", K_SECATTR},
+#define K_INDIRECT 44
+ {"indirect", K_INDIRECT},
{0, 0}
};
@@ -655,7 +655,7 @@ flushroutes(int argc, char *argv[])
(char *)rp < (char *)item->valp + item->length;
/* LINTED */
rp = (mib2_ipRouteEntry_t *)
- ((char *)rp + ipRouteEntrySize)) {
+ ((char *)rp + ipRouteEntrySize)) {
delRouteEntry(rp, NULL, seqno);
seqno++;
}
@@ -670,7 +670,7 @@ flushroutes(int argc, char *argv[])
if (item->group == MIB2_IP6) {
ipv6RouteEntrySize =
((mib2_ipv6IfStatsEntry_t *)item->valp)->
- ipv6RouteEntrySize;
+ ipv6RouteEntrySize;
assert(IS_P2ALIGNED(ipv6RouteEntrySize,
sizeof (mib2_ipv6RouteEntry_t *)));
break;
@@ -692,7 +692,7 @@ flushroutes(int argc, char *argv[])
(char *)rp6 < (char *)item->valp + item->length;
/* LINTED */
rp6 = (mib2_ipv6RouteEntry_t *)
- ((char *)rp6 + ipv6RouteEntrySize)) {
+ ((char *)rp6 + ipv6RouteEntrySize)) {
delRouteEntry(NULL, rp6, seqno);
seqno++;
}
@@ -812,7 +812,7 @@ delRouteEntry(mib2_ipRouteEntry_t *rp, mib2_ipv6RouteEntry_t *rp6, int seqno)
(void) printf("%-20.20s ",
rtm->rtm_flags & RTF_HOST ? routename(sa) :
- netname(sa));
+ netname(sa));
/* LINTED */
sa = (struct sockaddr *)(salen(sa) + (char *)sa);
(void) printf("%-20.20s ", routename(sa));
@@ -861,7 +861,7 @@ routename(const struct sockaddr *sa)
cp = "default";
if (cp == NULL && !nflag) {
hp = gethostbyaddr((char *)&in, sizeof (struct in_addr),
- AF_INET);
+ AF_INET);
if (hp != NULL) {
if (((cp = strchr(hp->h_name, '.')) != NULL) &&
(strcmp(cp + 1, domain) == 0))
@@ -892,7 +892,7 @@ routename(const struct sockaddr *sa)
cp = "default";
if (cp == NULL && !nflag) {
hp = getipnodebyaddr((char *)&in6,
- sizeof (struct in6_addr), AF_INET6, &error_num);
+ sizeof (struct in6_addr), AF_INET6, &error_num);
if (hp != NULL) {
if (((cp = strchr(hp->h_name, '.')) != NULL) &&
(strcmp(cp + 1, domain) == 0))
@@ -1120,8 +1120,8 @@ print_rtcmd_short(FILE *to, rtcmd_irep_t *rcip, boolean_t gw_good,
break;
case AF_INET6:
if (inet_ntop(AF_INET6,
- &rcip->ri_gate.sin6.sin6_addr, obuf,
- INET6_ADDRSTRLEN) != NULL) {
+ &rcip->ri_gate.sin6.sin6_addr, obuf,
+ INET6_ADDRSTRLEN) != NULL) {
if (nflag) {
(void) fprintf(to, ": gateway %s",
obuf);
@@ -1405,6 +1405,9 @@ args_to_rtcmd(rtcmd_irep_t *rcip, char **argv, char *cmd_string)
return (B_FALSE);
}
break;
+ case K_INDIRECT:
+ rcip->ri_flags |= RTF_INDIRECT;
+ break;
default:
if (dash_keyword) {
syntax_bad_keyword(tok + 1);
@@ -1479,8 +1482,8 @@ args_to_rtcmd(rtcmd_irep_t *rcip, char **argv, char *cmd_string)
}
if (rcip->ri_af == AF_INET6 &&
memcmp(&rcip->ri_mask.sin6.sin6_addr,
- &in6_host_mask,
- sizeof (struct in6_addr)) == 0) {
+ &in6_host_mask,
+ sizeof (struct in6_addr)) == 0) {
rcip->ri_flags |= RTF_HOST;
}
} else {
@@ -1853,8 +1856,8 @@ newroute(char **argv)
break;
case AF_INET6:
if (inet_ntop(AF_INET6,
- (void *)&newrt->ri_dst.sin6.sin6_addr,
- obuf, INET6_ADDRSTRLEN) != NULL) {
+ (void *)&newrt->ri_dst.sin6.sin6_addr,
+ obuf, INET6_ADDRSTRLEN) != NULL) {
(void) printf(" %s", obuf);
break;
}
@@ -2236,7 +2239,7 @@ in_getaddr(char *s, struct sockaddr_in *sin, int *plenp, int which,
inet_lnaof(sin->sin_addr) == INADDR_ANY)) {
/* This looks like a network address. */
inet_makenetandmask(rcip, ntohl(val),
- sin);
+ sin);
}
}
return (B_TRUE);
@@ -2562,7 +2565,7 @@ static char metricnames[] =
static char routeflags[] =
"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT"
"\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE"
- "\016PRIVATE\017PROTO2\020PROTO1\021MULTIRT\022SETSRC";
+ "\016PRIVATE\017PROTO2\020PROTO1\021MULTIRT\022SETSRC\023INDIRECT";
static char ifnetflags[] =
"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP"
"\011PPROMISC\012ALLMULTI\013INTELLIGENT\014MULTICAST"
@@ -2623,7 +2626,7 @@ print_rtmsg(struct rt_msghdr *rtm, int msglen)
break;
default:
(void) printf("pid: %ld, seq %d, errno %d, flags:",
- rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
+ rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
bprintf(stdout, rtm->rtm_flags, routeflags);
pmsg_common(rtm, msglen);
break;
@@ -2649,7 +2652,7 @@ print_getmsg(rtcmd_irep_t *req_rt, struct rt_msghdr *rtm, int msglen)
if (rtm->rtm_msglen > (ushort_t)msglen) {
(void) fprintf(stderr,
gettext("message length mismatch, in packet %d, "
- "returned %d\n"), rtm->rtm_msglen, msglen);
+ "returned %d\n"), rtm->rtm_msglen, msglen);
}
if (rtm->rtm_errno) {
(void) fprintf(stderr, "RTM_GET: %s (errno %d)\n",
@@ -2675,7 +2678,7 @@ print_getmsg(rtcmd_irep_t *req_rt, struct rt_msghdr *rtm, int msglen)
case RTA_IFP:
if (sa->sa_family == AF_LINK &&
((struct sockaddr_dl *)sa)->
- sdl_nlen != 0)
+ sdl_nlen != 0)
ifp = (struct sockaddr_dl *)sa;
break;
case RTA_SRC:
@@ -3122,8 +3125,8 @@ mibget(int sd)
(void) fprintf(stderr, gettext("mibget %d gives "
"T_ERROR_ACK: TLI_error = 0x%lx, UNIX_error = "
"0x%lx\n"), j, tea->TLI_error, tea->UNIX_error);
- errno = (tea->TLI_error == TSYSERR)
- ? tea->UNIX_error : EPROTO;
+ errno = (tea->TLI_error == TSYSERR) ?
+ tea->UNIX_error : EPROTO;
break;
}
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.c b/usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.c
index cae75df60d..b8b56259ad 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.c
@@ -166,6 +166,7 @@ boolean_t useicmp = _B_FALSE; /* use icmp echo instead of udp packets */
boolean_t docksum = _B_TRUE; /* calculate checksums */
static boolean_t collect_stat = _B_FALSE; /* print statistics */
boolean_t settos = _B_FALSE; /* set type-of-service field */
+int dontfrag = 0; /* IP*_DONTFRAG */
static int max_timeout = 5; /* quit after this consecutive timeouts */
static boolean_t probe_all = _B_FALSE; /* probe all the IFs of the target */
static boolean_t pick_src = _B_FALSE; /* traceroute picks the src address */
@@ -315,6 +316,7 @@ main(int argc, char **argv)
case 'F':
off = IP_DF;
+ dontfrag = 1;
break;
case 'g':
@@ -1361,6 +1363,24 @@ setup_socket(struct pr_set *pr, int packet_len)
exit(EXIT_FAILURE);
}
}
+
+ /* We enable or disable to not depend on the kernel default */
+ if (pr->family == AF_INET) {
+ if (setsockopt(ssock, IPPROTO_IP, IP_DONTFRAG,
+ (char *)&dontfrag, sizeof (dontfrag)) == -1) {
+ Fprintf(stderr, "%s: IP_DONTFRAG %s\n", prog,
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ if (setsockopt(ssock, IPPROTO_IPV6, IPV6_DONTFRAG,
+ (char *)&dontfrag, sizeof (dontfrag)) == -1) {
+ Fprintf(stderr, "%s: IPV6_DONTFRAG %s\n", prog,
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ }
+
if (pr->family == AF_INET) {
rcvsock4 = rsock;
sndsock4 = ssock;