From ed6e675ccbe2a3e2c57dfb35e4c71684a25110b0 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 9 Jul 2014 05:39:54 +0000 Subject: Add withdrawal hashes to publication and rrdp. svn path=/branches/tk705/; revision=5888 --- rpki/left_right.py | 54 ++++++++-------- rpki/pubd.py | 4 +- rpki/publication.py | 26 ++------ rpki/relaxng.py | 96 +++++++++++++++++----------- rpki/rpkid.py | 179 +++++++++++++++++++++++++++++++--------------------- rpki/rpkid_tasks.py | 4 +- rpki/sql_schemas.py | 2 +- rpki/x509.py | 8 +-- 8 files changed, 207 insertions(+), 166 deletions(-) (limited to 'rpki') diff --git a/rpki/left_right.py b/rpki/left_right.py index e4b664b9..c90cac29 100644 --- a/rpki/left_right.py +++ b/rpki/left_right.py @@ -312,42 +312,38 @@ class self_elt(data_elt): def serve_publish_world_now(self, cb, eb): """ Handle a left-right publish_world_now action for this self. - - The publication stuff needs refactoring, right now publication is - interleaved with local operations in a way that forces far too - many bounces through the task system for any complex update. The - whole thing ought to be rewritten to queue up outgoing publication - PDUs and only send them when we're all done or when we need to - force publication at a particular point in a multi-phase operation. - - Once that reorganization has been done, this method should be - rewritten to reuse the low-level publish() methods that each - object will have...but we're not there yet. So, for now, we just - do this via brute force. Think of it as a trial version to see - whether we've identified everything that needs to be republished - for this operation. """ + publisher = rpki.rpkid.publication_queue() + def loop(iterator, parent): - q_msg = rpki.publication.msg.query() + repo = parent.repository for ca in parent.cas: ca_detail = ca.active_ca_detail if ca_detail is not None: - q_msg.append(rpki.publication.publish_elt.make( - ca_detail.crl_uri, ca_detail.latest_crl)) - q_msg.append(rpki.publication.publish_elt.make( - ca_detail.manifest_uri, ca_detail.latest_manifest)) - q_msg.extend(rpki.publication.publish_elt.make( - c.uri, c.cert) for c in ca_detail.child_certs) - q_msg.extend(rpki.publication.publish_elt.make( - r.uri, r.roa) for r in ca_detail.roas if r.roa is not None) - q_msg.extend(rpki.publication.publish_elt.make( - g.uri, g.ghostbuster) for g in ca_detail.ghostbusters) - q_msg.extend(rpki.publication.publish_elt.make( - c.uri, c.cert) for c in ca_detail.ee_certificates) - parent.repository.call_pubd(iterator, eb, q_msg) + publisher.queue( + uri = ca_detail.crl_uri, new_obj = ca_detail.latest_crl, repository = repo) + publisher.queue( + uri = ca_detail.manifest_uri, new_obj = ca_detail.latest_manifest, repository = repo) + for c in ca_detail.child_certs: + publisher.queue( + uri = c.uri, new_obj = c.cert, repository = repo) + for r in ca_detail.roas: + if r.roa is not None: + publisher.queue( + uri = r.uri, new_obj = r.roa, repository = repo) + for g in ca_detail.ghostbusters: + publisher.queue( + uri = g.uri, new_obj = g.ghostbuster, repository = repo) + for c in ca_detail.ee_certificates: + publisher.queue( + uri = c.uri, new_obj = c.cert, repository = repo) + iterator() - rpki.async.iterator(self.parents, loop, cb) + def done(): + publisher.call_pubd(cb, eb) + + rpki.async.iterator(self.parents, loop, done) def serve_run_now(self, cb, eb): """ diff --git a/rpki/pubd.py b/rpki/pubd.py index 46e431c4..14de1999 100644 --- a/rpki/pubd.py +++ b/rpki/pubd.py @@ -188,7 +188,7 @@ class session_obj(rpki.sql.sql_persistent): "uuid") ## @var expiration_interval - # How long to wait after retiring a snapshot before purging it from the database. + # How long to wait after retiring a snapshot before purging it from the database. expiration_interval = rpki.sundial.timedelta(hours = 6) @@ -318,7 +318,7 @@ class snapshot_obj(rpki.sql.sql_persistent): obj.delete(self) - + class object_obj(rpki.sql.sql_persistent): """ A published object. diff --git a/rpki/publication.py b/rpki/publication.py index 19ab2107..7b5abaf9 100644 --- a/rpki/publication.py +++ b/rpki/publication.py @@ -49,11 +49,15 @@ class base_publication_elt(rpki.xml_utils.base_elt, publication_namespace): Base element for publication protocol. Publish and withdraw PDUs subclass this. """ - attributes = ("tag", "uri") + attributes = ("tag", "uri", "hash") + + tag = None + uri = None + hash = None payload = None def __repr__(self): - return rpki.log.log_repr(self, self.uri, self.payload) + return rpki.log.log_repr(self, self.tag, self.uri, self.hash, self.payload) def serve_dispatch(self, r_msg, snapshot, cb, eb): """ @@ -138,15 +142,6 @@ class publish_elt(base_publication_elt): f.write(self.payload.get_DER()) os.rename(filename_tmp, filename) - @classmethod - def make(cls, uri, obj, tag = None): - """ - Construct a publication PDU. - """ - - assert isinstance(obj, rpki.x509.uri_dispatch(uri)) - return cls.make_pdu(uri = uri, payload = obj, tag = tag) - class withdraw_elt(base_publication_elt): @@ -177,15 +172,6 @@ class withdraw_elt(base_publication_elt): else: dirname = os.path.dirname(dirname) - @classmethod - def make(cls, uri, obj, tag = None): - """ - Construct a withdrawal PDU. - """ - - assert isinstance(obj, rpki.x509.uri_dispatch(uri)) - return cls.make_pdu(uri = uri, tag = tag) - class report_error_elt(rpki.xml_utils.text_elt, publication_namespace): """ diff --git a/rpki/relaxng.py b/rpki/relaxng.py index d01f7e28..218edfc4 100644 --- a/rpki/relaxng.py +++ b/rpki/relaxng.py @@ -1806,29 +1806,30 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''3 - + - - - - query - - - - - - - - reply - - - - - - + + query + + + + + + + + + + + + + reply + + + + @@ -1865,6 +1866,14 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring(r''' + + + + + [0-9a-fA-F]+ + + + @@ -1872,16 +1881,19 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring(r''' - + + + + - + @@ -1890,15 +1902,16 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring(r''' - + + - + @@ -2162,24 +2175,35 @@ rrdp = lxml.etree.RelaxNG(lxml.etree.fromstring(r''' - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +