OSDN Git Service

datagram: remove rendundant 'peeked' argument
authorPaolo Abeni <pabeni@redhat.com>
Mon, 8 Apr 2019 08:15:59 +0000 (10:15 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2019 16:51:54 +0000 (09:51 -0700)
After commit a297569fe00a ("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: Paolo Abeni <pabeni@redhat.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
include/net/udp.h
net/core/datagram.c
net/ipv4/udp.c
net/ipv6/udp.c
net/unix/af_unix.c

index 69b5538..a06275a 100644 (file)
@@ -3370,17 +3370,17 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
                                          unsigned int flags,
                                          void (*destructor)(struct sock *sk,
                                                           struct sk_buff *skb),
-                                         int *peeked, int *off, int *err,
+                                         int *off, int *err,
                                          struct sk_buff **last);
 struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned flags,
                                        void (*destructor)(struct sock *sk,
                                                           struct sk_buff *skb),
-                                       int *peeked, int *off, int *err,
+                                       int *off, int *err,
                                        struct sk_buff **last);
 struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
                                    void (*destructor)(struct sock *sk,
                                                       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,
                                  int *err);
 __poll_t datagram_poll(struct file *file, struct socket *sock,
index fd6d948..d8ce937 100644 (file)
@@ -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);
 void udp_skb_destructor(struct sock *sk, struct sk_buff *skb);
 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,
                                           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);
index 91bb5a0..45a162e 100644 (file)
@@ -167,7 +167,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
                                          unsigned int flags,
                                          void (*destructor)(struct sock *sk,
                                                           struct sk_buff *skb),
-                                         int *peeked, int *off, int *err,
+                                         int *off, int *err,
                                          struct sk_buff **last)
 {
        bool peek_at_off = false;
@@ -194,7 +194,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
                                        return NULL;
                                }
                        }
-                       *peeked = 1;
                        refcount_inc(&skb->users);
                } else {
                        __skb_unlink(skb, queue);
@@ -212,7 +211,6 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
  *     @sk: socket
  *     @flags: MSG\_ flags
  *     @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
  *           within an skb where data actually starts
  *     @err: error code returned
@@ -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,
                                        void (*destructor)(struct sock *sk,
                                                           struct sk_buff *skb),
-                                       int *peeked, int *off, int *err,
+                                       int *off, int *err,
                                        struct sk_buff **last)
 {
        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,
        if (error)
                goto no_packet;
 
-       *peeked = 0;
        do {
                /* Again only user level code calls this function, so nothing
                 * 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,
                 */
                spin_lock_irqsave(&queue->lock, cpu_flags);
                skb = __skb_try_recv_from_queue(sk, queue, flags, destructor,
-                                               peeked, off, &error, last);
+                                               off, &error, last);
                spin_unlock_irqrestore(&queue->lock, cpu_flags);
                if (error)
                        goto no_packet;
@@ -294,7 +291,7 @@ EXPORT_SYMBOL(__skb_try_recv_datagram);
 struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
                                    void (*destructor)(struct sock *sk,
                                                       struct sk_buff *skb),
-                                   int *peeked, int *off, int *err)
+                                   int *off, int *err)
 {
        struct sk_buff *skb, *last;
        long timeo;
@@ -302,8 +299,8 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
        timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
 
        do {
-               skb = __skb_try_recv_datagram(sk, flags, destructor, peeked,
-                                             off, err, &last);
+               skb = __skb_try_recv_datagram(sk, flags, destructor, off, err,
+                                             &last);
                if (skb)
                        return skb;
 
@@ -319,10 +316,10 @@ EXPORT_SYMBOL(__skb_recv_datagram);
 struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned int flags,
                                  int noblock, int *err)
 {
-       int peeked, off = 0;
+       int off = 0;
 
        return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
-                                  NULL, &peeked, &off, err);
+                                  NULL, &off, err);
 }
 EXPORT_SYMBOL(skb_recv_datagram);
 
index 372fdc5..3c58ba0 100644 (file)
@@ -1631,7 +1631,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 EXPORT_SYMBOL(udp_ioctl);
 
 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 *queue;
@@ -1650,13 +1650,11 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
                        break;
 
                error = -EAGAIN;
-               *peeked = 0;
                do {
                        spin_lock_bh(&queue->lock);
                        skb = __skb_try_recv_from_queue(sk, queue, flags,
                                                        udp_skb_destructor,
-                                                       peeked, off, err,
-                                                       &last);
+                                                       off, err, &last);
                        if (skb) {
                                spin_unlock_bh(&queue->lock);
                                return skb;
@@ -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,
                                                        udp_skb_dtor_locked,
-                                                       peeked, off, err,
-                                                       &last);
+                                                       off, err, &last);
                        spin_unlock(&sk_queue->lock);
                        spin_unlock_bh(&queue->lock);
                        if (skb)
@@ -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);
        struct sk_buff *skb;
        unsigned int ulen, copied;
-       int peeked, peeking, off;
-       int err;
+       int off, err, peeking = flags & MSG_PEEK;
        int is_udplite = IS_UDPLITE(sk);
        bool checksum_valid = false;
 
@@ -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);
 
 try_again:
-       peeking = flags & MSG_PEEK;
        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)
                return err;
 
@@ -1762,7 +1757,7 @@ try_again:
        }
 
        if (unlikely(err)) {
-               if (!peeked) {
+               if (!peeking) {
                        atomic_inc(&sk->sk_drops);
                        UDP_INC_STATS(sock_net(sk),
                                      UDP_MIB_INERRORS, is_udplite);
@@ -1771,7 +1766,7 @@ try_again:
                return err;
        }
 
-       if (!peeked)
+       if (!peeking)
                UDP_INC_STATS(sock_net(sk),
                              UDP_MIB_INDATAGRAMS, is_udplite);
 
index b444483..d538faf 100644 (file)
@@ -285,8 +285,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
        struct inet_sock *inet = inet_sk(sk);
        struct sk_buff *skb;
        unsigned int ulen, copied;
-       int peeked, peeking, off;
-       int err;
+       int off, err, peeking = flags & MSG_PEEK;
        int is_udplite = IS_UDPLITE(sk);
        struct udp_mib __percpu *mib;
        bool checksum_valid = false;
@@ -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);
 
 try_again:
-       peeking = flags & MSG_PEEK;
        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)
                return err;
 
@@ -340,14 +338,14 @@ try_again:
                        goto csum_copy_err;
        }
        if (unlikely(err)) {
-               if (!peeked) {
+               if (!peeking) {
                        atomic_inc(&sk->sk_drops);
                        SNMP_INC_STATS(mib, UDP_MIB_INERRORS);
                }
                kfree_skb(skb);
                return err;
        }
-       if (!peeked)
+       if (!peeking)
                SNMP_INC_STATS(mib, UDP_MIB_INDATAGRAMS);
 
        sock_recv_ts_and_drops(msg, sk, skb);
index ddb838a..e68d745 100644 (file)
@@ -2040,8 +2040,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
        struct unix_sock *u = unix_sk(sk);
        struct sk_buff *skb, *last;
        long timeo;
+       int skip;
        int err;
-       int peeked, skip;
 
        err = -EOPNOTSUPP;
        if (flags&MSG_OOB)
@@ -2053,8 +2053,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
                mutex_lock(&u->iolock);
 
                skip = sk_peek_offset(sk, flags);
-               skb = __skb_try_recv_datagram(sk, flags, NULL, &peeked, &skip,
-                                             &err, &last);
+               skb = __skb_try_recv_datagram(sk, flags, NULL, &skip, &err,
+                                             &last);
                if (skb)
                        break;