lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230629203005.2137107-2-eric@garver.life>
Date: Thu, 29 Jun 2023 16:30:04 -0400
From: Eric Garver <eric@...ver.life>
To: netdev@...r.kernel.org
Cc: dev@...nvswitch.org,
	Pravin B Shelar <pshelar@....org>,
	Ilya Maximets <i.maximets@....org>
Subject: [PATCH net-next 1/2] net: openvswitch: add drop reasons

These are counterparts to userspace's xlate_error values.

Signed-off-by: Eric Garver <eric@...ver.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 --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 */
-- 
2.39.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