Centos-kernel-stream-9/net/openvswitch/drop.h

42 lines
955 B
C
Raw Normal View History

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* OpenvSwitch drop reason list.
*/
#ifndef OPENVSWITCH_DROP_H
#define OPENVSWITCH_DROP_H
#include <linux/skbuff.h>
#include <net/dropreason.h>
#define OVS_DROP_REASONS(R) \
R(OVS_DROP_LAST_ACTION) \
R(OVS_DROP_ACTION_ERROR) \
net: openvswitch: add explicit drop action Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2232283 Upstream Status: net-next.git commit e7bc7db9ba463e763ac6113279cade19da9cb939 Author: Eric Garver <eric@garver.life> Date: Fri Aug 11 16:12:50 2023 +0200 net: openvswitch: add explicit drop action From: Eric Garver <eric@garver.life> This adds an explicit drop action. This is used by OVS to drop packets for which it cannot determine what to do. An explicit action in the kernel allows passing the reason _why_ the packet is being dropped or zero to indicate no particular error happened (i.e: OVS intentionally dropped the packet). Since the error codes coming from userspace mean nothing for the kernel, we squash all of them into only two drop reasons: - OVS_DROP_EXPLICIT_WITH_ERROR to indicate a non-zero value was passed - OVS_DROP_EXPLICIT to indicate a zero value was passed (no error) e.g. trace all OVS dropped skbs # perf trace -e skb:kfree_skb --filter="reason >= 0x30000" [..] 106.023 ping/2465 skb:kfree_skb(skbaddr: 0xffffa0e8765f2000, \ location:0xffffffffc0d9b462, protocol: 2048, reason: 196611) reason: 196611 --> 0x30003 (OVS_DROP_EXPLICIT) Also, this patch allows ovs-dpctl.py to add explicit drop actions as: "drop" -> implicit empty-action drop "drop(0)" -> explicit non-error action drop "drop(42)" -> explicit error action drop Signed-off-by: Eric Garver <eric@garver.life> Co-developed-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
2023-08-11 14:12:50 +00:00
R(OVS_DROP_EXPLICIT) \
R(OVS_DROP_EXPLICIT_WITH_ERROR) \
R(OVS_DROP_METER) \
R(OVS_DROP_RECURSION_LIMIT) \
R(OVS_DROP_DEFERRED_LIMIT) \
R(OVS_DROP_FRAG_L2_TOO_LONG) \
R(OVS_DROP_FRAG_INVALID_PROTO) \
R(OVS_DROP_CONNTRACK) \
R(OVS_DROP_IP_TTL) \
/* deliberate comment for trailing \ */
enum ovs_drop_reason {
__OVS_DROP_REASON = SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
SKB_DROP_REASON_SUBSYS_SHIFT,
#define ENUM(x) x,
OVS_DROP_REASONS(ENUM)
#undef ENUM
OVS_DROP_MAX,
};
static inline void
ovs_kfree_skb_reason(struct sk_buff *skb, enum ovs_drop_reason reason)
{
kfree_skb_reason(skb, (u32)reason);
}
#endif /* OPENVSWITCH_DROP_H */