trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject trafficserver git commit: TS-3240: fix IP address hash policy for the balancer plugin
Date Tue, 16 Dec 2014 00:58:19 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 566719961 -> 1f073588a


TS-3240: fix IP address hash policy for the balancer plugin

Fix the srcaddr hash policy and add the dstaddr hash policy.


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

Branch: refs/heads/master
Commit: 1f073588a1275860d99c5a95c7e1c3e571a1d554
Parents: 5667199
Author: James Peach <jpeach@apache.org>
Authored: Wed Dec 10 13:02:39 2014 -0800
Committer: James Peach <jpeach@apache.org>
Committed: Mon Dec 15 16:56:46 2014 -0800

----------------------------------------------------------------------
 CHANGES                               |  2 ++
 doc/reference/plugins/balancer.en.rst |  3 +++
 plugins/experimental/balancer/hash.cc | 17 ++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f073588/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4c8c891..cd2adb9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.3.0
 
+  *) [TS-3240] Add the `dstaddr` hash key to the balancer plugin.
+
   *) [TS-3239] Add a new `generator` plugin.
 
   *) [TS-3238] Stop referencing the global _res symbol.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f073588/doc/reference/plugins/balancer.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/balancer.en.rst b/doc/reference/plugins/balancer.en.rst
index 239d1b2..6d443a5 100644
--- a/doc/reference/plugins/balancer.en.rst
+++ b/doc/reference/plugins/balancer.en.rst
@@ -61,6 +61,9 @@ url
 srcaddr
   The source IP address of the request.
 
+dstaddr
+  The destination IP address of the request.
+
 Round Robin Balancing Policy
 ----------------------------
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f073588/plugins/experimental/balancer/hash.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/balancer/hash.cc b/plugins/experimental/balancer/hash.cc
index d90a02c..17c9c63 100644
--- a/plugins/experimental/balancer/hash.cc
+++ b/plugins/experimental/balancer/hash.cc
@@ -65,12 +65,25 @@ struct md5_key {
 
 typedef void (*HashComponent)(TSHttpTxn txn, TSRemapRequestInfo *, MD5_CTX *);
 
-// Hash on the source IP address;
+// Hash on the source (client) IP address.
 void
 HashTxnSrcaddr(TSHttpTxn txn, TSRemapRequestInfo *, MD5_CTX * ctx)
 {
   struct sockaddr const * sa;
 
+  sa = TSHttpTxnClientAddrGet(txn);
+  if (txn) {
+    MD5_Update(ctx, sa, sockaddrlen(sa));
+    TSDebug("balancer", "%s(addr[%zu]]", __func__, sockaddrlen(sa));
+  }
+}
+
+// Hash on the destination (server) IP address;
+void
+HashTxnDstaddr(TSHttpTxn txn, TSRemapRequestInfo *, MD5_CTX * ctx)
+{
+  struct sockaddr const * sa;
+
   sa = TSHttpTxnIncomingAddrGet(txn);
   if (txn) {
     MD5_Update(ctx, sa, sockaddrlen(sa));
@@ -195,6 +208,8 @@ MakeHashBalancer(const char * options)
         hash->hash_parts.push_back(HashTxnUrl);
       } else if (strcmp(opt, "srcaddr") == 0) {
         hash->hash_parts.push_back(HashTxnSrcaddr);
+      } else if (strcmp(opt, "dstaddr") == 0) {
+        hash->hash_parts.push_back(HashTxnDstaddr);
       } else {
         TSError("balancer: ignoring invalid hash field '%s'", opt);
       }


Mime
View raw message