You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/01/31 00:31:14 UTC

[01/12] git commit: TS-2304 Make the healthcheck plugin watch for file permission changes

Updated Branches:
  refs/heads/5.0.x 10dc9f728 -> 3a1fcd475


TS-2304 Make the healthcheck plugin watch for file permission changes


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c952398f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c952398f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c952398f

Branch: refs/heads/5.0.x
Commit: c952398ff733b119337d0406f21e2e32eddd2e4a
Parents: 77e2776
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 23 09:10:47 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Jan 27 14:27:17 2014 -0700

----------------------------------------------------------------------
 plugins/experimental/healthchecks/healthchecks.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c952398f/plugins/experimental/healthchecks/healthchecks.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/healthchecks/healthchecks.c b/plugins/experimental/healthchecks/healthchecks.c
index bb27505..89ee7a9 100644
--- a/plugins/experimental/healthchecks/healthchecks.c
+++ b/plugins/experimental/healthchecks/healthchecks.c
@@ -153,7 +153,7 @@ setup_watchers(int fd)
   char *dname;
 
   while (conf) {
-    conf->wd = inotify_add_watch(fd, conf->fname, IN_DELETE_SELF|IN_CLOSE_WRITE);
+    conf->wd = inotify_add_watch(fd, conf->fname, IN_DELETE_SELF|IN_CLOSE_WRITE|IN_ATTRIB);
     TSDebug(PLUGIN_NAME, "Setting up a watcher for %s", conf->fname);
     strncpy(fname, conf->fname, MAX_FILENAME_LEN - 1);
     dname = dirname(fname);
@@ -163,7 +163,7 @@ setup_watchers(int fd)
       dir = TSmalloc(sizeof(HCDirEntry));
       memset(dir, 0, sizeof(HCDirEntry));
       strncpy(dir->dname, dname, MAX_FILENAME_LEN - 1);
-      dir->wd = inotify_add_watch(fd, dname, IN_CREATE|IN_MOVED_FROM|IN_MOVED_TO);
+      dir->wd = inotify_add_watch(fd, dname, IN_CREATE|IN_MOVED_FROM|IN_MOVED_TO|IN_ATTRIB);
       if (!head_dir)
         head_dir = dir;
       else
@@ -242,7 +242,7 @@ hc_thread(void *data ATS_UNUSED)
           HCFileData *new_data = TSmalloc(sizeof(HCFileData));
           HCFileData *old_data;
 
-          if (event->mask & (IN_CLOSE_WRITE)) {
+          if (event->mask & (IN_CLOSE_WRITE|IN_ATTRIB)) {
             TSDebug(PLUGIN_NAME, "Modify file event (%d) on %s", event->mask, finfo->fname);
           } else if (event->mask & (IN_CREATE|IN_MOVED_TO)) {
             TSDebug(PLUGIN_NAME, "Create file event (%d) on %s", event->mask, finfo->fname);


[07/12] git commit: TS-2530 - Check for loopback interfaces to avoid false multi-cycle hop detection

Posted by zw...@apache.org.
TS-2530 - Check for loopback interfaces to avoid false multi-cycle hop detection


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/61dbe66e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/61dbe66e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/61dbe66e

Branch: refs/heads/5.0.x
Commit: 61dbe66ece9dff3ab98abfc3d2463ca65bd75d3e
Parents: eb450fa
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Wed Jan 29 10:10:17 2014 -0600
Committer: Alan M. Carroll <am...@network-geographics.com>
Committed: Wed Jan 29 10:10:17 2014 -0600

----------------------------------------------------------------------
 CHANGES                 |  2 ++
 iocore/utils/Machine.cc | 20 ++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61dbe66e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7fddf93..a45040f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2530] Check for loopback interfaces when computing the local address.
+
   *) [TS-2031] Prevent duplicate SSL SNI name registration.
    Author: Feifei Cai <ff...@yahoo-inc.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61dbe66e/iocore/utils/Machine.cc
----------------------------------------------------------------------
diff --git a/iocore/utils/Machine.cc b/iocore/utils/Machine.cc
index fdc089c..756d3a3 100644
--- a/iocore/utils/Machine.cc
+++ b/iocore/utils/Machine.cc
@@ -25,8 +25,8 @@
 #include "I_Machine.h"
 
 #if HAVE_IFADDRS_H
-#include <ifaddrs.h>
-# endif
+#  include <ifaddrs.h>
+#endif
 
 // Singleton
 Machine* Machine::_instance = NULL;
@@ -83,7 +83,6 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr)
         conf.ifc_len = sizeof(req);
         conf.ifc_req = req;
         status = ioctl(s, SIOCGIFCONF, &conf);
-        close(s);
       } else {
         status = -1;
       }
@@ -105,6 +104,7 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr)
         GL  // Global.
       } spot_type = NA, ip4_type = NA, ip6_type = NA;
       sockaddr const* ifip;
+      unsigned int ifflags;
       for (
 #if HAVE_IFADDRS_H
         ifaddrs* spot = ifa_addrs ; spot ; spot = spot->ifa_next
@@ -114,17 +114,22 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr)
       ) {
 #if HAVE_IFADDRS_H
         ifip = spot->ifa_addr;
+        ifflags = spot->ifa_flags;
 #else
         ifip = &spot->ifr_addr;
-#endif
 
+        // get the interface's flags
+        struct ifreq ifr;
+        ink_strlcpy(ifr.ifr_name, spot->ifr_name, IFNAMSIZ);
+        if (ioctl(s, SIOCGIFFLAGS, &ifr) == 0)   ifflags = ifr.ifr_flags;
+        else ifflags = 0; // flags not available, default to just looking at IP
+#endif
         if (!ats_is_ip(ifip)) spot_type = NA;
-        else if (ats_is_ip_loopback(ifip)) spot_type = LO;
+        else if (ats_is_ip_loopback(ifip) || (IFF_LOOPBACK & ifflags)) spot_type = LO;
         else if (ats_is_ip_linklocal(ifip)) spot_type = LL;
         else if (ats_is_ip_private(ifip)) spot_type = PR;
         else if (ats_is_ip_multicast(ifip)) spot_type = MC;
         else spot_type = GL;
-
         if (spot_type == NA) continue; // Next!
 
         if (ats_is_ip4(ifip)) {
@@ -150,6 +155,9 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr)
       else
         ats_ip_copy(&ip.sa, &ip6.sa);
     }
+#if ! HAVE_IFADDRS_H
+    close(s);
+#endif
   } else { // address provided.
     ats_ip_copy(&ip, addr);
     if (ats_is_ip4(addr)) ats_ip_copy(&ip4, addr);


[12/12] git commit: Merge branch 'master' into 5.0.x

Posted by zw...@apache.org.
Merge branch 'master' into 5.0.x


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3a1fcd47
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3a1fcd47
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3a1fcd47

Branch: refs/heads/5.0.x
Commit: 3a1fcd475c27b052bf7ff439c3545b20a53d93de
Parents: 10dc9f7 4b6f7ae
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 30 16:31:01 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 30 16:31:01 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |  15 ++
 cmd/traffic_line/traffic_line.cc                |  91 ++++++++
 doc/reference/commands/traffic_line.en.rst      |  15 ++
 doc/reference/plugins/header_rewrite.en.rst     |  66 +++---
 doc/reference/plugins/index.en.rst              |   1 +
 iocore/net/SSLCertLookup.cc                     |  30 ++-
 iocore/net/SSLUtils.cc                          |   4 +-
 iocore/net/test_certlookup.cc                   |  13 +-
 iocore/utils/Machine.cc                         |  20 +-
 lib/perl/Makefile.am                            |   2 +-
 plugins/conf_remap/conf_remap.cc                |  31 +--
 .../experimental/healthchecks/healthchecks.c    |   6 +-
 plugins/header_rewrite/Makefile.am              |   3 +-
 plugins/header_rewrite/README                   | 230 +------------------
 plugins/header_rewrite/condition.h              |   4 +-
 plugins/header_rewrite/expander.cc              | 138 +++++++++++
 plugins/header_rewrite/expander.h               |  49 ++++
 plugins/header_rewrite/operator.h               | 138 -----------
 plugins/header_rewrite/operators.cc             |   8 +-
 plugins/header_rewrite/value.h                  |  13 +-
 20 files changed, 439 insertions(+), 438 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3a1fcd47/CHANGES
----------------------------------------------------------------------
diff --cc CHANGES
index 34b2940,33ba8ee..2ffd565
--- a/CHANGES
+++ b/CHANGES
@@@ -1,12 -1,21 +1,27 @@@
                                                           -*- coding: utf-8 -*-
 +Changes with Apache Traffic Server 5.0.0
 +
 +  *) [TS-2290] Remove X-ID special log tag, and cleanup HdrToken confusion.
 +
 +  *) [TS-2088] Change TSRecordType enum values to powers of two
 +
  Changes with Apache Traffic Server 4.2.0
  
