mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-22 02:16:44 +00:00
nic_bridge: fix bug when reading MAC address
For reading the MAC address we try first to read it from the <policy> tag, and when it is not defined in the <policy> tag, we allocate a MAC. But there was no handling of the case that there is no appropriate <policy> tag. In this case we want to create the session with an allocated MAC also.
This commit is contained in:
parent
8cb8082206
commit
82ded858aa
@ -217,20 +217,24 @@ class Net::Root : public Genode::Root_component<Net::Session_component>
|
||||
Session_policy policy(label, _config);
|
||||
|
||||
/* determine session MAC address */
|
||||
mac = policy.attribute_value("mac", Mac_address());
|
||||
if (mac == Mac_address()) {
|
||||
mac = _mac_alloc.alloc(); }
|
||||
else if (_mac_alloc.mac_managed_by_allocator(mac)) {
|
||||
Genode::warning("Bad MAC address in policy");
|
||||
throw Service_denied();
|
||||
try {
|
||||
policy.attribute("mac").value<Mac_address>(&mac);
|
||||
if (_mac_alloc.mac_managed_by_allocator(mac)) {
|
||||
Genode::warning("Bad MAC address in policy");
|
||||
throw Service_denied();
|
||||
}
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
mac = _mac_alloc.alloc(); }
|
||||
|
||||
policy.attribute("ip_addr").value(ip_addr, sizeof(ip_addr));
|
||||
}
|
||||
catch (Xml_node::Nonexistent_attribute) {
|
||||
Genode::log("Missing \"ip_addr\" attribute in policy definition");
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) { }
|
||||
Genode::log("Missing \"ip_addr\" attribute in policy definition"); }
|
||||
|
||||
catch (Session_policy::No_policy_defined) {
|
||||
mac = _mac_alloc.alloc(); }
|
||||
|
||||
catch (Mac_allocator::Alloc_failed) {
|
||||
Genode::warning("Mac address allocation failed!");
|
||||
throw Service_denied();
|
||||
|
Loading…
x
Reference in New Issue
Block a user