You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/05/28 00:58:13 UTC

mesos git commit: Merged class Handle which is duplicated between filter/handle and queueing/handle.

Repository: mesos
Updated Branches:
  refs/heads/master 394fd1883 -> 4b1282c61


Merged class Handle which is duplicated between filter/handle and
queueing/handle.

Review: https://reviews.apache.org/r/34321


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

Branch: refs/heads/master
Commit: 4b1282c616aa92fd292a6c54997fa1dfca465deb
Parents: 394fd18
Author: Paul Brett <pa...@twopensource.com>
Authored: Wed May 27 15:48:39 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 27 15:58:15 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am                         |  3 +-
 src/linux/routing/filter/basic.cpp      | 17 +++---
 src/linux/routing/filter/basic.hpp      | 18 +++---
 src/linux/routing/filter/filter.hpp     | 21 ++++---
 src/linux/routing/filter/handle.hpp     | 34 +++++------
 src/linux/routing/filter/icmp.cpp       | 19 +++----
 src/linux/routing/filter/icmp.hpp       | 20 +++----
 src/linux/routing/filter/internal.hpp   | 20 +++----
 src/linux/routing/filter/ip.cpp         | 21 ++++---
 src/linux/routing/filter/ip.hpp         | 22 ++++----
 src/linux/routing/queueing/fq_codel.cpp |  7 ++-
 src/linux/routing/queueing/fq_codel.hpp |  2 +-
 src/linux/routing/queueing/handle.cpp   | 30 ----------
 src/linux/routing/queueing/handle.hpp   | 84 ----------------------------
 src/linux/routing/queueing/ingress.cpp  | 13 +++--
 src/linux/routing/queueing/ingress.hpp  | 23 +++++++-
 src/linux/routing/queueing/internal.hpp |  3 +-
 src/tests/routing_tests.cpp             | 11 ++--
 18 files changed, 131 insertions(+), 237 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 28669f6..e7281ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -496,10 +496,10 @@ if WITH_NETWORK_ISOLATOR
 	linux/routing/filter/ip.cpp					\
 	linux/routing/link/link.cpp					\
 	linux/routing/queueing/fq_codel.cpp				\
-	linux/routing/queueing/handle.cpp				\
 	linux/routing/queueing/ingress.cpp
 
   libmesos_no_3rdparty_la_SOURCES +=					\
+	linux/routing/handle.hpp					\
 	linux/routing/internal.hpp					\
 	linux/routing/route.hpp						\
 	linux/routing/utils.hpp						\
@@ -515,7 +515,6 @@ if WITH_NETWORK_ISOLATOR
 	linux/routing/link/internal.hpp					\
 	linux/routing/link/link.hpp					\
 	linux/routing/queueing/fq_codel.hpp				\
-	linux/routing/queueing/handle.hpp				\
 	linux/routing/queueing/ingress.hpp				\
 	linux/routing/queueing/internal.hpp
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/basic.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/basic.cpp b/src/linux/routing/filter/basic.cpp
index 755be7d..4ce8acb 100644
--- a/src/linux/routing/filter/basic.cpp
+++ b/src/linux/routing/filter/basic.cpp
@@ -25,6 +25,7 @@
 #include <stout/error.hpp>
 #include <stout/none.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/internal.hpp"
 
 #include "linux/routing/filter/action.hpp"
