From 5157987f8cb6c4eb812cf7b26baf39df63627a4f Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Fri, 6 Dec 2024 15:58:35 +0100 Subject: [PATCH 1/4] Overwrite incoming config with current endpoint config --- commons/zenoh-protocol/src/core/endpoint.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commons/zenoh-protocol/src/core/endpoint.rs b/commons/zenoh-protocol/src/core/endpoint.rs index 081463eb4..e7b127437 100644 --- a/commons/zenoh-protocol/src/core/endpoint.rs +++ b/commons/zenoh-protocol/src/core/endpoint.rs @@ -385,8 +385,9 @@ impl ConfigMut<'_> { self.0.address(), self.0.metadata(), parameters::from_iter(parameters::sort(parameters::join( - self.0.config().iter(), + // Endpoint config overwrites incoming config iter.map(|(k, v)| (k.borrow(), v.borrow())), + self.0.config().iter(), ))), )?; From f3f01dea14b37aa49a43bd1810e1725527e39f47 Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Fri, 6 Dec 2024 16:01:36 +0100 Subject: [PATCH 2/4] Update affected tests --- zenoh/tests/tcp_buffers.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/zenoh/tests/tcp_buffers.rs b/zenoh/tests/tcp_buffers.rs index 8d7568250..c443f1489 100644 --- a/zenoh/tests/tcp_buffers.rs +++ b/zenoh/tests/tcp_buffers.rs @@ -49,20 +49,8 @@ fn buffer_size_endpoint() { zenoh::open(config).wait().unwrap(); } -#[cfg(target_os = "macos")] -#[test] -#[should_panic(expected = "Can not create a new TCP listener")] -fn buffer_size_override() { - buffer_size_config_override(); -} - -#[cfg(not(target_os = "macos"))] #[test] -fn buffer_size_override() { - buffer_size_config_override(); -} - -fn buffer_size_config_override() { +fn buffer_size_endpoint_overwrite() { let mut config = Config::default(); config .insert_json5( From e215f6179f3e1d32317c8e85cac1dcfe02bdef1a Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Mon, 9 Dec 2024 13:01:45 +0100 Subject: [PATCH 3/4] Change overwrite behavior in transport logic instead of Endpoint This reverts commit 5157987f8cb6c4eb812cf7b26baf39df63627a4f. --- commons/zenoh-protocol/src/core/endpoint.rs | 3 +-- io/zenoh-links/zenoh-link-tls/src/utils.rs | 20 ++++++++++------ io/zenoh-transport/src/multicast/manager.rs | 12 +++++++--- io/zenoh-transport/src/unicast/manager.rs | 24 ++++++++++++++----- .../zenoh-test-unix-socket-0.sock.lock | 0 .../zenoh-test-unix-socket-1.sock.lock | 0 6 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock create mode 100644 io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock diff --git a/commons/zenoh-protocol/src/core/endpoint.rs b/commons/zenoh-protocol/src/core/endpoint.rs index e7b127437..081463eb4 100644 --- a/commons/zenoh-protocol/src/core/endpoint.rs +++ b/commons/zenoh-protocol/src/core/endpoint.rs @@ -385,9 +385,8 @@ impl ConfigMut<'_> { self.0.address(), self.0.metadata(), parameters::from_iter(parameters::sort(parameters::join( - // Endpoint config overwrites incoming config - iter.map(|(k, v)| (k.borrow(), v.borrow())), self.0.config().iter(), + iter.map(|(k, v)| (k.borrow(), v.borrow())), ))), )?; diff --git a/io/zenoh-links/zenoh-link-tls/src/utils.rs b/io/zenoh-links/zenoh-link-tls/src/utils.rs index e85be4573..9d96fbda6 100644 --- a/io/zenoh-links/zenoh-link-tls/src/utils.rs +++ b/io/zenoh-links/zenoh-link-tls/src/utils.rs @@ -32,7 +32,7 @@ use secrecy::ExposeSecret; use webpki::anchor_from_trusted_cert; use zenoh_config::Config as ZenohConfig; use zenoh_link_commons::{ - tcp::TcpSocketConfig, tls::WebPkiVerifierAnyServerName, ConfigurationInspector, + tcp::TcpSocketConfig, tls::WebPkiVerifierAnyServerName, ConfigurationInspector, BIND_INTERFACE, TCP_RX_BUFFER_SIZE, TCP_TX_BUFFER_SIZE, }; use zenoh_protocol::core::{ @@ -178,7 +178,7 @@ pub(crate) struct TlsServerConfig<'a> { } impl<'a> TlsServerConfig<'a> { - pub async fn new(config: &Config<'a>) -> ZResult { + pub async fn new(config: &'a Config<'_>) -> ZResult { let tls_server_client_auth: bool = match config.get(TLS_ENABLE_MTLS) { Some(s) => s .parse() @@ -277,8 +277,11 @@ impl<'a> TlsServerConfig<'a> { server_config: sc, tls_handshake_timeout, tls_close_link_on_expiration, - // TODO: add interface binding - tcp_socket_config: TcpSocketConfig::new(tcp_tx_buffer_size, tcp_rx_buffer_size, None), + tcp_socket_config: TcpSocketConfig::new( + tcp_tx_buffer_size, + tcp_rx_buffer_size, + config.get(BIND_INTERFACE), + ), }) } @@ -310,7 +313,7 @@ pub(crate) struct TlsClientConfig<'a> { } impl<'a> TlsClientConfig<'a> { - pub async fn new(config: &Config<'a>) -> ZResult { + pub async fn new(config: &'a Config<'_>) -> ZResult { let tls_client_server_auth: bool = match config.get(TLS_ENABLE_MTLS) { Some(s) => s .parse() @@ -440,8 +443,11 @@ impl<'a> TlsClientConfig<'a> { Ok(TlsClientConfig { client_config: cc, tls_close_link_on_expiration, - // TODO: add interface binding - tcp_socket_config: TcpSocketConfig::new(tcp_tx_buffer_size, tcp_rx_buffer_size, None), + tcp_socket_config: TcpSocketConfig::new( + tcp_tx_buffer_size, + tcp_rx_buffer_size, + config.get(BIND_INTERFACE), + ), }) } diff --git a/io/zenoh-transport/src/multicast/manager.rs b/io/zenoh-transport/src/multicast/manager.rs index e2899b1d1..8046d5bd5 100644 --- a/io/zenoh-transport/src/multicast/manager.rs +++ b/io/zenoh-transport/src/multicast/manager.rs @@ -256,9 +256,15 @@ impl TransportManager { .await?; // Fill and merge the endpoint configuration if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) { - endpoint - .config_mut() - .extend_from_iter(parameters::iter(config))?; + let mut config = parameters::Parameters::from(config.as_str()); + // Overwrite config with current endpoint parameters + config.extend_from_iter(endpoint.config().iter()); + endpoint = EndPoint::new( + endpoint.protocol(), + endpoint.address(), + endpoint.metadata(), + config.as_str(), + )?; } // Open the link diff --git a/io/zenoh-transport/src/unicast/manager.rs b/io/zenoh-transport/src/unicast/manager.rs index 5511451b3..749760475 100644 --- a/io/zenoh-transport/src/unicast/manager.rs +++ b/io/zenoh-transport/src/unicast/manager.rs @@ -385,9 +385,15 @@ impl TransportManager { .await?; // Fill and merge the endpoint configuration if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) { - endpoint - .config_mut() - .extend_from_iter(parameters::iter(config))?; + let mut config = parameters::Parameters::from(config.as_str()); + // Overwrite config with current endpoint parameters + config.extend_from_iter(endpoint.config().iter()); + endpoint = EndPoint::new( + endpoint.protocol(), + endpoint.address(), + endpoint.metadata(), + config.as_str(), + )?; }; manager.new_listener(endpoint).await } @@ -705,9 +711,15 @@ impl TransportManager { .await?; // Fill and merge the endpoint configuration if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) { - endpoint - .config_mut() - .extend_from_iter(parameters::iter(config))?; + let mut config = parameters::Parameters::from(config.as_str()); + // Overwrite config with current endpoint parameters + config.extend_from_iter(endpoint.config().iter()); + endpoint = EndPoint::new( + endpoint.protocol(), + endpoint.address(), + endpoint.metadata(), + config.as_str(), + )?; }; // Create a new link associated by calling the Link Manager diff --git a/io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock b/io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock new file mode 100644 index 000000000..e69de29bb diff --git a/io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock b/io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock new file mode 100644 index 000000000..e69de29bb From 7196899c08d2b8696141cfcddbdd216ba04117ba Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Mon, 9 Dec 2024 14:13:34 +0100 Subject: [PATCH 4/4] Remove mistakenly added files --- io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock | 0 io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock delete mode 100644 io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock diff --git a/io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock b/io/zenoh-transport/zenoh-test-unix-socket-0.sock.lock deleted file mode 100644 index e69de29bb..000000000 diff --git a/io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock b/io/zenoh-transport/zenoh-test-unix-socket-1.sock.lock deleted file mode 100644 index e69de29bb..000000000