Commit Graph

385 Commits

Author SHA1 Message Date
Menglong Dong bd1403b101 net: skb: introduce __skb_queue_purge_reason()
Introduce __skb_queue_purge_reason() to empty a skb list with drop
reason and make __skb_queue_purge() an inline call to it.

Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
2022-06-17 11:26:55 +08:00
Menglong Dong 19fc64385e net: skb: move enum skb_drop_reason to standalone header file
As the skb drop reasons are getting more and more, move the enum
'skb_drop_reason' and related function to the standalone header
'dropreason.h', as Jakub Kicinski suggested.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
2022-06-17 10:08:53 +08:00
Menglong Dong 66ede92e1c tcp: add drop reason support to tcp_ofo_queue()
[upstream commit 8fbf195798b56e1e87f62d01be636a6425c304c2]

packets in OFO queue might be redundant, and dropped.

tcp_drop() is no longer needed.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:53 +08:00
Menglong Dong 5c6caf8ba0 tcp: add drop reason support to tcp_prune_ofo_queue()
[upstream commit e7c89ae4078eab24af71ba26b91642e819a4bd7f]

Add one reason for packets dropped from OFO queue because
of memory pressure.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:53 +08:00
Menglong Dong 8c18d12403 tcp: add two drop reasons for tcp_ack()
[upstream commit 4b506af9c5b8de0da34097d50d9448dfb33d70c3]

Add TCP_TOO_OLD_ACK and TCP_ACK_UNSENT_DATA drop
reasons so that tcp_rcv_established() can report
them.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:53 +08:00
Menglong Dong 4173b6203c tcp: add drop reasons to tcp_rcv_state_process()
[upstream commit 669da7a71890b2b2a31a7e9571c0fdf1123e26ef]

Add basic support for drop reasons in tcp_rcv_state_process()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong 0a54b767a1 tcp: add drop reason support to tcp_validate_incoming()
[upstream commit da40b613f89c43c58986e6f30560ad6573a4d569]

Creates four new drop reasons for the following cases:

1) packet being rejected by RFC 7323 PAWS check
2) packet being rejected by SEQUENCE check
3) Invalid RST packet
4) Invalid SYN packet

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong 5e1ee4e3b3 net: skb: change the definition SKB_DR_SET()
[upstream commit 7ebd3f3ee51a9e02994cd0a1be44fbd325d1e0dc]

The SKB_DR_OR() is used to set the drop reason to a value when it is
not set or specified yet. SKB_NOT_DROPPED_YET should also be considered
as not set.

Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong 4fc2182cfa net: icmp: introduce function icmpv6_param_prob_reason()
[upstream commit 1ad6d548e2a452f21bcee4606ee4ec7afcde5f37]

In order to add the skb drop reasons support to icmpv6_param_prob(),
introduce the function icmpv6_param_prob_reason() and make
icmpv6_param_prob() an inline call to it. This new function will be
used in the following patches.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong 4ad7c174b5 net: ip: add skb drop reasons to ip forwarding
[upstream commit 2edc1a383fda8d2f580216292dfd9daeae691e47]

Replace kfree_skb() which is used in ip6_forward() and ip_forward()
with kfree_skb_reason().

The new drop reason 'SKB_DROP_REASON_PKT_TOO_BIG' is introduced for
the case that the length of the packet exceeds MTU and can't
fragment.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong f1c2829b63 net: ipv4: add skb drop reasons to ip_error()
[upstream commit c4eb664191b4a5ff6856478f903924176697719e]

Eventually, I find out the handler function for inputting route lookup
fail: ip_error().

The drop reasons we used in ip_error() are almost corresponding to
IPSTATS_MIB_*, and following new reasons are introduced:

SKB_DROP_REASON_IP_INADDRERRORS
SKB_DROP_REASON_IP_INNOROUTES

