[Devel] [PATCH RHEL7 COMMIT] ms/drop_monitor: Use pre_doit / post_doit hooks

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jul 28 22:28:44 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.66.1.vz7.188.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.66.1.vz7.188.6
------>
commit e6780f8f118c1fcdc02100ff2f79eba80f28679c
Author: Ido Schimmel <idosch at mellanox.com>
Date:   Mon Jul 4 21:51:56 2022 +0300

    ms/drop_monitor: Use pre_doit / post_doit hooks
    
    Each operation from user space should be protected by the global drop
    monitor mutex. Use the pre_doit / post_doit hooks to take / release the
    lock instead of doing it explicitly in each function.
    
    Signed-off-by: Ido Schimmel <idosch at mellanox.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    (cherry picked from commit b19d955055480ac4e03f5afec0ca80f0de7b7013)
    
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
    
    =================
    Patchset description:
    drop_monitor: Add packet alert mode
    
    Just port and adapt packet alert mode feature for RHEL7 kernel.
    
    https://jira.sw.ru/browse/PSBM-140937
    
    Ported-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 net/core/drop_monitor.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 7da7c634f267c..0e2be8e3e8845 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -245,12 +245,8 @@ static int set_all_monitor_traces(int state)
 	struct dm_hw_stat_delta *new_stat = NULL;
 	struct dm_hw_stat_delta *temp;
 
-	mutex_lock(&net_dm_mutex);
-
-	if (state == trace_state) {
-		rc = -EAGAIN;
-		goto out_unlock;
-	}
+	if (state == trace_state)
+		return -EAGAIN;
 
 	switch (state) {
 	case TRACE_ON:
@@ -292,9 +288,6 @@ static int set_all_monitor_traces(int state)
 	else
 		rc = -EINPROGRESS;
 
-out_unlock:
-	mutex_unlock(&net_dm_mutex);
-
 	return rc;
 }
 
@@ -374,10 +367,26 @@ static const struct genl_ops dropmon_ops[] = {
 	},
 };
 
+static int net_dm_nl_pre_doit(const struct genl_ops *ops,
+			      struct sk_buff *skb, struct genl_info *info)
+{
+	mutex_lock(&net_dm_mutex);
+
+	return 0;
+}
+
+static void net_dm_nl_post_doit(const struct genl_ops *ops,
+				struct sk_buff *skb, struct genl_info *info)
+{
+	mutex_unlock(&net_dm_mutex);
+}
+
 static struct genl_family net_drop_monitor_family = {
 	.hdrsize        = 0,
 	.name           = "NET_DM",
 	.version        = 2,
+	.pre_doit	= net_dm_nl_pre_doit,
+	.post_doit	= net_dm_nl_post_doit,
 	.module		= THIS_MODULE,
 	.ops		= dropmon_ops,
 	.n_ops		= ARRAY_SIZE(dropmon_ops),


More information about the Devel mailing list