diff mbox series

[net-next,1/2] net: openvswitch: add drop reasons

Message ID 20230629203005.2137107-2-eric@garver.life (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: openvswitch: add drop action | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 10 this patch: 10
netdev/cc_maintainers warning 4 maintainers not CCed: kuba@kernel.org edumazet@google.com davem@davemloft.net pabeni@redhat.com
netdev/build_clang fail Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 10 this patch: 10
netdev/checkpatch fail ERROR: Macros with complex values should be enclosed in parentheses WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Garver June 29, 2023, 8:30 p.m. UTC
These are counterparts to userspace's xlate_error values.

Signed-off-by: Eric Garver <eric@garver.life>
---
 include/net/dropreason.h   |  6 ++++++
 net/openvswitch/datapath.c | 17 +++++++++++++++++
 net/openvswitch/drop.h     | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 net/openvswitch/drop.h
diff mbox series

Patch

diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index 685fb37df8e8..653675bba758 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -23,6 +23,12 @@  enum skb_drop_reason_subsys {
 	 */
 	SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR,
 
+	/**
+	 * @SKB_DROP_REASON_SUBSYS_OPENVSWITCH: openvswitch drop reasons
+	 * see net/openvswitch/drop.h
+	 */
+	SKB_DROP_REASON_SUBSYS_OPENVSWITCH,
+
 	/** @SKB_DROP_REASON_SUBSYS_NUM: number of subsystems defined */
 	SKB_DROP_REASON_SUBSYS_NUM
 };
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index a6d2a0b1aa21..4ebdc52856ab 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -48,6 +48,7 @@ 
 #include "openvswitch_trace.h"
 #include "vport-internal_dev.h"
 #include "vport-netdev.h"
+#include "drop.h"
 
 unsigned int ovs_net_id __read_mostly;
 
@@ -2702,6 +2703,18 @@  static struct pernet_operations ovs_net_ops = {
 	.size = sizeof(struct ovs_net),
 };
 
+static const char * const ovs_drop_reasons[] = {
+	[0] = "OVS_XLATE_OK",
+#define S(x) #x,
+	OVS_DROP_REASONS(S)
+#undef S
+};
+
+static struct drop_reason_list drop_reason_list_ovs = {
+	.reasons = ovs_drop_reasons,
+	.n_reasons = ARRAY_SIZE(ovs_drop_reasons),
+};
+
 static int __init dp_init(void)
 {
 	int err;
@@ -2743,6 +2756,9 @@  static int __init dp_init(void)
 	if (err < 0)
 		goto error_unreg_netdev;
 
+	drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_OPENVSWITCH,
+				     &drop_reason_list_ovs);
+
 	return 0;
 
 error_unreg_netdev:
@@ -2769,6 +2785,7 @@  static void dp_cleanup(void)
 	ovs_netdev_exit();
 	unregister_netdevice_notifier(&ovs_dp_device_notifier);
 	unregister_pernet_device(&ovs_net_ops);
+	drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_OPENVSWITCH);
 	rcu_barrier();
 	ovs_vport_exit();
 	ovs_flow_exit();
diff --git a/net/openvswitch/drop.h b/net/openvswitch/drop.h
new file mode 100644
index 000000000000..787eda0083c1
--- /dev/null
+++ b/net/openvswitch/drop.h
@@ -0,0 +1,34 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * openvswitch drop reason list
+ */
+
+#ifndef OPENVSWITCH_DROP_H
+#define OPENVSWITCH_DROP_H
+#include <net/dropreason.h>
+
+/* these are counterparts to userspace xlate_error */
+#define OVS_DROP_REASONS(R)                      \
+	R(OVS_XLATE_BRIDGE_NOT_FOUND)            \
+	R(OVS_XLATE_RECURSION_TOO_DEEP)          \
+	R(OVS_XLATE_TOO_MANY_RESUBMITS)          \
+	R(OVS_XLATE_STACK_TOO_DEEP)              \
+	R(OVS_XLATE_NO_RECIRCULATION_CONTEXT)    \
+	R(OVS_XLATE_RECIRCULATION_CONFLICT)      \
+	R(OVS_XLATE_TOO_MANY_MPLS_LABELS)        \
+	R(OVS_XLATE_INVALID_TUNNEL_METADATA)     \
+	R(OVS_XLATE_UNSUPPORTED_PACKET_TYPE)     \
+	R(OVS_XLATE_CONGESTION_DROP)             \
+	R(OVS_XLATE_FORWARDING_DISABLED)         \
+	/* deliberate comment for trailing \ */
+
+enum ovs_drop_reason {
+	OVS_XLATE_OK = SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
+			SKB_DROP_REASON_SUBSYS_SHIFT,
+#define ENUM(x) x,
+	OVS_DROP_REASONS(ENUM)
+#undef ENUM
+	OVS_XLATE_MAX,
+};
+
+#endif /* OPENVSWITCH_DROP_H */