summaryrefslogtreecommitdiffstats
path: root/net/core/lwtunnel.c
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2016-10-14 11:25:36 -0700
committerDavid S. Miller <davem@davemloft.net>2016-10-15 17:33:41 -0400
commit1104d9ba443a3972052ea4eaa01e51f9ee084652 (patch)
tree3541ac4778bb5286fb77c7eed4c9ac914fd96ad4 /net/core/lwtunnel.c
parent02dc7658c711e5cb099db476c501ce898591bfc9 (diff)
downloadlinux-1104d9ba443a3972052ea4eaa01e51f9ee084652.tar.gz
linux-1104d9ba443a3972052ea4eaa01e51f9ee084652.tar.bz2
linux-1104d9ba443a3972052ea4eaa01e51f9ee084652.zip
lwtunnel: Add destroy state operation
Users of lwt tunnels may set up some secondary state in build_state function. Add a corresponding destroy_state function to allow users to clean up state. This destroy state function is called from lwstate_free. Also, we now free lwstate using kfree_rcu so user can assume structure is not freed before rcu. Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/lwtunnel.c')
-rw-r--r--net/core/lwtunnel.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
index e5f84c26ba1a..88fd64250b02 100644
--- a/net/core/lwtunnel.c
+++ b/net/core/lwtunnel.c
@@ -130,6 +130,19 @@ int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
}
EXPORT_SYMBOL(lwtunnel_build_state);
+void lwtstate_free(struct lwtunnel_state *lws)
+{
+ const struct lwtunnel_encap_ops *ops = lwtun_encaps[lws->type];
+
+ if (ops->destroy_state) {
+ ops->destroy_state(lws);
+ kfree_rcu(lws, rcu);
+ } else {
+ kfree(lws);
+ }
+}
+EXPORT_SYMBOL(lwtstate_free);
+
int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate)
{
const struct lwtunnel_encap_ops *ops;