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/06/03 01:41:20 UTC

[1/3] mesos git commit: Refactored the queueing discipline data structure.

Repository: mesos
Updated Branches:
  refs/heads/master f4a78e4bb -> efa8c91d7


Refactored the queueing discipline data structure.

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


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

Branch: refs/heads/master
Commit: c831758fb5b5db7767065fe1228d4a1736b772dc
Parents: f4a78e4
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Jun 2 14:53:53 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jun 2 16:37:16 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am                           |   1 +
 src/linux/routing/queueing/discipline.hpp |  62 ++++++++++++++
 src/linux/routing/queueing/fq_codel.cpp   |  59 ++++++-------
 src/linux/routing/queueing/fq_codel.hpp   |   5 +-
 src/linux/routing/queueing/ingress.cpp    |  57 ++++++-------
 src/linux/routing/queueing/ingress.hpp    |   7 +-
 src/linux/routing/queueing/internal.hpp   | 109 +++++++++++++++----------
 7 files changed, 183 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 081185b..f045b89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -545,6 +545,7 @@ if WITH_NETWORK_ISOLATOR
 	linux/routing/filter/priority.hpp				\
 	linux/routing/link/internal.hpp					\
 	linux/routing/link/link.hpp					\
+	linux/routing/queueing/discipline.hpp				\
 	linux/routing/queueing/fq_codel.hpp				\
 	linux/routing/queueing/ingress.hpp				\
 	linux/routing/queueing/internal.hpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/src/linux/routing/queueing/discipline.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/discipline.hpp b/src/linux/routing/queueing/discipline.hpp
