trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1044101 - in /trafficserver/traffic/trunk: configure.ac lib/tsconfig/TsBuilder.cc lib/tsconfig/TsBuilder.h lib/tsconfig/TsConfigLexer.h proxy/mgmt2/Makefile.am proxy/wccp/WccpEndPoint.cc proxy/wccp/WccpLocal.h proxy/wccp/WccpMsg.cc
Date Thu, 09 Dec 2010 19:26:58 GMT
Author: amc
Date: Thu Dec  9 19:26:57 2010
New Revision: 1044101

URL: http://svn.apache.org/viewvc?rev=1044101&view=rev
Log:
Some final tweaks to resolve TS-402.

TsConfig now has better automake integration. The lexical and grammar files
are built using implicit rules so all of the dependecies are handled correctly.
Additional code changes eliminated the need for a lexical header file and
the circular dependency betwee the lexical and grammar files.

WCCP was updated to support the REMOVAL_QUERY message. It was also updated to
check the assignment information reported by routers and resend the cache
assignment if the router's view is not consistent with the cache view. This
seems to resolve a timing issue with restarting Traffic Server.


Modified:
    trafficserver/traffic/trunk/configure.ac
    trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.cc
    trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.h
    trafficserver/traffic/trunk/lib/tsconfig/TsConfigLexer.h
    trafficserver/traffic/trunk/proxy/mgmt2/Makefile.am
    trafficserver/traffic/trunk/proxy/wccp/WccpEndPoint.cc
    trafficserver/traffic/trunk/proxy/wccp/WccpLocal.h
    trafficserver/traffic/trunk/proxy/wccp/WccpMsg.cc

Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Thu Dec  9 19:26:57 2010
@@ -336,15 +336,11 @@ AC_ARG_ENABLE([wccp],
   [AS_HELP_STRING([--enable-wccp],[enable WCCP v2])],
   [
     has_wccp=1
-    AC_SUBST([LIBWCCP], ["\$(top_builddir)/proxy/wccp/libwccp.a"])
-    AC_SUBST([LIBTSCONFIG], ["\$(top_builddir)/lib/tsconfig/libtsconfig.a"])
   ],
   [enable_wccp=no]
 )
 AC_MSG_RESULT([$enable_wccp])
 AC_SUBST(has_wccp)
-AC_SUBST(LIBWCCP)
-AC_SUBST(LIBTSCONFIG)
 AM_CONDITIONAL([BUILD_WCCP], [test "x$enable_wccp" = "xyes"])
 
 # Google profiler