+   *) [TS-2544] conf_remap plugin: allow for multiple configuration files.
+ 
+   *) [TS-2530] Check for loopback interfaces when computing the local address.
+    Author: Ron Barber rbarber@yahoo-inc.com
+ 
+   *) [TS-2031] Prevent duplicate SSL SNI name registration.
+    Author: Feifei Cai <ff...@yahoo-inc.com>
+ 
+   *) [TS-2501] Refactor and improve performance for the case without
+    expansions. Review: Alexey Ivanov <ai...@linkedin.com>.
+ 
+   *) [TS-2533 ] Add three commands previously provided by traffic_shell.
+ 
+   *) [TS-2304] Make the healthcheck plugin watch for file permission changes.
+ 
    *) [TS-2519] Make build version metrics non-persistent.
  
    *) [TS-1606] Log buffers are not flushed periodically when TS is launched 


[08/12] git commit: TS-2530 - CHANGES not correct, fixed.

Posted by zw...@apache.org.
TS-2530 - CHANGES not correct, fixed.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/666bb424
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/666bb424
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/666bb424

Branch: refs/heads/5.0.x
Commit: 666bb424786c4dc7f8816fb5568abb3d124b96f1
Parents: 61dbe66
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Wed Jan 29 10:25:47 2014 -0600
Committer: Alan M. Carroll <am...@network-geographics.com>
Committed: Wed Jan 29 10:25:47 2014 -0600

----------------------------------------------------------------------
 CHANGES | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/666bb424/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a45040f..ae5fd25 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@
 Changes with Apache Traffic Server 4.2.0
 
   *) [TS-2530] Check for loopback interfaces when computing the local address.
+   Author: Ron Barber rbarber@yahoo-inc.com
 
   *) [TS-2031] Prevent duplicate SSL SNI name registration.
    Author: Feifei Cai <ff...@yahoo-inc.com>


[11/12] git commit: TS-2329 Update documentation for header_rewrite plugin

Posted by zw...@apache.org.
TS-2329 Update documentation for header_rewrite plugin


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4b6f7ae8
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4b6f7ae8
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4b6f7ae8

Branch: refs/heads/5.0.x
Commit: 4b6f7ae87eac26eefcb795b9e1f1a45158c0cfcd
Parents: b314eb3
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 30 16:28:18 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 30 16:28:18 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/header_rewrite.en.rst |  13 +-
 doc/reference/plugins/index.en.rst          |   1 +
 plugins/header_rewrite/README               | 239 +----------------------
 3 files changed, 12 insertions(+), 241 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b6f7ae8/doc/reference/plugins/header_rewrite.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_rewrite.en.rst b/doc/reference/plugins/header_rewrite.en.rst
index 92c04c2..25fd9cf 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -49,16 +49,16 @@ The following operators are available::
 
   rm-header header-name                 [operator_flags]
   add-header header <value>             [operator_flags]
+  set-header header <value>             [operator_flags]
   set-status <status-code>              [operator_flags]
+  set-destination [qual] <value>        [operator_flags]
+  set-redirect <value>                  [operator_flags]
+  set-timeout-out <value>               [operator_flags]
   set-status-reason <value>             [operator_flags]
-  set-config config <value>             [operator_flags]
-  no-op                                 [operator_flags]
+  set-config overridable-config <value> [operator_flags]
   counter counter-name                  [operator_flags]
+  no-op                                 [operator_flags]
 
-The following operator(s) currently only works when instantiating the
-plugin as a remap plugin::
-
-  set-destination [qual] value
 
 Where qual is one of the support URL qualifiers::
 
@@ -124,6 +124,7 @@ each rule. This implies that a new hook condition starts a new rule as well.::
 
   cond %{READ_RESPONSE_HDR_HOOK}   (this is the default hook)
   cond %{READ_REQUEST_HDR_HOOK}
+  cond %{READ_REQUEST_PRE_REMAP_HOOK}
   cond %{SEND_REQUEST_HDR_HOOK}
   cond %{SEND_RESPONSE_HDR_HOOK}
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b6f7ae8/doc/reference/plugins/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/index.en.rst b/doc/reference/plugins/index.en.rst
index 33c0a2c..43a990f 100644
--- a/doc/reference/plugins/index.en.rst
+++ b/doc/reference/plugins/index.en.rst
@@ -44,6 +44,7 @@ Apache Traffic Server releases.
   conf_remap.en
   gzip.en
   header_filter.en
+  header_rewrite.en
   regex_remap.en
   stats_over_http.en
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b6f7ae8/plugins/header_rewrite/README
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/README b/plugins/header_rewrite/README
index 3ea6c6c..40ea174 100644
--- a/plugins/header_rewrite/README
+++ b/plugins/header_rewrite/README
@@ -1,8 +1,8 @@
 Apache Traffic Server Rewrite Header Plugin
 This is a plugin for ATS (Apache Traffic Server), that allows you to
 perform various header "rewrite" rules (operations) on a request or
-response. Currently, only one operation is supported, since we had to get
-this rolling asap.
+response. It is loosely modeled after Apache HTTPD's mod_rewrite.
+
 
 Using the plugin
 ----------------
@@ -22,237 +22,6 @@ phase (the default) causes a transaction hook to be instantiated and used
 at a later time. This allows you to setup e.g. a rule that gets executed
 during the origin response header parsing, using READ_RESPONSE_HDR_HOOK.
 
+For more information on how to use this plugin, please see
 
