diff options
author | Tom Parkin <tparkin@katalix.com> | 2013-03-19 02:11:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-20 12:10:39 -0400 |
commit | 48f72f92b31431c40279b0fba6c5588e07e67d95 (patch) | |
tree | 7a5aaf6723d503ae6ea56290b457f42c3ebd63e6 /net | |
parent | 02d13ed5f94af38c37d1abd53462fe48d78bcc9d (diff) |
l2tp: add session reorder queue purge function to core
If an l2tp session is deleted, it is necessary to delete skbs in-flight
on the session's reorder queue before taking it down.
Rather than having each pseudowire implementation reaching into the
l2tp_session struct to handle this itself, provide a function in l2tp_core to
purge the session queue.
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/l2tp/l2tp_core.c | 17 | ||||
-rw-r--r-- | net/l2tp/l2tp_core.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index e841ef2a68a5..69c316dd02dc 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -829,6 +829,23 @@ discard: | |||
829 | } | 829 | } |
830 | EXPORT_SYMBOL(l2tp_recv_common); | 830 | EXPORT_SYMBOL(l2tp_recv_common); |
831 | 831 | ||
832 | /* Drop skbs from the session's reorder_q | ||
833 | */ | ||
834 | int l2tp_session_queue_purge(struct l2tp_session *session) | ||
835 | { | ||
836 | struct sk_buff *skb = NULL; | ||
837 | BUG_ON(!session); | ||
838 | BUG_ON(session->magic != L2TP_SESSION_MAGIC); | ||
839 | while ((skb = skb_dequeue(&session->reorder_q))) { | ||
840 | atomic_long_inc(&session->stats.rx_errors); | ||
841 | kfree_skb(skb); | ||
842 | if (session->deref) | ||
843 | (*session->deref)(session); | ||
844 | } | ||
845 | return 0; | ||
846 | } | ||
847 | EXPORT_SYMBOL_GPL(l2tp_session_queue_purge); | ||
848 | |||
832 | /* Internal UDP receive frame. Do the real work of receiving an L2TP data frame | 849 | /* Internal UDP receive frame. Do the real work of receiving an L2TP data frame |
833 | * here. The skb is not on a list when we get here. | 850 | * here. The skb is not on a list when we get here. |
834 | * Returns 0 if the packet was a data packet and was successfully passed on. | 851 | * Returns 0 if the packet was a data packet and was successfully passed on. |
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index b0861f68a10b..d40713d105fc 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h | |||
@@ -246,6 +246,7 @@ extern struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunne | |||
246 | extern int l2tp_session_delete(struct l2tp_session *session); | 246 | extern int l2tp_session_delete(struct l2tp_session *session); |
247 | extern void l2tp_session_free(struct l2tp_session *session); | 247 | extern void l2tp_session_free(struct l2tp_session *session); |
248 | extern void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags, int length, int (*payload_hook)(struct sk_buff *skb)); | 248 | extern void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags, int length, int (*payload_hook)(struct sk_buff *skb)); |
249 | extern int l2tp_session_queue_purge(struct l2tp_session *session); | ||
249 | extern int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb); | 250 | extern int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb); |
250 | 251 | ||
251 | extern int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len); | 252 | extern int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len); |