Commit fd69c399 authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

datagram: remove rendundant 'peeked' argument

After commit a297569f ("net/udp: do not touch skb->peeked unless
really needed") the 'peeked' argument of __skb_try_recv_datagram()
and friends is always equal to !!'flags & MSG_PEEK'.

Since such argument is really a boolean info, and the callers have
already 'flags & MSG_PEEK' handy, we can remove it and clean-up the
code a bit.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1f17f774
...@@ -3370,17 +3370,17 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, ...@@ -3370,17 +3370,17 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
unsigned int flags, unsigned int flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err, int *off, int *err,
struct sk_buff **last); struct sk_buff **last);
struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned flags, struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err, int *off, int *err,
struct sk_buff **last); struct sk_buff **last);
struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err); int *off, int *err);
struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock, struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
int *err); int *err);
__poll_t datagram_poll(struct file *file, struct socket *sock, __poll_t datagram_poll(struct file *file, struct socket *sock,
......
...@@ -269,13 +269,13 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len); ...@@ -269,13 +269,13 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len);
int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb); int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb);
void udp_skb_destructor(struct sock *sk, struct sk_buff *skb); void udp_skb_destructor(struct sock *sk, struct sk_buff *skb);
struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
int noblock, int *peeked, int *off, int *err); int noblock, int *off, int *err);
static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags, static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
int noblock, int *err) int noblock, int *err)
{ {
int peeked, off = 0; int off = 0;
return __skb_recv_udp(sk, flags, noblock, &peeked, &off, err); return __skb_recv_udp(sk, flags, noblock, &off, err);
} }
int udp_v4_early_demux(struct sk_buff *skb); int udp_v4_early_demux(struct sk_buff *skb);
......
...@@ -167,7 +167,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, ...@@ -167,7 +167,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
unsigned int flags, unsigned int flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err, int *off, int *err,
struct sk_buff **last) struct sk_buff **last)
{ {
bool peek_at_off = false; bool peek_at_off = false;
...@@ -194,7 +194,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, ...@@ -194,7 +194,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
return NULL; return NULL;
} }
} }
*peeked = 1;
refcount_inc(&skb->users); refcount_inc(&skb->users);
} else { } else {
__skb_unlink(skb, queue); __skb_unlink(skb, queue);
...@@ -212,7 +211,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, ...@@ -212,7 +211,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
* @sk: socket * @sk: socket
* @flags: MSG\_ flags * @flags: MSG\_ flags
* @destructor: invoked under the receive lock on successful dequeue * @destructor: invoked under the receive lock on successful dequeue
* @peeked: returns non-zero if this packet has been seen before
* @off: an offset in bytes to peek skb from. Returns an offset * @off: an offset in bytes to peek skb from. Returns an offset
* within an skb where data actually starts * within an skb where data actually starts
* @err: error code returned * @err: error code returned
...@@ -246,7 +244,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, ...@@ -246,7 +244,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags, struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err, int *off, int *err,
struct sk_buff **last) struct sk_buff **last)
{ {
struct sk_buff_head *queue = &sk->sk_receive_queue; struct sk_buff_head *queue = &sk->sk_receive_queue;
...@@ -260,7 +258,6 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags, ...@@ -260,7 +258,6 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
if (error) if (error)
goto no_packet; goto no_packet;
*peeked = 0;
do { do {
/* Again only user level code calls this function, so nothing /* Again only user level code calls this function, so nothing
* interrupt level will suddenly eat the receive_queue. * interrupt level will suddenly eat the receive_queue.
...@@ -270,7 +267,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags, ...@@ -270,7 +267,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
*/ */
spin_lock_irqsave(&queue->lock, cpu_flags); spin_lock_irqsave(&queue->lock, cpu_flags);
skb = __skb_try_recv_from_queue(sk, queue, flags, destructor, skb = __skb_try_recv_from_queue(sk, queue, flags, destructor,
peeked, off, &error, last); off, &error, last);
spin_unlock_irqrestore(&queue->lock, cpu_flags); spin_unlock_irqrestore(&queue->lock, cpu_flags);
if (error) if (error)
goto no_packet; goto no_packet;
...@@ -294,7 +291,7 @@ EXPORT_SYMBOL(__skb_try_recv_datagram); ...@@ -294,7 +291,7 @@ EXPORT_SYMBOL(__skb_try_recv_datagram);
struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
void (*destructor)(struct sock *sk, void (*destructor)(struct sock *sk,
struct sk_buff *skb), struct sk_buff *skb),
int *peeked, int *off, int *err) int *off, int *err)
{ {
struct sk_buff *skb, *last; struct sk_buff *skb, *last;
long timeo; long timeo;
...@@ -302,8 +299,8 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, ...@@ -302,8 +299,8 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
do { do {
skb = __skb_try_recv_datagram(sk, flags, destructor, peeked, skb = __skb_try_recv_datagram(sk, flags, destructor, off, err,
off, err, &last); &last);
if (skb) if (skb)
return skb; return skb;
...@@ -319,10 +316,10 @@ EXPORT_SYMBOL(__skb_recv_datagram); ...@@ -319,10 +316,10 @@ EXPORT_SYMBOL(__skb_recv_datagram);
struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned int flags, struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned int flags,
int noblock, int *err) int noblock, int *err)
{ {
int peeked, off = 0; int off = 0;
return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
NULL, &peeked, &off, err); NULL, &off, err);
} }
EXPORT_SYMBOL(skb_recv_datagram); EXPORT_SYMBOL(skb_recv_datagram);
......
...@@ -1631,7 +1631,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -1631,7 +1631,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
EXPORT_SYMBOL(udp_ioctl); EXPORT_SYMBOL(udp_ioctl);
struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
int noblock, int *peeked, int *off, int *err) int noblock, int *off, int *err)
{ {
struct sk_buff_head *sk_queue = &sk->sk_receive_queue; struct sk_buff_head *sk_queue = &sk->sk_receive_queue;
struct sk_buff_head *queue; struct sk_buff_head *queue;
...@@ -1650,13 +1650,11 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, ...@@ -1650,13 +1650,11 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
break; break;
error = -EAGAIN; error = -EAGAIN;
*peeked = 0;
do { do {
spin_lock_bh(&queue->lock); spin_lock_bh(&queue->lock);
skb = __skb_try_recv_from_queue(sk, queue, flags, skb = __skb_try_recv_from_queue(sk, queue, flags,
udp_skb_destructor, udp_skb_destructor,
peeked, off, err, off, err, &last);
&last);
if (skb) { if (skb) {
spin_unlock_bh(&queue->lock); spin_unlock_bh(&queue->lock);
return skb; return skb;
...@@ -1677,8 +1675,7 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, ...@@ -1677,8 +1675,7 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
skb = __skb_try_recv_from_queue(sk, queue, flags, skb = __skb_try_recv_from_queue(sk, queue, flags,
udp_skb_dtor_locked, udp_skb_dtor_locked,
peeked, off, err, off, err, &last);
&last);
spin_unlock(&sk_queue->lock); spin_unlock(&sk_queue->lock);
spin_unlock_bh(&queue->lock); spin_unlock_bh(&queue->lock);
if (skb) if (skb)
...@@ -1713,8 +1710,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, ...@@ -1713,8 +1710,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name);
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen, copied; unsigned int ulen, copied;
int peeked, peeking, off; int off, err, peeking = flags & MSG_PEEK;
int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
bool checksum_valid = false; bool checksum_valid = false;
...@@ -1722,9 +1718,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, ...@@ -1722,9 +1718,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
return ip_recv_error(sk, msg, len, addr_len); return ip_recv_error(sk, msg, len, addr_len);
try_again: try_again:
peeking = flags & MSG_PEEK;
off = sk_peek_offset(sk, flags); off = sk_peek_offset(sk, flags);
skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); skb = __skb_recv_udp(sk, flags, noblock, &off, &err);
if (!skb) if (!skb)
return err; return err;
...@@ -1762,7 +1757,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, ...@@ -1762,7 +1757,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
} }
if (unlikely(err)) { if (unlikely(err)) {
if (!peeked) { if (!peeking) {
atomic_inc(&sk->sk_drops); atomic_inc(&sk->sk_drops);
UDP_INC_STATS(sock_net(sk), UDP_INC_STATS(sock_net(sk),
UDP_MIB_INERRORS, is_udplite); UDP_MIB_INERRORS, is_udplite);
...@@ -1771,7 +1766,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, ...@@ -1771,7 +1766,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
return err; return err;
} }
if (!peeked) if (!peeking)
UDP_INC_STATS(sock_net(sk), UDP_INC_STATS(sock_net(sk),
UDP_MIB_INDATAGRAMS, is_udplite); UDP_MIB_INDATAGRAMS, is_udplite);
......
...@@ -285,8 +285,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -285,8 +285,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen, copied; unsigned int ulen, copied;
int peeked, peeking, off; int off, err, peeking = flags & MSG_PEEK;
int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
struct udp_mib __percpu *mib; struct udp_mib __percpu *mib;
bool checksum_valid = false; bool checksum_valid = false;
...@@ -299,9 +298,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -299,9 +298,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
return ipv6_recv_rxpmtu(sk, msg, len, addr_len); return ipv6_recv_rxpmtu(sk, msg, len, addr_len);
try_again: try_again:
peeking = flags & MSG_PEEK;
off = sk_peek_offset(sk, flags); off = sk_peek_offset(sk, flags);
skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); skb = __skb_recv_udp(sk, flags, noblock, &off, &err);
if (!skb) if (!skb)
return err; return err;
...@@ -340,14 +338,14 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -340,14 +338,14 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
goto csum_copy_err; goto csum_copy_err;
} }
if (unlikely(err)) { if (unlikely(err)) {
if (!peeked) { if (!peeking) {
atomic_inc(&sk->sk_drops); atomic_inc(&sk->sk_drops);
SNMP_INC_STATS(mib, UDP_MIB_INERRORS); SNMP_INC_STATS(mib, UDP_MIB_INERRORS);
} }
kfree_skb(skb); kfree_skb(skb);
return err; return err;
} }
if (!peeked) if (!peeking)
SNMP_INC_STATS(mib, UDP_MIB_INDATAGRAMS); SNMP_INC_STATS(mib, UDP_MIB_INDATAGRAMS);
sock_recv_ts_and_drops(msg, sk, skb); sock_recv_ts_and_drops(msg, sk, skb);
......
...@@ -2040,8 +2040,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, ...@@ -2040,8 +2040,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
struct unix_sock *u = unix_sk(sk); struct unix_sock *u = unix_sk(sk);
struct sk_buff *skb, *last; struct sk_buff *skb, *last;
long timeo; long timeo;
int skip;
int err; int err;
int peeked, skip;
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
if (flags&MSG_OOB) if (flags&MSG_OOB)
...@@ -2053,8 +2053,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, ...@@ -2053,8 +2053,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
mutex_lock(&u->iolock); mutex_lock(&u->iolock);
skip = sk_peek_offset(sk, flags); skip = sk_peek_offset(sk, flags);
skb = __skb_try_recv_datagram(sk, flags, NULL, &peeked, &skip, skb = __skb_try_recv_datagram(sk, flags, NULL, &skip, &err,
&err, &last); &last);
if (skb) if (skb)
break; break;
......
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