Skip to content

Commit 392fda0

Browse files
MarkusLassilakartben
authored andcommitted
net: Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT
Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT to allow for longer timeouts. This can be used to prevent dropping packets when transmitting large amounts of data (with PPP). Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
1 parent 84d3caf commit 392fda0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

subsys/net/ip/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,12 @@ config NET_MAX_CONN
662662
The value depends on your network needs. The value
663663
should include both UDP and TCP connections.
664664

665+
config NET_CONN_PACKET_CLONE_TIMEOUT
666+
int "Timeout value in milliseconds for cloning a packet"
667+
default 100
668+
help
669+
Maximum wait time when cloning a packet for a network connection.
670+
665671
config NET_MAX_CONTEXTS
666672
int "Number of network contexts to allocate"
667673
default 6

subsys/net/ip/connection.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ LOG_MODULE_REGISTER(net_conn, CONFIG_NET_CONN_LOG_LEVEL);
3333
#include "connection.h"
3434
#include "net_stats.h"
3535

36-
/** How long to wait for when cloning multicast packet */
37-
#define CLONE_TIMEOUT K_MSEC(100)
38-
3936
/** Is this connection used or not */
4037
#define NET_CONN_IN_USE BIT(0)
4138

@@ -617,7 +614,7 @@ static enum net_verdict conn_raw_socket(struct net_pkt *pkt,
617614
NET_DBG("[%p] raw match found cb %p ud %p", conn, conn->cb,
618615
conn->user_data);
619616

620-
raw_pkt = net_pkt_clone(pkt, CLONE_TIMEOUT);
617+
raw_pkt = net_pkt_clone(pkt, K_MSEC(CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT));
621618
if (!raw_pkt) {
622619
net_stats_update_per_proto_drop(pkt_iface, proto);
623620
NET_WARN("pkt cloning failed, pkt %p dropped", pkt);
@@ -857,7 +854,8 @@ enum net_verdict net_conn_input(struct net_pkt *pkt,
857854
NET_DBG("[%p] mcast match found cb %p ud %p", conn, conn->cb,
858855
conn->user_data);
859856

860-
mcast_pkt = net_pkt_clone(pkt, CLONE_TIMEOUT);
857+
mcast_pkt = net_pkt_clone(
858+
pkt, K_MSEC(CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT));
861859
if (!mcast_pkt) {
862860
k_mutex_unlock(&conn_lock);
863861
goto drop;

0 commit comments

Comments
 (0)