face: bugfix of MulticastUdpFace receiving packets from all available NICs on Linux

Now on Linux the creation of MulticastUdpFace requires
CAP_NET_RAW capability if the name of the interface is specified

Change-Id: Iff53035371fb26c6ee40e1065a0935e5ed16dc60
Refs: #1475
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 79822f7..8397253 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -498,6 +498,7 @@
 
       if (useMcast && enableV4)
         {
+          std::list<shared_ptr<NetworkInterfaceInfo> > ipv4MulticastInterfaces;
           for (std::list<shared_ptr<NetworkInterfaceInfo> >::const_iterator i = nicList.begin();
                i != nicList.end();
                ++i)
@@ -505,13 +506,35 @@
               const shared_ptr<NetworkInterfaceInfo>& nic = *i;
               if (nic->isUp() && nic->isMulticastCapable() && !nic->ipv4Addresses.empty())
                 {
-                  shared_ptr<MulticastUdpFace> newFace =
-                    factory->createMulticastFace(nic->ipv4Addresses[0].to_string(),
-                                                 mcastGroup, mcastPort);
-
-                  addCreatedFaceToForwarder(newFace);
+                  ipv4MulticastInterfaces.push_back(nic);
                 }
             }
+
+          bool isNicNameNecessary = false;
+
+#if defined(__linux__)
+          if (ipv4MulticastInterfaces.size() > 1)
+            {
+              //On Linux, if we have more than one MulticastUdpFace we need to specify
+              //the name of the interface
+              isNicNameNecessary = true;
+            }
+#endif
+
+          for (std::list<shared_ptr<NetworkInterfaceInfo> >::const_iterator i =
+                 ipv4MulticastInterfaces.begin();
+               i != ipv4MulticastInterfaces.end();
+               ++i)
+            {
+              const shared_ptr<NetworkInterfaceInfo>& nic = *i;
+              shared_ptr<MulticastUdpFace> newFace;
+              newFace = factory->createMulticastFace(nic->ipv4Addresses[0].to_string(),
+                                                     mcastGroup,
+                                                     mcastPort,
+                                                     isNicNameNecessary ? nic->name : "");
+
+              addCreatedFaceToForwarder(newFace);
+            }
         }
     }
 }