Skip to content

Commit 794121f

Browse files
committed
net: Add onlink and forwarding check to IPv6-prepare
Deadloop happens when CONFIG_NET_ROUTING and VLAN are enabled. In function net_ipv6_prepare_for_send(), pkt->iface will be updated with net_pkt_set_iface(pkt, iface) in 2 scenarios: 1. ip_hdr->dst is onlink 2. check_route or nbr_lookup VLAN is virtual-iface which attaches to a physical-iface. Each time a packet being sent to a VLAN port will invoke twice of the net_send_data(). The 1st time, pkt->iface is set to virtual iface and the 2nd time to physical iface. However in above 2 scenarios, at the 2nd time of calling the net_send_data(), the pkt-iface will be changed back to virtual iface. The system runs into a deadloop. This can be proved by enabling CONFIG_NET_ROUTING with the VLAN sample. The main purpose for net_ipv6_prepare_for_send() is to set the right ll_dst address. If the ll_dst address is already set, then no need to go through it again. If the packet has done with the forwarding and set the ll_dst, then no need to check_route again. And, the pkt->iface will not be changed back to virtual iface. Fixes: #77402 Signed-off-by: Shrek Wang <[email protected]>
1 parent 4c6b1e5 commit 794121f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/net/ip/ipv6_nbr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,9 @@ enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt)
852852
*/
853853
if ((net_pkt_lladdr_dst(pkt)->addr &&
854854
((IS_ENABLED(CONFIG_NET_ROUTING) &&
855-
net_ipv6_is_ll_addr((struct in6_addr *)ip_hdr->dst)) ||
855+
(net_ipv6_is_ll_addr((struct in6_addr *)ip_hdr->dst) ||
856+
net_if_ipv6_addr_onlink(NULL, (struct in6_addr *)ip_hdr->dst) ||
857+
net_pkt_forwarding(pkt))) ||
856858
!IS_ENABLED(CONFIG_NET_ROUTING))) ||
857859
net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->dst) ||
858860
/* Workaround Linux bug, see:

0 commit comments

Comments
 (0)