[gssdp] client: Do not accept multicast packets on lo



commit 7ecb930d93714b34e751d63a1db47028a2bbf7fe
Author: Jens Georg <mail jensge org>
Date:   Sun Sep 18 08:50:45 2022 +0200

    client: Do not accept multicast packets on lo
    
    All multicast packets are also received on lo. If we answer those, we
    cause the remote site to receive locations for the wrong addresses on
    their lo interface.
    
    This was added because of missing announcements previously, not sure
    what exactly has changed since then
    
    Fixes #24

 libgssdp/gssdp-client.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index 60aeb06..a81f81d 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -1726,19 +1726,29 @@ socket_source_cb (GSSDPSocketSource *socket_source, GSSDPClient *client)
                                 msg = GSSDP_PKTINFO6_MESSAGE (messages[i]);
                                 msg_ifindex = gssdp_pktinfo6_message_get_ifindex (msg);
                                 local_addr = gssdp_pktinfo6_message_get_local_addr (msg);
-                        } else
+                        } else {
                                 continue;
+                        }
 
                         /* message needs to be on correct interface or on
                          * loopback (as kernel can be smart and route things
                          * there even if sent to another network) */
-                        if (!((msg_ifindex == priv->device.index ||
-                               msg_ifindex == LOOPBACK_IFINDEX) &&
-                              (g_inet_address_equal (local_addr,
-                                                     priv->device.host_addr) ||
-                               g_inet_address_equal (local_addr, group_addr)))) {
-                                goto out;
-                        } else {
+                        if (g_inet_address_equal (local_addr, group_addr)) {
+                                // This is a multicast packet. If the index is not our index, ignore
+                                if (msg_ifindex != priv->device.index) {
+                                        goto out;
+                                }
+                                break;
+                        }
+
+                        if (g_inet_address_equal (local_addr,
+                                                  priv->device.host_addr)) {
+                                // This is a "normal" packet. We can receive those
+
+                                if (msg_ifindex != priv->device.index &&
+                                    msg_ifindex != LOOPBACK_IFINDEX) {
+                                        goto out;
+                                }
                                 break;
                         }
                 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]