Commit 0343c554 authored by Benjamin Poirier's avatar Benjamin Poirier Committed by David S. Miller

sctp: Export sctp_do_peeloff

lookup sctp_association within sctp_do_peeloff() to enable its use outside of
the sctp code with minimal knowledge of the former.
Signed-off-by: default avatarBenjamin Poirier <bpoirier@suse.de>
Acked-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8622cbd
...@@ -413,6 +413,7 @@ static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) ...@@ -413,6 +413,7 @@ static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc)
/* Look up the association by its id. */ /* Look up the association by its id. */
struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id); struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id);
int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp);
/* A macro to walk a list of skbs. */ /* A macro to walk a list of skbs. */
#define sctp_skb_for_each(pos, head, tmp) \ #define sctp_skb_for_each(pos, head, tmp) \
......
...@@ -4170,14 +4170,16 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv ...@@ -4170,14 +4170,16 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
} }
/* Helper routine to branch off an association to a new socket. */ /* Helper routine to branch off an association to a new socket. */
SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc, int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
struct socket **sockp)
{ {
struct sock *sk = asoc->base.sk; struct sctp_association *asoc = sctp_id2assoc(sk, id);
struct socket *sock; struct socket *sock;
struct sctp_af *af; struct sctp_af *af;
int err = 0; int err = 0;
if (!asoc)
return -EINVAL;
/* An association cannot be branched off from an already peeled-off /* An association cannot be branched off from an already peeled-off
* socket, nor is this supported for tcp style sockets. * socket, nor is this supported for tcp style sockets.
*/ */
...@@ -4206,13 +4208,13 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc, ...@@ -4206,13 +4208,13 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
return err; return err;
} }
EXPORT_SYMBOL(sctp_do_peeloff);
static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval, int __user *optlen) static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval, int __user *optlen)
{ {
sctp_peeloff_arg_t peeloff; sctp_peeloff_arg_t peeloff;
struct socket *newsock; struct socket *newsock;
int retval = 0; int retval = 0;
struct sctp_association *asoc;
if (len < sizeof(sctp_peeloff_arg_t)) if (len < sizeof(sctp_peeloff_arg_t))
return -EINVAL; return -EINVAL;
...@@ -4220,15 +4222,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval ...@@ -4220,15 +4222,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval
if (copy_from_user(&peeloff, optval, len)) if (copy_from_user(&peeloff, optval, len))
return -EFAULT; return -EFAULT;
asoc = sctp_id2assoc(sk, peeloff.associd); retval = sctp_do_peeloff(sk, peeloff.associd, &newsock);
if (!asoc) {
retval = -EINVAL;
goto out;
}
SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p\n", __func__, sk, asoc);
retval = sctp_do_peeloff(asoc, &newsock);
if (retval < 0) if (retval < 0)
goto out; goto out;
...@@ -4239,8 +4233,8 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval ...@@ -4239,8 +4233,8 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval
goto out; goto out;
} }
SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p newsk: %p sd: %d\n", SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n",
__func__, sk, asoc, newsock->sk, retval); __func__, sk, newsock->sk, retval);
/* Return the fd mapped to the new socket. */ /* Return the fd mapped to the new socket. */
peeloff.sd = retval; peeloff.sd = retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment