From: Maxim Mamontov Date: Wed, 23 Nov 2011 19:19:40 +0000 (+0200) Subject: Add max_acl_per_pdu param X-Git-Url: https://git.stg.codes/ssmd.git/commitdiff_plain/bdbd190aca2ca879b723d0557eca771529363e2f Add max_acl_per_pdu param --- diff --git a/include/settings.h b/include/settings.h index e061b96..e384a42 100644 --- a/include/settings.h +++ b/include/settings.h @@ -36,6 +36,8 @@ class Settings { unsigned upProfileId() const throw() { return _upProfileId; } unsigned downProfileId() const throw() { return _downProfileId; } + size_t maxACLPerPDU() const throw() { return _maxACLPerPDU; } + const std::string & dataURL() const throw() { return _dataURL; } // Setters @@ -54,6 +56,8 @@ class Settings { void setUpProfileId(unsigned value) throw() { _upProfileId = value; } void setDownProfileId(unsigned value) throw() { _downProfileId = value; } + void setMaxACLPerPDU(size_t value) throw() { _maxACLPerPDU = value; } + void setDataURL(const std::string & value) throw() { _dataURL = value; } private: @@ -72,6 +76,8 @@ class Settings { unsigned _upProfileId; unsigned _downProfileId; + size_t _maxACLPerPDU; + std::string _dataURL; friend class SettingsParser; diff --git a/include/settings.inl.h b/include/settings.inl.h index e67aab7..1c771ce 100644 --- a/include/settings.inl.h +++ b/include/settings.inl.h @@ -18,7 +18,9 @@ Settings::Settings() _switchSyncInterval(180), _infoSyncInterval(60), _upProfileId(1), - _downProfileId(2) + _downProfileId(2), + _maxACLPerPDU(50), + _dataURL() { } @@ -35,6 +37,7 @@ Settings::Settings(const Settings & rvalue) _infoSyncInterval(rvalue._infoSyncInterval), _upProfileId(rvalue._upProfileId), _downProfileId(rvalue._downProfileId), + _maxACLPerPDU(rvalue._maxACLPerPDU), _dataURL(rvalue._dataURL) { } @@ -58,6 +61,7 @@ const Settings & Settings::operator=(const Settings & rvalue) _infoSyncInterval = rvalue._infoSyncInterval; _upProfileId = rvalue._upProfileId; _downProfileId = rvalue._downProfileId; + _maxACLPerPDU = rvalue._maxACLPerPDU; _dataURL = rvalue._dataURL; return *this; } diff --git a/src/settings.cpp b/src/settings.cpp index 5d04ad2..330a574 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -19,6 +19,7 @@ SettingsParser::SettingsParser() ("info-sync-interval,i", po::value(), "info synchronization interval") ("up-profile-id", po::value(), "switch's upload profile id") ("down-profile-id", po::value(), "switch's download profile id") + ("max-acl-per-pdu", po::value(), "maximum ACL's per PDU") ("data-url", po::value(), "data access URL") ("version,v", "show gssmd version and exit") ; @@ -78,6 +79,10 @@ void SettingsParser::init(int argc, char * argv[]) _settings._downProfileId = vm["down-profile-id"].as(); } + if (vm.count("max-acl-per-pdu")) { + _settings._downProfileId = vm["max-acl-per-pdu"].as(); + } + if (vm.count("data-url")) { _settings._dataURL = vm["data-url"].as(); } diff --git a/src/settingsfileparser.cpp b/src/settingsfileparser.cpp index 64f0d0b..10514ce 100644 --- a/src/settingsfileparser.cpp +++ b/src/settingsfileparser.cpp @@ -119,6 +119,9 @@ void SettingsParser::parseFile(const std::string & fileName) if (fieldValue(data, "sync", "down_profile_id", res)){ _settings._downProfileId = boost::lexical_cast(res); } + if (fieldValue(data, "sync", "max_acl_per_pdu", res)){ + _settings._maxACLPerPDU = boost::lexical_cast(res); + } if (fieldValue(data, "sync", "data_url", res)){ _settings._dataURL = res; } diff --git a/src/switch.cpp b/src/switch.cpp index b705402..bf18aa3 100644 --- a/src/switch.cpp +++ b/src/switch.cpp @@ -174,24 +174,27 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S dropACLOidPrefix += "."; dropACLOidPrefix += boost::lexical_cast(profileId); SNMPList aclsList(table.getList()); - Pdu pdu; - SNMPList::const_iterator it; - for (it = aclsList.begin(); it != aclsList.end(); ++it) { - int id; - if (int c = it->get_value(id) != SNMP_CLASS_SUCCESS) { - logger << "Switch::dropACLsByTable() - failed to get ACL id for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; + SNMPList::const_iterator it(aclsList.begin()); + size_t chunks = aclsList.size() / _settings.maxACLPerPDU() + 1; + for (size_t i = 0; i < chunks && it != aclsList.end(); ++i) { + Pdu pdu; + for (size_t j = 0; j < _settings.maxACLPerPDU() && it != aclsList.end(); ++j, ++it) { + int id; + if (int c = it->get_value(id) != SNMP_CLASS_SUCCESS) { + logger << "Switch::dropACLsByTable() - failed to get ACL id for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; + return false; + } + std::string dropACLOid(dropACLOidPrefix); + dropACLOid += "."; + dropACLOid += boost::lexical_cast(id); + Vb vb(Oid(dropACLOid.c_str())); + vb.set_value(int(6)); + pdu += vb; + } + if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { + logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; return false; } - std::string dropACLOid(dropACLOidPrefix); - dropACLOid += "."; - dropACLOid += boost::lexical_cast(id); - Vb vb(Oid(dropACLOid.c_str())); - vb.set_value(int(6)); - pdu += vb; - } - if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { - logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; - return false; } return true; }