Changeset 1587

Show
Ignore:
Timestamp:
01/14/06 15:00:17 (3 years ago)
Author:
hsantos
Message:

mld: added statistics. one may check statistics via 'show interface <name> mld stats' or the global ones via 'show mld stats'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mrd6/trunk/include/mrd/node.h

    r1586 r1587  
    464464}; 
    465465 
     466class statistics_node : public node { 
     467public: 
     468        typedef uint64_t counter_type; 
     469 
     470        statistics_node(node *parent, int count, const char **descriptions); 
     471        ~statistics_node(); 
     472 
     473        bool check_startup(); 
     474 
     475        /* calls check_startup and adds itself to parent */ 
     476        bool setup(); 
     477 
     478        counter_type &counter(int index) const; 
     479 
     480        bool output_info(base_stream &, const std::vector<std::string> &) const; 
     481 
     482private: 
     483        int m_count; 
     484        counter_type *m_counters; 
     485        const char **m_descriptions; 
     486}; 
     487 
    466488struct propval_integer : propval { 
    467489        propval_integer(const int32_t *); 
  • mrd6/trunk/include/mrdpriv/mld/router.h

    r1586 r1587  
    134134        bool send_mldv2_query(const in6_addr &); 
    135135 
     136        void message_available(const in6_addr &, const in6_addr &, icmp6_hdr *, int); 
    136137        void icmp_message_available(const in6_addr &, const in6_addr &, icmp6_hdr *, int); 
    137138 
    138         void handle_mldv1_membership_report(const in6_addr *, mldv1 *); 
    139         void handle_mldv2_membership_report(const in6_addr *, mldv2_report *, int); 
    140         void handle_mldv1_membership_reduction(const in6_addr *, mldv1 *); 
    141         void handle_membership_query(const in6_addr *); 
     139        void handle_mldv1_membership_report(const in6_addr &, mldv1 *); 
     140        void handle_mldv2_membership_report(const in6_addr &, mldv2_report *, int); 
     141        void handle_mldv1_membership_reduction(const in6_addr &, mldv1 *); 
     142        void handle_membership_query(const in6_addr &); 
    142143 
    143144        void handle_mode_change_for_group(int ver, const inet6_addr &reqsrc, 
     
    161162        intf_timer mif_query_timer_id, mif_other_querier_present_timer_id; 
    162163 
    163         uint64_t mif_stat_icmp_received; 
    164         uint64_t mif_stat_icmp_sent; 
     164        statistics_node m_stats; 
    165165 
    166166        void address_added_or_removed(bool, const inet6_addr &); 
    167  
    168         void added_or_removed_address(bool, const inet6_addr &); 
    169167}; 
    170168 
     
    303301        bool call_method(int, base_stream &, const std::vector<std::string> &); 
    304302 
     303        statistics_node &stats() { return m_stats; } 
     304 
    305305private: 
    306306        virtual mld_group *allocate_group(); 
     307 
     308        statistics_node m_stats; 
    307309}; 
    308310 
  • mrd6/trunk/include/mrdpriv/pim/interface.h

    r1586 r1587  
    170170        void address_added_or_removed(bool, const inet6_addr &); 
    171171 
    172         void added_or_removed_address(bool, const inet6_addr &); 
    173  
    174172        friend class pim_neighbour; 
    175173}; 
  • mrd6/trunk/src/mld/mld_router.cpp

    r1586 r1587  
    5757}; 
    5858 
     59enum { 
     60        SentQueryCount = 0, 
     61        FailedSendQueryCount, 
     62        ReceivedMembershipQueryCount, 
     63        ReceivedMembershipReductionCount, 
     64        ReceivedMembershipReportCount, 
     65        ReceivedMembershipReportV2Count, 
     66        BadMembershipReportV2Count, 
     67        MLDStatsCount 
     68}; 
     69 
     70const char *stats_descriptions[] = { 
     71        "Sent Queries", 
     72        "Failed Sent Queries", 
     73        "Received Queries", 
     74        "Received Membership Reductions", 
     75        "Received Membership Reports", 
     76        "Received Membership Reports (V2)", 
     77        "Bad Membership Reports (V2)", 
     78}; 
     79 
    5980mld_interface::mld_interface() 
    6081        : interface_node(mld), 
     
    6283                std::mem_fun(&mld_interface::handle_send_query_timeout)), 
    6384          mif_other_querier_present_timer_id("other mld querier present", this, 
    64                 std::mem_fun(&mld_interface::handle_other_querier_present_timeout)) { 
     85                std::mem_fun(&mld_interface::handle_other_querier_present_timeout)), 
     86          m_stats(this, MLDStatsCount, stats_descriptions) { 
    6587 
    6688        mif_isquerier = true; 
     
    101123 
    102124bool mld_interface::check_startup() { 
     125        if (!m_stats.setup()) 
     126                return false; 
    103127        return interface_node::check_startup(); 
    104128} 
     
    131155 
    132156void mld_interface::address_added_or_removed(bool added, const inet6_addr &addr) { 
    133         added_or_removed_address(added, addr); 
    134 } 
    135  
    136 void mld_interface::added_or_removed_address(bool added, const inet6_addr &addr) { 
    137157        if (added) { 
    138158                if (addr.is_linklocal()) { 
     
    205225} 
    206226 
     227void mld_interface::message_available(const in6_addr &from, const in6_addr &to, 
     228                                      icmp6_hdr *icmphdr, int len) { 
     229        loginfo(MESSAGE_SIG) << "Received a " 
     230                             << _mld_message_name(icmphdr->icmp6_type) 
     231                             << " from " << from << " to " << to << endl; 
     232 
     233        switch (icmphdr->icmp6_type) { 
     234        case ICMP6_MEMBERSHIP_REPORT: 
     235                handle_mldv1_membership_report(from, (mldv1 *)icmphdr); 
     236                break; 
     237        case ICMP6_MEMBERSHIP_REDUCTION: 
     238                handle_mldv1_membership_reduction(from, (mldv1 *)icmphdr); 
     239                break; 
     240        case ICMP6_MEMBERSHIP_QUERY: 
     241                handle_membership_query(from); 
     242                break; 
     243        case ICMP6_V2_MEMBERSHIP_REPORT: 
     244        case ICMP6_V2_MEMBERSHIP_REPORT_206: 
     245                handle_mldv2_membership_report(from, (mldv2_report *)icmphdr, len); 
     246                break; 
     247        } 
     248} 
     249 
    207250void mld_interface::icmp_message_available(const in6_addr &from, const in6_addr &to, 
    208                                         icmp6_hdr *icmphdr, int len) { 
     251                                           icmp6_hdr *icmphdr, int len) { 
     252        if (!_is_mld_message(icmphdr->icmp6_type)) { 
     253                return; 
     254        } 
     255 
    209256        if (conf()->has_property("proxy_to")) { 
    210257                const char *newintfname = conf()->get_property_string("proxy_to"); 
     
    222269                                        fatal = false; 
    223270                                } else { 
    224                                         newmldintf->icmp_message_available(from, to, icmphdr, len); 
     271                                        newmldintf->message_available(from, to, icmphdr, len); 
    225272                                        return; 
    226273                                } 
     
    236283        } 
    237284 
    238         if (_is_mld_message(icmphdr->icmp6_type)) { 
    239                 loginfo(MESSAGE_SIG) << "Received a " 
    240                                      << _mld_message_name(icmphdr->icmp6_type) 
    241                                      << " from " << from << " to " << to << endl; 
    242         } 
    243  
    244         switch (icmphdr->icmp6_type) { 
    245         case ICMP6_MEMBERSHIP_REPORT: 
    246                 handle_mldv1_membership_report(&from, (mldv1 *)icmphdr); 
    247                 break; 
    248         case ICMP6_MEMBERSHIP_REDUCTION: 
    249                 handle_mldv1_membership_reduction(&from, (mldv1 *)icmphdr); 
    250                 break; 
    251         case ICMP6_MEMBERSHIP_QUERY: 
    252                 handle_membership_query(&from); 
    253                 break; 
    254         case ICMP6_V2_MEMBERSHIP_REPORT: 
    255         case ICMP6_V2_MEMBERSHIP_REPORT_206: 
    256                 handle_mldv2_membership_report(&from, (mldv2_report *)icmphdr, len); 
    257                 break; 
    258         } 
     285        message_available(from, to, icmphdr, len); 
    259286} 
    260287 
     
    267294        } 
    268295 
     296        bool res; 
     297 
    269298        if (mif_mld_version >= 2) { 
    270                 return send_mldv2_query(addr); 
     299                res = send_mldv2_query(addr); 
    271300        } else { 
    272                 return send_mldv1_query(addr); 
    273         } 
     301                res = send_mldv1_query(addr); 
     302        } 
     303 
     304        if (res) { 
     305                m_stats.counter(SentQueryCount)++; 
     306                mld->stats().counter(SentQueryCount)++; 
     307        } else { 
     308                m_stats.counter(FailedSendQueryCount)++; 
     309                mld->stats().counter(FailedSendQueryCount)++; 
     310        } 
     311 
     312        return res; 
    274313} 
    275314 
     
    304343                } 
    305344 
    306                 mif_stat_icmp_sent++; 
    307  
    308                 return mld->send_icmp(owner(), in6addr_linkscope_allnodes, 
    309                                       query, query->length()); 
     345                if (mld->send_icmp(owner(), in6addr_linkscope_allnodes, 
     346                                   query, query->length())) { 
     347                        m_stats.counter(SentQueryCount)++; 
     348                        mld->stats().counter(SentQueryCount)++; 
     349                        return true; 
     350                } else { 
     351                        m_stats.counter(FailedSendQueryCount)++; 
     352                        mld->stats().counter(FailedSendQueryCount)++; 
     353                        return false; 
     354                } 
    310355        } 
    311356 
     
    386431} 
    387432 
    388 void mld_interface::handle_mldv1_membership_report(const in6_addr *src, 
    389                                                 mldv1 *mldhdr) { 
     433void mld_interface::handle_mldv1_membership_report(const in6_addr &src, 
     434                                                   mldv1 *mldhdr) { 
     435        m_stats.counter(ReceivedMembershipReportCount)++; 
     436        mld->stats().counter(ReceivedMembershipReportCount)++; 
     437 
    390438        if (!IN6_IS_ADDR_MULTICAST(&mldhdr->mcaddr) 
    391439                || IN6_IS_ADDR_MC_NODELOCAL(&mldhdr->mcaddr) 
     
    393441                return; 
    394442 
    395         handle_mode_change_for_group(1, *src, mldhdr->mcaddr, 
    396                         MLD_SSM_MODE_EXCLUDE, address_set()); 
    397 
    398  
    399 void mld_interface::handle_mldv2_membership_report(const in6_addr *src, 
    400                                         mldv2_report *mldhdr, int len) { 
     443        handle_mode_change_for_group(1, src, mldhdr->mcaddr, 
     444                                     MLD_SSM_MODE_EXCLUDE, address_set()); 
     445
     446 
     447void mld_interface::handle_mldv2_membership_report(const in6_addr &src, 
     448                                                   mldv2_report *mldhdr, 
     449                                                   int len) { 
     450        m_stats.counter(ReceivedMembershipReportV2Count)++; 
     451        mld->stats().counter(ReceivedMembershipReportV2Count)++; 
     452 
    401453        mldv2_mrec *mrec = mldhdr->mrecs(); 
    402454        int clen = 0; 
     
    414466        if (clen > len) { 
    415467                loginfo(MESSAGE_ERR) << "dropped badly formed MLDv2 Membership" 
    416                        << " report packet from " << *src << " (" << clen 
     468                       << " report packet from " << src << " (" << clen 
    417469                       << " > " << len << ")" << endl; 
     470 
     471                m_stats.counter(BadMembershipReportV2Count)++; 
     472                mld->stats().counter(BadMembershipReportV2Count)++; 
    418473                return; 
    419474        } 
     
    433488                } 
    434489 
    435                 handle_mode_change_for_group(2, *src, mrec->mca, mrec->type, sources); 
    436         } 
    437 
    438  
    439 void mld_interface::handle_mldv1_membership_reduction(const in6_addr *src, 
    440                                                         mldv1 *mldhdr) { 
     490                handle_mode_change_for_group(2, src, mrec->mca, mrec->type, sources); 
     491        } 
     492
     493 
     494void mld_interface::handle_mldv1_membership_reduction(const in6_addr &src, 
     495                                                      mldv1 *mldhdr) { 
     496        m_stats.counter(ReceivedMembershipReductionCount)++; 
     497        mld->stats().counter(ReceivedMembershipReductionCount)++; 
     498 
    441499        if (!IN6_IS_ADDR_MULTICAST(&mldhdr->mcaddr) 
    442500                || IN6_IS_ADDR_MC_NODELOCAL(&mldhdr->mcaddr) 
     
    444502                return; 
    445503 
    446         handle_mode_change_for_group(1, *src, mldhdr->mcaddr, 
    447                         MLD_SSM_CHANGE_TO_INCLUDE, address_set()); 
    448 
    449  
    450 void mld_interface::handle_membership_query(const in6_addr *src) { 
     504        handle_mode_change_for_group(1, src, mldhdr->mcaddr, 
     505                                     MLD_SSM_CHANGE_TO_INCLUDE, address_set()); 
     506
     507 
     508void mld_interface::handle_membership_query(const in6_addr &src) { 
     509        m_stats.counter(ReceivedMembershipQueryCount)++; 
     510        mld->stats().counter(ReceivedMembershipQueryCount)++; 
     511 
    451512        // there should only be a MLD querier in a subnet network 
    452513        // so, if we are currently a querier, let's check if we have priority 
    453514        if (mif_isquerier) { 
    454                 if (*src < *owner()->linklocal()) { 
     515                if (src < *owner()->linklocal()) { 
    455516                        change_is_querier(false); 
    456517 
    457                         mif_querier_addr = *src; 
     518                        mif_querier_addr = src; 
    458519                        loginfo(NORMAL) << "No longer the MLD querier in this interface." 
    459                                 << " Querier is at " << mif_querier_addr << endl; 
     520                                       << " Querier is at " << mif_querier_addr << endl; 
    460521                } 
    461522        } else { 
    462                 if (mif_querier_addr.is_any() || *src < mif_querier_addr) { 
    463                         mif_querier_addr = *src; 
     523                if (mif_querier_addr.is_any() || src < mif_querier_addr) { 
     524                        mif_querier_addr = src; 
    464525                        loginfo(NORMAL) << "Querier is now at " << mif_querier_addr << endl; 
    465526                } 
     
    10821143 
    10831144mld_router::mld_router() 
    1084         : router("mld") { 
     1145        : router("mld"), 
     1146          m_stats(this, MLDStatsCount, stats_descriptions) { 
     1147 
    10851148        in6addr_linkscope_allnodes = inet6_addr("ff02::1").address(); 
    10861149} 
     
    10941157 
    10951158bool mld_router::check_startup() { 
     1159        if (!m_stats.setup()) 
     1160                return false; 
     1161 
    10961162        if (!router::check_startup()) 
    10971163                return false; 
  • mrd6/trunk/src/mrd.cpp

    r1586 r1587  
    16251625                                        accept && i != m_create_group_acl.end(); ++i) { 
    16261626                        accept = i->second->request_group(0, ctx->requester, 
    1627                                                         ctx->groupaddr, owner); 
     1627                                                          ctx->groupaddr, owner); 
    16281628                } 
    16291629 
  • mrd6/trunk/src/node.cpp

    r1586 r1587  
    11271127} 
    11281128 
     1129statistics_node::statistics_node(node *parent, int count, 
     1130                                 const char **descriptions) 
     1131        : node(parent, "stats"), m_count(count), m_descriptions(descriptions) { 
     1132        m_counters = new counter_type[count]; 
     1133} 
     1134 
     1135statistics_node::~statistics_node() { 
     1136        delete [] m_counters; 
     1137        m_counters = 0; 
     1138} 
     1139 
     1140bool statistics_node::check_startup() { 
     1141        if (m_counters) { 
     1142                for (int i = 0; i < m_count; i++) { 
     1143                        m_counters[i] = 0; 
     1144                } 
     1145        } else { 
     1146                return false; 
     1147        } 
     1148 
     1149        return true; 
     1150} 
     1151 
     1152bool statistics_node::setup() { 
     1153        if (!check_startup()) 
     1154                return false; 
     1155        return m_parent->add_child(this) == this; 
     1156} 
     1157 
     1158statistics_node::counter_type &statistics_node::counter(int index) const { 
     1159        return m_counters[index]; 
     1160} 
     1161 
     1162bool statistics_node::output_info(base_stream &out, 
     1163                                  const std::vector<std::string> &args) const { 
     1164        if (!args.empty()) 
     1165                return false; 
     1166 
     1167        for (int i = 0; i < m_count; i++) { 
     1168                out << m_descriptions[i] << ": " << m_counters[i] << endl; 
     1169        } 
     1170 
     1171        return true; 
     1172} 
     1173 
  • mrd6/trunk/src/parser.cpp

    r1586 r1587  
    256256 
    257257static inline bool is_token_char(char c) { 
    258         return isalnum(c) || c == ':' || c == '/' || c == '-' || c == '_'
     258        return isalnum(c) || c == ':' || c == '/' || c == '-' || c == '_' || c == '.'
    259259} 
    260260 
  • mrd6/trunk/src/pim/pim_interface.cpp

    r1586 r1587  
    147147 
    148148void pim_interface::address_added_or_removed(bool added, const inet6_addr &addr) { 
    149         added_or_removed_address(added, addr); 
    150 } 
    151  
    152 void pim_interface::added_or_removed_address(bool added, const inet6_addr &addr) { 
    153149        if (added) { 
    154150                if (addr.is_linklocal()) { 
-->