Modified: trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.cc?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.cc (original)
+++ trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.cc Thu Dec  9 19:26:57 2010
@@ -49,35 +49,36 @@ namespace ts { namespace config {
 
 Builder&
 Builder::init() {
-    // Simple: Resize the vector and then fill in each element to
-    // dispatch through the static method. Callback data is a pointer
-    // to an entry in @c dispatch which contains pointer to this object
-    // and a pointer to the appropriate dispatch method.
-
-    _dispatch.resize(TS_CONFIG_N_EVENT_TYPES);
-
-    for ( size_t i = 0 ; i < TS_CONFIG_N_EVENT_TYPES ; ++i) {
-        _dispatch[i]._ptr = this;
-        _handlers.handler[i]._f = &self::dispatch;
-        _handlers.handler[i]._data = &(_dispatch[i]);
-    }
-
-    _dispatch[TsConfigEventGroupOpen]._method = &self::groupOpen;
-    _dispatch[TsConfigEventGroupName]._method = &self::groupName;
-    _dispatch[TsConfigEventGroupClose]._method = &self::groupClose;
-    _dispatch[TsConfigEventListOpen]._method = &self::listOpen;
-    _dispatch[TsConfigEventListClose]._method = &self::listClose;
-    _dispatch[TsConfigEventPathOpen]._method = &self::pathOpen;
-    _dispatch[TsConfigEventPathTag]._method = &self::pathTag;
-    _dispatch[TsConfigEventPathIndex]._method = &self::pathIndex;
-    _dispatch[TsConfigEventPathClose]._method = &self::pathClose;
-    _dispatch[TsConfigEventLiteralValue]._method = &self::literalValue;
-    _dispatch[TsConfigEventInvalidToken]._method = &self::invalidToken;
+  // Fill in each element to dispatch through the static
+  // method. Callback data is a pointer to an entry in @c dispatch
+  // which contains pointer to this object and a pointer to the
+  // appropriate dispatch method.
+
+  // Zero everything first, just to be safe.
+  memset(_dispatch, 0, sizeof(_dispatch));
+
+  for ( size_t i = 0 ; i < TS_CONFIG_N_EVENT_TYPES ; ++i) {
+    _dispatch[i]._ptr = this;
+    _handlers.handler[i]._f = &self::dispatch;
+    _handlers.handler[i]._data = &(_dispatch[i]);
+  }
+
+  _dispatch[TsConfigEventGroupOpen]._method = &self::groupOpen;
+  _dispatch[TsConfigEventGroupName]._method = &self::groupName;
+  _dispatch[TsConfigEventGroupClose]._method = &self::groupClose;
+  _dispatch[TsConfigEventListOpen]._method = &self::listOpen;
+  _dispatch[TsConfigEventListClose]._method = &self::listClose;
+  _dispatch[TsConfigEventPathOpen]._method = &self::pathOpen;
+  _dispatch[TsConfigEventPathTag]._method = &self::pathTag;
+  _dispatch[TsConfigEventPathIndex]._method = &self::pathIndex;
+  _dispatch[TsConfigEventPathClose]._method = &self::pathClose;
+  _dispatch[TsConfigEventLiteralValue]._method = &self::literalValue;
+  _dispatch[TsConfigEventInvalidToken]._method = &self::invalidToken;
 
-    _handlers.error._data = this;
-    _handlers.error._f = &self::syntaxErrorDispatch;
+  _handlers.error._data = this;
+  _handlers.error._f = &self::syntaxErrorDispatch;
 
-    return *this;
+  return *this;
 }
 
 // Error messages here have to just be logged, as they effectively report that
@@ -116,27 +117,10 @@ Builder::syntaxError(char const* text) {
 
 Rv<Configuration>
 Builder::build(Buffer const& buffer) {
-# if 1
   _v = _config.getRoot(); // seed current value.
   _errata.clear(); // no errors yet.
   tsconfig_parse_buffer(&_handlers, buffer._ptr, buffer._size);
   return MakeRv(_config, _errata);
-# else
-    yyscan_t lexer;
-    YY_BUFFER_STATE lexer_buffer_state;
-
-    _v = _config.getRoot();
-    _errata.clear();
-
-    tsconfiglex_init(&lexer);
-    tsconfigset_extra(&_handlers, lexer);
-    lexer_buffer_state = tsconfig_scan_buffer(buffer._ptr, buffer._size, lexer);
-    tsconfigparse(lexer, &_handlers);
-    tsconfig_delete_buffer(lexer_buffer_state, lexer);
-    tsconfiglex_destroy(lexer);
-
-    return MakeRv(_config, _errata);
-# endif
 }
 
 void

Modified: trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.h?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.h (original)
+++ trafficserver/traffic/trunk/lib/tsconfig/TsBuilder.h Thu Dec  9 19:26:57 2010
@@ -51,7 +51,7 @@ public:
     );
 protected:
     /// Dispatch table for parse events.
-    std::vector<Handler> _dispatch;
+    Handler _dispatch[TS_CONFIG_N_EVENT_TYPES];
     /// Event handler table for the parser.
     TsConfigHandlers _handlers;
     /// Dispatch methods

Modified: trafficserver/traffic/trunk/lib/tsconfig/TsConfigLexer.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/tsconfig/TsConfigLexer.h?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/tsconfig/TsConfigLexer.h (original)
+++ trafficserver/traffic/trunk/lib/tsconfig/TsConfigLexer.h Thu Dec  9 19:26:57 2010
@@ -7,8 +7,6 @@ struct TsConfigHandlers; // forward decl
     extern "C" {
 # endif
 
-// extern int tsconfigparse(yyscan_t lexer, struct TsConfigHandlers* handlers);
-
 /// Get the current line in the buffer during parsing.
 /// @return 1 based line number.
 extern int tsconfiglex_current_line(void);

Modified: trafficserver/traffic/trunk/proxy/mgmt2/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/Makefile.am?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/Makefile.am Thu Dec  9 19:26:57 2010
@@ -120,4 +120,11 @@ traffic_manager_LDADD = \
   @LIBEXPAT@ @LIBPCRE@ \
   @LIBSSL@ @LIBDB@ @LIBSQLITE3@ @LIBTCL@ @LIBICONV@ \
   @LIBM@ @LIBDL@ @LIBSOCKET@ @LIBNSL@ @LIBRESOLV@ \
-  @LIBTHREAD@ @LIBRT@ @LIBEXECINFO@ @LIBCAP@ @LIBWCCP@ @LIBTSCONFIG@
+  @LIBTHREAD@ @LIBRT@ @LIBEXECINFO@ @LIBCAP@
+
+# Must do it this way or the dependencies aren't detected.
+if BUILD_WCCP
+traffic_manager_LDADD += \
+  $(top_builddir)/proxy/wccp/libwccp.a \
+  $(top_builddir)/lib/tsconfig/libtsconfig.a
+endif

Modified: trafficserver/traffic/trunk/proxy/wccp/WccpEndPoint.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/wccp/WccpEndPoint.cc?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/wccp/WccpEndPoint.cc (original)
+++ trafficserver/traffic/trunk/proxy/wccp/WccpEndPoint.cc Thu Dec  9 19:26:57 2010
@@ -275,6 +275,15 @@ CacheImpl::GroupData::findCache(uint32 a
   );
 }
 
+CacheImpl::RouterBag::iterator
+CacheImpl::GroupData::findRouter(uint32 addr) {
+  return std::find_if(
+    m_routers.begin(),
+    m_routers.end(),
+    ts::predicate(&RouterData::m_addr, addr)
+  );
+}
+
 void
 CacheImpl::GroupData::resizeCacheSources() {
   int count = m_routers.size();
@@ -556,6 +565,27 @@ CacheImpl::generateRedirectAssign(
   msg.finalize();
 }
 
+bool
+CacheImpl::checkRouterAssignment(
+  GroupData const& group,
+  RouterViewComp const& comp
+) const {
+  // If group doesn't have an active assignment, always match w/o checking.
+  bool zret = ! group.m_assign_info.isActive();
+  if (! zret && ! comp.isEmpty()) { // invalid component doesn't match.
+    uint32 nc = comp.getCacheCount();
+    // Nothing for it but simple brute force - iterate over every bucket
+    // in the assignment and verify the corresponding bucket in the
+    // cache bit array is set.
+    zret = true;
+    for ( size_t b = 0 ; zret && b < N_BUCKETS ; ++b ) {
+      unsigned int c = group.m_assign_info[b].m_idx;
+      if (c >= nc || ! comp.cacheElt(c).getBucket(b)) zret = false;
+    }
+  }
+  return zret;
+}
+
 int
 CacheImpl::housekeeping() {
   int zret = 0;
@@ -586,8 +616,12 @@ CacheImpl::housekeeping() {
       && group.m_generation_time + ASSIGN_WAIT <= now
     ) {
       // Is a valid assignment possible?
-      if (group.m_assign_info.fill(group, m_addr))
-        ts::for_each(group.m_routers, ts::assign_member(&RouterData::m_assign, true));
+      if (group.m_assign_info.fill(group, m_addr)) {
+        group.m_assign_info.setActive(true);
+        ts::for_each(group.m_routers,
+          ts::assign_member(&RouterData::m_assign, true)
+        );
+      }
 
       // Always clear because no point in sending an assign we can't generate.
       group.m_assignment_pending = false;
@@ -756,6 +790,17 @@ CacheImpl::handleISeeYou(IpHeader const&
     ar_spot = group.m_routers.end() - 1;
     view_changed = true;
     logf(LVL_INFO, "Added source router %s to view %d", ip_addr_to_str(router_addr), group.m_svc.getSvcId());
+  } else {
+    // Existing router. If we have a valid assignment, check it and
+    // send again if this router hasn't updated.
+    if (!this->checkRouterAssignment(group, msg.m_router_view)) {
+      ar_spot->m_assign = true; // schedule an assignment message.
+      logf(LVL_INFO, "Router assignment reported from "
+        ATS_IP_PRINTF_CODE
+        " did not match local assignment. Resending assignment.\n ",
+        ATS_IP_OCTETS(router_addr)
+      );
+    }
   }
   ar_spot->m_recv.set(now, recv_id);
   ar_spot->m_generation = msg.m_router_view.getChangeNumber();
@@ -794,6 +839,61 @@ CacheImpl::handleISeeYou(IpHeader const&
   return zret;
 }
 
+ts::Errata
+CacheImpl::handleRemovalQuery(IpHeader const& ip_hdr, ts::Buffer const& chunk) {
+  ts::Errata zret;
+  RemovalQueryMsg msg;
+  time_t now = time(0);
+  int parse = msg.parse(chunk);
+
+  if (PARSE_SUCCESS != parse)
+    return log(LVL_INFO, "Ignored malformed WCCP2_REMOVAL_QUERY message.");
+
+  ServiceGroup svc(msg.m_service);
+  GroupMap::iterator spot = m_groups.find(svc.getSvcId());
+  if (spot == m_groups.end())
+    return logf(LVL_INFO, "WCCP2_REMOVAL_QUERY ignored - service group %d not found.", svc.getSvcId());
+
+  GroupData& group = spot->second;
+
+  if (!this->validateSecurity(msg, group))
+    return log(LVL_INFO, "Ignored WCCP2_REMOVAL_QUERY with invalid security.\n");
+
+  if (svc != group.m_svc)
+    return logf(LVL_INFO, "WCCP2_REMOVAL_QUERY ignored - service group definition %d does
not match.\n", svc.getSvcId());
+
+  uint32 target_addr = msg.m_query.getCacheAddr(); // intended cache
+  if (m_addr == target_addr) {
+    uint32 raddr = msg.m_query.getRouterAddr();
+    RouterBag::iterator router = group.findRouter(raddr);
+    if (group.m_routers.end() != router) {
+      router->m_rapid = true; // do rapid responses.
+      router->m_recv.set(now, msg.m_query.getRecvId());
+      logf(LVL_DEBUG, "WCCP2_REMOVAL_QUERY from router "
+        ATS_IP_PRINTF_CODE ".\n",
+        ATS_IP_OCTETS(raddr)
+      );
+    } else {
+      logf(LVL_INFO, "WCCP2_REMOVAL_QUERY from unknown router "
+        ATS_IP_PRINTF_CODE ".\n",
+        ATS_IP_OCTETS(raddr)
+      );
+    }
+  } else {
+    // Not an error in the multi-cast case, so just log under debug.
+    logf(LVL_DEBUG, "WCCP2_REMOVAL_QUERY ignored -- target cache address "
+      ATS_IP_PRINTF_CODE
+      " did not match local address "
+      ATS_IP_PRINTF_CODE
+      "\n.",
+      ATS_IP_OCTETS(target_addr), ATS_IP_OCTETS(m_addr)
+    );
+  }
+
+  logf(LVL_DEBUG, "Received WCCP2_REMOVAL_QUERY for group %d.", group.m_svc.getSvcId());
+
+  return zret;
+}
 // ------------------------------------------------------
 inline uint32
 RouterImpl::CacheData::idAddr() const {

Modified: trafficserver/traffic/trunk/proxy/wccp/WccpLocal.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/wccp/WccpLocal.h?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/wccp/WccpLocal.h (original)
+++ trafficserver/traffic/trunk/proxy/wccp/WccpLocal.h Thu Dec  9 19:26:57 2010
@@ -479,8 +479,8 @@ protected:
     component in the WCCP message. The component instance points at
     its corresponding data in the message. Values in the message are
     accessed through accessor methods which have the form @c
-    getf_NAME and @c setf_NAME for "get field" and "set field". The
-    @c setf_ methods return a reference to the component so that
+    getNAME and @c setNAME for "get field" and "set field". The
+    @c set methods return a reference to the component so that
     they can be chained.
 
     Most components will have an internal typedef @c raw_t which is a
@@ -960,7 +960,7 @@ public:
   /// Directly access assignment key.
   AssignmentKeyElt const& key_elt() const;
   /// Get address in assignment key.
-  uint32 getf_key_addr() const;
+  uint32 getKeyAddr() const;
   /// Set address in assignment key.
   self& setKeyAddr(uint32 addr);
   /// Get change number in assignment key.
@@ -979,6 +979,10 @@ public:
   CacheIdElt& cacheElt(
     int idx ///< Index of target element.
   );
+  /// Access cache element.
+  CacheIdElt const& cacheElt(
+    int idx ///< Index of target element.
+  ) const;
   /// Get router count field.
   /// @note No @c setf method because this cannot be changed independently.
   /// @see fill
@@ -1144,7 +1148,7 @@ public:
   /// Directly access assignment key.
   AssignmentKeyElt const& keyElt() const;
   /// Get address in assignment key.
-  uint32 getf_key_addr() const;
+  uint32 getKeyAddr() const;
   /// Set address in assignment key.
   self& setKeyAddr(uint32 addr);
   /// Get change number in assignment key.
@@ -1181,6 +1185,12 @@ public:
   Bucket const& bucket(
     int idx ///< Index of target bucket.
   ) const;
+  /** Compare a set of buckets.
+      @return @c true if the buckets are the same, @c false otherwise.
+  */
+  bool compare(
+    Bucket const buckets[N_BUCKETS] ///< Buckets to compare.
+  ) const;
   //@}
 
   /** Write serialization data.
@@ -1409,6 +1419,55 @@ public:
   );
 };
 
+/// Sect 5.6.8: Router Query Info Component.
+class QueryComp
+  : public CompWithHeader<QueryComp> {
+public:
+  typedef QueryComp self; ///< Self reference type.
+  typedef CompWithHeader<self> super; ///< Parent type.
+
+  /// Component type ID for this component.
+  static CompType const COMP_TYPE = QUERY_INFO;
+
+  /// Internal layout.
+  struct raw_t : public super::raw_t {
+    uint32 m_router_addr; ///< Identifying router address.
+    uint32 m_recv_id; ///< Receive ID router expects in reply.
+    uint32 m_to_addr; ///< Destination address of query.
+    uint32 m_cache_addr; ///< Identifying address of cache.
+  };
+
+  /// @name Accessors.
+  //@{
+  /// Directly access mask value element.
+  uint32 getRouterAddr() const; ///< Get identifying router address.
+  self& setRouterAddr(uint32 addr); ///< Set identifying router address.
+  uint32 getToAddr() const; ///< Get target address.
+  self& setToAddr(uint32 addr); ///< Set target address.
+  uint32 getCacheAddr() const; ///< Get identifying cache address.
+  self& setCacheAddr(uint32 addr); ///< Set identifying cache address.
+  uint32 getRecvId() const; ///< Get receive ID.
+  self& setRecvId(uint32 data); ///< Set receive ID.
+  //@}
+
+  /// Write serialization data.
+  /// This fills in all fields.
+  self& fill(
+    MsgBuffer& buffer, ///< Component storage.
+    uint32 routerAddr, ///< Router identifying address.
+    uint32 toAddr, ///< Destination address.
+    uint32 cacheAddr, ///< Cache identifying address.
+    uint32 recvId ///< Recieve ID.
+  );
+
+  /// Validate an existing structure.
+  /// @return Parse result.
+  int parse(MsgBuffer& buffer);
+
+  /// Compute the total size of the component.
+  static size_t calcSize();
+};
+
 /// Cache assignment hash function.
 inline uint8
 assignment_hash(
@@ -1479,6 +1538,20 @@ namespace detail {
       AssignInfoComp& comp ///< Component to fill.
     ) const;
 
+    /** Test this assignment against a component.
+        @return @c true if the assignments are the same, @c false otherwise.
+    */
+    bool compare(AssignInfoComp const& comp) const;
+
+    /// Access a bucket.
+    Bucket& operator [] (
+      size_t idx ///< Bucket index (0..N_BUCKETS-1)
+    );
+    /// Access a bucket.
+    Bucket const& operator [] (
+      size_t idx ///< Bucket index (0..N_BUCKETS-1)
+    ) const;
+
   protected:
     Key m_key; ///< Assignment key.
     bool m_active; ///< Active state.
@@ -1629,13 +1702,17 @@ public:
 
   RouterIdComp m_router_id; ///< Router ID.
   RouterViewComp m_router_view; ///< Router view data.
+  // The rest of these are optional. The spec says we should get
+  // an assignment or map, but in practice that doesn't happen with
+  // actual Cisco routers in the hash case. Perhaps it happens with
+  // a map.
   AssignInfoComp m_assignment; ///< Assignment data.
   AssignMapComp m_map; ///< Assignment map.
   CapComp m_capabilities; ///< Capabilities data.
   CmdComp m_command; ///< Command extension.
 };
 
-/// Sect 5.1: Layout and control for @c WCCP2_HERE_I_AM
+/// Sect 5.1: Layout and control for @c WCCP2_REDIRECT_ASSIGN
 class RedirectAssignMsg
   : public BaseMsg {
 public:
@@ -1666,6 +1743,35 @@ public:
   AssignMapComp m_alt_assign; ///< Alternate assignment data.
 };
 
+/// Sect 5.4: @c WCCP_REMOVAL_QUERY
+class RemovalQueryMsg
+  : public BaseMsg {
+public:
+  typedef RemovalQueryMsg self; ///< Self reference type.
+
+  /** Fill in the basic message structure.
+      This expects @c setBuffer to have already been called
+      with an appropriate buffer.
+      The actual router and cache data must be filled in
+      after this call, which will allocate the appropriate spaces
+      in the message layou.
+  */
+  void fill(
+    detail::cache::GroupData const& group, ///< Service group for message.
+    SecurityOption sec_opt, ///< Security option to use.
+    AssignmentKeyElt const& key, ///< Assignment key.
+    int n_routers, ///< Number of routers expected.
+    int n_caches ///< Number of caches expected.
+  );
+
+  /// Parse message data, presumed to be of this type.
+  int parse(
+    ts::Buffer const& buffer ///< Raw message data.
+  );
+
+  QueryComp m_query; ///< Router Removal Query component.
+};
+
 // ------------------------------------------------------
 /// Last packet information.
 struct PacketStamp {
@@ -1896,7 +2002,7 @@ namespace detail {
 
       /// Find a router by IP @a addr.
       /// @return A pointer to the router, or @c NULL if not found.
-      CacheData* findRouter(
+      RouterBag::iterator findRouter(
         uint32 addr ///< IP address of cache.
       );
 
@@ -2004,6 +2110,14 @@ public:
   /// Perform all scheduled housekeeping functions.
   /// @return 0 for success, -errno on error.
   virtual int housekeeping();
+
+  /** Check cache assignment reported by a router against internal assign.
+      @return @c true if they are the same, @c false otherwise.
+  */
+  virtual bool checkRouterAssignment(
+    GroupData const& group, ///< Group with assignment.
+    RouterViewComp const& comp ///< Assignment reported by router.
+  ) const;
 protected:
   /// Generate contents in HERE_I_AM @a msg for seed router.
   void generateHereIAm(
@@ -2027,6 +2141,11 @@ protected:
     IpHeader const& header, ///< IP packet data.
     ts::Buffer const& data ///< Buffer with message data.
   );
+  /// Process REMOVAL_QUERY message.
+  virtual ts::Errata handleRemovalQuery(
+    IpHeader const& header, ///< IP packet data.
+    ts::Buffer const& data ///< Message data.
+  );
 
   /// Map Service Group ID to Service Group Data.
   typedef std::map<uint8, GroupData> GroupMap;
@@ -2361,7 +2480,7 @@ RouterIdComp::calcSize(int n) {
 }
 
 inline uint32
-RouterViewComp::getf_key_addr() const {
+RouterViewComp::getKeyAddr() const {
   return this->key_elt().getAddr();
 }
 inline RouterViewComp&
@@ -2378,6 +2497,10 @@ RouterViewComp::setKeyChangeNumber(uint3
   this->key_elt().setChangeNumber(change_number);
   return *this;
 }
+inline CacheIdElt const&
+RouterViewComp::cacheElt(int idx) const {
+  return const_cast<self*>(this)->cacheElt(idx);
+}
 
 inline CacheIdElt&
 CacheIdComp::idElt() {
@@ -2454,6 +2577,15 @@ detail::Assignment::setActive(bool state
   m_active = state;
   return *this;
 }
+inline bool detail::Assignment::compare(AssignInfoComp const& comp) const {
+  return comp.compare(m_buckets);
+}
+inline detail::Assignment::Bucket& detail::Assignment::operator[] (size_t idx) {
+  return m_buckets[idx];
+}
+inline detail::Assignment::Bucket const& detail::Assignment::operator[] (size_t idx)
const {
+  return m_buckets[idx];
+}
 
 inline MsgBuffer::MsgBuffer() : super(0,0), _count(0) { }
 inline MsgBuffer::MsgBuffer(super const& that) : super(that), _count(0) { }
@@ -2564,6 +2696,9 @@ CompWithHeader<T>::checkHeader(MsgBuffer
 
 inline AssignInfoComp::Bucket& AssignInfoComp::bucket(int idx) { return m_buckets[idx];
}
 inline AssignInfoComp::Bucket const& AssignInfoComp::bucket(int idx) const{ return m_buckets[idx];
}
+inline bool AssignInfoComp::compare(Bucket const buckets[N_BUCKETS]) const {
+  return 0 == memcmp(buckets, m_buckets, sizeof(buckets));
+}
 
 inline CapComp::CapComp() : m_count(0), m_cached(false) { }
 inline CapComp& CapComp::invalidate() { m_cached = false; return *this; }
@@ -2585,6 +2720,36 @@ CapComp::getCacheAssignmentStyle() const
   return m_cache_assign;
 }
 
+inline uint32 QueryComp::getRouterAddr() const {
+  return access_field(&raw_t::m_router_addr, m_base);
+}
+inline QueryComp& QueryComp::setRouterAddr(uint32 addr) {
+  access_field(&raw_t::m_router_addr, m_base) = addr;
+  return *this;
+}
+inline uint32 QueryComp::getToAddr() const {
+  return access_field(&raw_t::m_to_addr, m_base);
+}
+inline QueryComp& QueryComp::setToAddr(uint32 addr) {
+  access_field(&raw_t::m_to_addr, m_base) = addr;
+  return *this;
+}
+inline uint32 QueryComp::getCacheAddr() const {
+  return access_field(&raw_t::m_cache_addr, m_base);
+}
+inline QueryComp& QueryComp::setCacheAddr(uint32 addr) {
+  access_field(&raw_t::m_cache_addr, m_base) = addr;
+  return *this;
+}
+inline uint32 QueryComp::getRecvId() const {
+  return get_field(&raw_t::m_recv_id, m_base);
+}
+inline QueryComp& QueryComp::setRecvId(uint32 data) {
+  set_field(&raw_t::m_recv_id, m_base, data);
+  return *this;
+}
+inline size_t QueryComp::calcSize() { return sizeof(raw_t); }
+
 inline detail::cache::SeedRouter::SeedRouter() { }
 
 inline detail::cache::SeedRouter::SeedRouter(uint32 addr)

Modified: trafficserver/traffic/trunk/proxy/wccp/WccpMsg.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/wccp/WccpMsg.cc?rev=1044101&r1=1044100&r2=1044101&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/wccp/WccpMsg.cc (original)
+++ trafficserver/traffic/trunk/proxy/wccp/WccpMsg.cc Thu Dec  9 19:26:57 2010
@@ -942,7 +942,7 @@ AssignInfoComp::setKeyChangeNumber(uint3
 }
   
 uint32
-AssignInfoComp::getf_key_addr() const {
+AssignInfoComp::getKeyAddr() const {
   return access_field(&raw_t::m_key, m_base).getAddr();
 }
 
@@ -1215,6 +1215,20 @@ CapComp::parse(MsgBuffer& buffer) {
   return zret;
 }
 // ------------------------------------------------------
+int
+QueryComp::parse(MsgBuffer& buffer) {
+  int zret = PARSE_SUCCESS;
+  if (buffer.getSpace()< sizeof(raw_t)) 
+    zret = PARSE_BUFFER_TOO_SMALL;
+  else {
+    m_base = buffer.getTail();
+    zret = this->checkHeader(buffer, COMP_TYPE);
+    if (PARSE_SUCCESS == zret)
+      buffer.use(this->calcSize());
+  }
+  return zret;
+}
+// ------------------------------------------------------
 MaskValueSetElt&
 AssignMapComp::elt(int idx) {
   return access_array<MaskValueSetElt>(m_base + sizeof(raw_t))[idx];
@@ -1332,8 +1346,6 @@ detail::Assignment::fill(cache::GroupDat
 
   this->m_dirty = true;
 
-  logf(LVL_DEBUG, "Generating assignment for group %d.", group.m_svc.getSvcId());
-
   // We need both routers and caches to do something useful.
   if (! (n_routers && n_caches)) return false;
 
@@ -1542,4 +1554,26 @@ ISeeYouMsg::parse(ts::Buffer const& buff
   return m_buffer.getSpace() ? PARSE_DATA_OVERRUN : PARSE_SUCCESS;
 }
 // ------------------------------------------------------
+int
+RemovalQueryMsg::parse(ts::Buffer const& buffer) {
+  int zret;
+  this->setBuffer(buffer);
+  if (!m_buffer.getBase()) return -EINVAL;
+  zret = m_header.parse(m_buffer);
+  if (PARSE_SUCCESS != zret) return zret;
+  if (REMOVAL_QUERY != m_header.getType()) return PARSE_MSG_WRONG_TYPE;
+
+  // Get the components.
+  zret = m_security.parse(m_buffer);
+  if (PARSE_SUCCESS != zret) return zret;
+
+  zret = m_service.parse(m_buffer);
+  if (PARSE_SUCCESS != zret) return zret;
+
+  zret = m_query.parse(m_buffer);
+  if (PARSE_SUCCESS != zret) return zret;
+
+  return m_buffer.getSpace() ? PARSE_DATA_OVERRUN : PARSE_SUCCESS;
+}
+// ------------------------------------------------------
 } // namespace wccp



Mime
View raw message