5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Nexenta Systems, Inc.
25 * Copyright 2017 Joyent, Inc.
26 * Copyright 2017 Gary Mills
27 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
28 */
29
30 #include <arpa/inet.h>
31 #include <errno.h>
32 #include <getopt.h>
33 #include <inet/ip.h>
34 #include <inet/iptun.h>
35 #include <inet/tunables.h>
36 #include <libdladm.h>
37 #include <libdliptun.h>
38 #include <libdllink.h>
39 #include <libinetutil.h>
40 #include <libipadm.h>
41 #include <locale.h>
42 #include <netdb.h>
43 #include <netinet/in.h>
44 #include <ofmt.h>
45 #include <stdarg.h>
1619 ushort_t zflags;
1620
1621 if ((zoneid = getzoneid()) == GLOBAL_ZONEID)
1622 return (_B_FALSE); /* from-gz only makes sense in a NGZ */
1623
1624 if (zone_getattr(zoneid, ZONE_ATTR_FLAGS, &zflags, sizeof (zflags)) < 0)
1625 return (_B_FALSE);
1626
1627 if (!(zflags & ZF_NET_EXCL))
1628 return (_B_TRUE); /* everything is from the GZ for shared-ip */
1629
1630 (void) strncpy(phyname, lifname, sizeof (phyname));
1631 if ((cp = strchr(phyname, ':')) != NULL)
1632 *cp = '\0';
1633 status = ipadm_if_info(iph, phyname, &if_info, 0, LIFC_DEFAULT);
1634 if (status != IPADM_SUCCESS)
1635 return (ret);
1636
1637 if (if_info->ifi_cflags & IFIF_L3PROTECT)
1638 ret = _B_TRUE;
1639 if (if_info)
1640 ipadm_free_if_info(if_info);
1641 return (ret);
1642 }
1643
1644 static boolean_t
1645 print_sa_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize)
1646 {
1647 show_addr_args_t *arg = ofarg->ofmt_cbarg;
1648 ipadm_addr_info_t *ainfo = arg->sa_info;
1649 char interface[LIFNAMSIZ];
1650 char addrbuf[MAXPROPVALLEN];
1651 char dstbuf[MAXPROPVALLEN];
1652 char prefixlenstr[MAXPROPVALLEN];
1653 int prefixlen;
1654 struct sockaddr_in *sin;
1655 struct sockaddr_in6 *sin6;
1656 sa_family_t af;
1657 char *phyname = NULL;
1658 struct ifaddrs *ifa = &ainfo->ia_ifa;
1659 fmask_t cflags_mask[] = {
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Nexenta Systems, Inc.
25 * Copyright (c) 2018, Joyent, Inc.
26 * Copyright 2017 Gary Mills
27 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
28 */
29
30 #include <arpa/inet.h>
31 #include <errno.h>
32 #include <getopt.h>
33 #include <inet/ip.h>
34 #include <inet/iptun.h>
35 #include <inet/tunables.h>
36 #include <libdladm.h>
37 #include <libdliptun.h>
38 #include <libdllink.h>
39 #include <libinetutil.h>
40 #include <libipadm.h>
41 #include <locale.h>
42 #include <netdb.h>
43 #include <netinet/in.h>
44 #include <ofmt.h>
45 #include <stdarg.h>
1619 ushort_t zflags;
1620
1621 if ((zoneid = getzoneid()) == GLOBAL_ZONEID)
1622 return (_B_FALSE); /* from-gz only makes sense in a NGZ */
1623
1624 if (zone_getattr(zoneid, ZONE_ATTR_FLAGS, &zflags, sizeof (zflags)) < 0)
1625 return (_B_FALSE);
1626
1627 if (!(zflags & ZF_NET_EXCL))
1628 return (_B_TRUE); /* everything is from the GZ for shared-ip */
1629
1630 (void) strncpy(phyname, lifname, sizeof (phyname));
1631 if ((cp = strchr(phyname, ':')) != NULL)
1632 *cp = '\0';
1633 status = ipadm_if_info(iph, phyname, &if_info, 0, LIFC_DEFAULT);
1634 if (status != IPADM_SUCCESS)
1635 return (ret);
1636
1637 if (if_info->ifi_cflags & IFIF_L3PROTECT)
1638 ret = _B_TRUE;
1639 ipadm_free_if_info(if_info);
1640 return (ret);
1641 }
1642
1643 static boolean_t
1644 print_sa_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize)
1645 {
1646 show_addr_args_t *arg = ofarg->ofmt_cbarg;
1647 ipadm_addr_info_t *ainfo = arg->sa_info;
1648 char interface[LIFNAMSIZ];
1649 char addrbuf[MAXPROPVALLEN];
1650 char dstbuf[MAXPROPVALLEN];
1651 char prefixlenstr[MAXPROPVALLEN];
1652 int prefixlen;
1653 struct sockaddr_in *sin;
1654 struct sockaddr_in6 *sin6;
1655 sa_family_t af;
1656 char *phyname = NULL;
1657 struct ifaddrs *ifa = &ainfo->ia_ifa;
1658 fmask_t cflags_mask[] = {
|