Isn't the name SKB_DROP_REASON_IP_HOSTUNREACH and
SKB_DROP_REASON_IP_NETUNREACH more accurate? To make them corresponding
to IPSTATS_MIB_*, we keep their name still.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:52 +08:00
Menglong Dong e6db69b1fe skb: add some helpers for skb drop reasons
[upstream commit d6d3146ce532268ad0ffd8d92d2b7492898decf1]

In order to simply the definition and assignment for
'enum skb_drop_reason', introduce some helpers.

SKB_DR() is used to define a variable of type 'enum skb_drop_reason'
with the 'SKB_DROP_REASON_NOT_SPECIFIED' initial value.

SKB_DR_SET() is used to set the value of the variable. Seems it is
a little useless? But it makes the code shorter.

SKB_DR_OR() is used to set the value of the variable if it is not set
yet, which means its value is SKB_DROP_REASON_NOT_SPECIFIED.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 6c595c775d net: icmp: add skb drop reasons to icmp protocol
[upstream commit b384c95a861eebf47e88695cf6a29f34e0b10b0f]

Replace kfree_skb() used in icmp_rcv() and icmpv6_rcv() with
kfree_skb_reason().

In order to get the reasons of the skb drops after icmp message handle,
we change the return type of 'handler()' in 'struct icmp_control' from
'bool' to 'enum skb_drop_reason'. This may change its original
intention, as 'false' means failure, but 'SKB_NOT_DROPPED_YET' means
success now. Therefore, all 'handler' and the call of them need to be
handled. Following 'handler' functions are involved:

icmp_unreach()
icmp_redirect()
icmp_echo()
icmp_timestamp()
icmp_discard()

And following new drop reasons are added:

SKB_DROP_REASON_ICMP_CSUM
SKB_DROP_REASON_INVALID_PROTO

The reason 'INVALID_PROTO' is introduced for the case that the packet
doesn't follow rfc 1122 and is dropped. This is not a common case, and
I believe we can locate the problem from the data in the packet. For now,
this 'INVALID_PROTO' is used for the icmp broadcasts with wrong types.

Maybe there should be a document file for these reasons. For example,
list all the case that causes the 'UNHANDLED_PROTO' and 'INVALID_PROTO'
drop reason. Therefore, users can locate their problems according to the
document.

Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong b01cc03925 net: skb: rename SKB_DROP_REASON_PTYPE_ABSENT
[upstream commit 9f8ed577c28813410614b418bad42285840c1a00]

As David Ahern suggested, the reasons for skb drops should be more
general and not be code based.

Therefore, rename SKB_DROP_REASON_PTYPE_ABSENT to
SKB_DROP_REASON_UNHANDLED_PROTO, which is used for the cases of no
L3 protocol handler, no L4 protocol handler, version extensions, etc.

From previous discussion, now we have the aim to make these reasons
more abstract and users based, avoiding code based.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong e8c5b7e7d4 net: tun: track dropped skb via kfree_skb_reason()
[upstream commit 4b4f052e2d89c2eb7e13ee28ba9e85f8097aef3d]

The TUN can be used as vhost-net backend. E.g, the tun_net_xmit() is the
interface to forward the skb from TUN to vhost-net/virtio-net.

However, there are many "goto drop" in the TUN driver. Therefore, the
kfree_skb_reason() is involved at each "goto drop" to help userspace
ftrace/ebpf to track the reason for the loss of packets.

The below reasons are introduced:

- SKB_DROP_REASON_DEV_READY
- SKB_DROP_REASON_NOMEM
- SKB_DROP_REASON_HDR_TRUNC
- SKB_DROP_REASON_TAP_FILTER
- SKB_DROP_REASON_TAP_TXFILTER

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong a5eb90247e net: tap: track dropped skb via kfree_skb_reason()
[upstream commit 736f16de75f9bb32d76f652cb66f04d1bc685057]

The TAP can be used as vhost-net backend. E.g., the tap_handle_frame() is
the interface to forward the skb from TAP to vhost-net/virtio-net.

However, there are many "goto drop" in the TAP driver. Therefore, the
kfree_skb_reason() is involved at each "goto drop" to help userspace
ftrace/ebpf to track the reason for the loss of packets.

