From ba406943f224a192575d08ccc7d8231dab72e042 Mon Sep 17 00:00:00 2001 From: Nipa Kumar Date: Wed, 27 Jul 2016 16:59:23 -0700 Subject: [PATCH] Close new Agent DNS XMPP connections until end-of-config is detected. Closes-Bug:1605341 Provide path to store the session key generated for dynamic updates Closes-Bug:1400879 Change-Id: I2965b6039a20715024b2fb69ff9554ca9df14078 --- src/dns/agent/agent_xmpp_channel.cc | 7 +++++++ src/dns/bind/named_config.cc | 6 ++++++ src/dns/bind/named_config.h | 6 ++++++ src/dns/testdata/named.conf.1 | 1 + src/dns/testdata/named.conf.2 | 1 + src/dns/testdata/named.conf.3 | 1 + src/dns/testdata/named.conf.4 | 1 + src/dns/testdata/named.conf.5 | 1 + src/dns/testdata/named.conf.6 | 1 + src/dns/testdata/named.conf.7 | 1 + src/dns/testdata/named.conf.8 | 1 + src/dns/testdata/named.conf.9 | 1 + src/dns/testdata/named.conf.rr_ext_disabled | 1 + src/dns/testdata/named.conf.rr_ext_disabled.2 | 1 + 14 files changed, 30 insertions(+) diff --git a/src/dns/agent/agent_xmpp_channel.cc b/src/dns/agent/agent_xmpp_channel.cc index 58afc58a75f..602748c10b7 100644 --- a/src/dns/agent/agent_xmpp_channel.cc +++ b/src/dns/agent/agent_xmpp_channel.cc @@ -192,6 +192,13 @@ DnsAgentXmppChannelManager::HandleXmppChannelEvent(XmppChannel *channel, DnsAgentXmppChannel *agent_xmpp_channel = new DnsAgentXmppChannel(channel, this); channel_map_.insert(std::make_pair(channel, agent_xmpp_channel)); + IFMapManager *ifmap_manager = + Dns::GetDnsManager()->get_ifmap_manager(); + if (ifmap_manager && !ifmap_manager->GetEndOfRibComputed()) { + DNS_XMPP_TRACE(DnsXmppTrace, "Peer:" + channel->PeerAddress() + + " Close due to EndofRib not computed"); + channel->Close(); + } } } else if (state == xmps::NOT_READY) { if (it != channel_map_.end()) { diff --git a/src/dns/bind/named_config.cc b/src/dns/bind/named_config.cc index b53520bd0fd..f241b0b449d 100644 --- a/src/dns/bind/named_config.cc +++ b/src/dns/bind/named_config.cc @@ -23,6 +23,7 @@ const string NamedConfig::NamedZoneFileSuffix = "zone"; const string NamedConfig::NamedZoneNSPrefix = "contrail-ns"; const string NamedConfig::NamedZoneMXPrefix = "contrail-mx"; const char NamedConfig::pid_file_name[] = "contrail-named.pid"; +const char NamedConfig::sessionkey_file_name[] = "session.key"; void NamedConfig::Init(const std::string& named_config_dir, const std::string& named_config_file, @@ -178,6 +179,7 @@ void NamedConfig::WriteOptionsConfig() { file_ << " managed-keys-directory \"" << named_config_dir_ << "\";" << endl; file_ << " empty-zones-enable no;" << endl; file_ << " pid-file \"" << GetPidFilePath() << "\";" << endl; + file_ << " session-keyfile \"" << GetSessionKeyFilePath() << "\";" << endl; file_ << " listen-on port " << Dns::GetDnsPort() << " { any; };" << endl; file_ << " allow-query { any; };" << endl; file_ << " allow-recursion { any; };" << endl; @@ -353,6 +355,10 @@ string NamedConfig::GetPidFilePath() { return (named_config_dir_ + pid_file_name); } +string NamedConfig::GetSessionKeyFilePath() { + return (named_config_dir_ + sessionkey_file_name); +} + string NamedConfig::GetZoneNSName(const string domain_name) { return (NamedZoneNSPrefix + "." + domain_name); } diff --git a/src/dns/bind/named_config.h b/src/dns/bind/named_config.h index 071e3f1a5e5..4582dc867cb 100644 --- a/src/dns/bind/named_config.h +++ b/src/dns/bind/named_config.h @@ -51,6 +51,7 @@ class NamedConfig { static const std::string NamedZoneNSPrefix; static const std::string NamedZoneMXPrefix; static const char pid_file_name[]; + static const char sessionkey_file_name[]; static const int NameWidth = 30; static const int NumberWidth = 10; static const int TypeWidth = 4; @@ -103,8 +104,12 @@ class NamedConfig { const std::string &name); virtual std::string GetResolveFile() { return "/etc/resolv.conf"; } std::string GetPidFilePath(); + std::string GetSessionKeyFilePath(); const std::string &named_config_dir() const { return named_config_dir_; } const std::string &named_config_file() const { return named_config_file_; } + const std::string &named_sessionkey_file() const { + return named_sessionkey_file_; + } protected: void CreateRndcConf(); @@ -130,6 +135,7 @@ class NamedConfig { std::ofstream file_; std::string named_config_file_; std::string named_config_dir_; + std::string named_sessionkey_file_; std::string named_log_file_; std::string rndc_config_file_; std::string rndc_secret_; diff --git a/src/dns/testdata/named.conf.1 b/src/dns/testdata/named.conf.1 index d089cd9623b..d57fb1074e7 100644 --- a/src/dns/testdata/named.conf.1 +++ b/src/dns/testdata/named.conf.1 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.2 b/src/dns/testdata/named.conf.2 index 271456301ad..c39433b465f 100644 --- a/src/dns/testdata/named.conf.2 +++ b/src/dns/testdata/named.conf.2 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.3 b/src/dns/testdata/named.conf.3 index ed0ae3fd7a7..14541ead251 100644 --- a/src/dns/testdata/named.conf.3 +++ b/src/dns/testdata/named.conf.3 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.4 b/src/dns/testdata/named.conf.4 index 8dadc7b8809..b5b6180cec2 100644 --- a/src/dns/testdata/named.conf.4 +++ b/src/dns/testdata/named.conf.4 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.5 b/src/dns/testdata/named.conf.5 index 4606d280ba5..df0398ef881 100644 --- a/src/dns/testdata/named.conf.5 +++ b/src/dns/testdata/named.conf.5 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.6 b/src/dns/testdata/named.conf.6 index 158be628d53..1082b7a5760 100644 --- a/src/dns/testdata/named.conf.6 +++ b/src/dns/testdata/named.conf.6 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.7 b/src/dns/testdata/named.conf.7 index 5c0363d2d50..b93d4fdf636 100644 --- a/src/dns/testdata/named.conf.7 +++ b/src/dns/testdata/named.conf.7 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.8 b/src/dns/testdata/named.conf.8 index 00c177a646c..3f9f43cbdeb 100644 --- a/src/dns/testdata/named.conf.8 +++ b/src/dns/testdata/named.conf.8 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.9 b/src/dns/testdata/named.conf.9 index 3d788cbbd4a..d13bcca5e4e 100644 --- a/src/dns/testdata/named.conf.9 +++ b/src/dns/testdata/named.conf.9 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.rr_ext_disabled b/src/dns/testdata/named.conf.rr_ext_disabled index 616c8d09832..181c95f5095 100644 --- a/src/dns/testdata/named.conf.rr_ext_disabled +++ b/src/dns/testdata/named.conf.rr_ext_disabled @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; }; diff --git a/src/dns/testdata/named.conf.rr_ext_disabled.2 b/src/dns/testdata/named.conf.rr_ext_disabled.2 index a468b755ffb..db441989a31 100644 --- a/src/dns/testdata/named.conf.rr_ext_disabled.2 +++ b/src/dns/testdata/named.conf.rr_ext_disabled.2 @@ -3,6 +3,7 @@ options { managed-keys-directory "./"; empty-zones-enable no; pid-file "./contrail-named.pid"; + session-keyfile "./session.key"; listen-on port 53 { any; }; allow-query { any; }; allow-recursion { any; };