Skip to content

Commit 0944bd4

Browse files
committed
mcproxy: handle special multicast addresses
* Add handling of special IPv4 and IPv6 mcast addresses while proxying. Signed-off-by: Mohd Husaam Mehdi <[email protected]>
1 parent 27b84ec commit 0944bd4

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
diff --git a/mcproxy/include/utils/mc_socket.hpp b/mcproxy/include/utils/mc_socket.hpp
2+
index dee287d..f547a7a 100644
3+
--- a/mcproxy/include/utils/mc_socket.hpp
4+
+++ b/mcproxy/include/utils/mc_socket.hpp
5+
@@ -66,6 +66,12 @@
6+
#define IPV6_ALL_SITE_LOCAL_ROUTER "ff05::2" //All routers on the site local network segment [RFC4291]
7+
#define IPV6_ALL_MLDv2_CAPABLE_ROUTERS "ff02::16" //All MLDv2-capable routers [RFC3810]
8+
#define IPV6_ALL_PIM_ROUTERS "ff02::d" //All PIM Routers
9+
+#define IPV6_UPNP_ADDR "ff02::f" //All PIM Routers
10+
+#define IPV6_MCAST_DNS_ADDR "ff02::fb" //All MCAST DNS
11+
+#define IPV6_NTP_ADDR "ff02::101" //NTP
12+
+#define IPV6_ALL_DHCP_AGENT_ADDR "ff02::1:2" //All DHCP agents
13+
+#define IPV6_ALL_DHCP_SERVER_ADDR "ff05::1:3" //All DHCP server
14+
+#define IPV6_ALL_SNOOPER_ADDR "ff02::6a" //All snooper
15+
16+
/**
17+
* @brief Wrapper for a multicast socket.
18+
diff --git a/mcproxy/src/proxy/proxy_instance.cpp b/mcproxy/src/proxy/proxy_instance.cpp
19+
index 7f98c59..59af68e 100644
20+
--- a/mcproxy/src/proxy/proxy_instance.cpp
21+
+++ b/mcproxy/src/proxy/proxy_instance.cpp
22+
@@ -865,10 +865,25 @@ void proxy_instance::add_multicast_entry(std::string device_name, addr_storage g
23+
from arp table, bridge mdb and fdb tables */
24+
25+
// Filter multicast router service groups from multicast stats
26+
- if (gaddr.to_string() == IPV4_ALL_IGMP_ROUTERS_ADDR
27+
- || gaddr.to_string() == IPV4_IGMPV3_ADDR
28+
- || gaddr.to_string() == IPV6_ALL_NODE_LOCAL_ROUTER
29+
+ size_t found_ip6 = gaddr.to_string().find(IPV6_ALL_NODES_ADDR);
30+
+ if (found_ip6 != std::string::npos)
31+
+ return;
32+
+
33+
+ size_t found_ip4 = gaddr.to_string().find("224.0.0.");
34+
+ if (found_ip4 != std::string::npos)
35+
+ return;
36+
+
37+
+ if (gaddr.to_string() == IPV6_ALL_NODE_LOCAL_ROUTER
38+
|| gaddr.to_string() == IPV6_ALL_SITE_LOCAL_ROUTER
39+
+ || gaddr.to_string() == IPV6_ALL_NODES_ADDR
40+
+ || gaddr.to_string() == IPV6_ALL_LINK_LOCAL_ROUTER
41+
+ || gaddr.to_string() == IPV6_ALL_PIM_ROUTERS
42+
+ || gaddr.to_string() == IPV6_UPNP_ADDR
43+
+ || gaddr.to_string() == IPV6_MCAST_DNS_ADDR
44+
+ || gaddr.to_string() == IPV6_NTP_ADDR
45+
+ || gaddr.to_string() == IPV6_ALL_SNOOPER_ADDR
46+
+ || gaddr.to_string() == IPV6_ALL_DHCP_AGENT_ADDR
47+
+ || gaddr.to_string() == IPV6_ALL_DHCP_SERVER_ADDR
48+
|| gaddr.to_string() == IPV6_ALL_MLDv2_CAPABLE_ROUTERS) {
49+
return;
50+
}
51+
diff --git a/mcproxy/src/proxy/querier.cpp b/mcproxy/src/proxy/querier.cpp
52+
index a87056e..165f59a 100644
53+
--- a/mcproxy/src/proxy/querier.cpp
54+
+++ b/mcproxy/src/proxy/querier.cpp
55+
@@ -100,27 +100,32 @@ unsigned int querier::get_effective_max_groups() const
56+
return 0;
57+
58+
if (is_IPv4(m_db.querier_version_mode)) {
59+
- auto router_group = m_db.group_info.find(addr_storage(IPV4_ALL_IGMP_ROUTERS_ADDR));
60+
- if (router_group != end(m_db.group_info)) {
61+
- max_groups++;
62+
- }
63+
- router_group = m_db.group_info.find(addr_storage(IPV4_IGMPV3_ADDR));
64+
- if (router_group != end(m_db.group_info)) {
65+
- max_groups++;
66+
+ for (auto & e : m_db.group_info) {
67+
+ size_t found_ip4 = e.first.to_string().find("224.0.0.");
68+
+ if (found_ip4 != std::string::npos)
69+
+ max_groups++;
70+
}
71+
} else if (is_IPv6(m_db.querier_version_mode)) {
72+
- auto router_group = m_db.group_info.find(addr_storage(IPV6_ALL_NODE_LOCAL_ROUTER));
73+
- if (router_group != end(m_db.group_info)) {
74+
- max_groups++;
75+
- }
76+
- router_group = m_db.group_info.find(addr_storage(IPV6_ALL_SITE_LOCAL_ROUTER));
77+
- if (router_group != end(m_db.group_info)) {
78+
- max_groups++;
79+
- }
80+
- router_group = m_db.group_info.find(addr_storage(IPV6_ALL_MLDv2_CAPABLE_ROUTERS));
81+
- if (router_group != end(m_db.group_info)) {
82+
- max_groups++;
83+
- }
84+
+ for (auto & e : m_db.group_info) {
85+
+ if (e.first.to_string() == IPV6_ALL_NODE_LOCAL_ROUTER
86+
+ || e.first.to_string() == IPV6_ALL_SITE_LOCAL_ROUTER
87+
+ || e.first.to_string() == IPV6_ALL_NODES_ADDR
88+
+ || e.first.to_string() == IPV6_ALL_LINK_LOCAL_ROUTER
89+
+ || e.first.to_string() == IPV6_ALL_PIM_ROUTERS
90+
+ || e.first.to_string() == IPV6_UPNP_ADDR
91+
+ || e.first.to_string() == IPV6_MCAST_DNS_ADDR
92+
+ || e.first.to_string() == IPV6_NTP_ADDR
93+
+ || e.first.to_string() == IPV6_ALL_SNOOPER_ADDR
94+
+ || e.first.to_string() == IPV6_ALL_DHCP_AGENT_ADDR
95+
+ || e.first.to_string() == IPV6_ALL_DHCP_SERVER_ADDR
96+
+ || e.first.to_string() == IPV6_ALL_MLDv2_CAPABLE_ROUTERS) {
97+
+ max_groups++;
98+
+ }
99+
+
100+
+ size_t found_ip6 = e.first.to_string().find(IPV6_ALL_NODES_ADDR);
101+
+ if (found_ip6 != std::string::npos)
102+
+ max_groups++;
103+
+ }
104+
} else {
105+
HC_LOG_ERROR("unknown ip version");
106+
}

0 commit comments

Comments
 (0)