@@ -361,7 +361,8 @@ TEST_P(NetworkConfig, PubSubInterfaceWhitelistLocalhost)
361
361
void interface_whitelist_test (
362
362
const std::vector<IPFinder::info_IP>& pub_interfaces,
363
363
const std::vector<IPFinder::info_IP>& sub_interfaces,
364
- bool interface_name = false )
364
+ bool interface_name = false ,
365
+ bool add_shm_descriptor = false )
365
366
{
366
367
PubSubReader<HelloWorldPubSubType> reader (TEST_TOPIC_NAME);
367
368
PubSubWriter<HelloWorldPubSubType> writer (TEST_TOPIC_NAME);
@@ -378,7 +379,7 @@ void interface_whitelist_test(
378
379
pub_udp_descriptor = std::make_shared<UDPv6TransportDescriptor>();
379
380
}
380
381
381
- // include the interfaces in the transport descriptor
382
+ // include the interfaces in the UDP transport descriptor
382
383
for (const auto & network_interface : pub_interfaces)
383
384
{
384
385
if (!interface_name)
@@ -391,10 +392,26 @@ void interface_whitelist_test(
391
392
}
392
393
}
393
394
394
- // Set the transport descriptor WITH interfaces in the writer
395
+ std::shared_ptr<SharedMemTransportDescriptor> pub_shm_descriptor;
396
+
397
+ if (add_shm_descriptor)
398
+ {
399
+ pub_shm_descriptor = std::make_shared<SharedMemTransportDescriptor>();
400
+ }
401
+
402
+ // Set the UDP transport descriptor WITH interfaces in the writer
395
403
writer.reliability (eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS).history_depth (10 ).
396
404
disable_builtin_transport ().
397
- add_user_transport_to_pparams (pub_udp_descriptor).init ();
405
+ add_user_transport_to_pparams (pub_udp_descriptor);
406
+
407
+ // If shared memory is requested, add it as well
408
+ if (add_shm_descriptor)
409
+ {
410
+ writer.add_user_transport_to_pparams (pub_shm_descriptor);
411
+ }
412
+
413
+ // Initialize the writer
414
+ writer.init ();
398
415
399
416
ASSERT_TRUE (writer.isInitialized ());
400
417
@@ -409,7 +426,7 @@ void interface_whitelist_test(
409
426
sub_udp_descriptor = std::make_shared<UDPv6TransportDescriptor>();
410
427
}
411
428
412
- // include the interfaces in the transport descriptor
429
+ // include the interfaces in the UDP transport descriptor
413
430
for (const auto & network_interface : sub_interfaces)
414
431
{
415
432
if (!interface_name)
@@ -422,10 +439,26 @@ void interface_whitelist_test(
422
439
}
423
440
}
424
441
425
- // Set the transport descriptor WITH interfaces in the reader
442
+ std::shared_ptr<SharedMemTransportDescriptor> sub_shm_descriptor;
443
+
444
+ if (add_shm_descriptor)
445
+ {
446
+ sub_shm_descriptor = std::make_shared<SharedMemTransportDescriptor>();
447
+ }
448
+
449
+ // Set the UDP transport descriptor WITH interfaces in the reader
426
450
reader.reliability (eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS).history_depth (10 ).
427
451
disable_builtin_transport ().
428
- add_user_transport_to_pparams (sub_udp_descriptor).init ();
452
+ add_user_transport_to_pparams (sub_udp_descriptor);
453
+
454
+ // If shared memory is requested, add it as well
455
+ if (add_shm_descriptor)
456
+ {
457
+ reader.add_user_transport_to_pparams (sub_shm_descriptor);
458
+ }
459
+
460
+ // Initialize the reader
461
+ reader.init ();
429
462
430
463
ASSERT_TRUE (reader.isInitialized ());
431
464
@@ -622,6 +655,44 @@ TEST_P(NetworkConfig, PubSubAsymmetricInterfaceWhitelistAllExceptLocalhost)
622
655
}
623
656
}
624
657
658
+ // Regression test for redmine issue #23213 to check in UDP that setting the interface whitelist in one
659
+ // of the endpoints, but not in the other, connection is established anyways.
660
+ // All available interfaces except loopback case.
661
+ // This test verifies that adding a SHM transport descriptor does not affect the communication in this concrete case.
662
+ TEST_P (NetworkConfig, PubSubAsymmetricInterfaceWhitelistAllExceptLocalhostSHM)
663
+ {
664
+ std::vector<IPFinder::info_IP> no_interfaces;
665
+
666
+ std::vector<IPFinder::info_IP> all_interfaces_except_localhost;
667
+ use_udpv4 ? GetIP4s (all_interfaces_except_localhost, false ) : GetIP6s (all_interfaces_except_localhost, false );
668
+
669
+ {
670
+ // IP address
671
+ {
672
+ // Whitelist only in publisher
673
+ interface_whitelist_test (all_interfaces_except_localhost, no_interfaces, false , true );
674
+ }
675
+
676
+ {
677
+ // Whitelist only in subscriber
678
+ interface_whitelist_test (no_interfaces, all_interfaces_except_localhost, false , true );
679
+ }
680
+ }
681
+
682
+ {
683
+ // Interface name
684
+ {
685
+ // Whitelist only in publisher
686
+ interface_whitelist_test (all_interfaces_except_localhost, no_interfaces, true , true );
687
+ }
688
+
689
+ {
690
+ // Whitelist only in subscriber
691
+ interface_whitelist_test (no_interfaces, all_interfaces_except_localhost, true , true );
692
+ }
693
+ }
694
+ }
695
+
625
696
TEST_P (NetworkConfig, SubGetListeningLocators)
626
697
{
627
698
PubSubReader<HelloWorldPubSubType> reader (TEST_TOPIC_NAME);
0 commit comments