Skip to content

net_if_tx sends a 0 Reference counter(pkt->ref == 0) packet #8131

@mazhenke

Description

@mazhenke

Hi,
I am an engineer from ARM china, and I am using Zephyr for some network demo, and it seems I run into a zephyr network issue, please help to have a check.

My test is a socket API based stress test, descriptions as bellow:

  1. On my PC, I ran a socket echo server, which simply did the following loop:
    connect -> receive -> send -> receive -> send -> ... ... -> receive -> send -> close
  2. On my board (nucleo_f429zi) I have implemented a sample echo client loop using socket APIs:
    a. sock = socket(xxx) // using AF_INET and SOCK_STREAM
    b. ret = connect(socket, xxx,xxx)
    c. while (1) {
    ret = send(xxx)
    ret = recv(xxx)
    }
    d. close(sock)
  3. In the project configurations, I only enabled IPV4 (CONFIG_NET_IPV6=n), and enabled some net debug options(CONFIG_NET_LOG=y, CONFIG_SYS_LOG_NET_LEVEL=4), and some other configurations which I think it is not related with this issue.

And also I add a assert at
static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
function in net_if.c file :

**NET_ASSERT(pkt->ref != 0);
if (0 == pkt->ref) {
    while (1);
}**

and my stress test ran into the assert, UART log:


[net/ethernet] [DBG] ethernet_send: (0x200044f4): Found ARP entry, sending pkt 0x2000615c to iface 0x2000d6a0
[net/core] [DBG] processing_data: (0x200044f4): Consumed pkt 0x20005bb8
[net/pkt] [DBG] net_pkt_print: (0x200044f4): TX 13 RX 13 RDATA 32 TDATA 35
[net/if] [DBG] net_if_tx: (0x2000457c): Processing (pkt 0x2000615c, data len 40, prio 0, ref: 1) network packet
[net/pkt] [DBG] net_pkt_unref_debug: (0x2000457c): TX [13] pkt 0x2000615c ref 0 frags 0x20007708 (eth_tx():123)
[net/pkt] [DBG] net_pkt_unref_debug: (0x2000457c): TDATA (tx_bufs) [35] frag 0x20007708 ref 0 frags 0x00000000 (eth_tx():123)
[net/pkt] [DBG] net_pkt_frag_unref_debug: (0x2000457c): TDATA (tx_bufs) [35] frag 0x20007708 ref 0 (net_pkt_unref_debug():802)
[net/if] [DBG] net_if_tx: (0x2000457c): Calling context send cb 0x20003ac8 token 0x00000000 status 0
BG] find_entry: (0x20005004): [0] iface 0x2000d6a0 dst 192.168.1.101 ll 00:80:E1:D5:8F:62 pending 0x00000000
[net/arp] [DBG] net_arp_prepare: (0x20005004): ARP using ll 00:80:E1:D5:8F:62 for IP 57.76.0.8
[net/ethernet] [DBG] ethernet_send: (0x20005004): Found ARP entry, sending pkt 0x2000615c to iface 0x2000d6a0
[net/if] [DBG] net_if_tx: (0x2000457c): Processing (pkt 0x2000615c, data len 268, prio 0, **ref: 0**) network packet
**[net/if] [ERR] net_if_tx: {assert: 'pkt->ref != 0' failed}**

Please have a check, thanks a lot!

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions