You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2014/08/10 20:28:35 UTC
[1/2] git commit: TS-2999: Add dscp_remap plugin code
Repository: trafficserver
Updated Branches:
refs/heads/master 465b2cb2f -> 04699c5f7
TS-2999: Add dscp_remap plugin code
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/279402a5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/279402a5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/279402a5
Branch: refs/heads/master
Commit: 279402a5522ad2b94186bd35c516e17c0d0491f4
Parents: 465b2cb
Author: Jan van Doorn <Ja...@cable.comcast.com>
Authored: Sun Aug 10 12:09:37 2014 -0600
Committer: Phil Sorber <so...@apache.org>
Committed: Sun Aug 10 12:10:37 2014 -0600
----------------------------------------------------------------------
plugins/experimental/dscp_remap/dscp_remap.cc | 109 +++++++++++++++++++++
1 file changed, 109 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/279402a5/plugins/experimental/dscp_remap/dscp_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/dscp_remap/dscp_remap.cc b/plugins/experimental/dscp_remap/dscp_remap.cc
new file mode 100644
index 0000000..b26c24c
--- /dev/null
+++ b/plugins/experimental/dscp_remap/dscp_remap.cc
@@ -0,0 +1,109 @@
+/**
+
+ @section license License
+
+ 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <ts/ts.h>
+#include <ts/remap.h>
+
+static const char* PLUGIN_NAME = "dscp_remap";
+
+struct DscpRemapInstance {
+ int tos;
+
+ DscpRemapInstance() : tos(0) { } ;
+};
+
+TSReturnCode
+TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
+{
+ if (!api_info) {
+ strncpy(errbuf, "[tsremap_init] - Invalid TSRemapInterface argument", (size_t)(errbuf_size - 1));
+ return TS_ERROR;
+ }
+
+ if (api_info->tsremap_version < TSREMAP_VERSION) {
+ snprintf(errbuf, errbuf_size - 1, "[TSRemapInit] - Incorrect API version %ld.%ld", api_info->tsremap_version >> 16, (api_info->tsremap_version & 0xffff));
+ return TS_ERROR;
+ }
+
+ TSDebug(PLUGIN_NAME, "plugin is succesfully initialized");
+ return TS_SUCCESS;
+}
+
+TSReturnCode
+TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf, int errbuf_size)
+{
+ int dscp;
+ DscpRemapInstance* di;
+
+ dscp = atoi(argv[2]);
+
+ di = new DscpRemapInstance();
+ *ih = (void *) di;
+
+ di->tos = dscp << 2;
+
+ return TS_SUCCESS;
+}
+
+void
+TSRemapDeleteInstance(void* ih)
+{
+ DscpRemapInstance* di = static_cast<DscpRemapInstance*>(ih);
+ delete di;
+}
+
+TSRemapStatus
+TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
+{
+ int sockfd;
+ DscpRemapInstance* di = static_cast<DscpRemapInstance*>(ih);
+ int tos = di->tos;
+ int retval;
+
+ retval = TSHttpTxnClientFdGet(txnp, &sockfd);
+ if (retval != TS_SUCCESS) {
+ TSError("Error getting sockfd: %d\n", retval);
+ return TSREMAP_NO_REMAP;
+ }
+
+ // Find out if this is a v4 or v6 connection, there's a different way of
+ // setting the marking
+ TSHttpSsn ssnp = TSHttpTxnSsnGet(txnp);
+ const struct sockaddr *client_addr = TSHttpSsnClientAddrGet(ssnp);
+ if (client_addr->sa_family == AF_INET6) {
+ retval = setsockopt(sockfd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos));
+ } else {
+ retval = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
+ }
+
+ if (retval != TS_SUCCESS) {
+ TSError("Error setting sockfd: %d\n", retval);
+ }
+
+ return TSREMAP_NO_REMAP;
+}
[2/2] git commit: TS-2999: Add dscp_remap plugin to build and update
CHANGES and NOTICE
Posted by so...@apache.org.
TS-2999: Add dscp_remap plugin to build and update CHANGES and NOTICE
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/04699c5f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/04699c5f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/04699c5f
Branch: refs/heads/master
Commit: 04699c5f7a2b22eaf987e58ceb1b0d89c22c06b6
Parents: 279402a
Author: Phil Sorber <so...@apache.org>
Authored: Sun Aug 10 12:27:08 2014 -0600
Committer: Phil Sorber <so...@apache.org>
Committed: Sun Aug 10 12:27:08 2014 -0600
----------------------------------------------------------------------
CHANGES | 2 ++
NOTICE | 2 +-
configure.ac | 1 +
plugins/experimental/Makefile.am | 1 +
plugins/experimental/dscp_remap/Makefile.am | 21 +++++++++++++++++++++
plugins/experimental/dscp_remap/dscp_remap.cc | 7 +++++--
6 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6f6dac7..52cc34b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.1.0
+ *) [TS-2999] Add dscp_remap plugin to experimental plugins.
+
*) [TS-2564] Cherry pick for full cache compatibility.
*) [TS-2362] Make cache backwards compatible to 3.2.0.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 6132ce6..6cb75d7 100644
--- a/NOTICE
+++ b/NOTICE
@@ -54,7 +54,7 @@ Copyright (c) 2013 LinkedIn
~~~
-remap_stats and url_sig plugins developed by Comcast.
+remap_stats, url_sig and dscp_remap plugins developed by Comcast.
Copyright (C) 2014 Comcast
~~~
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index ef3a882..b33413a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1935,6 +1935,7 @@ AS_IF([test "x$enable_experimental_plugins" = xyes], [
plugins/experimental/channel_stats/Makefile
plugins/experimental/collapsed_connection/Makefile
plugins/experimental/custom_redirect/Makefile
+ plugins/experimental/dscp_remap/Makefile
plugins/experimental/epic/Makefile
plugins/experimental/escalate/Makefile
plugins/experimental/esi/Makefile
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/plugins/experimental/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am
index 57fec8c..5331719 100644
--- a/plugins/experimental/Makefile.am
+++ b/plugins/experimental/Makefile.am
@@ -22,6 +22,7 @@ SUBDIRS = \
channel_stats \
collapsed_connection \
custom_redirect \
+ dscp_remap \
epic \
escalate \
esi \
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/plugins/experimental/dscp_remap/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/dscp_remap/Makefile.am b/plugins/experimental/dscp_remap/Makefile.am
new file mode 100644
index 0000000..eade7c4
--- /dev/null
+++ b/plugins/experimental/dscp_remap/Makefile.am
@@ -0,0 +1,21 @@
+# 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.
+
+include $(top_srcdir)/build/plugins.mk
+
+pkglib_LTLIBRARIES = dscp_remap.la
+dscp_remap_la_SOURCES = dscp_remap.cc
+dscp_remap_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04699c5f/plugins/experimental/dscp_remap/dscp_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/dscp_remap/dscp_remap.cc b/plugins/experimental/dscp_remap/dscp_remap.cc
index b26c24c..6d8337c 100644
--- a/plugins/experimental/dscp_remap/dscp_remap.cc
+++ b/plugins/experimental/dscp_remap/dscp_remap.cc
@@ -19,6 +19,9 @@
limitations under the License.
*/
+#include "ink_config.h"
+#include "ink_defs.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -55,7 +58,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
}
TSReturnCode
-TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf, int errbuf_size)
+TSRemapNewInstance(int argc ATS_UNUSED, char* argv[], void** ih, char* errbuf ATS_UNUSED, int errbuf_size ATS_UNUSED)
{
int dscp;
DscpRemapInstance* di;
@@ -78,7 +81,7 @@ TSRemapDeleteInstance(void* ih)
}
TSRemapStatus
-TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
+TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri ATS_UNUSED)
{
int sockfd;
DscpRemapInstance* di = static_cast<DscpRemapInstance*>(ih);