components/ptp/patches/01-zone.patch
branchs11-update
changeset 2987 01d2e6a3aae8
child 5007 0052258cbb9d
equal deleted inserted replaced
2986:eb4911976ff2 2987:01d2e6a3aae8
       
     1 18301028 ptpd in {kernel, native} Zone may conflict with hw mode ptpd in global zone
       
     2 
       
     3 Following patch prevents ptpd from running in a zone.
       
     4 
       
     5 diff -ur ptpd-2.2.0/src/Makefile /builds/pjalan/ptp-userland/components/ptp/ptpd-2.2.0/src/Makefile
       
     6 --- ptpd-2.2.0/src/Makefile	Fri Mar  7 10:29:54 2014
       
     7 +++ /builds/pjalan/ptp-userland/components/ptp/ptpd-2.2.0/src/Makefile	Fri Mar  7 10:41:20 2014
       
     8 @@ -46,7 +46,7 @@
       
     9  #CFLAGS += -DPTP_EXPERIMENTAL
       
    10  
       
    11  LDFLAGS+= -lm -lrt
       
    12 -LDFLAGS += -lnsl -lsocket -m64
       
    13 +LDFLAGS += -lnsl -lsocket -lv12n -m64
       
    14  
       
    15  PROG = ptpd
       
    16  SRCS = ptpd.c arith.c bmc.c protocol.c display.c\
       
    17 diff -ur ptpd-2.2.0/src/ptpd2.8 /builds/pjalan/ptp-userland/components/ptp/ptpd-2.2.0/src/ptpd2.8
       
    18 --- ptpd-2.2.0/src/ptpd2.8	Fri Mar  7 11:11:33 2014
       
    19 +++ /builds/pjalan/n2ptp-userland/components/ptp/ptpd-2.2.0/src/ptpd2.8	Fri Mar  7 11:04:51 2014
       
    20 @@ -1,6 +1,6 @@
       
    21  .\" -*- nroff -*"
       
    22  .\"
       
    23 -.\" Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
       
    24 +.\" Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
       
    25  .\"
       
    26  .TH ptpd "1M" "January, 2012" "version 2.2.0" "System Administration Commands"
       
    27  .SH NAME
       
    28 @@ -316,10 +316,7 @@
       
    29  generate upto 40 MB of data in a window of 24 hours and many
       
    30  times more if enabled with -P option.
       
    31  .P
       
    32 -Solaris does not allow creation of a vnic on a network
       
    33 -interface which is providing hardware assistance to ptpd.
       
    34 -Vice versa, ptpd cannot get hardware assistance from an
       
    35 -interfac which has pre-existing vnic(s).
       
    36 +Solaris does not allow ptpd to run inside a zones(5).
       
    37  
       
    38  .SH SEE ALSO
       
    39  svcs(1), svcadm(1M), attributes(5), smf(5)
       
    40 diff -ur ptpd-2.2.0/src/dep/startup.c /builds/pjalan/ptp-userland/components/ptp/ptpd-2.2.0/src/dep/startup.c
       
    41 --- ptpd-2.2.0/src/dep/startup.c	Fri Mar  7 10:29:54 2014
       
    42 +++ /builds/pjalan/ptp-userland/components/ptp/ptpd-2.2.0/src/dep/startup.c	Fri Mar  7 10:41:20 2014
       
    43 @@ -1,5 +1,5 @@
       
    44  /*-
       
    45 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
       
    46 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
       
    47   * Copyright (c) 2011-2012 Solarflare Communications Inc
       
    48   * Copyright (c) 2009-2011 George V. Neville-Neil, Steven Kreuzer, 
       
    49   *                         Martin Burnicki, Gael Mace, Alexandre Van Kempen
       
    50 @@ -40,6 +40,7 @@
       
    51   */
       
    52  
       
    53  #include "../ptpd.h"
       
    54 +#include <libv12n.h>
       
    55  
       
    56  PtpClock *ptpClock;
       
    57  
       
    58 @@ -615,8 +616,25 @@
       
    59  		);
       
    60  }
       
    61  
       
    62 +Boolean
       
    63 +is_zone(void) {
       
    64 +	v12n_env_t *env;
       
    65 +	Boolean       is_zone = FALSE;
       
    66 +	char            *name;
       
    67  
       
    68 +	if ((env = v12n_get_current_env()) == NULL)
       
    69 +		return (is_zone);
       
    70  
       
    71 +	name = v12n_get_env_prop(env, V12N_PROP_NAME);
       
    72 +	if (name != NULL && strstr(name, "zone") != NULL) {
       
    73 +		INFO("Inside %s\n", name);
       
    74 +		is_zone = TRUE;
       
    75 +	}
       
    76 +	free(name);
       
    77 +	v12n_free_env(env);
       
    78 +	return (is_zone);
       
    79 +}
       
    80 +
       
    81  PtpClock *
       
    82  ptpdStartup(int argc, char **argv, Integer16 * ret, RunTimeOpts * rtOpts)
       
    83  {
       
    84 @@ -632,6 +650,7 @@
       
    85    Boolean time_mode_specified = FALSE;
       
    86    TimeMode default_time_mode;
       
    87    Boolean use_hardware_assist = FALSE;
       
    88 +  Boolean allow_inside_zone = FALSE;
       
    89    Boolean is_error;
       
    90  
       
    91    dump_command_line_parameters(argc, argv);
       
    92 @@ -643,7 +662,7 @@
       
    93  #endif
       
    94  */
       
    95  
       
    96 -   const char *getopt_string = "?HgGWb:cCf:ST:dDPR:xO:tM:a:w:u:ehzl:o:i:n:N:y:m:v:r:s:p:q:Y:BjLV:XZK";
       
    97 +   const char *getopt_string = "?HgGWb:cCf:ST:dDPR:xO:tM:a:w:u:ehzl:o:i:n:N:y:m:v:r:s:p:q:Y:BjLV:XZKF";
       
    98  
       
    99    /* parse command line arguments */
       
   100    while ((c = getopt(argc, argv, getopt_string)) != -1) {
       
   101 @@ -831,6 +850,10 @@
       
   102        rtOpts->verboseStats = TRUE;
       
   103        rtOpts->csvStats = TRUE;
       
   104        break;
       
   105 +
       
   106 +    case 'F':
       
   107 +      allow_inside_zone = TRUE;
       
   108 +      break;
       
   109      case 'P':
       
   110        rtOpts->displayPackets = TRUE;
       
   111        break;
       
   112 @@ -1181,6 +1204,13 @@
       
   113        rtOpts->time_mode = default_time_mode;
       
   114      }
       
   115  
       
   116 +   /* If insize a zone, fail to start unless forced */
       
   117 +    if (is_zone() && !allow_inside_zone) {
       
   118 +	    ERROR("Not allowed to run inside a zone\n");
       
   119 +	    *ret = 4;
       
   120 +	    return 0;
       
   121 +    }
       
   122 +
       
   123    ptpClock = (PtpClock *) calloc(1, sizeof(PtpClock));
       
   124    if (!ptpClock) {
       
   125      PERROR("failed to allocate memory for protocol engine data");