The below reasons are introduced:

- SKB_DROP_REASON_SKB_CSUM
- SKB_DROP_REASON_SKB_GSO_SEG
- SKB_DROP_REASON_SKB_UCOPY_FAULT
- SKB_DROP_REASON_DEV_HDR
- SKB_DROP_REASON_FULL_RING

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong d8ef0a13e1 net: dev: use kfree_skb_reason() for __netif_receive_skb_core()
[upstream commit 6c2728b7c14164928cb7cb9c847dead101b2d503]

Add reason for skb drops to __netif_receive_skb_core() when packet_type
not found to handle the skb. For this purpose, the drop reason
SKB_DROP_REASON_PTYPE_ABSENT is introduced. Take ether packets for
example, this case mainly happens when L3 protocol is not supported.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 3e3b03b88c net: dev: use kfree_skb_reason() for sch_handle_ingress()
[upstream commit a568aff26ac03ee9eb1482683514914a5ec3b4c3]

Replace kfree_skb() used in sch_handle_ingress() with
kfree_skb_reason(). Following drop reasons are introduced:

SKB_DROP_REASON_TC_INGRESS

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 62ea5a4a66 net: dev: use kfree_skb_reason() for do_xdp_generic()
[upstream commit 7e726ed81e1ddd5fdc431e02b94fcfe2a9876d42]

Replace kfree_skb() used in do_xdp_generic() with kfree_skb_reason().
The drop reason SKB_DROP_REASON_XDP is introduced for this case.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong a90e7a5bd2 net: dev: use kfree_skb_reason() for enqueue_to_backlog()
[upstream commit 44f0bd40803c0e04f1c8cd59df3c7acce783ae9c]

Replace kfree_skb() used in enqueue_to_backlog() with
kfree_skb_reason(). The skb rop reason SKB_DROP_REASON_CPU_BACKLOG is
introduced for the case of failing to enqueue the skb to the per CPU
backlog queue. The further reason can be backlog queue full or RPS
flow limition, and I think we needn't to make further distinctions.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 5f74796b87 net: dev: add skb drop reasons to __dev_xmit_skb()
[upstream commit 7faef0547f4c29031a68d058918b031a8e520d49]

Add reasons for skb drops to __dev_xmit_skb() by replacing
kfree_skb_list() with kfree_skb_list_reason(). The drop reason of
SKB_DROP_REASON_QDISC_DROP is introduced for qdisc enqueue fails.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 87cda931d4 net: skb: introduce the function kfree_skb_list_reason()
[upstream commit 215b0f1963d4e34fccac6992b3debe26f78a6eb8]

To report reasons of skb drops, introduce the function
kfree_skb_list_reason() and make kfree_skb_list() an inline call to
it. This function will be used in the next commit in
__dev_xmit_skb().

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 812c0cd229 net: dev: use kfree_skb_reason() for sch_handle_egress()
[upstream commit 98b4d7a4e7374a44c4afd9f08330e72f6ad0d644]

Replace kfree_skb() used in sch_handle_egress() with kfree_skb_reason().
The drop reason SKB_DROP_REASON_TC_EGRESS is introduced. Considering
the code path of tc egerss, we make it distinct with the drop reason
of SKB_DROP_REASON_QDISC_DROP in the next commit.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:51 +08:00
Menglong Dong 05de5bf971 net: neigh: use kfree_skb_reason() for __neigh_event_send()
[upstream commit a5736edda10ca2ba075606baad1dda3f2426766d]

Replace kfree_skb() used in __neigh_event_send() with
kfree_skb_reason(). Following drop reasons are added:

SKB_DROP_REASON_NEIGH_FAILED
SKB_DROP_REASON_NEIGH_QUEUEFULL
SKB_DROP_REASON_NEIGH_DEAD

The first two reasons above should be the hot path that skb drops
in neighbour subsystem.

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong d783526d4a skb: make drop reason booleanable
[upstream commit 1330b6ef3313fcec577d2b020c290dc8b9f11f1a]

