Skip to content

Commit

Permalink
face: handle PcapHelper::Error when applying multicast configuration
Browse files Browse the repository at this point in the history
When the network interface state is changed, NFD reconfigures its
multicast ethernet faces. The code responsible for this is prone to
a TOCTOU race condition, e.g., if an interface is quickly brought up
and then down again. This currently raises an uncaught exception when
we try to set a packet filter for that interface.

Prevent this issue by catching PcapHelper errors in the same manner
as we catch EthernetTransport errors, and skip creating the face.

Refs: #5297
Change-Id: I9f91ac7c42dec06de34128cb34d6de8bb57e8cf5
  • Loading branch information
awlane authored and Pesa committed Oct 8, 2023
1 parent 1e0c88e commit 9c36a65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 9 additions & 7 deletions .mailmap
5 changes: 5 additions & 0 deletions daemon/face/ethernet-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ethernet-factory.hpp"
#include "generic-link-service.hpp"
#include "multicast-ethernet-transport.hpp"
#include "pcap-helper.hpp"

#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm/copy.hpp>
Expand Down Expand Up @@ -337,6 +338,10 @@ EthernetFactory::applyMcastConfigToNetif(const ndn::net::NetworkInterface& netif
NFD_LOG_WARN("Cannot create multicast face on " << netif.getName() << ": " << e.what());
return nullptr;
}
catch (const PcapHelper::Error& e) {
NFD_LOG_WARN("Cannot create multicast face on " << netif.getName() << ": " << e.what());
return nullptr;
}

if (face->getId() == INVALID_FACEID) {
// new face: register with forwarding
Expand Down

0 comments on commit 9c36a65

Please sign in to comment.