diff --git a/include/net/buf.h b/include/net/buf.h index a2d5196b75c..931eedd0b52 100644 --- a/include/net/buf.h +++ b/include/net/buf.h @@ -399,9 +399,6 @@ struct net_buf { /** List pointer used for TCP retransmit buffering */ sys_snode_t sent_list; - /** Size of the user data associated with this buffer. */ - uint16_t user_data_size; - /** Reference count. */ uint8_t ref; diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 7ff334762e1..6217f7046a2 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -876,7 +876,7 @@ int bt_conn_send(struct bt_conn *conn, struct net_buf *buf) { BT_DBG("conn handle %u buf len %u", conn->handle, buf->len); - if (buf->user_data_size < BT_BUF_USER_DATA_MIN) { + if (buf->pool->user_data_size < BT_BUF_USER_DATA_MIN) { BT_ERR("Too small user data size"); net_buf_unref(buf); return -EINVAL; diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 56e27cc0f18..0b6777a1a75 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -3458,7 +3458,7 @@ int bt_recv(struct net_buf *buf) BT_DBG("buf %p len %u", buf, buf->len); - if (buf->user_data_size < BT_BUF_USER_DATA_MIN) { + if (buf->pool->user_data_size < BT_BUF_USER_DATA_MIN) { BT_ERR("Too small user data size"); net_buf_unref(buf); return -EINVAL; diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index a984d4ff259..f3c9d6c2dc7 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -1553,9 +1553,9 @@ static struct net_buf *l2cap_chan_create_seg(struct bt_l2cap_le_chan *ch, } /* Segment if there is no space in the user_data */ - if (buf->user_data_size < BT_BUF_USER_DATA_MIN) { + if (buf->pool->user_data_size < BT_BUF_USER_DATA_MIN) { BT_WARN("Too small buffer user_data_size %u", - buf->user_data_size); + buf->pool->user_data_size); goto segment; } diff --git a/subsys/net/buf.c b/subsys/net/buf.c index 7ad3a61e1ad..afa0a269e55 100644 --- a/subsys/net/buf.c +++ b/subsys/net/buf.c @@ -64,7 +64,6 @@ static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool, buf->pool = pool; buf->size = pool->buf_size; - buf->user_data_size = pool->user_data_size; return buf; } diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c index d93ea0c8248..6a2f050ec07 100644 --- a/subsys/net/ip/net_core.c +++ b/subsys/net/ip/net_core.c @@ -586,9 +586,9 @@ static inline enum net_verdict process_data(struct net_buf *buf, * contains user data. The rest of the fragments should * be data fragments without user data. */ - if (!buf->frags || !buf->user_data_size) { + if (!buf->frags || !buf->pool->user_data_size) { NET_DBG("Corrupted buffer (frags %p, data size %u)", - buf->frags, buf->user_data_size); + buf->frags, buf->pool->user_data_size); NET_STATS(++net_stats.processing_error); return NET_DROP; diff --git a/tests/net/buf/src/main.c b/tests/net/buf/src/main.c index a6a66b6fedf..e5016a12578 100644 --- a/tests/net/buf/src/main.c +++ b/tests/net/buf/src/main.c @@ -238,7 +238,7 @@ static void net_buf_test_4(void) frag = buf->frags; - assert_equal(frag->user_data_size, 0, "Invalid user data size"); + assert_equal(frag->pool->user_data_size, 0, "Invalid user data size"); i = 0; while (frag) {