@@ -33,8 +34,6 @@
 #include "linux/routing/filter/internal.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 using std::string;
 
 namespace routing {
@@ -87,7 +86,7 @@ namespace basic {
 
 Try<bool> exists(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol)
 {
   return internal::exists(link, parent, Classifier(protocol));
@@ -96,10 +95,10 @@ Try<bool> exists(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid)
+    const Option<Handle>& classid)
 {
   return internal::create(
       link,
@@ -114,7 +113,7 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
     const action::Redirect& redirect)
@@ -132,7 +131,7 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
     const action::Mirror& mirror)
@@ -150,7 +149,7 @@ Try<bool> create(
 
 Try<bool> remove(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol)
 {
   return internal::remove(link, parent, Classifier(protocol));
@@ -159,7 +158,7 @@ Try<bool> remove(
 
 Try<bool> update(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const action::Mirror& mirror)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/basic.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/basic.hpp b/src/linux/routing/filter/basic.hpp
index 99b0b05..f1999bf 100644
--- a/src/linux/routing/filter/basic.hpp
+++ b/src/linux/routing/filter/basic.hpp
@@ -26,12 +26,12 @@
 #include <stout/option.hpp>
 #include <stout/try.hpp>
 
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/filter/action.hpp"
 #include "linux/routing/filter/filter.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 // This is a work around. Including <linux/if_ether.h> causes
 // duplicated definitions on some platforms with old glibc.
 #ifndef ETH_P_ALL
@@ -71,7 +71,7 @@ private:
 // to the given parent exists on the link.
 Try<bool> exists(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol);
 
 
@@ -82,10 +82,10 @@ Try<bool> exists(
 // can choose to specify an optional priority for the filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid);
+    const Option<Handle>& classid);
 
 
 // Creates a basic packet filter with given protocol attached to the
@@ -96,7 +96,7 @@ Try<bool> create(
 // filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
     const action::Redirect& redirect);
@@ -110,7 +110,7 @@ Try<bool> create(
 // an optional priority for the filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const Option<Priority>& priority,
     const action::Mirror& mirror);
@@ -122,7 +122,7 @@ Try<bool> create(
 // the link.
 Try<bool> remove(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol);
 
 
@@ -132,7 +132,7 @@ Try<bool> remove(
 // is found on the link.
 Try<bool> update(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     uint16_t protocol,
     const action::Mirror& mirror);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/filter.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/filter.hpp b/src/linux/routing/filter/filter.hpp
index 024582c..aaca57f 100644
--- a/src/linux/routing/filter/filter.hpp
+++ b/src/linux/routing/filter/filter.hpp
@@ -25,12 +25,11 @@
 
 #include <stout/option.hpp>
 
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/filter/action.hpp"
-#include "linux/routing/filter/handle.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 namespace routing {
 namespace filter {
 
@@ -50,7 +49,7 @@ class Filter
 {
 public:
   // Creates a filter with no action.
-  Filter(const queueing::Handle& _parent,
+  Filter(const Handle& _parent,
          const Classifier& _classifier,
          const Option<Priority>& _priority,
          const Option<Handle>& _handle)
@@ -60,11 +59,11 @@ public:
       handle_(_handle) {}
 
   // Creates a filter with specified classid.
-  Filter(const queueing::Handle& _parent,
+  Filter(const Handle& _parent,
          const Classifier& _classifier,
          const Option<Priority>& _priority,
          const Option<Handle>& _handle,
-         const Option<queueing::Handle>& _classid)
+         const Option<Handle>& _classid)
     : parent_(_parent),
       classifier_(_classifier),
       priority_(_priority),
@@ -73,7 +72,7 @@ public:
 
   // TODO(jieyu): Support arbitrary number of actions.
   template <typename Action>
-  Filter(const queueing::Handle& _parent,
+  Filter(const Handle& _parent,
          const Classifier& _classifier,
          const Option<Priority>& _priority,
          const Option<Handle>& _handle,
@@ -93,11 +92,11 @@ public:
     actions_.push_back(process::Shared<action::Action>(new A(action)));
   }
 
-  const queueing::Handle& parent() const { return parent_; }
+  const Handle& parent() const { return parent_; }
   const Classifier& classifier() const { return classifier_; }
   const Option<Priority>& priority() const { return priority_; }
   const Option<Handle>& handle() const { return handle_; }
-  const Option<queueing::Handle>& classid() const { return classid_; }
+  const Option<Handle>& classid() const { return classid_; }
 
   // Returns all the actions attached to this filter.
   const std::vector<process::Shared<action::Action>>& actions() const
@@ -108,7 +107,7 @@ public:
 private:
   // Each filter is attached to a queueing object (either a queueing
   // discipline or a queueing class).
-  queueing::Handle parent_;
+  Handle parent_;
 
   // The filter specific classifier.
   Classifier classifier_;
@@ -132,7 +131,7 @@ private:
   //
   // Kernel uses classid and flowid interchangeably. However, in our
   // code base, we use classid consistently.
-  Option<queueing::Handle> classid_;
+  Option<Handle> classid_;
 
   // The set of actions attached to this filer. Note that we use
   // Shared here to make Filter copyable.

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/handle.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/handle.hpp b/src/linux/routing/filter/handle.hpp
index 1901774..461ace2 100644
--- a/src/linux/routing/filter/handle.hpp
+++ b/src/linux/routing/filter/handle.hpp
@@ -21,30 +21,22 @@
 
 #include <stdint.h>
 
+#include "linux/routing/handle.hpp"
+
 namespace routing {
 namespace filter {
 
-// Represents the handle for a traffic control (tc) filter. Different
-// types of filters have different types of handles. This is the base
-// class of all types of filters.
-class Handle
-{
-public:
-  explicit Handle(uint32_t _handle) : handle(_handle) {}
-  virtual ~Handle() {}
-
-  uint32_t get() const { return handle; }
-
-protected:
-  uint32_t handle;
-};
-
-
-// Represents a u32 filter handle. A u32 filter handle has three
-// parts. The first number identifies a hash table, the second number
-// identifies a bucket within the hash table, and the third number
-// identifies the filter item within the bucket.
-// http://ace-host.stuart.id.au/russell/files/tc/doc/cls_u32.txt
+// When the number of Linux kernel Traffic Control (TC) objects
+// attached to an interface is high, the kernel can spend a
+// significant amount of time looking up TC filters (an operation that
+// must be performed for every packet on the interface). To speed up
+// these lookups, an alternative interpretation of the handle bits,
+// the U32Handle, can be used breaking down the identifier into hash
+// table id (htid), bucket (hash) and filter item (node) within the
+// bucket. Careful selection of the handles by the administrator
+// allows for the construction of hash tables that can significantly
+// reduce lookup times.
+// See http://ace-host.stuart.id.au/russell/files/tc/doc/cls_u32.txt
 class U32Handle : public Handle
 {
 public:

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/icmp.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/icmp.cpp b/src/linux/routing/filter/icmp.cpp
index 60703e7..76877fb 100644
--- a/src/linux/routing/filter/icmp.cpp
+++ b/src/linux/routing/filter/icmp.cpp
@@ -29,6 +29,7 @@
 #include <stout/error.hpp>
 #include <stout/none.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/internal.hpp"
 
 #include "linux/routing/filter/action.hpp"
@@ -37,8 +38,6 @@
 #include "linux/routing/filter/internal.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 using std::string;
 using std::vector;
 
@@ -205,7 +204,7 @@ namespace icmp {
 
 Try<bool> exists(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   return internal::exists(link, parent, classifier);
@@ -214,7 +213,7 @@ Try<bool> exists(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Redirect& redirect)
@@ -232,7 +231,7 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Mirror& mirror)
@@ -250,10 +249,10 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid)
+    const Option<Handle>& classid)
 {
   return internal::create(
       link,
@@ -268,7 +267,7 @@ Try<bool> create(
 
 Try<bool> remove(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   return internal::remove(link, parent, classifier);
@@ -277,7 +276,7 @@ Try<bool> remove(
 
 Try<bool> update(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const action::Mirror& mirror)
 {
@@ -294,7 +293,7 @@ Try<bool> update(
 
 Result<vector<Classifier>> classifiers(
     const string& link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   return internal::classifiers<Classifier>(link, parent);
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/icmp.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/icmp.hpp b/src/linux/routing/filter/icmp.hpp
index d55eeee..9e167b0 100644
--- a/src/linux/routing/filter/icmp.hpp
+++ b/src/linux/routing/filter/icmp.hpp
@@ -27,12 +27,12 @@
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/filter/action.hpp"
 #include "linux/routing/filter/filter.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 namespace routing {
 namespace filter {
 namespace icmp {
@@ -61,7 +61,7 @@ private:
 // given parent on the link which matches the specified classifier.
 Try<bool> exists(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier);
 
 
@@ -73,7 +73,7 @@ Try<bool> exists(
 // an optional priority for the filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Redirect& redirect);
@@ -88,7 +88,7 @@ Try<bool> create(
 // filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Mirror& mirror);
@@ -102,10 +102,10 @@ Try<bool> create(
 // for the filter.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid);
+    const Option<Handle>& classid);
 
 
 // Removes the ICMP packet filter attached to the given parent that
@@ -113,7 +113,7 @@ Try<bool> create(
 // such a filter is not found.
 Try<bool> remove(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier);
 
 
@@ -122,7 +122,7 @@ Try<bool> remove(
 // false if such a filter is not found.
 Try<bool> update(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const action::Mirror& mirror);
 
@@ -132,7 +132,7 @@ Try<bool> update(
 // parent is not found.
 Result<std::vector<Classifier>> classifiers(
     const std::string& link,
-    const queueing::Handle& parent);
+    const Handle& parent);
 
 } // namespace icmp {
 } // namespace filter {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/internal.hpp b/src/linux/routing/filter/internal.hpp
index c74098d..10f0bea 100644
--- a/src/linux/routing/filter/internal.hpp
+++ b/src/linux/routing/filter/internal.hpp
@@ -50,16 +50,16 @@
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/internal.hpp"
 
 #include "linux/routing/filter/action.hpp"
 #include "linux/routing/filter/filter.hpp"
+#include "linux/routing/filter/handle.hpp"
 #include "linux/routing/filter/priority.hpp"
 
 #include "linux/routing/link/internal.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 namespace routing {
 namespace filter {
 namespace internal {
@@ -441,7 +441,7 @@ Result<Filter<Classifier>> decodeFilter(const Netlink<struct rtnl_cls>& cls)
   }
 
   // Decode the parent.
-  queueing::Handle parent(rtnl_tc_get_parent(TC_CAST(cls.get())));
+  Handle parent(rtnl_tc_get_parent(TC_CAST(cls.get())));
 
   // Decode the priority. If the priority is not specified by the
   // user, kernel will assign a priority to the filter. So we should
@@ -461,7 +461,7 @@ Result<Filter<Classifier>> decodeFilter(const Netlink<struct rtnl_cls>& cls)
     return None();
   }
 
-  Option<queueing::Handle> classid;
+  Option<Handle> classid;
   if (rtnl_tc_get_kind(TC_CAST(cls.get())) == std::string("u32")) {
     uint32_t _classid;
     if (rtnl_u32_get_classid(cls.get(), &_classid) == 0) {
@@ -489,7 +489,7 @@ Result<Filter<Classifier>> decodeFilter(const Netlink<struct rtnl_cls>& cls)
 // parent on the link.
 inline Try<std::vector<Netlink<struct rtnl_cls>>> getClses(
     const Netlink<struct rtnl_link>& link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   Try<Netlink<struct nl_sock>> socket = routing::socket();
   if (socket.isError()) {
@@ -532,7 +532,7 @@ inline Try<std::vector<Netlink<struct rtnl_cls>>> getClses(
 template <typename Classifier>
 Result<Netlink<struct rtnl_cls>> getCls(
     const Netlink<struct rtnl_link>& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   Try<std::vector<Netlink<struct rtnl_cls>>> clses = getClses(link, parent);
@@ -565,7 +565,7 @@ Result<Netlink<struct rtnl_cls>> getCls(
 template <typename Classifier>
 Try<bool> exists(
     const std::string& _link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
@@ -645,7 +645,7 @@ Try<bool> create(const std::string& _link, const Filter<Classifier>& filter)
 template <typename Classifier>
 Try<bool> remove(
     const std::string& _link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
@@ -766,7 +766,7 @@ Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
 template <typename Classifier>
 Result<std::vector<Filter<Classifier>>> filters(
     const std::string& _link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
   if (link.isError()) {
@@ -806,7 +806,7 @@ Result<std::vector<Filter<Classifier>>> filters(
 template <typename Classifier>
 Result<std::vector<Classifier>> classifiers(
     const std::string& link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   Result<std::vector<Filter<Classifier>>> _filters =
     filters<Classifier>(link, parent);

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/ip.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/ip.cpp b/src/linux/routing/filter/ip.cpp
index 0d25e2d..0f3b856 100644
--- a/src/linux/routing/filter/ip.cpp
+++ b/src/linux/routing/filter/ip.cpp
@@ -25,6 +25,7 @@
 #include <stout/error.hpp>
 #include <stout/none.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/internal.hpp"
 
 #include "linux/routing/filter/action.hpp"
@@ -33,8 +34,6 @@
 #include "linux/routing/filter/ip.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 using std::string;
 using std::vector;
 
@@ -457,7 +456,7 @@ Try<PortRange> PortRange::fromBeginMask(uint16_t begin, uint16_t mask)
 
 Try<bool> exists(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   return internal::exists(link, parent, classifier);
@@ -466,7 +465,7 @@ Try<bool> exists(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Redirect& redirect)
@@ -484,7 +483,7 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const Option<Handle>& handle,
@@ -503,7 +502,7 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Terminal& terminal)
@@ -520,10 +519,10 @@ Try<bool> create(
 
 Try<bool> create(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid)
+    const Option<Handle>& classid)
 {
   return internal::create(
       link,
@@ -537,7 +536,7 @@ Try<bool> create(
 
 Try<bool> remove(
     const string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier)
 {
   return internal::remove(link, parent, classifier);
@@ -546,7 +545,7 @@ Try<bool> remove(
 
 Result<vector<Filter<Classifier>>> filters(
     const string& link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   return internal::filters<Classifier>(link, parent);
 }
@@ -554,7 +553,7 @@ Result<vector<Filter<Classifier>>> filters(
 
 Result<vector<Classifier>> classifiers(
     const string& link,
-    const queueing::Handle& parent)
+    const Handle& parent)
 {
   return internal::classifiers<Classifier>(link, parent);
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/filter/ip.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/ip.hpp b/src/linux/routing/filter/ip.hpp
index 62bb5f8..9645f94 100644
--- a/src/linux/routing/filter/ip.hpp
+++ b/src/linux/routing/filter/ip.hpp
@@ -34,12 +34,12 @@
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/filter/action.hpp"
 #include "linux/routing/filter/filter.hpp"
 #include "linux/routing/filter/priority.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 namespace routing {
 namespace filter {
 namespace ip {
@@ -147,7 +147,7 @@ private:
 // that matches the specified classifier exists on the link.
 Try<bool> exists(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier);
 
 
@@ -158,7 +158,7 @@ Try<bool> exists(
 // same classifier already exists.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Redirect& redirect);
@@ -169,7 +169,7 @@ Try<bool> create(
 // TODO(jieyu): Revisit this once the kernel bug is fixed.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const Option<Handle>& handle,
@@ -182,7 +182,7 @@ Try<bool> create(
 // parent with the same classifier already exists.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
     const action::Terminal& terminal);
@@ -194,10 +194,10 @@ Try<bool> create(
 // already exists.
 Try<bool> create(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier,
     const Option<Priority>& priority,
-    const Option<queueing::Handle>& classid);
+    const Option<Handle>& classid);
 
 
 // Removes the IP packet filter attached to the given parent that
@@ -205,7 +205,7 @@ Try<bool> create(
 // such a filter is not found.
 Try<bool> remove(
     const std::string& link,
-    const queueing::Handle& parent,
+    const Handle& parent,
     const Classifier& classifier);
 
 
@@ -213,7 +213,7 @@ Try<bool> remove(
 // the link. Returns none if the link or the parent is not found.
 Result<std::vector<Filter<Classifier>>> filters(
     const std::string& link,
-    const queueing::Handle& parent);
+    const Handle& parent);
 
 
 // Returns the classifiers of all the IP packet filters attached to
@@ -221,7 +221,7 @@ Result<std::vector<Filter<Classifier>>> filters(
 // parent is not found.
 Result<std::vector<Classifier>> classifiers(
     const std::string& link,
-    const queueing::Handle& parent);
+    const Handle& parent);
 
 } // namespace ip {
 } // namespace filter {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/fq_codel.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/fq_codel.cpp b/src/linux/routing/queueing/fq_codel.cpp
index 02ad8df..f9db58b 100644
--- a/src/linux/routing/queueing/fq_codel.cpp
+++ b/src/linux/routing/queueing/fq_codel.cpp
@@ -26,8 +26,9 @@
 #include <stout/nothing.hpp>
 #include <stout/result.hpp>
 
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/queueing/fq_codel.hpp"
-#include "linux/routing/queueing/handle.hpp"
 #include "linux/routing/queueing/internal.hpp"
 
 using std::string;
@@ -70,7 +71,7 @@ Try<Nothing> encode<fq_codel::Discipline>(
         string(nl_geterror(error)));
   }
 
-  rtnl_tc_set_parent(TC_CAST(qdisc.get()), EGRESS_ROOT.get());
+  rtnl_tc_set_parent(TC_CAST(qdisc.get()), EGRESS_ROOT().get());
   rtnl_tc_set_handle(TC_CAST(qdisc.get()), fq_codel::HANDLE.get());
 
   // We don't set fq_codel parameters here, use the default:
@@ -94,7 +95,7 @@ Result<fq_codel::Discipline> decode<fq_codel::Discipline>(
     const Netlink<struct rtnl_qdisc>& qdisc)
 {
   if (rtnl_tc_get_kind(TC_CAST(qdisc.get())) != string("fq_codel") ||
-      rtnl_tc_get_parent(TC_CAST(qdisc.get())) != EGRESS_ROOT.get() ||
+      rtnl_tc_get_parent(TC_CAST(qdisc.get())) != EGRESS_ROOT().get() ||
       rtnl_tc_get_handle(TC_CAST(qdisc.get())) != fq_codel::HANDLE.get()) {
     return None();
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/fq_codel.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/fq_codel.hpp b/src/linux/routing/queueing/fq_codel.hpp
index 4f67ab7..0248616 100644
--- a/src/linux/routing/queueing/fq_codel.hpp
+++ b/src/linux/routing/queueing/fq_codel.hpp
@@ -23,7 +23,7 @@
 
 #include <stout/try.hpp>
 
-#include "linux/routing/queueing/handle.hpp"
+#include "linux/routing/handle.hpp"
 
 namespace routing {
 namespace queueing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/handle.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/handle.cpp b/src/linux/routing/queueing/handle.cpp
deleted file mode 100644
index cd34fc4..0000000
--- a/src/linux/routing/queueing/handle.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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 <netlink/route/tc.h>
-
-#include "linux/routing/queueing/handle.hpp"
-
-namespace routing {
-namespace queueing {
-
-const Handle INGRESS_ROOT = Handle(TC_H_INGRESS);
-const Handle EGRESS_ROOT = Handle(TC_H_ROOT);
-
-} // namespace queueing {
-} // namespace routing {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/handle.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/handle.hpp b/src/linux/routing/queueing/handle.hpp
deleted file mode 100644
index 5f0cb77..0000000
--- a/src/linux/routing/queueing/handle.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef __LINUX_ROUTING_QUEUEING_HANDLE_HPP__
-#define __LINUX_ROUTING_QUEUEING_HANDLE_HPP__
-
-#include <stdint.h>
-
-namespace routing {
-namespace queueing {
-
-// Represents a handle for a queueing object (either a queueing
-// discipline or a queueing class). It can be specified by combining a
-// primary number and a secondary number (modeled after traffic
-// control object handle used in kernel).
-class Handle
-{
-public:
-  explicit Handle(uint32_t _handle) : handle(_handle) {}
-
-  Handle(uint16_t primary, uint16_t secondary)
-  {
-    handle = (((uint32_t) primary) << 16) + secondary;
-  }
-
-  // NOTE: This is used to construct a classid. The higher 16 bits of
-  // the given 'parent' will be the primary and the lower 16 bits is
-  // specified by the given 'id'.
-  Handle(Handle parent, uint16_t id)
-  {
-    handle = (((uint32_t) parent.primary()) << 16) + id;
-  }
-
-  uint16_t primary() const { return handle >> 16; }
-  uint16_t secondary() const { return handle & 0x0000ffff; }
-  uint32_t get() const { return handle; }
-
-private:
-  uint32_t handle;
-};
-
-
-// Packets flowing from the device driver to the network stack are
-// called ingress traffic, and packets flowing from the network stack
-// to the device driver are called egress traffic (shown below).
-//
-//        +---------+
-//        | Network |
-//        |  Stack  |
-//        |---------|
-//        |  eth0   |
-//        +---------+
-//           ^   |
-//   Ingress |   | Egress
-//           |   |
-//    -------+   +------>
-
-
-// The parent of the root ingress queueing discipline.
-extern const Handle INGRESS_ROOT;
-
-
-// The parent of the root egress queueing discipline.
-extern const Handle EGRESS_ROOT;
-
-} // namespace queueing {
-} // namespace routing {
-
-#endif // __LINUX_ROUTING_QUEUEING_HANDLE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/ingress.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp
index 47c7337..fece104 100644
--- a/src/linux/routing/queueing/ingress.cpp
+++ b/src/linux/routing/queueing/ingress.cpp
@@ -26,7 +26,8 @@
 #include <stout/nothing.hpp>
 #include <stout/result.hpp>
 
-#include "linux/routing/queueing/handle.hpp"
+#include "linux/routing/handle.hpp"
+
 #include "linux/routing/queueing/ingress.hpp"
 #include "linux/routing/queueing/internal.hpp"
 
@@ -37,6 +38,9 @@ namespace queueing {
 
 namespace ingress {
 
+const Handle ROOT = Handle(TC_H_INGRESS);
+const Handle HANDLE = Handle(0xffff, 0);
+
 // The ingress queueing discipline is not exposed to the user.
 struct Discipline
 {
@@ -69,7 +73,7 @@ Try<Nothing> encode<ingress::Discipline>(
         string(nl_geterror(error)));
   }
 
-  rtnl_tc_set_parent(TC_CAST(qdisc.get()), INGRESS_ROOT.get());
+  rtnl_tc_set_parent(TC_CAST(qdisc.get()), ingress::ROOT.get());
   rtnl_tc_set_handle(TC_CAST(qdisc.get()), ingress::HANDLE.get());
 
   return Nothing();
@@ -85,7 +89,7 @@ Result<ingress::Discipline> decode<ingress::Discipline>(
     const Netlink<struct rtnl_qdisc>& qdisc)
 {
   if (rtnl_tc_get_kind(TC_CAST(qdisc.get())) != string("ingress") ||
-      rtnl_tc_get_parent(TC_CAST(qdisc.get())) != INGRESS_ROOT.get() ||
+      rtnl_tc_get_parent(TC_CAST(qdisc.get())) != ingress::ROOT.get() ||
       rtnl_tc_get_handle(TC_CAST(qdisc.get())) != ingress::HANDLE.get()) {
     return None();
   }
@@ -101,9 +105,6 @@ Result<ingress::Discipline> decode<ingress::Discipline>(
 
 namespace ingress {
 
-const Handle HANDLE = Handle(0xffff, 0);
-
-
 Try<bool> exists(const string& link)
 {
   return internal::exists(link, Discipline());

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/ingress.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.hpp b/src/linux/routing/queueing/ingress.hpp
index b323a7f..4c96b60 100644
--- a/src/linux/routing/queueing/ingress.hpp
+++ b/src/linux/routing/queueing/ingress.hpp
@@ -23,13 +23,32 @@
 
 #include <stout/try.hpp>
 
-#include "linux/routing/queueing/handle.hpp"
+#include "linux/routing/handle.hpp"
 
 namespace routing {
 namespace queueing {
 namespace ingress {
 
-// The handle of the ingress queueing discipline is fixed.
+// Packets flowing from the device driver to the network stack are
+// called ingress traffic, and packets flowing from the network stack
+// to the device driver are called egress traffic (shown below).
+//
+//        +---------+
+//        | Network |
+//        |  Stack  |
+//        |---------|
+//        |  eth0   |
+//        +---------+
+//           ^   |
+//   Ingress |   | Egress
+//           |   |
+//    -------+   +------>
+//
+// For the ingress traffic, there are two immutable handles defined
+// for the interface which specify the root handle under which a
+// queueing discipline can be created, and the handle of any created
+// ingress filter.
+extern const Handle ROOT;
 extern const Handle HANDLE;
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/linux/routing/queueing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/internal.hpp b/src/linux/routing/queueing/internal.hpp
index 7c6c4d3..d43a9fd 100644
--- a/src/linux/routing/queueing/internal.hpp
+++ b/src/linux/routing/queueing/internal.hpp
@@ -38,12 +38,11 @@
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/internal.hpp"
 
 #include "linux/routing/link/internal.hpp"
 
-#include "linux/routing/queueing/handle.hpp"
-
 namespace routing {
 namespace queueing {
 namespace internal {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4b1282c6/src/tests/routing_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/routing_tests.cpp b/src/tests/routing_tests.cpp
index 6bf5e63..2066a56 100644
--- a/src/tests/routing_tests.cpp
+++ b/src/tests/routing_tests.cpp
@@ -37,19 +37,20 @@
 #include <stout/net.hpp>
 #include <stout/stringify.hpp>
 
+#include "linux/routing/handle.hpp"
 #include "linux/routing/route.hpp"
 #include "linux/routing/utils.hpp"
 
 #include "linux/routing/diagnosis/diagnosis.hpp"
 
 #include "linux/routing/filter/basic.hpp"
+#include "linux/routing/filter/handle.hpp"
 #include "linux/routing/filter/icmp.hpp"
 #include "linux/routing/filter/ip.hpp"
 
 #include "linux/routing/link/link.hpp"
 
 #include "linux/routing/queueing/fq_codel.hpp"
-#include "linux/routing/queueing/handle.hpp"
 #include "linux/routing/queueing/ingress.hpp"
 
 using namespace process;
@@ -440,7 +441,7 @@ TEST_F(RoutingVethTest, ROOT_FqCodelClassifier)
       fq_codel::HANDLE,
       ETH_P_ALL,
       None(),
-      queueing::Handle(fq_codel::HANDLE, 0)));
+      Handle(fq_codel::HANDLE, 0)));
 
   EXPECT_SOME_TRUE(basic::exists(TEST_VETH_LINK, fq_codel::HANDLE, ETH_P_ALL));
 
@@ -449,7 +450,7 @@ TEST_F(RoutingVethTest, ROOT_FqCodelClassifier)
       fq_codel::HANDLE,
       ETH_P_ARP,
       None(),
-      queueing::Handle(fq_codel::HANDLE, 0)));
+      Handle(fq_codel::HANDLE, 0)));
 
   // There is a kernel bug which could cause this test fail. Please
   // make sure your kernel, if newer than 3.14, has commit:
@@ -463,7 +464,7 @@ TEST_F(RoutingVethTest, ROOT_FqCodelClassifier)
       fq_codel::HANDLE,
       icmp::Classifier(None()),
       None(),
-      queueing::Handle(fq_codel::HANDLE, 0)));
+      Handle(fq_codel::HANDLE, 0)));
 
   EXPECT_SOME_TRUE(icmp::exists(
       TEST_VETH_LINK,
@@ -495,7 +496,7 @@ TEST_F(RoutingVethTest, ROOT_FqCodelClassifier)
       fq_codel::HANDLE,
       classifier,
       None(),
-      queueing::Handle(fq_codel::HANDLE, 1)));
+      Handle(fq_codel::HANDLE, 1)));
 
   EXPECT_SOME_TRUE(ip::exists(TEST_VETH_LINK, fq_codel::HANDLE, classifier));
 }