We have a number of cases where function returns drop/no drop
decision as a boolean. Now that we want to report the reason
code as well we have to pass extra output arguments.

We can make the reason code evaluate correctly as bool.

I believe we're good to reorder the reasons as they are
reported to user space as strings.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 73d5fd5a9f net: ip: add skb drop reasons for ip egress path
[upstream commit 5e187189ec324f78035d33a4bc123a9c4ca6f3e3]

Replace kfree_skb() which is used in the packet egress path of IP layer
with kfree_skb_reason(). Functions that are involved include:

__ip_queue_xmit()
ip_finish_output()
ip_mc_finish_output()
ip6_output()
ip6_finish_output()
ip6_finish_output2()

Following new drop reasons are introduced:

SKB_DROP_REASON_IP_OUTNOROUTES
SKB_DROP_REASON_BPF_CGROUP_EGRESS
SKB_DROP_REASON_IPV6DISABLED
SKB_DROP_REASON_NEIGH_CREATEFAIL

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 3f087ee3e2 net: tcp: use tcp_drop_reason() for tcp_data_queue_ofo()
[upstream commit d25e481be0c519d1a458b14191dc8c2a8bb3e24a]

Replace tcp_drop() used in tcp_data_queue_ofo with tcp_drop_reason().
Following drop reasons are introduced:

SKB_DROP_REASON_TCP_OFOMERGE

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong ed55232fcd net: tcp: use tcp_drop_reason() for tcp_data_queue()
[upstream commit a7ec381049c0d1f03e342063d75f5c3b314d0ec2]

Replace tcp_drop() used in tcp_data_queue() with tcp_drop_reason().
Following drop reasons are introduced:

SKB_DROP_REASON_TCP_ZEROWINDOW
SKB_DROP_REASON_TCP_OLD_DATA
SKB_DROP_REASON_TCP_OVERWINDOW

SKB_DROP_REASON_TCP_OLD_DATA is used for the case that end_seq of skb
less than the left edges of receive window. (Maybe there is a better
name?)

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 5022778011 net: tcp: use tcp_drop_reason() for tcp_rcv_established()
[upstream commit 2a968ef60e1fac4e694d9f60ce19a3b66b40e8c3]

Replace tcp_drop() used in tcp_rcv_established() with tcp_drop_reason().
Following drop reasons are added:

SKB_DROP_REASON_TCP_FLAGS

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 4dd1a57f34 net: tcp: add skb drop reasons to tcp_add_backlog()
[upstream commit 7a26dc9e7b43f5a24c4b843713e728582adf1c38]

Pass the address of drop_reason to tcp_add_backlog() to store the
reasons for skb drops when fails. Following drop reasons are
introduced:

SKB_DROP_REASON_SOCKET_BACKLOG

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 5dc7231e40 net: tcp: add skb drop reasons to tcp_v{4,6}_inbound_md5_hash()
[upstream commit 643b622b51f1f0015e0a80f90b4ef9032e6ddb1b]

Pass the address of drop reason to tcp_v4_inbound_md5_hash() and
tcp_v6_inbound_md5_hash() to store the reasons for skb drops when this
function fails. Therefore, the drop reason can be passed to
kfree_skb_reason() when the skb needs to be freed.

Following drop reasons are added:

SKB_DROP_REASON_TCP_MD5NOTFOUND
SKB_DROP_REASON_TCP_MD5UNEXPECTED
SKB_DROP_REASON_TCP_MD5FAILURE

SKB_DROP_REASON_TCP_MD5* above correspond to LINUX_MIB_TCPMD5*

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong ff14c81d15 net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb()
[upstream commit 08d4c0370c400fa6ef2194f9ee2e8dccc4a7ab39]

Replace kfree_skb() with kfree_skb_reason() in __udp_queue_rcv_skb().
Following new drop reasons are introduced:

SKB_DROP_REASON_SOCKET_RCVBUFF
SKB_DROP_REASON_PROTO_MEM

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:50 +08:00
Menglong Dong 4b8f422ed7 net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu()
[upstream commit 10580c4791902571777603cb980414892dd5f149]