-Operators
----------
-The following operators are available:
-
-  rm-header header-name                 [operator_flags]
-  add-header header <value>             [operator_flags]
-  set-status <status-code>              [operator_flags]
-  set-status-reason <value>             [operator_flags]
-  set-config config <value>             [operator_flags]
-  no-op                                 [operator_flags]
-  counter counter-name                  [operator_flags]
-
-The following operator(s) currently only works when instantiating the
-plugin as a remap plugin:
-
-  set-destination [qual] value
-
-Where qual is one of the support URL qualifiers
-
-  HOST
-  PORT
-  PATH
-  QUERY
-
-For example (as a remap rule):
-
-  cond %{HEADER:X-Mobile} = "foo"
-  set-destination HOST foo.mobile.bar.com [L]
-
-
-Operator flags
---------------
-
-The operator flags are optional, and must not contain whitespaces inside
-the brackets. Currently, only one flag is supported:
-
-  [L]   Last rule, do not continue
-
-
-Variable expansion
-------------------
-Currntly only limited variable expansion is supported in add-header. Supported
-substitutions include:
-  %<proto>      Protocol
-  %<port>       Port
-  %<chi>        Client IP
-  %<cqhl>       Client request length
-  %<cqhm>       Client HTTP method
-  %<cquup>      Client unmapped URI
-
-
-Conditions
-----------
-The conditions are used as qualifiers: The operators specified will
-only be evaluated if the condition(s) are met.
-
-  cond %{STATUS} operand                        [condition_flags]
-  cond %{RANDOM:nn} operand                     [condition_flags]
-  cond %{ACCESS:file}                           [condition_flags]
-  cond %{TRUE}                                  [condition_flags]
-  cond %{FALSE}                                 [condition_flags]
-  cond %{HEADER:header-name} operand            [condition_flags]
-  cond %{COOKIE:cookie-name} operand            [condition_flags]
-  cond %{CLIENT-HEADER:header-name} operand     [condition_flags]
-  cond %{PROTOCOL} operand                      [condition_flags]
-  cond %{PORT} operand                          [condition_flags]
-  cond %{HOST} operand                          [condition_flags]
-  cond %{TOHOST} operand                        [condition_flags]
-  cond %{FROMHOST} operand                      [condition_flags]
-  cond %{PATH} operand                          [condition_flags]
-  cond %{PARAMS} operand                        [condition_flags]
-  cond %{QUERY} operand                         [condition_flags]
-
-
-The difference between HEADER and CLIENT-HEADER is that HEADER adapts to the
-hook it's running in, whereas CLIENT-HEADER always applies to the client
-request header. The %{TRUE} condition is also the default condition if no
-other conditions are specified.
-
-These conditions have to be first in a ruleset, and you can only have one in
-each rule. This implies that a new hook condition starts a new rule as well.
-
-  cond %{READ_RESPONSE_HDR_HOOK}   (this is the default hook)
-  cond %{READ_REQUEST_HDR_HOOK}
-  cond %{SEND_REQUEST_HDR_HOOK}
-  cond %{SEND_RESPONSE_HDR_HOOK}
-
-For remap.config plugin instanations, the default hook is named
-REMAP_PSEUDO_HOOK. This can be useful if you are mixing other hooks in a
-configuration, but being the default it is also optional.
-
-
-Condition flags
----------------
-
-The condition flags are optional, and you can combine more than one into
-a comma separated list of flags. Note that whitespaces are not allowed inside
-the brackets:
-
-  [NC]  Not case sensitive condition (when applicable) [NOT IMPLEMENTED!]
-  [AND] AND with next condition (default)
-  [OR]  OR with next condition
-  [NOT] Invert this condition
-
-
-Operands to conditions
-----------------------
-  /string/  # regular expression
-  <string   # lexically lower
-  >string   # lexically greater
-  =string   # lexically equal
-
-The absense of a "matcher" means value exists).
-
-
-Values
-------
-Setting e.g. a header with a value can take the following formats:
-
-  - Any of the cond definitions, that extracts a value from the request
-  - $N 0 <= N <= 9, as grouped in a regular expression
-  - string (which can contain the above)
-  - null
-
-
-Examples
---------
-
-cond %{HEADER:X-Y-Foobar}
-cond %{COOKIE:X-DC}  =DC1
-add-header X-Y-Fiefum %{HEADER:X-Y-Foobar}
-add-header X-Forwarded-For %<chi>
-rm-header X-Y-Foobar
-rm-header Set-Cookie
-counter plugin.header_rewrite.x-y-foobar-dc1
-
-cond %{HEADER:X-Y-Foobar} "Some string" [AND,NC]
-
-
-
-RELEASES
---------
-Version 2.0.0 (6/8/12, bcall)
--- Ported to ATS
-
-Version 1.7.3 (12/01/11,sambani)
--- changed mdbm locks to mutex
-
-Version 1.7.2 (10/18/11,cdoshi)
--- check for url redirect length
-
-Version 1.7.1 (10/18/11,cdoshi)
--- use size_t instead of unsigned
-
-Version 1.7.0 (10/17/11,cdoshi)
- - Support for %{PATH}
-
-Version 1.6.9 (10,17,11,cdoshi)
- - Support for PATH condition
-
-Version 1.6.8 (10/17/11,cdoshi)
- -  Replace the INKHttpHdrStatusSet with INKHttptxnSetHttpRetStatus
-
-Version 1.6.7 (07/21/11, bcall)
-  - [bug 4699620] - Removed some extra printf()'s
-
-Version 1.6.6 (cdoshi)
-  - when Host adder is added setHostChange will be called
-
-Version 1.6.5 (cdoshi)
-  - fix QSA for set-destination
-
-Version 1.6.4 (cdoshi)
-  - support QSA for set-destination
-
-Version 1.6.3 (cdoshi)
-  - support the query,fix the remap stuff
-
-Version 1.6.2 (cdoshi)
-  - Support for regex matcher
-
-Version 1.6.1 (09/15/10, leif)
-  - [bug 3985913]
-
-Version 1.6.0 (07/14/10, leif)
-  - Added support for the timeout-out operator.
-  - Added support for the set-redirect operator.
-  - Added support for INK_HTTP_READ_REQUEST_PRE_REMAP_HOOK (this means we
-  now require YTS 1.18.1 or later).
-
-Version 1.5.0 (06/02/10, leif)
-  - Add support for running as a remap plugin.
-  - Add support for set-destination operator (this currently only works in
-  a remap plugin).
-
-Version 1.4.1 (02/09/10, leif)
-  - Cleanup of error messages.
-  - Changed name from MDBM to DBM.
-
-Version 1.4 (01/20/10, leif)
-  - Added support for CLIENT-HEADER condition.
-  - Cleanup in flags handling and features.
-  - Support MDBM as a condition.
-
-Version 1.3.1 (12/22/09, leif)
-  - Fixed package to support MDBM v2.x and v3.x.
-
-Version 1.3 (12/22/09, leif)
-  - Refactored to allow conditions to be used as values.
-  - Added condition for HEADER.
-  - Added condition for MDBM lookups.
-  - Fixed consistency problems on HOOK names.
-
-Version 1.2 (10/28/09, leif)
-  - Added support for SEND_RESPONSE_HDR_HOOK.
-
-Version 1.1 (10/08/09, leif)
-  - Added support for SEND_REQUEST_HDR_HOOK.
-
-Version 1.0 (9/24/09, leif)
-  - Added support for two hooks.
-  - Added "add-header". Remember to "rm-header" the header first if you
-  want to assure there's only one version.
-  - Added support for %{RANDOM:NN} condition
-  - Added support for %{ACCESS:file} condition
-  - Lots of more code cleanup.
-
-Version 0.2 (7/24/09, leif)
-  - Added support for some basic conditions.
-  - Added support for setting the return status code and reason.
-
-Version 0.1 (7/13/09, leif)
-  - Initial version.
+  http://docs.trafficserver.apache.org/en/latest/reference/plugins/header_rewrite.en.html


[05/12] git commit: TS-2031: Prevent duplicate SSL SNI name registration

Posted by zw...@apache.org.
TS-2031: Prevent duplicate SSL SNI name registration

If you have two certs that has the same CNs, the last one wins in
the SNI negotiation. We not detect this case, issue a warning and
preserve the existing registration.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/063b320a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/063b320a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/063b320a

Branch: refs/heads/5.0.x
Commit: 063b320a72bafe837ff018a04912b6632984084d
Parents: e8f18ea
Author: Feifei Cai <ff...@yahoo-inc.com>
Authored: Tue Jan 28 09:40:48 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Jan 28 09:40:48 2014 -0800

----------------------------------------------------------------------
 CHANGES                       |  3 +++
 iocore/net/SSLCertLookup.cc   | 30 +++++++++++++++++++++++++-----
 iocore/net/SSLUtils.cc        |  4 ++--
 iocore/net/test_certlookup.cc | 13 +++++++------
 4 files changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/063b320a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f71c4a2..7fddf93 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2031] Prevent duplicate SSL SNI name registration.
+   Author: Feifei Cai <ff...@yahoo-inc.com>
+
   *) [TS-2501] Refactor and improve performance for the case without
    expansions. Review: Alexey Ivanov <ai...@linkedin.com>.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/063b320a/iocore/net/SSLCertLookup.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLCertLookup.cc b/iocore/net/SSLCertLookup.cc
