You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/07 07:39:03 UTC
[GitHub] [incubator-nuttx-apps] XinStellaris opened a new pull request, #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
XinStellaris opened a new pull request, #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312
Signed-off-by: 田昕 <ti...@xiaomi.com>
## Summary
If Many devices begin DHCPC at the same time. Current DHCP will fail because one device will receive many dhcp packets not for it, and thus exceeds retry count.
Here I made following modification:
1. Receiving unexpected packets does not result in retry count increasing(Only recv timeout will increase retry count)
2. A bigger timeout for discover/request phase. We do want to give up if client keeps receiving useless packets.
3. More controlled way of re-send dhcp discover/request, rather than possible burst sending multiple dhcp packets.
## Impact
DHCP
## Testing
ESP32C3 tested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964766032
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
I will add the exponential backoff now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 merged pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964837000
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
remove exponential backoff
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964733423
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
In this case, we should loop in recv until the timeout
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
In this case, we should loop in recv until the timeout.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964867813
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -804,67 +811,70 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Get the ACK/NAK response to the REQUEST (or timeout) */
- result = recv(pdhcpc->sockfd, &pdhcpc->packet,
- sizeof(struct dhcp_msg), 0);
- if (result >= 0)
+ recv_begin = clock();
+ do
{
- /* Parse the response */
+ result = recv(pdhcpc->sockfd, &pdhcpc->packet,
+ sizeof(struct dhcp_msg), 0);
+ if (result >= 0)
+ {
+ /* Parse the response */
- msgtype = dhcpc_parsemsg(pdhcpc, result, presult);
+ msgtype = dhcpc_parsemsg(pdhcpc, result, presult);
- /* The ACK response means that the server has accepted
- * our request and we have the lease.
- */
+ /* The ACK response means that the server has accepted
+ * our request and we have the lease.
+ */
- if (msgtype == DHCPACK)
- {
- ninfo("Received ACK\n");
- state = STATE_HAVE_LEASE;
- }
+ if (msgtype == DHCPACK)
+ {
+ ninfo("Received ACK\n");
+ state = STATE_HAVE_LEASE;
+ }
- /* NAK means the server has refused our request. Break out of
- * this loop with state == STATE_HAVE_OFFER and send DISCOVER
- * again
- */
+ /* NAK means the server has refused our request */
- else if (msgtype == DHCPNAK)
- {
- ninfo("Received NAK\n");
- break;
- }
+ else if (msgtype == DHCPNAK)
+ {
+ ninfo("Received NAK\n");
+ return ERROR;
Review Comment:
The "goes back to send DISCOVER" was invalid since https://github.com/apache/incubator-nuttx-apps/pull/862
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964707301
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -703,6 +705,8 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
*/
retries = 0;
+ last_send = 0;
Review Comment:
remove last_send
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
don't need changedhcp_send since it is impossible to block for long time..
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -767,6 +776,14 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
return ERROR;
}
+
+ current = clock();
+
+ if (TICK2MSEC(current - last_send) >
Review Comment:
```suggestion
if (TICK2MSEC(clock() - current ) >
```
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -783,6 +800,8 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
*/
retries = 0;
+ last_send = 0;
Review Comment:
apply the same change in following code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964726827
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
The change is to prevent dhcp_send from burst send multiple discover.
If not, every time we come back here we will send a dhcp.
This is bad when we are receiving un-wanted dhcp packets, then the do-while will keep sending
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964854954
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -804,67 +811,70 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Get the ACK/NAK response to the REQUEST (or timeout) */
- result = recv(pdhcpc->sockfd, &pdhcpc->packet,
- sizeof(struct dhcp_msg), 0);
- if (result >= 0)
+ recv_begin = clock();
+ do
{
- /* Parse the response */
+ result = recv(pdhcpc->sockfd, &pdhcpc->packet,
+ sizeof(struct dhcp_msg), 0);
+ if (result >= 0)
+ {
+ /* Parse the response */
- msgtype = dhcpc_parsemsg(pdhcpc, result, presult);
+ msgtype = dhcpc_parsemsg(pdhcpc, result, presult);
- /* The ACK response means that the server has accepted
- * our request and we have the lease.
- */
+ /* The ACK response means that the server has accepted
+ * our request and we have the lease.
+ */
- if (msgtype == DHCPACK)
- {
- ninfo("Received ACK\n");
- state = STATE_HAVE_LEASE;
- }
+ if (msgtype == DHCPACK)
+ {
+ ninfo("Received ACK\n");
+ state = STATE_HAVE_LEASE;
+ }
- /* NAK means the server has refused our request. Break out of
- * this loop with state == STATE_HAVE_OFFER and send DISCOVER
- * again
- */
+ /* NAK means the server has refused our request */
- else if (msgtype == DHCPNAK)
- {
- ninfo("Received NAK\n");
- break;
- }
+ else if (msgtype == DHCPNAK)
+ {
+ ninfo("Received NAK\n");
+ return ERROR;
Review Comment:
Attention here, it was "break" before this patch.
But since it no longer goes back to send DISCOVER, I changed it to "return ERROR"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#issuecomment-1239093717
After some discussion, maybe it is better to delete all new Kconfig.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] XinStellaris commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
XinStellaris commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964759730
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -720,13 +724,18 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
/* Send the DISCOVER command */
- ninfo("Broadcast DISCOVER\n");
- if (dhcpc_sendmsg(pdhcpc, presult, DHCPDISCOVER) < 0)
+ if (last_send == 0 ||
Review Comment:
According to RFC2131: "DHCP clients are responsible for all message retransmission. The
client MUST adopt a retransmission strategy that incorporates a
randomized exponential backoff algorithm to determine the delay
between retransmissions. The delay between retransmissions SHOULD be
chosen to allow sufficient time for replies from the server to be
delivered based on the characteristics of the internetwork between
the client and the server. "
It is better to let dhcp send delay be different from recv time out. So I think recv time out shouldn't be related to send delay. That is the reason why I put a last_send here.
In the future we might need to add an exponential backoff algorithm here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1312: netutils/dhcpc:receiving unexpected packet not leading to dhcp retry.
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1312:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1312#discussion_r964921091
##########
netutils/dhcpc/dhcpc.c:
##########
@@ -680,6 +680,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
uint8_t msgtype;
int retries;
int state;
+ clock_t recv_begin;
Review Comment:
recv_begin->start/begin
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org