qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject qpid-dispatch git commit: DISPATCH-1063 - Ensure that the to-override for a delivery uses the internal/routable address and not the external address for an auto-link.
Date Thu, 05 Jul 2018 17:43:17 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 31666130b -> e2f73cdc2


DISPATCH-1063 - Ensure that the to-override for a delivery uses the internal/routable address
and not the external address for an auto-link.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/e2f73cdc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/e2f73cdc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/e2f73cdc

Branch: refs/heads/master
Commit: e2f73cdc27fdc81fcc92d0cb882323562b119f5d
Parents: 3166613
Author: Ted Ross <tross@redhat.com>
Authored: Thu Jul 5 13:38:36 2018 -0400
Committer: Ted Ross <tross@redhat.com>
Committed: Thu Jul 5 13:38:36 2018 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/router_core.h   | 11 +++++++
 src/router_core/connections.c         |  6 ++++
 src/router_core/route_control.c       |  5 ++--
 src/router_core/router_core_private.h |  1 +
 src/router_node.c                     | 15 ++++++++--
 tests/system_tests_multi_tenancy.py   | 47 ++++++++++++++++++++++++++++--
 6 files changed, 78 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index e0a1f41..ec2f1b4 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -470,6 +470,17 @@ qd_direction_t qdr_link_direction(const qdr_link_t *link);
 int qdr_link_phase(const qdr_link_t *link);
 
 /**
+ * qdr_link_internal_address
+ *
+ * If this link is associated with an auto_link and the auto_link has different
+ * internal and external addresses, return the internal (routing) address.
+ *
+ * @param link Link object
+ * @return 0 or the auto_link's internal address.
+ */
+const char *qdr_link_internal_address(const qdr_link_t *link);
+
+/**
  * qdr_link_is_anonymous
  *
  * Indicate whether the link is anonymous.  Note that this is determined inside

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 721c1a7..eafe413 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -368,6 +368,12 @@ int qdr_link_phase(const qdr_link_t *link)
 }
 
 
+const char *qdr_link_internal_address(const qdr_link_t *link)
+{
+    return link && link->auto_link ? link->auto_link->internal_addr : 0;
+}
+
+
 bool qdr_link_is_anonymous(const qdr_link_t *link)
 {
     return link->owning_addr == 0;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/src/router_core/route_control.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_control.c b/src/router_core/route_control.c
index 53c0b53..4d4d1b8 100644
--- a/src/router_core/route_control.c
+++ b/src/router_core/route_control.c
@@ -240,9 +240,10 @@ static void qdr_auto_link_activate_CT(qdr_core_t *core, qdr_auto_link_t
*al, qdr
 
         key = (const char*) qd_hash_key_by_handle(al->addr->hash_handle);
         if (key || al->external_addr) {
-            if (al->external_addr)
+            if (al->external_addr) {
                 qdr_terminus_set_address(term, al->external_addr);
-            else
+                al->internal_addr = &key[2];
+            } else
                 qdr_terminus_set_address(term, &key[2]); // truncate the "Mp" annotation
(where p = phase)
             al->link = qdr_create_link_CT(core, conn, QD_LINK_ENDPOINT, al->dir, source,
target);
             al->link->auto_link = al;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/src/router_core/router_core_private.h
----------------------------------------------------------------------
diff --git a/src/router_core/router_core_private.h b/src/router_core/router_core_private.h
index cbb7315..d493037 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -623,6 +623,7 @@ struct qdr_auto_link_t {
     char                  *name;
     qdr_address_t         *addr;
     char                  *external_addr;
+    const char            *internal_addr;
     int                    phase;
     qd_direction_t         dir;
     qdr_conn_identifier_t *conn_id;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index 4bf6a48..6bda298 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -547,9 +547,18 @@ static void AMQP_rx_handler(void* context, qd_link_t *link)
         //
         // This is a targeted link, not anonymous.
         //
-        const char *term_addr = pn_terminus_get_address(qd_link_remote_target(link));
-        if (!term_addr)
-            term_addr = pn_terminus_get_address(qd_link_source(link));
+
+        //
+        // Look in a series of locations for the terminus address, starting
+        // with the qdr_link (in case this is an auto-link with separate
+        // internal and external addresses).
+        //
+        const char *term_addr = qdr_link_internal_address(rlink);
+        if (!term_addr) {
+            term_addr = pn_terminus_get_address(qd_link_remote_target(link));
+            if (!term_addr)
+                term_addr = pn_terminus_get_address(qd_link_source(link));
+        }
 
         if (term_addr) {
             qd_composed_field_t *to_override = qd_compose_subfield(0);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e2f73cdc/tests/system_tests_multi_tenancy.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_multi_tenancy.py b/tests/system_tests_multi_tenancy.py
index 2319236..6674dc9 100644
--- a/tests/system_tests_multi_tenancy.py
+++ b/tests/system_tests_multi_tenancy.py
@@ -56,6 +56,8 @@ class RouterTest(TestCase):
                 ('linkRoute', {'prefix': '0.0.0.0/link', 'direction': 'out', 'containerId':
'LRC'}),
                 ('autoLink', {'addr': '0.0.0.0/queue.waypoint', 'containerId': 'ALC', 'direction':
'in'}),
                 ('autoLink', {'addr': '0.0.0.0/queue.waypoint', 'containerId': 'ALC', 'direction':
'out'}),
+                ('autoLink', {'addr': '0.0.0.0/queue.ext', 'containerId': 'ALCE', 'direction':
'in', 'externalAddr': 'EXT'}),
+                ('autoLink', {'addr': '0.0.0.0/queue.ext', 'containerId': 'ALCE', 'direction':
'out', 'externalAddr': 'EXT'}),
                 ('address', {'prefix': 'closest', 'distribution': 'closest'}),
                 ('address', {'prefix': 'spread', 'distribution': 'balanced'}),
                 ('address', {'prefix': 'multicast', 'distribution': 'multicast'}),
@@ -422,6 +424,46 @@ class RouterTest(TestCase):
         self.assertEqual(None, test.error)
 
 
+    def test_33_one_router_waypoint_no_tenant_external_addr(self):
+        test = WaypointTest(self.routers[0].addresses[0],
+                            self.routers[0].addresses[2],
+                            "0.0.0.0/queue.ext",
+                            "EXT",
+                            "ALCE")
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_34_one_router_waypoint_external_addr(self):
+        test = WaypointTest(self.routers[0].addresses[1],
+                            self.routers[0].addresses[2],
+                            "queue.ext",
+                            "EXT",
+                            "ALCE")
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_35_two_router_waypoint_no_tenant_external_addr(self):
+        test = WaypointTest(self.routers[0].addresses[0],
+                            self.routers[1].addresses[2],
+                            "0.0.0.0/queue.ext",
+                            "EXT",
+                            "ALCE")
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_36_two_router_waypoint_external_addr(self):
+        test = WaypointTest(self.routers[0].addresses[1],
+                            self.routers[1].addresses[2],
+                            "queue.ext",
+                            "EXT",
+                            "ALCE")
+        test.run()
+        self.assertEqual(None, test.error)
+
+
 class Entity(object):
     def __init__(self, status_code, status_description, attrs):
         self.status_code        = status_code
@@ -794,12 +836,13 @@ class LinkRouteTest(MessagingHandler):
 
 
 class WaypointTest(MessagingHandler):
-    def __init__(self, first_host, second_host, first_address, second_address):
+    def __init__(self, first_host, second_host, first_address, second_address, container_id="ALC"):
         super(WaypointTest, self).__init__()
         self.first_host     = first_host
         self.second_host    = second_host
         self.first_address  = first_address
         self.second_address = second_address
+        self.container_id   = container_id
 
         self.first_conn        = None
         self.second_conn       = None
@@ -886,7 +929,7 @@ class WaypointTest(MessagingHandler):
 
     def run(self):
         container = Container(self)
-        container.container_id = 'ALC'
+        container.container_id = self.container_id
         container.run()
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message