Skip to content

Commit d7b8255

Browse files
committed
net: icmp: Send replies with timeout K_NO_WAIT
This ensure system stays operational in icmp flood situation. Signed-off-by: Cla Mattia Galliard <[email protected]>
1 parent 38d6094 commit d7b8255

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

subsys/net/ip/icmp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int send_icmpv4_echo_request(struct net_icmp_ctx *ctx,
207207
ctx->user_data = user_data;
208208
ctx->iface = iface;
209209

210-
if (net_send_data(pkt) >= 0) {
210+
if (net_try_send_data(pkt, K_NO_WAIT) >= 0) {
211211
net_stats_update_icmp_sent(iface);
212212
return 0;
213213
}
@@ -330,7 +330,7 @@ static int send_icmpv6_echo_request(struct net_icmp_ctx *ctx,
330330
ctx->user_data = user_data;
331331
ctx->iface = iface;
332332

333-
if (net_send_data(pkt) >= 0) {
333+
if (net_try_send_data(pkt, K_NO_WAIT) >= 0) {
334334
net_stats_update_icmp_sent(iface);
335335
return 0;
336336
}

subsys/net/ip/icmpv4.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ static int icmpv4_handle_echo_request(struct net_icmp_ctx *ctx,
493493
net_sprint_ipv4_addr(src),
494494
net_sprint_ipv4_addr(&ip_hdr->src));
495495

496-
if (net_send_data(reply) < 0) {
496+
if (net_try_send_data(reply, K_NO_WAIT) < 0) {
497497
goto drop;
498498
}
499499

@@ -588,7 +588,7 @@ int net_icmpv4_send_error(struct net_pkt *orig, uint8_t type, uint8_t code)
588588
net_sprint_ipv4_addr(&ip_hdr->dst),
589589
net_sprint_ipv4_addr(&ip_hdr->src));
590590

591-
if (net_send_data(pkt) >= 0) {
591+
if (net_try_send_data(pkt, K_NO_WAIT) >= 0) {
592592
net_stats_update_icmp_sent(net_pkt_iface(orig));
593593
return 0;
594594
}

subsys/net/ip/icmpv6.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int icmpv6_handle_echo_request(struct net_icmp_ctx *ctx,
169169
net_sprint_ipv6_addr(src),
170170
net_sprint_ipv6_addr(&ip_hdr->src));
171171

172-
if (net_send_data(reply) < 0) {
172+
if (net_try_send_data(reply, K_NO_WAIT) < 0) {
173173
goto drop;
174174
}
175175

@@ -319,7 +319,7 @@ int net_icmpv6_send_error(struct net_pkt *orig, uint8_t type, uint8_t code,
319319
net_sprint_ipv6_addr(src),
320320
net_sprint_ipv6_addr(&ip_hdr->src));
321321

322-
if (net_send_data(pkt) >= 0) {
322+
if (net_try_send_data(pkt, K_NO_WAIT) >= 0) {
323323
net_stats_update_icmp_sent(net_pkt_iface(pkt));
324324
return 0;
325325
}

0 commit comments

Comments
 (0)