new file mode 100644
index 0000000..c154eb8
--- /dev/null
+++ b/src/linux/routing/queueing/discipline.hpp
@@ -0,0 +1,62 @@
+/**
+ * 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_DISCIPLINE_HPP__
+#define __LINUX_ROUTING_QUEUEING_DISCIPLINE_HPP__
+
+#include <string>
+
+#include <stout/option.hpp>
+
+#include "linux/routing/handle.hpp"
+
+namespace routing {
+namespace queueing {
+
+template <typename Config>
+class Discipline
+{
+public:
+  Discipline(
+      const std::string& _kind,
+      const Handle& _parent,
+      const Option<Handle>& _handle,
+      const Config& _config)
+    : kind_(_kind),
+      parent_(_parent),
+      handle_(_handle),
+      config_(_config) {}
+
+  const std::string& kind() const { return kind_; }
+  const Handle& parent() const { return parent_; }
+  const Option<Handle>& handle() const { return handle_; }
+  const Config& config() const { return config_; }
+
+private:
+  std::string kind_;
+  Handle parent_;
+  Option<Handle> handle_;
+
+  // TODO(jieyu): Consider making it optional.
+  Config config_;
+};
+
+} // namespace queueing {
+} // namespace routing {
+
+#endif // __LINUX_ROUTING_QUEUEING_DISCIPLINE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/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 4dc2a9d..976c6a7 100644
--- a/src/linux/routing/queueing/fq_codel.cpp
+++ b/src/linux/routing/queueing/fq_codel.cpp
@@ -38,15 +38,10 @@ namespace queueing {
 
 namespace fq_codel {
 
-// TODO(cwang): The fq_codel queueing discipline is not exposed to the
-// user because we use all the default parameters currently.
-struct Discipline
-{
-  bool operator == (const Discipline& that) const
-  {
-    return true;
-  }
-};
+// TODO(cwang): The fq_codel queueing discipline configuration is not
+// exposed to the user because we use all the default parameters
+// currently.
+struct Config {};
 
 } // namespace fq_codel {
 
@@ -56,24 +51,14 @@ struct Discipline
 
 namespace internal {
 
-// Encodes an fq_codel queueing discipline into the libnl queueing
-// discipline 'qdisc'. Each type of queueing discipline needs to
-// implement this function.
+// Encodes an fq_codel queueing discipline configuration into the
+// libnl queueing discipline 'qdisc'. Each type of queueing discipline
+// needs to implement this function.
 template <>
-Try<Nothing> encode<fq_codel::Discipline>(
+Try<Nothing> encode<fq_codel::Config>(
     const Netlink<struct rtnl_qdisc>& qdisc,
-    const fq_codel::Discipline& discipline)
+    const fq_codel::Config& config)
 {
-  int error = rtnl_tc_set_kind(TC_CAST(qdisc.get()), "fq_codel");
-  if (error != 0) {
-    return Error(
-        "Failed to set the kind of the queueing discipline: " +
-        string(nl_geterror(error)));
-  }
-
-  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:
   //   limit 10240p
   //   flows 1024
@@ -86,21 +71,19 @@ Try<Nothing> encode<fq_codel::Discipline>(
 }
 
 
-// Decodes the fq_codel queue discipline from the libnl queueing
-// discipline 'qdisc'. Each type of queueing discipline needs to
-// implement this function. Returns None if the libnl queueing
+// Decodes the fq_codel queue discipline configuration from the libnl
+// queueing discipline 'qdisc'. Each type of queueing discipline needs
+// to implement this function. Returns None if the libnl queueing
 // discipline is not an fq_codel queueing discipline.
 template <>
-Result<fq_codel::Discipline> decode<fq_codel::Discipline>(
+Result<fq_codel::Config> decode<fq_codel::Config>(
     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_handle(TC_CAST(qdisc.get())) != fq_codel::HANDLE.get()) {
+  if (rtnl_tc_get_kind(TC_CAST(qdisc.get())) != fq_codel::KIND) {
     return None();
   }
 
-  return fq_codel::Discipline();
+  return fq_codel::Config();
 }
 
 } // namespace internal {
@@ -116,19 +99,25 @@ const int DEFAULT_FLOWS = 1024;
 
 Try<bool> exists(const string& link)
 {
-  return internal::exists(link, Discipline());
+  return internal::exists(link, EGRESS_ROOT, KIND);
 }
 
 
 Try<bool> create(const string& link)
 {
-  return internal::create(link, Discipline());
+  return internal::create(
+      link,
+      Discipline<Config>(
+          KIND,
+          EGRESS_ROOT,
+          HANDLE,
+          Config()));
 }
 
 
 Try<bool> remove(const string& link)
 {
-  return internal::remove(link, Discipline());
+  return internal::remove(link, EGRESS_ROOT, KIND);
 }
 
 } // namespace fq_codel {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/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 7de1e31..49c8df6 100644
--- a/src/linux/routing/queueing/fq_codel.hpp
+++ b/src/linux/routing/queueing/fq_codel.hpp
@@ -29,12 +29,15 @@ namespace routing {
 namespace queueing {
 namespace fq_codel {
 
+constexpr char KIND[] = "fq_codel";
+
+
 // NOTE: Root queueing discipline handle has to be X:0, so handle's
 // secondary number has to be 0 here. There can be only one root
 // queueing discipline on the egress side of a link and fq_codel is
 // classless and hence there is only one instance of fq_codel per
 // link. This allows us to fix the fq_codel handle.
-constexpr Handle HANDLE(1, 0);
+constexpr Handle HANDLE = Handle(1, 0);
 
 
 // The default number of flows for the fq_codel queueing discipline.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/src/linux/routing/queueing/ingress.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp
index ae0c38d..051300f 100644
--- a/src/linux/routing/queueing/ingress.cpp
+++ b/src/linux/routing/queueing/ingress.cpp
@@ -38,14 +38,9 @@ namespace queueing {
 
 namespace ingress {
 
-// The ingress queueing discipline is not exposed to the user.
-struct Discipline
-{
-  bool operator == (const Discipline& that) const
-  {
-    return true;
-  }
-};
+// The ingress queueing discipline configuration is not currently
+// exposed to the user.
+struct Config {};
 
 } // namespace ingress {
 
@@ -55,43 +50,31 @@ struct Discipline
 
 namespace internal {
 
-// Encodes an ingress queueing discipline into the libnl queueing
-// discipline 'qdisc'. Each type of queueing discipline needs to
-// implement this function.
+// Encodes an ingress queueing discipline configuration into the libnl
+// queueing discipline 'qdisc'. Each type of queueing discipline needs
+// to implement this function.
 template <>
-Try<Nothing> encode<ingress::Discipline>(
+Try<Nothing> encode<ingress::Config>(
     const Netlink<struct rtnl_qdisc>& qdisc,
-    const ingress::Discipline& discipline)
+    const ingress::Config& config)
 {
-  int error = rtnl_tc_set_kind(TC_CAST(qdisc.get()), "ingress");
-  if (error != 0) {
-    return Error(
-        "Failed to set the kind of the queueing discipline: " +
-        string(nl_geterror(error)));
-  }
-
-  rtnl_tc_set_parent(TC_CAST(qdisc.get()), ingress::ROOT.get());
-  rtnl_tc_set_handle(TC_CAST(qdisc.get()), ingress::HANDLE.get());
-
   return Nothing();
 }
 
 
-// Decodes the ingress queue discipline from the libnl queueing
-// discipline 'qdisc'. Each type of queueing discipline needs to
-// implement this function. Returns None if the libnl queueing
+// Decodes the ingress queue discipline configuration from the libnl
+// queueing discipline 'qdisc'. Each type of queueing discipline needs
+// to implement this function. Returns None if the libnl queueing
 // discipline is not an ingress queueing discipline.
 template <>
-Result<ingress::Discipline> decode<ingress::Discipline>(
+Result<ingress::Config> decode<ingress::Config>(
     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_handle(TC_CAST(qdisc.get())) != ingress::HANDLE.get()) {
+  if (rtnl_tc_get_kind(TC_CAST(qdisc.get())) != ingress::KIND) {
     return None();
   }
 
-  return ingress::Discipline();
+  return ingress::Config();
 }
 
 } // namespace internal {
@@ -104,19 +87,25 @@ namespace ingress {
 
 Try<bool> exists(const string& link)
 {
-  return internal::exists(link, Discipline());
+  return internal::exists(link, ROOT, KIND);
 }
 
 
 Try<bool> create(const string& link)
 {
-  return internal::create(link, Discipline());
+  return internal::create(
+      link,
+      Discipline<Config>(
+          KIND,
+          ROOT,
+          HANDLE,
+          Config()));
 }
 
 
 Try<bool> remove(const string& link)
 {
-  return internal::remove(link, Discipline());
+  return internal::remove(link, ROOT, KIND);
 }
 
 } // namespace ingress {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/src/linux/routing/queueing/ingress.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.hpp b/src/linux/routing/queueing/ingress.hpp
index 84506fe..a4582f2 100644
--- a/src/linux/routing/queueing/ingress.hpp
+++ b/src/linux/routing/queueing/ingress.hpp
@@ -29,6 +29,9 @@ namespace routing {
 namespace queueing {
 namespace ingress {
 
+constexpr char KIND[] = "ingress";
+
+
 // 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).
@@ -48,8 +51,8 @@ namespace ingress {
 // for the interface which specify the root handle under which a
 // queueing discipline can be created, and the handle of any created
 // ingress filter.
-constexpr Handle ROOT(Handle(TC_H_INGRESS));
-constexpr Handle HANDLE(Handle(0xffff, 0));
+constexpr Handle ROOT = Handle(TC_H_INGRESS);
+constexpr Handle HANDLE = Handle(0xffff, 0);
 
 
 // Returns true if there exists an ingress qdisc on the link.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c831758f/src/linux/routing/queueing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/internal.hpp b/src/linux/routing/queueing/internal.hpp
index d43a9fd..d0c81ab 100644
--- a/src/linux/routing/queueing/internal.hpp
+++ b/src/linux/routing/queueing/internal.hpp
@@ -43,6 +43,8 @@
 
 #include "linux/routing/link/internal.hpp"
 
+#include "linux/routing/queueing/discipline.hpp"
+
 namespace routing {
 namespace queueing {
 namespace internal {
@@ -52,29 +54,30 @@ namespace internal {
 /////////////////////////////////////////////////
 
 // Forward declaration. Each type of queueing discipline needs to
-// implement this function to encode itself into the libnl queueing
-// discipline (rtnl_qdisc).
-template <typename Discipline>
+// implement this function to encode its type specific configurations
+// into the libnl queueing discipline (rtnl_qdisc).
+template <typename Config>
 Try<Nothing> encode(
     const Netlink<struct rtnl_qdisc>& qdisc,
-    const Discipline& discipline);
+    const Config& config);
 
 
 // Forward declaration. Each type of queueing discipline needs to
-// implement this function to decode itself from the libnl queueing
-// discipline (rtnl_qdisc). Returns None if the libnl queueing
-// discipline does not match the specified queueing discipline type.
-template <typename Discipline>
-Result<Discipline> decode(const Netlink<struct rtnl_qdisc>& qdisc);
+// implement this function to decode its type specific configurations
+// from the libnl queueing discipline (rtnl_qdisc). Returns None if
+// the libnl queueing discipline does not match the specified queueing
+// discipline type.
+template <typename Config>
+Result<Config> decode(const Netlink<struct rtnl_qdisc>& qdisc);
 
 
 // Encodes a queueing discipline (in our representation) to a libnl
 // queueing discipline (rtnl_qdisc). We use template here so that it
 // works for any type of queueing discipline.
-template <typename Discipline>
-Try<Netlink<struct rtnl_qdisc>> encode(
+template <typename Config>
+Try<Netlink<struct rtnl_qdisc>> encodeDiscipline(
     const Netlink<struct rtnl_link>& link,
-    const Discipline& discipline)
+    const Discipline<Config>& discipline)
 {
   struct rtnl_qdisc* q = rtnl_qdisc_alloc();
   if (q == NULL) {
@@ -84,9 +87,21 @@ Try<Netlink<struct rtnl_qdisc>> encode(
   Netlink<struct rtnl_qdisc> qdisc(q);
 
   rtnl_tc_set_link(TC_CAST(qdisc.get()), link.get());
+  rtnl_tc_set_parent(TC_CAST(qdisc.get()), discipline.parent().get());
+
+  if (discipline.handle().isSome()) {
+    rtnl_tc_set_handle(TC_CAST(qdisc.get()), discipline.handle().get().get());
+  }
+
+  int error = rtnl_tc_set_kind(TC_CAST(qdisc.get()), discipline.kind().c_str());
+  if (error != 0) {
+    return Error(
+        "Failed to set the kind of the queueing discipline: " +
+        std::string(nl_geterror(error)));
+  }
 
   // Perform queue discipline specific encoding.
-  Try<Nothing> encoding = encode(qdisc, discipline);
+  Try<Nothing> encoding = encode(qdisc, discipline.config());
   if (encoding.isError()) {
     return Error(
         "Failed to encode the queueing discipline: " +
@@ -132,14 +147,13 @@ inline Try<std::vector<Netlink<struct rtnl_qdisc>>> getQdiscs(
 }
 
 
-// Returns the libnl queueing discipline (rtnl_qdisc) that matches the
-// specified queueing discipline on the link. Return None if no match
-// has been found. We use template here so that it works for any type
-// of queueing discipline.
-template <typename Discipline>
-Result<Netlink<struct rtnl_qdisc>> getQdisc(
+// Returns the libnl queueing discipline (rtnl_qdisc) attached to the
+// given parent that matches the specified queueing discipline kind on
+// the link. Return None if no match has been found.
+inline Result<Netlink<struct rtnl_qdisc>> getQdisc(
     const Netlink<struct rtnl_link>& link,
-    const Discipline& discipline)
+    const Handle& parent,
+    const std::string& kind)
 {
   Try<std::vector<Netlink<struct rtnl_qdisc>>> qdiscs = getQdiscs(link);
   if (qdiscs.isError()) {
@@ -147,13 +161,8 @@ Result<Netlink<struct rtnl_qdisc>> getQdisc(
   }
 
   foreach (const Netlink<struct rtnl_qdisc>& qdisc, qdiscs.get()) {
-    // The decode function will return None if 'qdisc' does not match
-    // the specified queueing discipline. In that case, we just move
-    // on to the next libnl queueing discipline.
-    Result<Discipline> result = decode<Discipline>(qdisc);
-    if (result.isError()) {
-      return Error("Failed to decode: " + result.error());
-    } else if (result.isSome() && result.get() == discipline) {
+    if (rtnl_tc_get_parent(TC_CAST(qdisc.get())) == parent.get() &&
+        rtnl_tc_get_kind(TC_CAST(qdisc.get())) == kind) {
       return qdisc;
     }
   }
@@ -165,11 +174,13 @@ Result<Netlink<struct rtnl_qdisc>> getQdisc(
 // Internal queueing APIs.
 /////////////////////////////////////////////////
 
-// Returns true if the specified queueing discipline exists on the
-// link. We use template here so that it works for any type of
-// queueing discipline.
-template <typename Discipline>
-Try<bool> exists(const std::string& _link, const Discipline& discipline)
+// Returns true if there exists a queueing discipline attached to the
+// given parent that matches the specified queueing discipline kind on
+// the link.
+inline Try<bool> exists(
+    const std::string& _link,
+    const Handle& parent,
+    const std::string& kind)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
   if (link.isError()) {
@@ -178,19 +189,23 @@ Try<bool> exists(const std::string& _link, const Discipline& discipline)
     return false;
   }
 
-  Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), discipline);
+  Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), parent, kind);
   if (qdisc.isError()) {
     return Error(qdisc.error());
   }
+
   return qdisc.isSome();
 }
 
 
-// Creates a new queueing discipline on the link. Returns false if the
-// same queueing discipline already exists on the link. We use
-// template here so that it works for any type of queueing discipline.
-template <typename Discipline>
-Try<bool> create(const std::string& _link, const Discipline& discipline)
+// Creates a new queueing discipline on the link. Returns false if a
+// queueing discipline attached to the same parent with the same
+// configuration already exists on the link. We use template here so
+// that it works for any type of queueing discipline.
+template <typename Config>
+Try<bool> create(
+    const std::string& _link,
+    const Discipline<Config>& discipline)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
   if (link.isError()) {
@@ -199,7 +214,9 @@ Try<bool> create(const std::string& _link, const Discipline& discipline)
     return Error("Link '" + _link + "' is not found");
   }
 
-  Try<Netlink<struct rtnl_qdisc>> qdisc = encode(link.get(), discipline);
+  Try<Netlink<struct rtnl_qdisc>> qdisc =
+    encodeDiscipline(link.get(), discipline);
+
   if (qdisc.isError()) {
     return Error("Failed to encode the queueing discipline: " + qdisc.error());
   }
@@ -229,11 +246,13 @@ Try<bool> create(const std::string& _link, const Discipline& discipline)
 }
 
 
-// Removes the specified queueing discipline on the link. Return false
-// if the queueing discipline is not found. We use template here so
-// that it works for any type of queueing discipline.
-template <typename Discipline>
-Try<bool> remove(const std::string& _link, const Discipline& discipline)
+// Removes the specified discipline attached to the given parent that
+// matches the specified queueing discipline kind on the link. Return
+// false if such a queueing discipline is not found.
+inline Try<bool> remove(
+    const std::string& _link,
+    const Handle& parent,
+    const std::string& kind)
 {
   Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
   if (link.isError()) {
@@ -242,7 +261,7 @@ Try<bool> remove(const std::string& _link, const Discipline& discipline)
     return false;
   }
 
-  Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), discipline);
+  Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), parent, kind);
   if (qdisc.isError()) {
     return Error(qdisc.error());
   } else if (qdisc.isNone()) {


[3/3] mesos git commit: Moved ingress root handle to a proper location.

Posted by ji...@apache.org.
Moved ingress root handle to a proper location.

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


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

Branch: refs/heads/master
Commit: efa8c91d7b8a5d5c52643080e6de860dd4cdd9ba
Parents: c9fb7eb
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Jun 2 15:00:48 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jun 2 16:40:20 2015 -0700

----------------------------------------------------------------------
 src/linux/routing/handle.hpp           |  6 +++---
 src/linux/routing/queueing/ingress.cpp |  6 +++---
 src/linux/routing/queueing/ingress.hpp | 21 +--------------------
 3 files changed, 7 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/efa8c91d/src/linux/routing/handle.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/handle.hpp b/src/linux/routing/handle.hpp
index aed810e..c107a7e 100644
--- a/src/linux/routing/handle.hpp
+++ b/src/linux/routing/handle.hpp
@@ -81,9 +81,9 @@ protected:
 //           |   |
 //    -------+   +------>
 //
-// The parent of the root egress queueing discipline has an immutable
-// handle.
-constexpr Handle EGRESS_ROOT(TC_H_ROOT);
+// The root handles for both ingress and egress are immutable.
+constexpr Handle EGRESS_ROOT = Handle(TC_H_ROOT);
+constexpr Handle INGRESS_ROOT = Handle(TC_H_INGRESS);
 
 } // namespace routing {
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/efa8c91d/src/linux/routing/queueing/ingress.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp
index 051300f..e96f547 100644
--- a/src/linux/routing/queueing/ingress.cpp
+++ b/src/linux/routing/queueing/ingress.cpp
@@ -87,7 +87,7 @@ namespace ingress {
 
 Try<bool> exists(const string& link)
 {
-  return internal::exists(link, ROOT, KIND);
+  return internal::exists(link, INGRESS_ROOT, KIND);
 }
 
 
@@ -97,7 +97,7 @@ Try<bool> create(const string& link)
       link,
       Discipline<Config>(
           KIND,
-          ROOT,
+          INGRESS_ROOT,
           HANDLE,
           Config()));
 }
@@ -105,7 +105,7 @@ Try<bool> create(const string& link)
 
 Try<bool> remove(const string& link)
 {
-  return internal::remove(link, ROOT, KIND);
+  return internal::remove(link, INGRESS_ROOT, KIND);
 }
 
 } // namespace ingress {

http://git-wip-us.apache.org/repos/asf/mesos/blob/efa8c91d/src/linux/routing/queueing/ingress.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.hpp b/src/linux/routing/queueing/ingress.hpp
index a4582f2..2b7e1d3 100644
--- a/src/linux/routing/queueing/ingress.hpp
+++ b/src/linux/routing/queueing/ingress.hpp
@@ -32,26 +32,7 @@ namespace ingress {
 constexpr char KIND[] = "ingress";
 
 
-// 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.
-constexpr Handle ROOT = Handle(TC_H_INGRESS);
+// The handle of the ingress queueing discipline is immutable.
 constexpr Handle HANDLE = Handle(0xffff, 0);
 
 


[2/3] mesos git commit: Fixed a bug in qdisc search function.

Posted by ji...@apache.org.
Fixed a bug in qdisc search function.

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


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

Branch: refs/heads/master
Commit: c9fb7ebf57aeb9f09b9e1daa8b14f97665f1bba5
Parents: c831758
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Jun 2 14:54:34 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jun 2 16:40:12 2015 -0700

----------------------------------------------------------------------
 src/linux/routing/filter/internal.hpp   |  6 +++++-
 src/linux/routing/queueing/internal.hpp | 10 ++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c9fb7ebf/src/linux/routing/filter/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/internal.hpp b/src/linux/routing/filter/internal.hpp
index 10f0bea..8a48102 100644
--- a/src/linux/routing/filter/internal.hpp
+++ b/src/linux/routing/filter/internal.hpp
@@ -517,7 +517,11 @@ inline Try<std::vector<Netlink<struct rtnl_cls>>> getClses(
 
   for (struct nl_object* o = nl_cache_get_first(cache.get());
        o != NULL; o = nl_cache_get_next(o)) {
-    nl_object_get(o); // Increment the reference counter.
+    // NOTE: We increment the reference counter here because 'cache'
+    // will be freed when this function finishes and we want this
+    // object's life to be longer than this function.
+    nl_object_get(o);
+
     results.push_back(Netlink<struct rtnl_cls>((struct rtnl_cls*) o));
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c9fb7ebf/src/linux/routing/queueing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/internal.hpp b/src/linux/routing/queueing/internal.hpp
index d0c81ab..3713f6a 100644
--- a/src/linux/routing/queueing/internal.hpp
+++ b/src/linux/routing/queueing/internal.hpp
@@ -139,8 +139,14 @@ inline Try<std::vector<Netlink<struct rtnl_qdisc>>> getQdiscs(
 
   for (struct nl_object* o = nl_cache_get_first(cache.get());
        o != NULL; o = nl_cache_get_next(o)) {
-    nl_object_get(o); // Increment the reference counter.
-    results.push_back(Netlink<struct rtnl_qdisc>((struct rtnl_qdisc*) o));
+    if (rtnl_tc_get_ifindex(TC_CAST(o)) == rtnl_link_get_ifindex(link.get())) {
+      // NOTE: We increment the reference counter here because 'cache'
+      // will be freed when this function finishes and we want this
+      // object's life to be longer than this function.
+      nl_object_get(o);
+
+      results.push_back(Netlink<struct rtnl_qdisc>((struct rtnl_qdisc*) o));
+    }
   }
 
   return results;