index fe14369..df77418 100644
--- a/iocore/net/SSLCertLookup.cc
+++ b/iocore/net/SSLCertLookup.cc
@@ -216,7 +216,7 @@ bool
 SSLContextStorage::insert(SSL_CTX * ctx, const char * name)
 {
   ats_wildcard_matcher wildcard;
-  bool inserted = true;
+  bool inserted = false;
 
   if (wildcard.match(name)) {
     // We turn wildcards into the reverse DNS form, then insert them into the trie
@@ -231,17 +231,37 @@ SSLContextStorage::insert(SSL_CTX * ctx, const char * name)
       return false;
     }
 
-    Debug("ssl", "indexed wildcard certificate for '%s' as '%s' with SSL_CTX %p", name, reversed, ctx);
     entry = new SSLEntry(ctx);
     inserted = this->wildcards.Insert(reversed, entry, 0 /* rank */, -1 /* keylen */);
-    if (inserted) {
-      entry.release();
+    if (!inserted) {
+      SSLEntry * found;
+
+      // We fail to insert, so the longest wildcard match search should return the full match value.
+      found = this->wildcards.Search(reversed);
+      if (found != NULL && found->ctx != ctx) {
+        Warning("previously indexed wildcard certificate for '%s' as '%s', cannot index it with SSL_CTX %p now",
+            name, reversed, ctx);
+      }
+
+      goto done;
     }
+
+    Debug("ssl", "indexed wildcard certificate for '%s' as '%s' with SSL_CTX %p", name, reversed, ctx);
+    entry.release();
   } else {
-    Debug("ssl", "indexed '%s' with SSL_CTX %p", name, ctx);
+    InkHashTableValue value;
+
+    if (ink_hash_table_lookup(this->hostnames, name, &value) && (void *)ctx != value) {
+      Warning("previously indexed '%s' with SSL_CTX %p, cannot index it with SSL_CTX %p now", name, value, ctx);
+      goto done;
+    }
+
+    inserted = true;
     ink_hash_table_insert(this->hostnames, name, (void *)ctx);
+    Debug("ssl", "indexed '%s' with SSL_CTX %p", name, ctx);
   }
 
+done:
   // Keep a unique reference to the SSL_CTX, so that we can free it later. Since we index by name, multiple
   // certificates can be indexed for the same name. If this happens, we will overwrite the previous pointer
   // and leak a context. So if we insert a certificate, keep an ownership reference to it.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/063b320a/iocore/net/SSLUtils.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc
index 833ac7d..68f017a 100644
--- a/iocore/net/SSLUtils.cc
+++ b/iocore/net/SSLUtils.cc
@@ -611,8 +611,8 @@ asn1_strdup(ASN1_STRING * s)
 }
 
 // Given a certificate and it's corresponding SSL_CTX context, insert hash
-// table aliases for all of the subject and subjectAltNames. Note that we don't
-// deal with wildcards (yet).
+// table aliases for subject CN and subjectAltNames DNS without wildcard,
+// insert trie aliases for those with wildcard.
 static void
 ssl_index_certificate(SSLCertLookup * lookup, SSL_CTX * ctx, const char * certfile)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/063b320a/iocore/net/test_certlookup.cc
