From ed0e5b924d8f47a04a8671dc96bd9857122b454d Mon Sep 17 00:00:00 2001 From: Sabrina Dubroca Date: Thu, 1 Oct 2026 09:57:25 +0200 Subject: [PATCH] net: strparser: remove unused abort_parser/lock/unlock callbacks The lock/unlock callbacks were introduced in 2017 (bbb03029a899 ("strparser: Generalize strparser")) and haven't been used. The abort_parser callback has existed since strp was committed (2016) and has also never been used. This patch replaces those indirections with the only possible direct call. Signed-off-by: Sabrina Dubroca Link: https://patch.msgid.link/e55bcc033317dddd47a6dfda6575c755ae7175f7.1790702233.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski --- include/net/strparser.h | 3 --- net/strparser/strparser.c | 39 +++++---------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/include/net/strparser.h b/include/net/strparser.h index 0ed73e364faa..78e8e3e12ed3 100644 --- a/include/net/strparser.h +++ b/include/net/strparser.h @@ -46,9 +46,6 @@ struct strp_callbacks { int (*read_sock)(struct strparser *strp, read_descriptor_t *desc, sk_read_actor_t recv_actor); int (*read_sock_done)(struct strparser *strp, int err); - void (*abort_parser)(struct strparser *strp, int err); - void (*lock)(struct strparser *strp); - void (*unlock)(struct strparser *strp); }; struct strp_msg { diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c index a23f4b4dfc67..b5319ed56857 100644 --- a/net/strparser/strparser.c +++ b/net/strparser/strparser.c @@ -75,7 +75,7 @@ static void strp_parser_err(struct strparser *strp, int err, desc->error = err; kfree_skb(strp->skb_head); strp->skb_head = NULL; - strp->cb.abort_parser(strp, err); + strp_abort_strp(strp, err); } static inline int strp_peek_len(struct strparser *strp) @@ -409,7 +409,7 @@ static void do_strp_work(struct strparser *strp) /* We need the read lock to synchronize with strp_data_ready. We * need the socket lock for calling strp_read_sock. */ - strp->cb.lock(strp); + lock_sock(strp->sk); if (unlikely(strp->stopped)) goto out; @@ -421,7 +421,7 @@ static void do_strp_work(struct strparser *strp) queue_work(strp_wq, &strp->work); out: - strp->cb.unlock(strp); + release_sock(strp->sk); } static void strp_work(struct work_struct *w) @@ -436,18 +436,8 @@ static void strp_msg_timeout(struct work_struct *w) /* Message assembly timed out */ STRP_STATS_INCR(strp->stats.msg_timeouts); - strp->cb.lock(strp); - strp->cb.abort_parser(strp, -ETIMEDOUT); - strp->cb.unlock(strp); -} - -static void strp_sock_lock(struct strparser *strp) -{ lock_sock(strp->sk); -} - -static void strp_sock_unlock(struct strparser *strp) -{ + strp_abort_strp(strp, -ETIMEDOUT); release_sock(strp->sk); } @@ -455,36 +445,17 @@ int strp_init(struct strparser *strp, struct sock *sk, const struct strp_callbacks *cb) { - if (!cb || !cb->rcv_msg || !cb->parse_msg) + if (!cb || !cb->rcv_msg || !cb->parse_msg || !sk) return -EINVAL; - /* The sk (sock) arg determines the mode of the stream parser. - * - * If the sock is set then the strparser is in receive callback mode. - * The upper layer calls strp_data_ready to kick receive processing - * and strparser calls the read_sock function on the socket to - * get packets. - * - * If the sock is not set then the strparser is in general mode. - * The upper layer calls strp_process for each skb to be parsed. - */ - - if (!sk) { - if (!cb->lock || !cb->unlock) - return -EINVAL; - } - memset(strp, 0, sizeof(*strp)); strp->sk = sk; - strp->cb.lock = cb->lock ? : strp_sock_lock; - strp->cb.unlock = cb->unlock ? : strp_sock_unlock; strp->cb.rcv_msg = cb->rcv_msg; strp->cb.parse_msg = cb->parse_msg; strp->cb.read_sock = cb->read_sock; strp->cb.read_sock_done = cb->read_sock_done ? : default_read_sock_done; - strp->cb.abort_parser = cb->abort_parser ? : strp_abort_strp; INIT_DELAYED_WORK(&strp->msg_timer_work, strp_msg_timeout); INIT_WORK(&strp->work, strp_work);