Replace kfree_skb() with kfree_skb_reason() in ip_protocol_deliver_rcu().
Following new drop reasons are introduced:

SKB_DROP_REASON_XFRM_POLICY
SKB_DROP_REASON_IP_NOPROTO

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:49 +08:00
Menglong Dong e2c9a3cdbb net: ipv4: use kfree_skb_reason() in ip_rcv_finish_core()
[upstream commit c1f166d1f7eef212096a98b22f5acf92f9af353d]

Replace kfree_skb() with kfree_skb_reason() in ip_rcv_finish_core(),
following drop reasons are introduced:

SKB_DROP_REASON_IP_RPFILTER
SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:49 +08:00
Menglong Dong f616870507 net: ipv4: use kfree_skb_reason() in ip_rcv_core()
[upstream commit 33cba42985c8144eef78d618fc1e51aaa074b169]

Replace kfree_skb() with kfree_skb_reason() in ip_rcv_core(). Three new
drop reasons are introduced:

SKB_DROP_REASON_OTHERHOST
SKB_DROP_REASON_IP_CSUM
SKB_DROP_REASON_IP_INHDR

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:49 +08:00
Menglong Dong b3e09bbf60 net: netfilter: use kfree_drop_reason() for NF_DROP
[upstream commit 2df3041ba3be950376e8c25a8f6da22f7fcc765c]

Replace kfree_skb() with kfree_skb_reason() in nf_hook_slow() when
skb is dropped by reason of NF_DROP. Following new drop reasons
are introduced:

SKB_DROP_REASON_NETFILTER_DROP

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:49 +08:00
Menglong Dong bd6ebc0897 net: skb_drop_reason: add document for drop reasons
[upstream commit 88590b369354092183bcba04e2368010c462557f]

Add document for following existing drop reasons:

SKB_DROP_REASON_NOT_SPECIFIED
SKB_DROP_REASON_NO_SOCKET
SKB_DROP_REASON_PKT_TOO_SMALL
SKB_DROP_REASON_TCP_CSUM
SKB_DROP_REASON_SOCKET_FILTER
SKB_DROP_REASON_UDP_CSUM

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-17 10:08:49 +08:00
Menglong Dong 7c3303625e net: socket: rename SKB_DROP_REASON_SOCKET_FILTER
[upstream commit 364df53c081d93fcfd6b91085ff2650c7f17b3c7]

Rename SKB_DROP_REASON_SOCKET_FILTER, which is used
as the reason of skb drop out of socket filter before
it's part of a released kernel. It will be used for
more protocols than just TCP in future series.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/all/20220127091308.91401-2-imagedong@tencent.com/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-06-17 10:08:49 +08:00
Menglong Dong 126f789dbd net: skb: use kfree_skb_reason() in __udp4_lib_rcv()
[upstream commit 1c7fab70df085d866a3765955f397ca2b4025b15]

Replace kfree_skb() with kfree_skb_reason() in __udp4_lib_rcv.
New drop reason 'SKB_DROP_REASON_UDP_CSUM' is added for udp csum
error.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-06-17 10:08:49 +08:00
Menglong Dong cca40cd586 net: skb: use kfree_skb_reason() in tcp_v4_rcv()
[upstream commit 85125597419aec3aa7b8f3b8713e415f997796f2]

Replace kfree_skb() with kfree_skb_reason() in tcp_v4_rcv(). Following
drop reasons are added:

SKB_DROP_REASON_NO_SOCKET
SKB_DROP_REASON_PKT_TOO_SMALL
SKB_DROP_REASON_TCP_CSUM
SKB_DROP_REASON_TCP_FILTER

After this patch, 'kfree_skb' event will print message like this:

$           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
$              | |         |   |||||     |         |
          <idle>-0       [000] ..s1.    36.113438: kfree_skb: skbaddr=(____ptrval____) protocol=2048 location=(____ptrval____) reason: NO_SOCKET