----------------------------------------------------------------------
diff --git a/iocore/net/test_certlookup.cc b/iocore/net/test_certlookup.cc
index e0ba053..9a78a5f 100644
--- a/iocore/net/test_certlookup.cc
+++ b/iocore/net/test_certlookup.cc
@@ -56,12 +56,12 @@ REGRESSION_TEST(SSLCertificateLookup)(RegressionTest* t, int /* atype ATS_UNUSED
   box.check(lookup.insert(notwild, "*.notwild.com"), "insert wildcard context");
   box.check(lookup.insert(b_notwild, "*.b.notwild.com"), "insert wildcard context");
 
-  // XXX inserting the same certificate multiple times ought to always fail, but it doesn't
-  // when we store a hash value.
-  lookup.insert(foo, "www.foo.com");
-  lookup.insert(wild, "*.wild.com");
-  lookup.insert(notwild, "*.notwild.com");
-  lookup.insert(b_notwild, "*.b.notwild.com");
+  // To test name collisions, we need to shuffle the SSL_CTX's so that we try to
+  // index the same name with a different SSL_CTX.
+  box.check(lookup.insert(wild, "www.foo.com") == false, "insert host duplicate");
+  box.check(lookup.insert(foo, "*.wild.com") == false, "insert wildcard duplicate");
+  box.check(lookup.insert(b_notwild, "*.notwild.com") == false, "insert wildcard conext duplicate");
+  box.check(lookup.insert(notwild, "*.b.notwild.com") == false, "insert wildcard conext duplicate");
 
   // Basic wildcard cases.
   box.check(lookup.findInfoInHash("a.wild.com") == wild, "wildcard lookup for a.wild.com");
@@ -186,6 +186,7 @@ SSLReleaseContext(SSL_CTX * ctx)
 
 int main(int argc, const char ** argv)
 {
+  diags = new Diags(NULL, NULL, stdout);
   res_track_memory = 1;
 
   SSL_library_init();


[09/12] git commit: Update the docs for header_rewrite and the operators

Posted by zw...@apache.org.
Update the docs for header_rewrite and the operators


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/017a9961
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/017a9961
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/017a9961

Branch: refs/heads/5.0.x
Commit: 017a9961495bde7a8df17c15bba3c290dcdea1ac
Parents: 666bb42
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 30 15:45:42 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 30 15:45:42 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/header_rewrite.en.rst | 57 +++++++++++++-----------
 plugins/header_rewrite/README               | 57 ++++++++++++++----------
 plugins/header_rewrite/condition.h          |  4 +-
 3 files changed, 66 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/017a9961/doc/reference/plugins/header_rewrite.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_rewrite.en.rst b/doc/reference/plugins/header_rewrite.en.rst
index 2069d26..92c04c2 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -47,13 +47,13 @@ Operators
 
 The following operators are available::
 
-  rm-header header-name                 [flags]
-  add-header header <value>             [flags]
-  set-status <status-code>              [flags]
-  set-status-reason <value>             [flags]
-  set-config config <value>             [flags]
-  no-op                                 [flags]
-  counter counter-name                  [flags]
+  rm-header header-name                 [operator_flags]
+  add-header header <value>             [operator_flags]
+  set-status <status-code>              [operator_flags]
+  set-status-reason <value>             [operator_flags]
+  set-config config <value>             [operator_flags]
+  no-op                                 [operator_flags]
+  counter counter-name                  [operator_flags]
 
 The following operator(s) currently only works when instantiating the
 plugin as a remap plugin::
@@ -74,7 +74,9 @@ For example (as a remap rule)::
 
 Operator flags
 --------------
-::
+
+The operator flags are optional, and must not contain whitespaces inside
+the brackets. Currently, only one flag is supported::
 
   [L]   Last rule, do not continue
 
@@ -95,22 +97,22 @@ Conditions
 The conditions are used as qualifiers: The operators specified will
 only be evaluated if the condition(s) are met::
 
-  cond %{STATUS} operand                        [flags]
-  cond %{RANDOM:nn} operand                     [flags]
-  cond %{ACCESS:file}                           [flags]
-  cond %{TRUE}                                  [flags]
-  cond %{FALSE}                                 [flags]
-  cond %{HEADER:header-name} operand            [flags]
-  cond %{COOKIE:cookie-name} operand            [flags]
-  cond %{CLIENT-HEADER:header-name} operand     [flags]
-  cond %{PROTOCOL} operand                      [flags]
-  cond %{PORT} operand                          [flags]
-  cond %{HOST} operand                          [flags]
-  cond %{TOHOST} operand                        [false]
-  cond %{FROMHOST} operand                      [false]
-  cond %{PATH} operand                          [false]
-  cond %{PARAMS} operand                        [false]
-  cond %{QUERY} operand                         [false]
+  cond %{STATUS} operand                        [condition_flags]
+  cond %{RANDOM:nn} operand                     [condition_flags]
+  cond %{ACCESS:file}                           [condition_flags]
+  cond %{TRUE}                                  [condition_flags]
+  cond %{FALSE}                                 [condition_flags]
+  cond %{HEADER:header-name} operand            [condition_flags]
+  cond %{COOKIE:cookie-name} operand            [condition_flags]
+  cond %{CLIENT-HEADER:header-name} operand     [condition_flags]
+  cond %{PROTOCOL} operand                      [condition_flags]
+  cond %{PORT} operand                          [condition_flags]
+  cond %{HOST} operand                          [condition_flags]
+  cond %{TOHOST} operand                        [condition_flags]
+  cond %{FROMHOST} operand                      [condition_flags]
+  cond %{PATH} operand                          [condition_flags]
+  cond %{PARAMS} operand                        [condition_flags]
+  cond %{QUERY} operand                         [condition_flags]
 
 The difference between HEADER and CLIENT-HEADER is that HEADER adapts to the
 hook it's running in, whereas CLIENT-HEADER always applies to the client
@@ -132,9 +134,12 @@ configuration, but being the default it is also optional.
 ---------------
 Condition flags
 ---------------
-::
 
-  [NC]  Not case sensitive condition (when applicable)
+The condition flags are optional, and you can combine more than one into
+a comma separated list of flags. Note that whitespaces are not allowed inside
+the brackets::
+
+  [NC]  Not case sensitive condition (when applicable) [NOT IMPLEMENTED!]
   [AND] AND with next condition (default)
   [OR]  OR with next condition
   [NOT] Invert this condition

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/017a9961/plugins/header_rewrite/README
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/README b/plugins/header_rewrite/README
index fba6693..3ea6c6c 100644
--- a/plugins/header_rewrite/README
+++ b/plugins/header_rewrite/README
@@ -27,13 +27,13 @@ Operators
 ---------
 The following operators are available:
 
-  rm-header header-name                 [flags]
-  add-header header <value>             [flags]
-  set-status <status-code>              [flags]
-  set-status-reason <value>             [flags]
-  set-config config <value>             [flags]
-  no-op                                 [flags]
-  counter counter-name                  [flags]
+  rm-header header-name                 [operator_flags]
+  add-header header <value>             [operator_flags]
+  set-status <status-code>              [operator_flags]
+  set-status-reason <value>             [operator_flags]
+  set-config config <value>             [operator_flags]
+  no-op                                 [operator_flags]
+  counter counter-name                  [operator_flags]
 
 The following operator(s) currently only works when instantiating the
 plugin as a remap plugin:
@@ -55,6 +55,10 @@ For example (as a remap rule):
 
 Operator flags
 --------------
+
+The operator flags are optional, and must not contain whitespaces inside
+the brackets. Currently, only one flag is supported:
+
   [L]   Last rule, do not continue
 
 
@@ -75,22 +79,22 @@ Conditions
 The conditions are used as qualifiers: The operators specified will
 only be evaluated if the condition(s) are met.
 
-  cond %{STATUS} operand                        [flags]
-  cond %{RANDOM:nn} operand                     [flags]
-  cond %{ACCESS:file}                           [flags]
-  cond %{TRUE}                                  [flags]
-  cond %{FALSE}                                 [flags]
-  cond %{HEADER:header-name} operand            [flags]
-  cond %{COOKIE:cookie-name} operand            [flags]
-  cond %{CLIENT-HEADER:header-name} operand     [flags]
-  cond %{PROTOCOL} operand                      [flags]
-  cond %{PORT} operand                          [flags]
-  cond %{HOST} operand                          [flags]
-  cond %{TOHOST} operand                        [false]
-  cond %{FROMHOST} operand                      [false]
-  cond %{PATH} operand                          [false]
-  cond %{PARAMS} operand                        [false]
-  cond %{QUERY} operand                         [false]
+  cond %{STATUS} operand                        [condition_flags]
+  cond %{RANDOM:nn} operand                     [condition_flags]
+  cond %{ACCESS:file}                           [condition_flags]
+  cond %{TRUE}                                  [condition_flags]
+  cond %{FALSE}                                 [condition_flags]
+  cond %{HEADER:header-name} operand            [condition_flags]
+  cond %{COOKIE:cookie-name} operand            [condition_flags]
+  cond %{CLIENT-HEADER:header-name} operand     [condition_flags]
+  cond %{PROTOCOL} operand                      [condition_flags]
+  cond %{PORT} operand                          [condition_flags]
+  cond %{HOST} operand                          [condition_flags]
+  cond %{TOHOST} operand                        [condition_flags]
+  cond %{FROMHOST} operand                      [condition_flags]
+  cond %{PATH} operand                          [condition_flags]
+  cond %{PARAMS} operand                        [condition_flags]
+  cond %{QUERY} operand                         [condition_flags]
 
 
 The difference between HEADER and CLIENT-HEADER is that HEADER adapts to the
@@ -113,7 +117,12 @@ configuration, but being the default it is also optional.
 
 Condition flags
 ---------------
-  [NC]  Not case sensitive condition (when applicable)
+
+The condition flags are optional, and you can combine more than one into
+a comma separated list of flags. Note that whitespaces are not allowed inside
+the brackets:
+
+  [NC]  Not case sensitive condition (when applicable) [NOT IMPLEMENTED!]
   [AND] AND with next condition (default)
   [OR]  OR with next condition
   [NOT] Invert this condition

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/017a9961/plugins/header_rewrite/condition.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/condition.h b/plugins/header_rewrite/condition.h
index a33786c..308e943 100644
--- a/plugins/header_rewrite/condition.h
+++ b/plugins/header_rewrite/condition.h
@@ -37,9 +37,9 @@ enum CondModifiers {
   COND_OR = 1,
   COND_AND = 2,
   COND_NOT = 4,
-  COND_NOCASE = 8,
+  COND_NOCASE = 8, // Not implemented
   COND_LAST = 16,
-  COND_CHAIN = 32
+  COND_CHAIN = 32  // Not implemented
 };
 
 


[10/12] git commit: TS-2544 conf_remap plugin: allow for multiple configuration files

Posted by zw...@apache.org.
TS-2544 conf_remap plugin: allow for multiple configuration files


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b314eb3b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b314eb3b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b314eb3b

Branch: refs/heads/5.0.x
Commit: b314eb3b9f4ede143347f0f505a965b35e03f5f4
Parents: 017a996
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 30 16:00:35 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 30 16:00:35 2014 -0700

----------------------------------------------------------------------
 CHANGES                          |  2 ++
 plugins/conf_remap/conf_remap.cc | 31 ++++++++++++++++++-------------
 2 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b314eb3b/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ae5fd25..33ba8ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2544] conf_remap plugin: allow for multiple configuration files.
+
   *) [TS-2530] Check for loopback interfaces when computing the local address.
    Author: Ron Barber rbarber@yahoo-inc.com
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b314eb3b/plugins/conf_remap/conf_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/conf_remap/conf_remap.cc b/plugins/conf_remap/conf_remap.cc
index f2f8026..78dc17a 100644
--- a/plugins/conf_remap/conf_remap.cc
+++ b/plugins/conf_remap/conf_remap.cc
@@ -25,7 +25,8 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-static const char* PLUGIN_NAME = "conf_remap";
+static const char PLUGIN_NAME[] = "conf_remap";
+
 // This makes the plugin depend on the version of traffic server installed, but that's
 // OK, since this plugin is distributed only with the "core" (it's a core piece).
 #define MAX_OVERRIDABLE_CONFIGS TS_CONFIG_LAST_ENTRY
@@ -85,10 +86,12 @@ RemapConfigs::parse_file(const char* fn)
     return false;
 
   if (NULL == (file = TSfopen(fn, "r"))) {
-    TSError("conf_remap: could not open config file %s", fn);
+    TSError("%s: could not open config file %s", PLUGIN_NAME, fn);
     return false;
   }
 
+  TSDebug(PLUGIN_NAME, "loading configuration file %s", fn);
+
   while (NULL != TSfgets(file, buf, sizeof(buf))) {
     char *ln, *tok;
     char *s = buf;
@@ -103,26 +106,26 @@ RemapConfigs::parse_file(const char* fn)
       continue;
 
     if (strncmp(tok, "CONFIG", 6)) {
-      TSError("conf_remap: file %s, line %d: non-CONFIG line encountered", fn, line_num);
+      TSError("%s: file %s, line %d: non-CONFIG line encountered", PLUGIN_NAME, fn, line_num);
       continue;
     }
 
     // Find the configuration name
     tok = strtok_r(NULL, " \t", &ln);
     if (TSHttpTxnConfigFind(tok, -1, &name, &expected_type) != TS_SUCCESS) {
-      TSError("conf_remap: file %s, line %d: no records.config name given", fn, line_num);
+      TSError("%s: file %s, line %d: no records.config name given", PLUGIN_NAME, fn, line_num);
       continue;
     }
     
     // Find the type (INT or STRING only)
     tok = strtok_r(NULL, " \t", &ln);
     if (TS_RECORDDATATYPE_NULL == (type = str_to_datatype(tok))) {
-      TSError("conf_remap: file %s, line %d: only INT and STRING types supported", fn, line_num);
+      TSError("%s: file %s, line %d: only INT and STRING types supported", PLUGIN_NAME, fn, line_num);
       continue;
     }
 
     if (type != expected_type) {
-      TSError("conf_remap: file %s, line %d: mismatch between provide data type, and expected type", fn, line_num);
+      TSError("%s: file %s, line %d: mismatch between provide data type, and expected type", PLUGIN_NAME, fn, line_num);
       continue;
     }
 
@@ -146,7 +149,7 @@ RemapConfigs::parse_file(const char* fn)
       tok = NULL;
     }
     if (!tok) {
-      TSError("conf_remap: file %s, line %d: the configuration must provide a value", fn, line_num);
+      TSError("%s: file %s, line %d: the configuration must provide a value", PLUGIN_NAME, fn, line_num);
       continue;
     }
 
@@ -160,7 +163,7 @@ RemapConfigs::parse_file(const char* fn)
       _items[_current]._data_len = strlen(tok);
       break;
     default:
-      TSError("conf_remap: file %s, line %d: type not support (unheard of)", fn, line_num);
+      TSError("%s: file %s, line %d: type not support (unheard of)", PLUGIN_NAME, fn, line_num);
       continue;
       break;
     }
@@ -204,11 +207,13 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
   } else {
     RemapConfigs* conf = new(RemapConfigs);
 
-    if (conf->parse_file(argv[2])) {
-      *ih = static_cast<void*>(conf);
-    } else {
-      *ih = NULL;
-      delete conf;
+    for (int i=2; i < argc; ++i) {
+      if (conf->parse_file(argv[i])) {
+        *ih = static_cast<void*>(conf);
+      } else {
+        *ih = NULL;
+        delete conf;
+      }
     }
   }
 


[04/12] git commit: TS-2501 Refactor and improve performance for the case without expansions

Posted by zw...@apache.org.
TS-2501 Refactor and improve performance for the case without expansions


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e8f18ea0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e8f18ea0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e8f18ea0

Branch: refs/heads/5.0.x
Commit: e8f18ea04e074670ba6c4d98c00edffd0d2d4a68
Parents: 8c47c09
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jan 23 05:07:44 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Jan 27 15:29:51 2014 -0700

----------------------------------------------------------------------
 CHANGES                             |   3 +
 plugins/header_rewrite/Makefile.am  |   3 +-
 plugins/header_rewrite/expander.cc  | 138 +++++++++++++++++++++++++++++++
 plugins/header_rewrite/expander.h   |  49 +++++++++++
 plugins/header_rewrite/operator.h   | 138 -------------------------------
 plugins/header_rewrite/operators.cc |   8 +-
 plugins/header_rewrite/value.h      |  13 ++-
 7 files changed, 208 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 325773f..f71c4a2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2501] Refactor and improve performance for the case without
+   expansions. Review: Alexey Ivanov <ai...@linkedin.com>.
+
   *) [TS-2533 ] Add three commands previously provided by traffic_shell.
 
   *) [TS-2304] Make the healthcheck plugin watch for file permission changes.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/Makefile.am b/plugins/header_rewrite/Makefile.am
index bef7840..ee17870 100644
--- a/plugins/header_rewrite/Makefile.am
+++ b/plugins/header_rewrite/Makefile.am
@@ -33,7 +33,8 @@ header_rewrite_la_SOURCES = \
   regex_helper.cc \
   resources.cc \
   ruleset.cc \
-  statement.cc
+  statement.cc \
+  expander.cc
 header_rewrite_la_LDFLAGS = $(BOOST_LDFLAGS) $(TS_PLUGIN_LDFLAGS)
 
 endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/expander.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/expander.cc b/plugins/header_rewrite/expander.cc
new file mode 100644
index 0000000..258ba47
--- /dev/null
+++ b/plugins/header_rewrite/expander.cc
@@ -0,0 +1,138 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// expander.cc: Implementation of the Variable Expander base class
+//
+#include <ts/ts.h>
+#include "expander.h"
+
+
+// Helper function to cleanly get the IP as a string.
+std::string
+getIP(sockaddr const * s_sockaddr)
+{
+  const struct sockaddr_in *s_sockaddr_in;
+  const struct sockaddr_in6 *s_sockaddr_in6;
+
+  if (s_sockaddr == NULL)
+    return "";
+
+  char res[INET6_ADDRSTRLEN] = { '\0' };
+
+  switch (s_sockaddr->sa_family) {
+  case AF_INET:
+    s_sockaddr_in = reinterpret_cast<const struct sockaddr_in *>(s_sockaddr);
+    inet_ntop(s_sockaddr_in->sin_family, &s_sockaddr_in->sin_addr, res, INET_ADDRSTRLEN);
+    break;
+  case AF_INET6:
+    s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 *>(s_sockaddr);
+    inet_ntop(s_sockaddr_in6->sin6_family, &s_sockaddr_in6->sin6_addr, res, INET6_ADDRSTRLEN);
+    break;
+  }
+
+  return res;
+}
+
+
+// Main expander method
+std::string
+VariableExpander::expand(const Resources& res)
+{
+  std::string result;
+
+  result.reserve(512); // TODO: Can be optimized
+  result.assign(_source);
+
+  while (true) {
+    std::string::size_type start = result.find("%<");
+    if (start == std::string::npos)
+      break;
+
+    std::string::size_type end = result.find(">", start);
+    if (end == std::string::npos)
+      break;
+
+    std::string first_part = result.substr(0, start);
+    std::string last_part = result.substr(end + 1);
+
+    // Now evaluate the variable
+    std::string variable = result.substr(start, end - start + 1);
+
+    // This will be the value to replace the "variable" section of the string with
+    std::string resolved_variable = "";
+
+    // Initialize some stuff
+    TSMBuffer bufp;
+    TSMLoc hdr_loc;
+    TSMLoc url_loc;
+
+    if (variable == "%<proto>") {
+      // Protocol of the incoming request
+      if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
+        int len;
+        resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
+      }
+    } else if (variable == "%<port>") {
+      // Original port of the incoming request
+      if (TSHttpTxnClientReqGet(res.txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
+        if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc) == TS_SUCCESS) {
+          std::stringstream out;
+          out << TSUrlPortGet(bufp, url_loc);
+          resolved_variable = out.str();
+          TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+        }
+        TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+      }
+    } else if (variable == "%<chi>") {
+      // IP address of the client's host machine
+      resolved_variable = getIP(TSHttpTxnClientAddrGet(res.txnp));
+    } else if (variable == "%<cqhl>") {
+      // The client request header length; the header length in the client request to Traffic Server.
+      std::stringstream out;
+      out << TSHttpHdrLengthGet(res.client_bufp, res.client_hdr_loc);
+      resolved_variable = out.str();
+    } else if (variable == "%<cqhm>") {
+      // The HTTP method in the client request to Traffic Server: GET, POST, and so on (subset of cqtx).
+      int method_len;
+      const char *methodp = TSHttpHdrMethodGet(res.client_bufp, res.client_hdr_loc, &method_len);
+      if (methodp && method_len) {
+        resolved_variable.assign(methodp, method_len);
+      }
+    } else if (variable == "%<cquup>") {
+      // The client request unmapped URL path. This field records a URL path
+      // before it is remapped (reverse proxy mode).
+      if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
+        int path_len;
+        const char *path = TSUrlPathGet(bufp, url_loc, &path_len);
+
+        if (path && path_len) {
+          resolved_variable.assign(path, path_len);
+        }
+        TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
+      }
+    }
+
+    // TODO(SaveTheRbtz): Can be optimized
+    result.assign(first_part);
+    result.append(resolved_variable);
+    result.append(last_part);
+  }
+
+  return result;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/expander.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/expander.h b/plugins/header_rewrite/expander.h
new file mode 100644
index 0000000..cc28637
--- /dev/null
+++ b/plugins/header_rewrite/expander.h
@@ -0,0 +1,49 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Public interface for the Variable Expander
+//
+#ifndef __EXPANDER_H__
+#define __EXPANDER_H__ 1
+
+#include <string>
+#include <ts/ts.h>
+
+#include "resources.h"
+#include "statement.h"
+#include "parser.h"
+
+#include <iostream>
+#include <arpa/inet.h>
+#include <sstream>
+
+class VariableExpander {
+public:
+  VariableExpander(const std::string &source)
+    : _source(source)
+  { }
+
+  std::string expand(const Resources& res);
+
+private:
+  std::string _source;
+};
+
+
+#endif // __EXPANDER_H

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/operator.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operator.h b/plugins/header_rewrite/operator.h
index 5c24925..a017b35 100644
--- a/plugins/header_rewrite/operator.h
+++ b/plugins/header_rewrite/operator.h
@@ -29,9 +29,6 @@
 #include "statement.h"
 #include "parser.h"
 
-#include <iostream>
-#include <arpa/inet.h>
-#include <sstream>
 
 // Operator modifiers
 enum OperModifiers {
@@ -96,139 +93,4 @@ private:
   DISALLOW_COPY_AND_ASSIGN(OperatorHeaders);
 };
 
-
-class VariableExpander {
-private:
-  std::string _source;
-public:
-  VariableExpander(const std::string &source) :
-      _source(source) {
-  }
-
-  std::string expand(const Resources& res) {
-    std::string result;
-    result.reserve(512); // TODO: Can be optimized
-    result.assign(_source);
-
-    while (true) {
-      std::string::size_type start = result.find("%<");
-      if (start == std::string::npos)
-        break;
-
-      std::string::size_type end = result.find(">", start);
-      if (end == std::string::npos)
-        break;
-
-      std::string first_part = result.substr(0, start);
-      std::string last_part = result.substr(end + 1);
-
-      // Now evaluate the variable
-      std::string variable = result.substr(start, end - start + 1);
-
-      // This will be the value to replace the "variable" section of the string with
-      std::string resolved_variable = "";
-
-      // Initialize some stuff
-      TSMBuffer bufp;
-      TSMLoc hdr_loc;
-      TSMLoc url_loc;
-
-      if (variable == "%<proto>") {
-        // Protocol of the incoming request
-        if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
-          int len;
-          resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
-        }
-      } else if (variable == "%<port>") {
-        // Original port of the incoming request
-        if (TSHttpTxnClientReqGet(res.txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
-          if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc) == TS_SUCCESS) {
-            std::stringstream out;
-            out << TSUrlPortGet(bufp, url_loc);
-            resolved_variable = out.str();
-            TSHandleMLocRelease(bufp, hdr_loc, url_loc);
-          }
-          TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
-        }
-      } else if (variable == "%<chi>") {
-        // IP address of the client's host machine
-        resolved_variable = getIP(TSHttpTxnClientAddrGet(res.txnp));
-      } else if (variable == "%<cqhl>") {
-        // The client request header length; the header length in the client request to Traffic Server.
-        std::stringstream out;
-        out << TSHttpHdrLengthGet(res.client_bufp, res.client_hdr_loc);
-        resolved_variable = out.str();
-      } else if (variable == "%<cqhm>") {
-        // The HTTP method in the client request to Traffic Server: GET, POST, and so on (subset of cqtx).
-        int method_len;
-        const char *methodp = TSHttpHdrMethodGet(res.client_bufp, res.client_hdr_loc, &method_len);
-        if (methodp && method_len) {
-          resolved_variable.assign(methodp, method_len);
-        }
-      } else if (variable == "%<cquup>") {
-        // The client request unmapped URL path. This field records a URL path
-        // before it is remapped (reverse proxy mode).
-        if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
-          int path_len;
-          const char *path = TSUrlPathGet(bufp, url_loc, &path_len);
-
-          if (path && path_len) {
-            resolved_variable.assign(path, path_len);
-          }
-          TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
-        }
-      }
-
-      // TODO(SaveTheRbtz): Can be optimized
-      result.assign(first_part);
-      result.append(resolved_variable);
-      result.append(last_part);
-    }
-
-    return result;
-  }
-
-private:
-  std::string getIP(sockaddr const * s_sockaddr) {
-    const struct sockaddr_in *s_sockaddr_in;
-    const struct sockaddr_in6 *s_sockaddr_in6;
-
-    if (s_sockaddr == NULL)
-      return "";
-
-    char res[INET6_ADDRSTRLEN] = { '\0' };
-
-    switch (s_sockaddr->sa_family) {
-      case AF_INET:
-        s_sockaddr_in = reinterpret_cast<const struct sockaddr_in *>(s_sockaddr);
-        inet_ntop(s_sockaddr_in->sin_family, &s_sockaddr_in->sin_addr, res, INET_ADDRSTRLEN);
-        break;
-      case AF_INET6:
-        s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 *>(s_sockaddr);
-        inet_ntop(s_sockaddr_in6->sin6_family, &s_sockaddr_in6->sin6_addr, res, INET6_ADDRSTRLEN);
-        break;
-    }
-
-    return std::string(res);
-  }
-
-  std::string getURL(const Resources& res) {
-    TSMBuffer bufp;
-    TSMLoc url_loc;
-
-    if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) != TS_SUCCESS)
-      return "";
-
-    int url_len;
-    char *url = TSUrlStringGet(bufp, url_loc, &url_len);
-    std::string ret;
-    if (url && url_len)
-      ret.assign(url, url_len);
-    TSfree(url);
-    TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
-
-    return ret;
-  }
-};
-
 #endif // __OPERATOR_H

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/operators.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.cc b/plugins/header_rewrite/operators.cc
index 9aa7ebe..d6a60e5 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include "operators.h"
+#include "expander.h"
 
 // OperatorConfig
 void
@@ -386,8 +387,11 @@ OperatorAddHeader::exec(const Resources& res) const
 
   _value.append_value(value, res);
 
-  VariableExpander ve(value);
-  value = ve.expand(res);
+  if (_value.need_expansion()) {
+    VariableExpander ve(value);
+
+    value = ve.expand(res);
+  }
 
   // Never set an empty header (I don't think that ever makes sense?)
   if (value.empty()) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8f18ea0/plugins/header_rewrite/value.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/value.h b/plugins/header_rewrite/value.h
index cbdd7f8..9fb5856 100644
--- a/plugins/header_rewrite/value.h
+++ b/plugins/header_rewrite/value.h
@@ -42,10 +42,10 @@ class Value : Statement
 {
 public:
   Value()
-    : _value(""), _int_value(0), _float_value(0.0), _cond_val(NULL)
+    : _need_expander(false), _value(""), _int_value(0), _float_value(0.0), _cond_val(NULL)
   {
     TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Value");
-  };
+  }
 
   void
   set_value(const std::string& val)
@@ -58,6 +58,10 @@ public:
       if (_cond_val) {
         _cond_val->initialize(parser);
       }
+    } else if (_value.find("%<") != std::string::npos) { // It has a Variable to expand
+      _need_expander = true; // And this is clearly not an integer or float ...
+      // TODO: This is still not optimal, we should pre-parse the _value string here,
+      // and perhaps populate a per-Value VariableExpander that holds state.
     } else {
       _int_value = strtol(_value.c_str(), NULL, 10);
       _float_value = strtod(_value.c_str(), NULL);
@@ -65,7 +69,8 @@ public:
   }
 
   void
-  append_value(std::string& s, const Resources& res) const {
+  append_value(std::string& s, const Resources& res) const
+  {
     if (_cond_val) {
       _cond_val->append_value(s, res);
     } else {
@@ -79,10 +84,12 @@ public:
   double get_float_value() const { return _float_value; }
 
   bool empty() const { return _value.empty(); }
+  bool need_expansion() const { return _need_expander; }
 
 private:
   DISALLOW_COPY_AND_ASSIGN(Value);
 
+  bool _need_expander;
   std::string _value;
   int _int_value;
   double _float_value;


[06/12] git commit: TS-2539: clean up Generated Perl files

Posted by zw...@apache.org.
TS-2539: clean up Generated Perl files


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/eb450fa8
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/eb450fa8
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/eb450fa8

Branch: refs/heads/5.0.x
Commit: eb450fa809efb1d2586cad6b267982edc73014b2
Parents: 063b320
Author: Igor Galić <i....@brainsware.org>
Authored: Wed Jan 29 16:57:22 2014 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Wed Jan 29 16:57:22 2014 +0100

----------------------------------------------------------------------
 lib/perl/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eb450fa8/lib/perl/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/perl/Makefile.am b/lib/perl/Makefile.am
index 496f217..f2457c5 100644
--- a/lib/perl/Makefile.am
+++ b/lib/perl/Makefile.am
@@ -29,7 +29,7 @@ Makefile-pl: Makefile.PL
 	$(PERL) Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)
 
 distclean-local:
-	-rm -f Makefile-pl
+	-rm -rf Makefile-pl MYMETA.* blip
 
 #test: check
 


[03/12] git commit: TS-2533 Add three commands previously provided by traffic_shell.

Posted by zw...@apache.org.
TS-2533 Add three commands previously provided by traffic_shell.

This adds the following command line options:

     --alarms        Show all alarms currently active (show:alarms)
     --status	     Show the current proxy server status (show:status)
     -- clear_alarms Clear selected alarms. Arguments are the name string,
                     the event number, or the string "all".


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8c47c09a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8c47c09a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8c47c09a

Branch: refs/heads/5.0.x
Commit: 8c47c09a47e5472b616d7dc2681ea6f0978491b5
Parents: dff82e3
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Jan 27 10:29:35 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Jan 27 14:51:57 2014 -0700

----------------------------------------------------------------------
 CHANGES                                    |  2 +
 cmd/traffic_line/traffic_line.cc           | 91 +++++++++++++++++++++++++
 doc/reference/commands/traffic_line.en.rst | 15 ++++
 3 files changed, 108 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c47c09a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f1802a4..325773f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2533 ] Add three commands previously provided by traffic_shell.
+
   *) [TS-2304] Make the healthcheck plugin watch for file permission changes.
 
   *) [TS-2519] Make build version metrics non-persistent.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c47c09a/cmd/traffic_line/traffic_line.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_line/traffic_line.cc b/cmd/traffic_line/traffic_line.cc
index f25c95d..0e25105 100644
--- a/cmd/traffic_line/traffic_line.cc
+++ b/cmd/traffic_line/traffic_line.cc
@@ -47,6 +47,9 @@ static int ClearNode;
 static char ZeroCluster[1024];
 static char ZeroNode[1024];
 static char StorageCmdOffline[1024];
+static int ShowAlarms;
+static int ShowStatus;
+static char ClearAlarms[1024];
 static int VersionFlag;
 
 static TSError
@@ -74,6 +77,7 @@ handleArgInvocation()
     TSError err;
     TSRecordEle *rec_ele = TSRecordEleCreate();
     char *name = *ZeroNode ? ZeroNode : ZeroCluster;
+
     if ((err = TSRecordGet(name, rec_ele)) != TS_ERR_OKAY) {
       fprintf(stderr, "%s: %s\n", programName, TSGetErrorMessage(err));
       TSRecordEleDestroy(rec_ele);
@@ -87,6 +91,87 @@ handleArgInvocation()
     return TS_ERR_FAIL;
   } else if (*StorageCmdOffline) {
     return TSStorageDeviceCmdOffline(StorageCmdOffline);
+  } else if (ShowAlarms == 1) {
+    // Show all active alarms, this was moved from the old traffic_shell implementation (show:alarms).
+    TSList events = TSListCreate();
+
+    if (TS_ERR_OKAY != TSActiveEventGetMlt(events)) {
+      TSListDestroy(events);
+      fprintf(stderr, "Error Retrieving Alarm List\n");
+      return TS_ERR_FAIL;
+    }
+
+    int count = TSListLen(events);
+
+    if (count > 0) {
+      printf("Active Alarms\n");
+      for (int i = 0; i < count; i++) {
+        char* name = static_cast<char *>(TSListDequeue(events));
+        printf("  %d. %s\n", i + 1, name);
+      }
+    } else {
+      printf("\nNo active alarms.\n");
+    }
+    TSListDestroy(events);
+    return TS_ERR_OKAY;
+  } else if (*ClearAlarms != '\0') {
+    // Clear (some) active alarms, this was moved from the old traffic_shell implementation (config:alarm)
+    TSList events = TSListCreate();
+    size_t len = strlen(ClearAlarms);
+
+    if (TS_ERR_OKAY != TSActiveEventGetMlt(events)) {
+      TSListDestroy(events);
+      fprintf(stderr, "Error Retrieving Alarm List\n");
+      return TS_ERR_FAIL;
+    }
+
+    int count = TSListLen(events);
+
+    if (count == 0) {
+      printf("No Alarms to resolve\n");
+      TSListDestroy(events);
+      return TS_ERR_OKAY;
+    }
+
+    int errors = 0;
+    bool all = false;
+    int num = -1;
+
+    if ((3 == len) && (0 == strncasecmp(ClearAlarms, "all", len))) {
+      all = true;
+    } else  {
+      num = strtol(ClearAlarms, NULL, 10) - 1;
+      if (num <= 0)
+        num = -1;
+    }
+
+    for (int i = 0; i < count; i++) {
+      char* name = static_cast<char*>(TSListDequeue(events));
+
+      if (all || ((num > -1) && (num == i)) || ((strlen(name) == len) && (0 == strncasecmp(ClearAlarms, name, len)))) {
+        if (TS_ERR_OKAY != TSEventResolve(name)) {
+          fprintf(stderr, "Errur: Unable to resolve alarm %s\n", name);
+          ++errors;
+        }
+        if (num > 0) // If a specific event number was specified, we can stop now
+          break;
+      }
+    }
+    TSListDestroy(events);
+    return (errors > 0 ? TS_ERR_FAIL: TS_ERR_OKAY);
+  } else if (ShowStatus == 1) {
+    switch (TSProxyStateGet()) {
+    case TS_PROXY_ON:
+      printf("Proxy -- on\n");
+      break;
+    case TS_PROXY_OFF:
+      printf("Proxy -- off\n");
+      break;
+    case TS_PROXY_UNDEFINED:
+      printf("Proxy status undefined\n");
+      break;
+    }
+    return TS_ERR_OKAY;
   } else if (*ReadVar != '\0') {        // Handle a value read
     if (*SetVar != '\0' || *VarValue != '\0') {
       fprintf(stderr, "%s: Invalid Argument Combination: Can not read and set values at the same time\n", programName);
@@ -166,6 +251,9 @@ main(int /* argc ATS_UNUSED */, char **argv)
   ZeroNode[0] = '\0';
   VersionFlag = 0;
   *StorageCmdOffline = 0;
+  ShowAlarms = 0;
+  ShowStatus = 0;
+  ClearAlarms[0] = '\0';
 
   // build the application information structure
   appVersionInfo.setup(PACKAGE_NAME,"traffic_line", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
@@ -190,6 +278,9 @@ main(int /* argc ATS_UNUSED */, char **argv)
     {"zero_cluster", 'Z', "Zero Specific Statistic (cluster wide)", "S1024", &ZeroCluster, NULL, NULL},
     {"zero_node", 'z', "Zero Specific Statistic (local node)", "S1024", &ZeroNode, NULL, NULL},
     {"offline", '-', "Mark cache storage offline", "S1024", &StorageCmdOffline, NULL, NULL},
+    {"alarms", '-', "Show all alarms", "F", &ShowAlarms, NULL, NULL},
+    {"clear_alarms", '-', "Clear specified, or all,  alarms", "S1024", &ClearAlarms, NULL, NULL},
+    {"status", '-', "Show proxy server status", "F", &ShowStatus, NULL, NULL},
     {"version", 'V', "Print Version Id", "T", &VersionFlag, NULL, NULL},
   };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c47c09a/doc/reference/commands/traffic_line.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/traffic_line.en.rst b/doc/reference/commands/traffic_line.en.rst
index 213cd40..8f8425b 100644
--- a/doc/reference/commands/traffic_line.en.rst
+++ b/doc/reference/commands/traffic_line.en.rst
@@ -120,6 +120,21 @@ Options
    used this storage to other storage. This has exactly the same effect as a disk failure for that storage. This does
    not persist across restarts of the :program:`traffic_server` process.
 
+.. option:: --alarms
+
+   List all alarm events that have not been acknowledged (cleared).
+
+.. option:: --clear_alarms [all | #event | name]
+
+   Clear (acknowledge) an alarm event. The arguments are "all" for all current
+   alarms, a specific alarm number (e.g. ''1''), or an alarm string identifier
+   (e.g. ''MGMT_ALARM_PROXY_CONFIG_ERROR'').
+
+.. option:: --status
+
+   Show the current proxy server status, indicating if we're running or not.
+
+
 .. traffic-line-performance-statistics
 
 Performance Statistics


[02/12] git commit: Added TS-2304 to CHANGES.

Posted by zw...@apache.org.
Added TS-2304 to CHANGES.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dff82e38
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dff82e38
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dff82e38

Branch: refs/heads/5.0.x
Commit: dff82e38e409be1e785e091ef8d83ff66f6e4c1f
Parents: c952398
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Jan 27 14:27:49 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Jan 27 14:27:49 2014 -0700

----------------------------------------------------------------------
 CHANGES | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dff82e38/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d2cce2d..f1802a4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2304] Make the healthcheck plugin watch for file permission changes.
+
   *) [TS-2519] Make build version metrics non-persistent.
 
   *) [TS-1606] Log buffers are not flushed periodically when TS is launched