ip4_canforward(): don't route multicast packets

Added LWIP_HOOK_IP4_CANFORWARD to still implement multicast routing.
See bug #52914

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Simon Goldschmidt
2018-06-12 06:45:30 +02:00
parent 1fd145fbc9
commit 6ea2483546
2 changed files with 30 additions and 3 deletions

View File

@@ -237,13 +237,19 @@ ip4_canforward(struct pbuf *p)
{
u32_t addr = lwip_htonl(ip4_addr_get_u32(ip4_current_dest_addr()));
#ifdef LWIP_HOOK_IP4_CANFORWARD
int ret = LWIP_HOOK_IP4_CANFORWARD(p, addr);
if (ret >= 0) {
return ret;
}
#endif /* LWIP_HOOK_IP4_CANFORWARD */
if (p->flags & PBUF_FLAG_LLBCAST) {
/* don't route link-layer broadcasts */
return 0;
}
if ((p->flags & PBUF_FLAG_LLMCAST) && !IP_MULTICAST(addr)) {
/* don't route link-layer multicasts unless the destination address is an IP
multicast address */
if ((p->flags & PBUF_FLAG_LLMCAST) || IP_MULTICAST(addr)) {
/* don't route link-layer multicasts (use LWIP_HOOK_IP4_CANFORWARD instead) */
return 0;
}
if (IP_EXPERIMENTAL(addr)) {