Skip to content

Commit

Permalink
vsomeip 2.10.8
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 8936891 commit 565b97b
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 349 deletions.
17 changes: 17 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changes
=======

v2.10.8
- Change dispatching of availability states in case an availability
handler of a service instance is blocked in user code: Availability
states of a service instance are now never dispatched parallel. The
next availability state for a service instance is only dispatched
after the blocked availability handler returned from user code. If
the availability of the service instance changes in the meantime,
subsequent incoming messages of the service instance are queued
until the availability change was reported to the user code.
- Subscriptions to remotely offered services are now always done based
on the protocol(s) the remote service is offered with. The
subscription_type parameter of the application::subscribe method is
ignored.
- Added wildcard support ("any") for the uid and gid json parameters
in the security configuration.
- Fix possible deadlock on application shutdown

v2.10.7
- Fix potential deadlock when expiring remote subscriptions
- Rework restarting of tcp client endpoints to prevent heap corruption
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project (vsomeip)

set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 10)
set (VSOMEIP_PATCH_VERSION 7)
set (VSOMEIP_PATCH_VERSION 8)
set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in
set (CMAKE_VERBOSE_MAKEFILE off)
Expand Down
2 changes: 2 additions & 0 deletions documentation/vsomeipUserGuide
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,12 @@ For remote clients this entry should be skipped.
**** 'uid'
+
Specifies the LINUX user id of the above client(s) as decimal number.
As a wildcard "any" can be used.

**** 'gid'
+
Specifies the LINUX group id of the above client(s) as decimal number.
As a wildcard "any" can be used.

