Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 291107
b: refs/heads/master
c: 0343c55
h: refs/heads/master
i:
  291105: d24b8d8
  291103: d5499d1
v: v3
  • Loading branch information
Benjamin Poirier authored and David S. Miller committed Mar 8, 2012
1 parent f3b624f commit f907be4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b8622cbd58f345d48f683d881abe3037c60aa673
refs/heads/master: 0343c5543b1d3ffa08e6716d82afb62648b80eba
1 change: 1 addition & 0 deletions trunk/include/net/sctp/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc)
/* Look up the association by its 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. */
#define sctp_skb_for_each(pos, head, tmp) \
Expand Down
24 changes: 9 additions & 15 deletions trunk/net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
struct socket **sockp)
int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
{
struct sock *sk = asoc->base.sk;
struct sctp_association *asoc = sctp_id2assoc(sk, id);
struct socket *sock;
struct sctp_af *af;
int err = 0;

if (!asoc)
return -EINVAL;

/* An association cannot be branched off from an already peeled-off
* socket, nor is this supported for tcp style sockets.
*/
Expand Down Expand Up @@ -4206,29 +4208,21 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,

return err;
}
EXPORT_SYMBOL(sctp_do_peeloff);

static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval, int __user *optlen)
{
sctp_peeloff_arg_t peeloff;
struct socket *newsock;
int retval = 0;
struct sctp_association *asoc;

if (len < sizeof(sctp_peeloff_arg_t))
return -EINVAL;
len = sizeof(sctp_peeloff_arg_t);
if (copy_from_user(&peeloff, optval, len))
return -EFAULT;

asoc = sctp_id2assoc(sk, peeloff.associd);
if (!asoc) {
retval = -EINVAL;
goto out;
}

SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p\n", __func__, sk, asoc);

retval = sctp_do_peeloff(asoc, &newsock);
retval = sctp_do_peeloff(sk, peeloff.associd, &newsock);
if (retval < 0)
goto out;

Expand All @@ -4239,8 +4233,8 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval
goto out;
}

SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p newsk: %p sd: %d\n",
__func__, sk, asoc, newsock->sk, retval);
SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n",
__func__, sk, newsock->sk, retval);

/* Return the fd mapped to the new socket. */
peeloff.sd = retval;
Expand Down

0 comments on commit f907be4

Please sign in to comment.