Skip to content

Commit

Permalink
lwip: Add patch to fix RA LLADDR processing (project-chip#29600)
Browse files Browse the repository at this point in the history
* 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 <commits@restyled.io>
  • Loading branch information
2 people authored and HunsupJung committed Oct 23, 2023
1 parent 9ae3e60 commit 33b47ba
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,8 @@ LightingApp
LightingColor
LightingState
LinkSoftwareAndDocumentationPack
lladdr
LLADDR
LocalConfigDisabled
localedef
localhost
Expand Down
8 changes: 8 additions & 0 deletions src/lwip/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/lwip/patches/nd6_lladdr_fix.patch
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 33b47ba

Please sign in to comment.