fw: require valid FaceId in outgoing Interest/Data pipelines
This is to avoid sending via a failed/closed face.
refs #1732
Change-Id: I31b205c2b97185e7955107a2591f8c4d2b7f0cc0
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 45728ea..56012dc 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -151,6 +151,10 @@
Forwarder::onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace,
bool wantNewNonce)
{
+ if (outFace.getId() == INVALID_FACEID) {
+ NFD_LOG_WARN("onOutgoingInterest face=invalid interest=" << pitEntry->getName());
+ return;
+ }
NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() <<
" interest=" << pitEntry->getName());
@@ -304,6 +308,10 @@
void
Forwarder::onOutgoingData(const Data& data, Face& outFace)
{
+ if (outFace.getId() == INVALID_FACEID) {
+ NFD_LOG_WARN("onOutgoingData face=invalid data=" << data.getName());
+ return;
+ }
NFD_LOG_DEBUG("onOutgoingData face=" << outFace.getId() << " data=" << data.getName());
// /localhost scope control
diff --git a/tests/daemon/fw/forwarder.cpp b/tests/daemon/fw/forwarder.cpp
index 3a20033..263967b 100644
--- a/tests/daemon/fw/forwarder.cpp
+++ b/tests/daemon/fw/forwarder.cpp
@@ -356,6 +356,8 @@
shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
forwarder.addFace(face1);
forwarder.addFace(face2);
+ forwarder.addFace(face3);
+ forwarder.addFace(face4);
Pit& pit = forwarder.getPit();
shared_ptr<Interest> interest0 = makeInterest("ndn:/");