Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209844
b: refs/heads/master
c: 68d6ac6
h: refs/heads/master
v: v3
  • Loading branch information
Johannes Berg authored and David S. Miller committed Aug 19, 2010
1 parent b0a8976 commit 6eefab6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 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: e243f5b6de35b6fc394bc2e1e1737afe538e7e0c
refs/heads/master: 68d6ac6d2740b6a55f3ae92a4e0be6d881904b32
46 changes: 16 additions & 30 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
struct netlink_sock *nlk = nlk_sk(sk);
int noblock = flags&MSG_DONTWAIT;
size_t copied;
struct sk_buff *skb, *frag __maybe_unused = NULL;
struct sk_buff *skb, *data_skb;
int err;

if (flags&MSG_OOB)
Expand All @@ -1418,45 +1418,35 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
if (skb == NULL)
goto out;

data_skb = skb;

#ifdef CONFIG_COMPAT_NETLINK_MESSAGES
if (unlikely(skb_shinfo(skb)->frag_list)) {
bool need_compat = !!(flags & MSG_CMSG_COMPAT);

/*
* If this skb has a frag_list, then here that means that
* we will have to use the frag_list skb for compat tasks
* and the regular skb for non-compat tasks.
* If this skb has a frag_list, then here that means that we
* will have to use the frag_list skb's data for compat tasks
* and the regular skb's data for normal (non-compat) tasks.
*
* The skb might (and likely will) be cloned, so we can't
* just reset frag_list and go on with things -- we need to
* keep that. For the compat case that's easy -- simply get
* a reference to the compat skb and free the regular one
* including the frag. For the non-compat case, we need to
* avoid sending the frag to the user -- so assign NULL but
* restore it below before freeing the skb.
* If we need to send the compat skb, assign it to the
* 'data_skb' variable so that it will be used below for data
* copying. We keep 'skb' for everything else, including
* freeing both later.
*/
if (need_compat) {
struct sk_buff *compskb = skb_shinfo(skb)->frag_list;
skb_get(compskb);
kfree_skb(skb);
skb = compskb;
} else {
frag = skb_shinfo(skb)->frag_list;
skb_shinfo(skb)->frag_list = NULL;
}
if (flags & MSG_CMSG_COMPAT)
data_skb = skb_shinfo(skb)->frag_list;
}
#endif

msg->msg_namelen = 0;

copied = skb->len;
copied = data_skb->len;
if (len < copied) {
msg->msg_flags |= MSG_TRUNC;
copied = len;
}

skb_reset_transport_header(skb);
err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
skb_reset_transport_header(data_skb);
err = skb_copy_datagram_iovec(data_skb, 0, msg->msg_iov, copied);

if (msg->msg_name) {
struct sockaddr_nl *addr = (struct sockaddr_nl *)msg->msg_name;
Expand All @@ -1476,11 +1466,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
}
siocb->scm->creds = *NETLINK_CREDS(skb);
if (flags & MSG_TRUNC)
copied = skb->len;

#ifdef CONFIG_COMPAT_NETLINK_MESSAGES
skb_shinfo(skb)->frag_list = frag;
#endif
copied = data_skb->len;

skb_free_datagram(sk, skb);

Expand Down

0 comments on commit 6eefab6

Please sign in to comment.