Print this page
OS-4807 arp(1M) and ndp(1M) should use zone_get_nroot()

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/usr.sbin/ndp.c
          +++ new/usr/src/cmd/cmd-inet/usr.sbin/ndp.c
↓ open down ↓ 32 lines elided ↑ open up ↑
  33   33  #include <sys/mac.h>
  34   34  #include <sys/socket.h>
  35   35  #include <sys/sockio.h>
  36   36  #include <netdb.h>
  37   37  #include <net/if_types.h>
  38   38  #include <netinet/in.h>
  39   39  #include <arpa/inet.h>
  40   40  #include <inet/ip.h>
  41   41  #include <net/if_dl.h>
  42   42  #include <net/route.h>
       43 +#include <zone.h>
  43   44  
  44   45  typedef struct  sockaddr_in6    sin6_t;
  45   46  
  46   47  #define BUF_SIZE 2048
  47   48  typedef struct rtmsg_pkt {
  48   49          struct  rt_msghdr m_rtm;
  49   50          char    m_space[BUF_SIZE];
  50   51  } rtmsg_pkt_t;
  51   52  
  52   53  enum ndp_action {
↓ open down ↓ 35 lines elided ↑ open up ↑
  88   89  static  void    ndp_lifr2ip(struct lifreq *, char *, int);
  89   90  
  90   91  static  int     ndp_get(int, struct lifreq *, void *);
  91   92  static  void    ndp_get_all(void);
  92   93  static  int     ndp_delete(int, struct lifreq *, void *);
  93   94  static  int     ndp_set(int, struct lifreq *, void *);
  94   95  static  int     ndp_set_nce(char *, char *, char *[], int);
  95   96  static  int     ndp_set_file(char *);
  96   97  
  97   98  static  char            *ndp_iface = NULL;
  98      -static  char            *netstat_path = "/usr/bin/netstat";
  99   99  static  pid_t           ndp_pid;
 100  100  static  boolean_t       ndp_noresolve = B_FALSE; /* Don't lookup addresses */
 101  101  static  boolean_t       ndp_run = B_TRUE;
 102  102  
 103  103  #define MAX_ATTEMPTS 5
 104  104  #define MAX_OPTS 5
 105  105  #define WORDSEPS " \t\r\n"
      106 +#define NETSTAT_PATH    "/usr/bin/netstat"
 106  107  
 107  108  /*
 108  109   * Macros borrowed from route(1M) for working with PF_ROUTE messages
 109  110   */
 110  111  #define RT_ADVANCE(x, n) ((x) += ndp_salen(n))
 111  112  #define RT_NEXTADDR(cp, w, u) \
 112  113          l = ndp_salen(u); \
 113  114          (void) memmove(cp, u, l); \
 114  115          cp += l;
 115  116  
↓ open down ↓ 644 lines elided ↑ open up ↑
 760  761  
 761  762          return (ndp_display(lifrp));
 762  763  }
 763  764  
 764  765  /*
 765  766   * Print out all NDP entries
 766  767   */
 767  768  static void
 768  769  ndp_get_all(void)
 769  770  {
      771 +        char netstat_path[MAXPATHLEN];
      772 +        const char *zroot = zone_get_nroot();
      773 +
      774 +        (void) snprintf(netstat_path, sizeof (netstat_path), "%s%s", zroot != NULL ?
      775 +            zroot : "", NETSTAT_PATH);
      776 +
 770  777          (void) execl(netstat_path, "netstat",
 771  778              (ndp_noresolve ? "-np" : "-p"),
 772  779              "-f", "inet6", (char *)0);
 773  780          ndp_fatal("Coudn't exec %s: %s", netstat_path, strerror(errno));
 774  781  }
 775  782  
 776  783  /*
 777  784   * Perform a SIOCLIFDELND ioctl
 778  785   */
 779  786  /*ARGSUSED*/
↓ open down ↓ 332 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX