From 33b47ba393bd71c9d1d91a99d1196f54fd63c850 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Fri, 13 Oct 2023 22:27:48 -0400 Subject: [PATCH] lwip: Add patch to fix RA LLADDR processing (#29600) * lwip: Add patch to fix RA LLADDR processing * Fix weird spacing issue in patch. * Restyled by prettier-markdown * Add lladdr to wordlist --------- Co-authored-by: Restyled.io --- .github/.wordlist.txt | 2 ++ src/lwip/patches/README.md | 8 ++++++++ src/lwip/patches/nd6_lladdr_fix.patch | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/lwip/patches/nd6_lladdr_fix.patch diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index 4486fdafe19d48..f16d617c7c6e1c 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -791,6 +791,8 @@ LightingApp LightingColor LightingState LinkSoftwareAndDocumentationPack +lladdr +LLADDR LocalConfigDisabled localedef localhost diff --git a/src/lwip/patches/README.md b/src/lwip/patches/README.md index b41708670b2ef9..cb56e7a22e5d0d 100644 --- a/src/lwip/patches/README.md +++ b/src/lwip/patches/README.md @@ -19,6 +19,14 @@ Troubleshooting: The patch uses the `ip6_addr_net_eq` function, which is a recent API change on upstream LwIP. The previous version of this function is `ip6_addr_netcmp`, so this function call may need to be replaced on older forks. +### ND6 LLADDR fix + +This patch fixes a bug where the RA processing fails if the RA includes an +LLADDR option with a hw address that is not the max length. This happens for +thread devices. + +- patch file: nd6_lladdr_fix.patch + ## Important upstream patches ### Malformed neighbor solicitation packet fix diff --git a/src/lwip/patches/nd6_lladdr_fix.patch b/src/lwip/patches/nd6_lladdr_fix.patch new file mode 100644 index 00000000000000..8ce931e01d1712 --- /dev/null +++ b/src/lwip/patches/nd6_lladdr_fix.patch @@ -0,0 +1,24 @@ +diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c +index 55b5774f..8559d69b 100644 +--- a/src/core/ipv6/nd6.c ++++ b/src/core/ipv6/nd6.c +@@ -686,14 +686,15 @@ nd6_input(struct pbuf *p, struct netif *inp) + switch (option_type) { + case ND6_OPTION_TYPE_SOURCE_LLADDR: + { +- struct lladdr_option *lladdr_opt; +- if (option_len < (ND6_LLADDR_OPTION_MIN_LENGTH + inp->hwaddr_len)) { ++ const u8_t option_type_and_length_size = 1 + 1; ++ const u8_t *addr_cursor; ++ if (option_len < (option_type_and_length_size + inp->hwaddr_len)) { + goto lenerr_drop_free_return; + } +- lladdr_opt = (struct lladdr_option *)buffer; ++ addr_cursor = buffer + option_type_and_length_size; + if ((default_router_list[i].neighbor_entry != NULL) && + (default_router_list[i].neighbor_entry->state == ND6_INCOMPLETE)) { +- SMEMCPY(default_router_list[i].neighbor_entry->lladdr, lladdr_opt->addr, inp->hwaddr_len); ++ SMEMCPY(default_router_list[i].neighbor_entry->lladdr, addr_cursor, inp->hwaddr_len); + default_router_list[i].neighbor_entry->state = ND6_REACHABLE; + default_router_list[i].neighbor_entry->counter.reachable_time = reachable_time; + }