Skip to content

net: ip: Frequent 4G/5G switching triggers rs_timeout infinite loop, causing WDT exception #77325

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

Closed
AndyKauo opened this issue Aug 21, 2024 · 5 comments · Fixed by #88957
Closed
Assignees
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@AndyKauo
Copy link

Is your enhancement proposal related to a problem? Please describe.

The process of frequently switching between 4G and 5G triggers network interface up and down events, as well as initiates the RSRA flow of IPv6. When the network interface goes up, the function net_if_start_rs() appends rs_node to the list using sys_slist_append. However, it may add the same node to the linked list multiple times (rs_node = rs_node.next), because Z_GENLIST_APPEND does not check if the same rs_node is already added, resulting in an infinite loop in rs_timeout() in net_if.c.

Links to relevant code:

Describe the solution you'd like

There are two solutions as follows:

  1. Modify the network flow of notify_iface_down() to add net_if_stop_rs(iface) at the end. This ensures the corresponding node is removed.
static void notify_iface_down(struct net_if *iface)
{
    struct net_if_link_cb *link, *tmp;

    SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&link_callbacks, link, tmp, node) {
        if (link->cb->iface_down) {
            link->cb->iface_down(iface, link->user_data);
        }
    }

+   net_if_stop_rs(iface); // Ensure the corresponding node is removed
}
  1. Modify Z_GENLIST_APPEND () to include a check for the new node's validity. We also found that Linux performs the same check in list.h on kernel.org as well.
#define Z_GENLIST_APPEND(__lname, __nname)				\
	static inline void						\
	sys_ ## __lname ## _append(sys_ ## __lname ## _t *list,		\
				   sys_ ## __nname ## _t *node)		\
	{								\
		z_ ## __nname ## _next_set(node, NULL);			\
									\
		if (sys_ ## __lname ## _peek_tail(list) == NULL) {	\
			z_ ## __lname ## _tail_set(list, node);		\
			z_ ## __lname ## _head_set(list, node);		\
+		} else if (sys_ ## __lname ## _peek_tail(list) != node) { \
			z_ ## __nname ## _next_set(			\
				sys_ ## __lname ## _peek_tail(list),	\
				node);					\
			z_ ## __lname ## _tail_set(list, node);		\
		}							\
	}
@AndyKauo AndyKauo added the Enhancement Changes/Updates/Additions to existing features label Aug 21, 2024
Copy link

Hi @AndyKauo! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@jukkar
Copy link
Member

jukkar commented Aug 21, 2024

2. Modify Z_GENLIST_APPEND () to include a check for the new node's validity. We also found that Linux performs the same check in list.h on kernel.org as well.

Could you please send a PR having this solution as it is a more general one.

@AndyKauo
Copy link
Author

AndyKauo commented Aug 21, 2024

Thank you for your feedback and for accepting my suggestion. I would love to submit a pull request with the proposed changes. However, due to firewall restrictions on my company's network, I am currently unable to create a PR. I will need to wait until the weekend to upload the changes from home.

@AndyKauo
Copy link
Author

Hi @jukkar @rlubos
Would it be possible for you to help submit this PR? I'm still experiencing firewall issues and would greatly appreciate your assistance. Thank you very much.

#define Z_GENLIST_APPEND(__lname, __nname)				\
	static inline void						\
	sys_ ## __lname ## _append(sys_ ## __lname ## _t *list,		\
				   sys_ ## __nname ## _t *node)		\
	{								\
		z_ ## __nname ## _next_set(node, NULL);			\
									\
		if (sys_ ## __lname ## _peek_tail(list) == NULL) {	\
			z_ ## __lname ## _tail_set(list, node);		\
			z_ ## __lname ## _head_set(list, node);		\
+		} else if (sys_ ## __lname ## _peek_tail(list) != node) { \
			z_ ## __nname ## _next_set(			\
				sys_ ## __lname ## _peek_tail(list),	\
				node);					\
			z_ ## __lname ## _tail_set(list, node);		\
		}							\
	}

@jukkar
Copy link
Member

jukkar commented Aug 23, 2024

Can't you submit the PR using HTTP endpoint in github i.e., having https://github.com./zephyrproject-rtos/zephyr.git as a git remote repo address? You can access github web UI so that URL should work ok.

As a last resort, we can certainly help, but it would be really good if you could do this yourself.

@jukkar jukkar added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug and removed Enhancement Changes/Updates/Additions to existing features labels Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants