• Yan Zhai's avatar
    net: introduce sk_skb_reason_drop function · ba8de796
    Yan Zhai authored
    Long used destructors kfree_skb and kfree_skb_reason do not pass
    receiving socket to packet drop tracepoints trace_kfree_skb.
    This makes it hard to track packet drops of a certain netns (container)
    or a socket (user application).
    
    The naming of these destructors are also not consistent with most sk/skb
    operating functions, i.e. functions named "sk_xxx" or "skb_xxx".
    Introduce a new functions sk_skb_reason_drop as drop-in replacement for
    kfree_skb_reason on local receiving path. Callers can now pass receiving
    sockets to the tracepoints.
    
    kfree_skb and kfree_skb_reason are still usable but they are now just
    inline helpers that call sk_skb_reason_drop.
    
    Note it is not feasible to do the same to consume_skb. Packets not
    dropped can flow through multiple receive handlers, and have multiple
    receiving sockets. Leave it untouched for now.
    Suggested-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarYan Zhai <yan@cloudflare.com>
    Acked-by: default avatarJesper Dangaard Brouer <hawk@kernel.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    ba8de796
skbuff.c 179 KB