-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[components][net][lwip][port] Fix next-hop finding in lwip_ip4_route_src. #7504
[components][net][lwip][port] Fix next-hop finding in lwip_ip4_route_src. #7504
Conversation
We should compare source IP address and netif IP address with netmask at the same time. Original implementation always return default netif to caller.
components/net/lwip/port/sys_arch.c
Outdated
@@ -684,15 +684,15 @@ struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src) | |||
/* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */ | |||
if (src != NULL) | |||
{ | |||
if (ip4_addr_cmp(src, netif_ip4_addr(netif))) | |||
if (ip4_addr_netcmp(src, netif_ip4_addr(netif), netif_ip4_netmask(netif))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这一步的src具体是谁?根据之前的经验发现src其实就是来自某个netif的addr,所以必然会出现src==netif->addr。而在多网卡的情况下,如果存在多个子网相同的情况ip4_addr_netcmp将取决于链表中的靠前的netif网卡对象。
所以请教一下lwip_ip4_route_src的真实意图到底是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按我的理解是src匹配路由的规则就是相当于socket 的bind操作。
而如果没有socket的bind操作的话,其实只要在此函数的末尾不要让他返回default对象,而是返回NULl就行了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree and tested.
已修改成 route_src search 不到就回傳NULL; 後面還是有一個 search dest ip address 的 ip routing。
netdev_ping should execute with specified networking interface, not default_interface first.
Return NULL if have no matching in lwip_ip4_route_src. This reverts commit 8958093.
Thanks. |
拉取/合并请求描述:(PR description)
[
Original implementation always return default netif to caller.
We should compare source IP address and netif IP address with netmask at the same time.
Tested on multi-ethernet cards on Nuvoton platform.
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up