All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Chapman <jchapman@katalix.com>
To: netdev@vger.kernel.org
Subject: [PATCH net-next 10/16] l2tp: add session_free callback
Date: Fri,  9 Feb 2018 15:00:26 +0000	[thread overview]
Message-ID: <1518188432-9245-11-git-send-email-jchapman@katalix.com> (raw)
In-Reply-To: <1518188432-9245-1-git-send-email-jchapman@katalix.com>

When a session refcount hits 0, the session is freed via
l2tp_session_free. Some pseudowires (ppp, eth) may have additional
resources to free when this happens. Add a session_free callback that
can be used by pseudowires to override the default kfree. The callback
is responsible for freeing the session.

Signed-off-by: James Chapman <jchapman@katalix.com>
---
 net/l2tp/l2tp_core.c | 7 +++++--
 net/l2tp/l2tp_core.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 869dec89ff0f..d6306ba2d78e 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1662,12 +1662,15 @@ void l2tp_session_free(struct l2tp_session *session)
 
 	BUG_ON(refcount_read(&session->ref_count) != 0);
 
+	if (session->session_free)
+		session->session_free(session);
+	else
+		kfree(session);
+
 	if (tunnel) {
 		BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
 		l2tp_tunnel_dec_refcount(tunnel);
 	}
-
-	kfree(session);
 }
 EXPORT_SYMBOL_GPL(l2tp_session_free);
 
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
index 98709086fe84..be3fa986dfd1 100644
--- a/net/l2tp/l2tp_core.h
+++ b/net/l2tp/l2tp_core.h
@@ -125,6 +125,7 @@ struct l2tp_session {
 	int (*build_header)(struct l2tp_session *session, void *buf);
 	void (*recv_skb)(struct l2tp_session *session, struct sk_buff *skb, int data_len);
 	void (*session_close)(struct l2tp_session *session);
+	void (*session_free)(struct l2tp_session *session);
 #if IS_ENABLED(CONFIG_L2TP_DEBUGFS)
 	void (*show)(struct seq_file *m, void *priv);
 #endif
-- 
1.9.1

  parent reply	other threads:[~2018-02-09 15:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 15:00 [PATCH net-next 00/16] l2tp: fix API races discovered by syzbot James Chapman
2018-02-09 15:00 ` [PATCH net-next 01/16] l2tp: update sk_user_data while holding sk_callback_lock James Chapman
2018-02-09 15:00 ` [PATCH net-next 02/16] l2tp: add RCU read lock to protect tunnel ptr in ip socket destroy James Chapman
2018-02-09 15:00 ` [PATCH net-next 03/16] l2tp: don't use inet_shutdown on tunnel destroy James Chapman
2018-02-09 15:00 ` [PATCH net-next 04/16] l2tp: refactor tunnel lifetime handling wrt its socket James Chapman
2018-02-09 15:00 ` [PATCH net-next 05/16] l2tp: use tunnel closing flag James Chapman
2018-02-09 15:00 ` [PATCH net-next 06/16] l2tp: refactor session lifetime handling James Chapman
2018-02-09 15:00 ` [PATCH net-next 07/16] l2tp: hide sessions if they are closing James Chapman
2018-02-12  3:37   ` kbuild test robot
2018-02-09 15:00 ` [PATCH net-next 08/16] l2tp: hide session from pppol2tp_sock_to_session if it is closing James Chapman
2018-02-09 15:00 ` [PATCH net-next 09/16] l2tp: refactor pppol2tp_connect James Chapman
2018-02-09 15:00 ` James Chapman [this message]
2018-02-09 15:00 ` [PATCH net-next 11/16] l2tp: do session destroy using a workqueue James Chapman
2018-02-09 15:00 ` [PATCH net-next 12/16] l2tp: simplify l2tp_tunnel_closeall James Chapman
2018-02-09 15:00 ` [PATCH net-next 13/16] l2tp: refactor ppp session cleanup paths James Chapman
2018-02-09 15:00 ` [PATCH net-next 14/16] l2tp: remove redundant sk_user_data check when creating tunnels James Chapman
2018-02-09 15:00 ` [PATCH net-next 15/16] l2tp: remove unwanted error message James Chapman
2018-02-09 15:00 ` [PATCH net-next 16/16] l2tp: make __l2tp_session_unhash internal James Chapman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518188432-9245-11-git-send-email-jchapman@katalix.com \
    --to=jchapman@katalix.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.