-
Notifications
You must be signed in to change notification settings - Fork 28
app: PPP fixes for recovery #304
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ linkname nrf91 | |
| local | ||
| passive | ||
| persist | ||
| holdoff 5 | ||
| holdoff 10 | ||
| nodetach | ||
| noauth | ||
| noipdefault | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,9 +46,6 @@ static struct modem_pipe *ppp_urc_pipe; | |
| static struct k_thread ppp_data_passing_thread_id; | ||
| static k_timepoint_t ppp_pdn_timeout; | ||
| static K_THREAD_STACK_DEFINE(ppp_data_passing_thread_stack, KB(2)); | ||
| static void ppp_data_passing_thread(void*, void*, void*); | ||
| static void sm_ppp_activate_pdp_dwork_fn(struct k_work *work); | ||
| static K_WORK_DELAYABLE_DEFINE(activate_pdp_dwork, sm_ppp_activate_pdp_dwork_fn); | ||
|
|
||
| enum ppp_action { | ||
| PPP_START, | ||
|
|
@@ -104,6 +101,13 @@ const char *const ppp_socket_names[PPP_FDS_COUNT] = { | |
| }; | ||
| static int ppp_fds[PPP_FDS_COUNT] = { -1, -1, -1 }; | ||
|
|
||
| /* Forward declarations */ | ||
| static void ppp_data_passing_thread(void*, void*, void*); | ||
| static void sm_ppp_activate_pdp_dwork_fn(struct k_work *work); | ||
| static int ppp_stop(enum ppp_reason reason); | ||
| static void ppp_cmd_fail_return_to_at_mode(void); | ||
| static K_WORK_DELAYABLE_DEFINE(activate_pdp_dwork, sm_ppp_activate_pdp_dwork_fn); | ||
|
|
||
| static const char *ppp_action_str(enum ppp_action action) | ||
| { | ||
| switch (action) { | ||
|
|
@@ -374,13 +378,7 @@ static int ppp_start(void) | |
| return 0; | ||
|
|
||
| error: | ||
| ppp_state = PPP_STATE_STOPPED; | ||
|
|
||
| if (ppp_pipe) { | ||
| modem_ppp_release(&ppp_module); | ||
| sm_at_host_attach(ppp_pipe); | ||
| } | ||
| ppp_pipe = NULL; | ||
| ppp_stop(PPP_REASON_ERROR); | ||
| return ret; | ||
| } | ||
|
|
||
|
|
@@ -399,6 +397,7 @@ static int ppp_stop(enum ppp_reason reason) | |
| } | ||
|
|
||
| ppp_state = PPP_STATE_STOPPING; | ||
| close_ppp_sockets(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason to make this earlier? To close them even if the interface closure fails? Could there still be data coming when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was suspecting that these sockets would have been one reason why closing the interface fails. They keep forwarding traffic, so it can cumulate data and block the LCP messages going through. I'm unsure if there was any real effect of this after all, but it does not seem to break anything doing it in this order. |
||
|
|
||
| if (sm_ppp_keep_pipe_attached) { | ||
| switch (reason) { | ||
|
|
@@ -415,13 +414,19 @@ static int ppp_stop(enum ppp_reason reason) | |
| at_monitor_pause(&sm_ppp_on_cgev); | ||
| } | ||
|
|
||
| /* Bring the interface down before releasing pipes and carrier. | ||
| * This is needed for LCP to notify the remote endpoint that the link is going down. | ||
| */ | ||
| int ret = net_if_down(ppp_iface); | ||
| if (net_if_is_admin_up(ppp_iface)) { | ||
| /* Bring the interface down before releasing pipes and carrier. | ||
| * This is needed for LCP to notify the remote endpoint that the link is going down. | ||
| */ | ||
| int ret = net_if_down(ppp_iface); | ||
|
|
||
| if (ret) { | ||
| LOG_WRN("Failed to bring PPP interface down (%d).", ret); | ||
| if (ret) { | ||
| LOG_WRN("Failed to bring PPP interface down (%d).", ret); | ||
| /* Retry later */ | ||
| net_if_dormant_on(ppp_iface); | ||
| delegate_ppp_event(PPP_STOP, reason); | ||
| return ret; | ||
| } | ||
| } | ||
|
|
||
| modem_ppp_release(&ppp_module); | ||
|
|
@@ -436,8 +441,6 @@ static int ppp_stop(enum ppp_reason reason) | |
| net_if_carrier_off(ppp_iface); | ||
| net_if_dormant_on(ppp_iface); | ||
|
|
||
| close_ppp_sockets(); | ||
|
|
||
| ppp_state = PPP_STATE_STOPPED; | ||
| send_status_notification(); | ||
|
|
||
|
|
@@ -692,7 +695,7 @@ static int sm_ppp_init(void) | |
| k_thread_create(&ppp_data_passing_thread_id, ppp_data_passing_thread_stack, | ||
| K_THREAD_STACK_SIZEOF(ppp_data_passing_thread_stack), | ||
| ppp_data_passing_thread, NULL, NULL, NULL, | ||
| K_PRIO_COOP(10), 0, K_NO_WAIT); | ||
| K_LOWEST_APPLICATION_THREAD_PRIO, 0, K_NO_WAIT); | ||
| k_thread_name_set(&ppp_data_passing_thread_id, "ppp_data_passing"); | ||
|
|
||
| ppp_iface = modem_ppp_get_iface(&ppp_module); | ||
|
|
@@ -933,6 +936,7 @@ static void ppp_data_passing_thread(void*, void*, void*) | |
| } else { | ||
| LOG_DBG("Connection down. Stop."); | ||
| } | ||
| ppp_state = PPP_STATE_STOPPING; | ||
| delegate_ppp_event(PPP_STOP, PPP_REASON_NETWORK); | ||
| continue; | ||
| } | ||
|
|
@@ -975,7 +979,7 @@ static void ppp_data_passing_thread(void*, void*, void*) | |
| LOG_ERR("Only sent %zd out of %zd bytes to %s socket.", | ||
| send_ret, len, ppp_socket_names[dst]); | ||
| } else { | ||
| LOG_DBG("Forwarded %zd bytes to %s socket.", | ||
| LOG_DBG_RATELIMIT_RATE(5000, "Forwarded %zd bytes to %s socket.", | ||
| send_ret, ppp_socket_names[dst]); | ||
| } | ||
| } | ||
|
|
||
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.