The commit is pushed to "branch-rh9-5.14.0-162.6.1.vz9.18.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.6.1.vz9.18.2
------>
commit 5ecd985073d227328ae243b763b3622130d19e47
Author: Menglong Dong <imaged...@tencent.com>
Date:   Tue Jan 3 17:39:26 2023 +0200

    net: sock: introduce sock_queue_rcv_skb_reason()
    
    In order to report the reasons of skb drops in 'sock_queue_rcv_skb()',
    introduce the function 'sock_queue_rcv_skb_reason()'.
    
    As the return value of 'sock_queue_rcv_skb()' is used as the error code,
    we can't make it as drop reason and have to pass extra output argument.
    'sock_queue_rcv_skb()' is used in many places, so we can't change it
    directly.
    
    Introduce the new function 'sock_queue_rcv_skb_reason()' and make
    'sock_queue_rcv_skb()' an inline call to it.
    
    Reviewed-by: Hao Peng <flyingp...@tencent.com>
    Reviewed-by: Jiang Biao <benbji...@tencent.com>
    Signed-off-by: Menglong Dong <imaged...@tencent.com>
    Reviewed-by: David Ahern <dsah...@kernel.org>
    Signed-off-by: David S. Miller <da...@davemloft.net>
    Acked-by: Nikolay Borisov <nbori...@suse.com>
    Signed-off-by: Nikolay Borisov <nikolay.bori...@virtuozzo.com>
    
    ======
    Patchset description:
    ms/net: Annotate skb free sites with reason
    
    This series backports most of the patches that add a reason to skb free 
sites.
    
    https://jira.sw.ru/browse/PSBM-143302
    
    Feature: net: improve verbosity of dropped packets reporting
---
 include/net/sock.h |  9 ++++++++-
 net/core/sock.c    | 30 ++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index da0073e87f04..4273b22a9d98 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2361,7 +2361,14 @@ int __sk_queue_drop_skb(struct sock *sk, struct 
sk_buff_head *sk_queue,
                        void (*destructor)(struct sock *sk,
                                           struct sk_buff *skb));
 int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
-int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
+
+int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb,
+                             enum skb_drop_reason *reason);
+
+static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
+{
+       return sock_queue_rcv_skb_reason(sk, skb, NULL);
+}
 
 int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb);
 struct sk_buff *sock_dequeue_err_skb(struct sock *sk);
diff --git a/net/core/sock.c b/net/core/sock.c
index f01c013ecae1..07f9162b13c5 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -499,17 +499,35 @@ int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff 
*skb)
 }
 EXPORT_SYMBOL(__sock_queue_rcv_skb);
 
-int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
+int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb,
+                             enum skb_drop_reason *reason)
 {
+       enum skb_drop_reason drop_reason;
        int err;
 
        err = sk_filter(sk, skb);
-       if (err)
-               return err;
-
-       return __sock_queue_rcv_skb(sk, skb);
+       if (err) {
+               drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
+               goto out;
+       }
+       err = __sock_queue_rcv_skb(sk, skb);
+       switch (err) {
+       case -ENOMEM:
+               drop_reason = SKB_DROP_REASON_SOCKET_RCVBUFF;
+               break;
+       case -ENOBUFS:
+               drop_reason = SKB_DROP_REASON_PROTO_MEM;
+               break;
+       default:
+               drop_reason = SKB_NOT_DROPPED_YET;
+               break;
+       }
+out:
+       if (reason)
+               *reason = drop_reason;
+       return err;
 }
-EXPORT_SYMBOL(sock_queue_rcv_skb);
+EXPORT_SYMBOL(sock_queue_rcv_skb_reason);
 
 int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
                     const int nested, unsigned int trim_cap, bool refcounted)
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to