The reason of skb drop is printed too.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-06-17 10:08:49 +08:00
Menglong Dong 6d0da2faf7 net: skb: introduce kfree_skb_reason()
[upstream commit c504e5c2f9648a1e5c2be01e8c3f59d394192bd3]

Introduce the interface kfree_skb_reason(), which is able to pass
the reason why the skb is dropped to 'kfree_skb' tracepoint.

Add the 'reason' field to 'trace_kfree_skb', therefor user can get
more detail information about abnormal skb with 'drop_monitor' or
eBPF.

All drop reasons are defined in the enum 'skb_drop_reason', and
they will be print as string in 'kfree_skb' tracepoint in format
of 'reason: XXX'.

( Maybe the reasons should be defined in a uapi header file, so that
user space can use them? )

Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-06-17 10:08:49 +08:00
Kairui Song ef9529c002 x86: kdump: move reserve_crashkernel[_low]() into crash_core.c
From: Chen Zhou <chenzhou10@huawei.com>
Link: https://lkml.org/lkml/2021/1/30/53
Link: 8cb8686864

Make the functions reserve_crashkernel[_low]() as generic.
Arm64 will use these to reimplement crashkernel=X.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Tested-by: John Donnelly <John.p.donnelly@oracle.com>
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Acked-by: Xie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: Kairui Song <kasong@tencent.com>
2022-06-06 13:50:12 +08:00
frankjpliu 7503de0908
Merge pull request #194 from chenmengc/dev/sli_merge_main
Dev/sli merge main
2022-04-20 15:17:37 +08:00
frankjpliu b54509a3af
Merge pull request #177 from lanxinyuchs/lanxinyu/tk4/sysctl-write-forbid
sysctl: restrict the writting for key parameters
2022-04-20 14:58:24 +08:00
Lan Xinyu 2d927e094e sysctl: restrict the writing for key parameters
Users may modify some sysctl parameters intentionally or unintentionally,
which may cause problems such as disconnection of the container network
connection.

Therefore, the modification of key sysctl parameters is
restricted on the host and in the container that shares the network
namespace with the host.
2022-04-19 19:57:10 +08:00
frankjpliu 0d557e88b4
Merge pull request #185 from Tencent/tk4/haisuwang
Support buffer I/O qos function in cgroup v1
2022-04-19 16:50:14 +08:00
Bin Lai 36ce5bdb96 sli/kabi: add the kabi reserve space for sli structure
In order to avoid breaking system kabi, we add the reserve space
for sli structure. Then we can use the reserved space to fix bug
by hotpatch.

Signed-off-by: Bin Lai <robinlai@tencent.com>
Reviewed-by: Bauerchen <bauerchen@tencent.com>
2022-04-18 21:10:23 +08:00
Bin Lai 8979f4ffb9 kabi: introduce more kabi-related macro
Currently, there is only KABI_RESERVE macro in the kabi.h. So we
introduce more kabi-related macros, then we could use the reserved
space more easily by the macros.

Signed-off-by: Bin Lai <robinlai@tencent.com>
Reviewed-by: Mengmeng Chen <bauerchen@tencent.com>
Reviewed-by: benbjiang <benbjiang@tencent.com>
2022-04-18 21:10:10 +08:00
bauerchen 9620012f40 sli: sli.monitor support cgroup v1
Signed-off-by: bauerchen <bauerchen@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2022-04-18 21:09:31 +08:00
bauerchen 34961244de sli: add sli_monitor notify mechanism
Sli can collect much information such as cpu stall and memory stall, but
now this key info only exported to userspace by cgroupfs interface, so
if user app want to feel the resource load, it have to monitor the
cgroupfs file periodly  which have some latency and more resource
consumpetion.

Sli montior notify mechanism can solve this issue. It prides interface
which can be monitored by use app using poll or epoll. So User app can  get
informed at the first time the resource load reaches threshold.

Signed-off-by: bauerchen <bauerchen@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2022-04-18 21:08:43 +08:00