This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9e0852c6a4ee44c8d1fa2e9c8121257cdcf24533 Author: gaohedong <[email protected]> AuthorDate: Sat Mar 15 22:24:05 2025 +0800 net/pkt: delete the read-back mechanism in pkt stack When app send a pkt-packet, then it will read back it and case some problem. Connection should not read back the message sent by itself. Signed-off-by: gaohedong <[email protected]> --- net/pkt/pkt.h | 2 ++ net/pkt/pkt_input.c | 8 ++++++++ net/pkt/pkt_sendmsg.c | 13 ++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/net/pkt/pkt.h b/net/pkt/pkt.h index 69102847784..4b9e0d0deed 100644 --- a/net/pkt/pkt.h +++ b/net/pkt/pkt.h @@ -74,6 +74,8 @@ struct pkt_conn_s */ struct iob_queue_s readahead; /* Read-ahead buffering */ + + FAR struct iob_s *pendiob; /* The iob currently being sent */ }; /**************************************************************************** diff --git a/net/pkt/pkt_input.c b/net/pkt/pkt_input.c index 230aaf03695..d2d7611b981 100644 --- a/net/pkt/pkt_input.c +++ b/net/pkt/pkt_input.c @@ -156,6 +156,14 @@ static int pkt_in(FAR struct net_driver_s *dev) { uint16_t flags; + if (conn->pendiob == dev->d_iob) + { + /* Do not read back the packet sent by oneself */ + + conn->pendiob = NULL; + return OK; + } + #if defined(CONFIG_NET_TIMESTAMP) && !defined(CONFIG_ARCH_HAVE_NETDEV_TIMESTAMP) /* Get system as timestamp if no hardware timestamp */ diff --git a/net/pkt/pkt_sendmsg.c b/net/pkt/pkt_sendmsg.c index 3e9d670d02d..7d153d67cf8 100644 --- a/net/pkt/pkt_sendmsg.c +++ b/net/pkt/pkt_sendmsg.c @@ -60,6 +60,7 @@ struct send_s { FAR struct socket *snd_sock; /* Points to the parent socket structure */ FAR struct devif_callback_s *snd_cb; /* Reference to callback instance */ + FAR struct pkt_conn_s *snd_conn; /* Reference to the packet connection */ sem_t snd_sem; /* Used to wake up the waiting thread */ FAR const uint8_t *snd_buffer; /* Points to the buffer of data to send */ size_t snd_buflen; /* Number of bytes in the buffer to send */ @@ -115,8 +116,9 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, goto end_wait; } - dev->d_len = dev->d_sndlen; - pstate->snd_sent = pstate->snd_buflen; + dev->d_len = dev->d_sndlen; + pstate->snd_sent = pstate->snd_buflen; + pstate->snd_conn->pendiob = dev->d_iob; /* Make sure no ARP request overwrites this ARP request. This * flag will be cleared in arp_out(). @@ -224,9 +226,10 @@ ssize_t pkt_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg, memset(&state, 0, sizeof(struct send_s)); nxsem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */ - state.snd_sock = psock; /* Socket descriptor to use */ - state.snd_buflen = len; /* Number of bytes to send */ - state.snd_buffer = buf; /* Buffer to send from */ + state.snd_sock = psock; /* Socket descriptor to use */ + state.snd_buflen = len; /* Number of bytes to send */ + state.snd_buffer = buf; /* Buffer to send from */ + state.snd_conn = psock->s_conn; /* Connection info */ if (len > 0) {