*** 'allow/deny'
+
Expand Down
6 changes: 6 additions & 0 deletions implementation/configuration/include/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ namespace vsomeip {
namespace cfg {

struct policy {
policy() :
uid_(0), is_uid_set_(false), gid_(0), is_gid_set_(false) {
}

std::set<std::pair<service_t, instance_t>> allowed_services_;
std::set<std::pair<service_t, instance_t>> allowed_offers_;
std::set<std::pair<service_t, instance_t>> denied_services_;
std::set<std::pair<service_t, instance_t>> denied_offers_;
std::uint32_t uid_;
bool is_uid_set_;
std::uint32_t gid_;
bool is_gid_set_;
bool allow_;
};

Expand Down
25 changes: 14 additions & 11 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ void configuration_impl::load_policy(const boost::property_tree::ptree &_tree) {
}
}
if (overrides) {
VSOMEIP_WARNING << std::hex << "Security configuration: "
VSOMEIP_INFO << std::hex << "Security configuration: "
<< "Client range 0x" << firstClient
<< " - 0x" << lastClient << " overrides policy of "
<< std::dec << overrides << " clients";
Expand All @@ -1684,31 +1684,33 @@ void configuration_impl::load_policy(const boost::property_tree::ptree &_tree) {
its_converter >> client;
if (client != 0x0) {
if (policies_.find(client) != policies_.end()) {
VSOMEIP_WARNING << std::hex << "Security configuration: "
VSOMEIP_INFO << std::hex << "Security configuration: "
<< "Overriding policy for client 0x" << client << ".";
}
policies_[client] = policy;
}
}
} else if (i->first == "credentials") {
uint32_t uid = 0x0;
uint32_t gid = 0x0;
for (auto n = i->second.begin();
n != i->second.end(); ++n) {
if (n->first == "uid") {
std::stringstream its_converter;
std::string value = n->second.data();
its_converter << std::dec << value;
its_converter >> uid;
if (value != "any") {
its_converter << std::dec << value;
its_converter >> policy->uid_ ;
policy->is_uid_set_ = true;
}
} else if (n->first == "gid") {
std::stringstream its_converter;
std::string value = n->second.data();
its_converter << std::dec << value;
its_converter >> gid;
if (value != "any") {
its_converter << std::dec << value;
its_converter >> policy->gid_ ;
policy->is_gid_set_ = true;
}
}
}
policy->uid_ = uid;
policy->gid_ = gid;
} else if (i->first == "allow") {
if (allow_deny_set) {
VSOMEIP_WARNING << "Security configuration: \"allow\" tag overrides "
Expand Down Expand Up @@ -2410,7 +2412,8 @@ bool configuration_impl::check_credentials(client_t _client, uint32_t _uid,
}
auto its_client = policies_.find(_client);
if (its_client != policies_.end()) {
if (its_client->second->uid_ == _uid && its_client->second->gid_ == _gid) {
if ((!its_client->second->is_uid_set_ || its_client->second->uid_ == _uid)
&& (!its_client->second->is_gid_set_ || its_client->second->gid_ == _gid)) {
return true;
}
}
Expand Down
7 changes: 6 additions & 1 deletion implementation/endpoints/include/client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi
virtual void print_status() = 0;

protected:
enum class cei_state_e : std::uint8_t {
CLOSED,
CONNECTING,
ESTABLISHED
};
virtual void send_queued() = 0;
void shutdown_and_close_socket(bool _recreate_socket);
void shutdown_and_close_socket_unlocked(bool _recreate_socket);
Expand All @@ -84,7 +89,7 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi
std::mutex connect_timer_mutex_;
boost::asio::steady_timer connect_timer_;
std::atomic<uint32_t> connect_timeout_;
std::atomic<bool> is_connected_;
std::atomic<cei_state_e> state_;

// send data
message_buffer_ptr_t packetizer_;
Expand Down
20 changes: 13 additions & 7 deletions implementation/endpoints/src/client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ client_endpoint_impl<Protocol>::client_endpoint_impl(
socket_(new socket_type(_io)), remote_(_remote),
flush_timer_(_io), connect_timer_(_io),
connect_timeout_(VSOMEIP_DEFAULT_CONNECT_TIMEOUT), // TODO: use config variable
is_connected_(false),
state_(cei_state_e::CLOSED),
packetizer_(std::make_shared<message_buffer_t>()),
queue_size_(0),
was_not_connected_(false),
Expand All @@ -55,11 +55,16 @@ bool client_endpoint_impl<Protocol>::is_client() const {

template<typename Protocol>
bool client_endpoint_impl<Protocol>::is_connected() const {
return is_connected_;
return state_ == cei_state_e::ESTABLISHED;
}

template<typename Protocol>
void client_endpoint_impl<Protocol>::set_connected(bool _connected) { is_connected_ = _connected;}
void client_endpoint_impl<Protocol>::set_connected(bool _connected) {
if (_connected) {
state_ = cei_state_e::ESTABLISHED;
} else {
state_ = cei_state_e::CLOSED;
}}
template<typename Protocol>void client_endpoint_impl<Protocol>::stop() {
{
std::lock_guard<std::mutex> its_lock(mutex_);
Expand Down Expand Up @@ -222,8 +227,8 @@ void client_endpoint_impl<Protocol>::connect_cbk(
if (connect_timeout_ < VSOMEIP_MAX_CONNECT_TIMEOUT)
connect_timeout_ = (connect_timeout_ << 1);

if (is_connected_) {
is_connected_ = false;
if (state_ != cei_state_e::ESTABLISHED) {
state_ = cei_state_e::CLOSED;
its_host->on_disconnect(this->shared_from_this());
}
} else {
Expand All @@ -233,7 +238,7 @@ void client_endpoint_impl<Protocol>::connect_cbk(
}
connect_timeout_ = VSOMEIP_DEFAULT_CONNECT_TIMEOUT; // TODO: use config variable
set_local_port();
if (!is_connected_) {
if (state_ != cei_state_e::ESTABLISHED) {
its_host->on_connect(this->shared_from_this());
}

Expand Down Expand Up @@ -270,7 +275,7 @@ void client_endpoint_impl<Protocol>::send_cbk(
send_queued();
}
} else if (_error == boost::asio::error::broken_pipe) {
is_connected_ = false;
state_ = cei_state_e::CLOSED;
bool stopping(false);
{
std::lock_guard<std::mutex> its_lock(mutex_);
Expand Down Expand Up @@ -319,6 +324,7 @@ void client_endpoint_impl<Protocol>::send_cbk(
connect();
} else if (_error == boost::asio::error::not_connected
|| _error == boost::asio::error::bad_descriptor) {
state_ = cei_state_e::CLOSED;
was_not_connected_ = true;
shutdown_and_close_socket(true);
connect();
Expand Down
6 changes: 5 additions & 1 deletion implementation/endpoints/src/local_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ bool local_client_endpoint_impl::is_local() const {
}

void local_client_endpoint_impl::restart() {
is_connected_ = false;
if (state_ == cei_state_e::CONNECTING) {
return;
}
state_ = cei_state_e::CONNECTING;
{
std::lock_guard<std::mutex> its_lock(mutex_);
sending_blocked_ = false;
Expand Down Expand Up @@ -113,6 +116,7 @@ void local_client_endpoint_impl::connect() {
VSOMEIP_WARNING << "local_client_endpoint_impl::connect: "
<< "couldn't enable SO_REUSEADDR: " << its_error.message();
}
state_ = cei_state_e::CONNECTING;
socket_->connect(remote_, its_connect_error);

// Credentials
Expand Down
10 changes: 6 additions & 4 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ void tcp_client_endpoint_impl::start() {
}

void tcp_client_endpoint_impl::restart() {
is_connected_ = false;
if (state_ == cei_state_e::CONNECTING) {
return;
}
state_ = cei_state_e::CONNECTING;
std::string address_port_local;
{
std::lock_guard<std::mutex> its_lock(socket_mutex_);
Expand Down Expand Up @@ -137,7 +140,7 @@ void tcp_client_endpoint_impl::connect() {
"Error binding socket: " << its_bind_error.message();
}
}

state_ = cei_state_e::CONNECTING;
socket_->async_connect(
remote_,
std::bind(
Expand Down Expand Up @@ -180,7 +183,6 @@ void tcp_client_endpoint_impl::receive(message_buffer_ptr_t _recv_buffer,
_recv_buffer->resize(its_required_capacity, 0x0);
}
buffer_size = _missing_capacity;
_missing_capacity = 0;
} else if (buffer_shrink_threshold_
&& shrink_count_ > buffer_shrink_threshold_
&& _recv_buffer_size == 0) {
Expand Down Expand Up @@ -517,7 +519,7 @@ void tcp_client_endpoint_impl::receive_cbk(
<< _error.message() << "( " << std::dec << _error.value()
<< ") local: " << get_address_port_local()
<< " remote: " << get_address_port_remote();
is_connected_ = false;
state_ = cei_state_e::CLOSED;
shutdown_and_close_socket_unlocked(false);
} else {
VSOMEIP_WARNING << "tcp_client_endpoint receive_cbk: "
Expand Down
7 changes: 5 additions & 2 deletions implementation/endpoints/src/udp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void udp_client_endpoint_impl::connect() {
"Error binding socket: " << its_bind_error.message();
}
}

state_ = cei_state_e::CONNECTING;
socket_->async_connect(
remote_,
std::bind(
Expand All @@ -77,7 +77,10 @@ void udp_client_endpoint_impl::start() {
}

void udp_client_endpoint_impl::restart() {
is_connected_ = false;
if (state_ == cei_state_e::CONNECTING) {
return;
}
state_ = cei_state_e::CONNECTING;
{
std::lock_guard<std::mutex> its_lock(mutex_);
queue_.clear();
Expand Down
32 changes: 7 additions & 25 deletions implementation/routing/src/routing_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3204,32 +3204,14 @@ void routing_manager_impl::on_identify_response(client_t _client, service_t _ser
void routing_manager_impl::identify_for_subscribe(client_t _client,
service_t _service, instance_t _instance, major_version_t _major,
subscription_type_e _subscription_type) {
if (_subscription_type == subscription_type_e::SU_RELIABLE_AND_UNRELIABLE
|| _subscription_type == subscription_type_e::SU_PREFER_UNRELIABLE
|| _subscription_type == subscription_type_e::SU_UNRELIABLE) {
if (!has_identified(_client, _service, _instance, false)
&& !is_identifying(_client, _service, _instance, false)) {
if (!send_identify_message(_client, _service, _instance, _major,
false) && _subscription_type
== subscription_type_e::SU_PREFER_UNRELIABLE) {
send_identify_message(_client, _service, _instance, _major,
true);
}
}
(void)_subscription_type;
if (!has_identified(_client, _service, _instance, false)
&& !is_identifying(_client, _service, _instance, false)) {
send_identify_message(_client, _service, _instance, _major, false);
}

if (_subscription_type == subscription_type_e::SU_RELIABLE_AND_UNRELIABLE
|| _subscription_type == subscription_type_e::SU_PREFER_RELIABLE
|| _subscription_type == subscription_type_e::SU_RELIABLE) {
if (!has_identified(_client, _service, _instance, true)
&& !is_identifying(_client, _service, _instance, true)) {
if (!send_identify_message(_client, _service, _instance, _major,
true) && _subscription_type
== subscription_type_e::SU_PREFER_RELIABLE) {
send_identify_message(_client, _service, _instance, _major,
false);
}
}
if (!has_identified(_client, _service, _instance, true)
&& !is_identifying(_client, _service, _instance, true)) {
send_identify_message(_client, _service, _instance, _major, true);
}
}

Expand Down
15 changes: 9 additions & 6 deletions implementation/routing/src/routing_manager_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,15 @@ void routing_manager_proxy::register_event(client_t _client,
_event, _eventgroups, _is_field, _is_provided);
}
}
VSOMEIP_INFO << "REGISTER EVENT("
<< std::hex << std::setw(4) << std::setfill('0') << _client << "): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << _event
<< ":is_provider=" << _is_provided << "]";

if(_is_provided) {
VSOMEIP_INFO << "REGISTER EVENT("
<< std::hex << std::setw(4) << std::setfill('0') << _client << "): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _instance << "."
<< std::hex << std::setw(4) << std::setfill('0') << _event
<< ":is_provider=" << _is_provided << "]";
}
}

void routing_manager_proxy::unregister_event(client_t _client,
Expand Down
Loading

0 comments on commit 565b97b

Please sign in to comment.