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-next>] [day] [month] [year] [list]
Message-Id: <20210401040303.61743-1-xuchunmei@linux.alibaba.com>
Date:   Thu,  1 Apr 2021 12:03:03 +0800
From:   Chunmei Xu <xuchunmei@...ux.alibaba.com>
To:     idosch@...sch.org, dsahern@...il.com
Cc:     netdev@...r.kernel.org
Subject: [PATCH v2] ip-nexthop: support flush by id

since id is unique for nexthop, it is heavy to dump all nexthops.
use existing delete_nexthop to support flush by id

Signed-off-by: Chunmei Xu <xuchunmei@...ux.alibaba.com>
---
 ip/ipnexthop.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index 20cde586..419bcb0a 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -460,6 +460,24 @@ static int ipnh_get_id(__u32 id)
 	return 0;
 }
 
+static int ipnh_list_flush_id(__u32 id, int action)
+{
+	int err;
+
+	if (action == IPNH_LIST)
+		return ipnh_get_id(id);
+
+	if (rtnl_open(&rth_del, 0) < 0) {
+		fprintf(stderr, "Cannot open rtnetlink\n");
+		return EXIT_FAILURE;
+	}
+
+	err = delete_nexthop(id);
+	rtnl_close(&rth_del);
+
+	return err;
+}
+
 static int ipnh_list_flush(int argc, char **argv, int action)
 {
 	unsigned int all = (argc == 0);
@@ -490,7 +508,7 @@ static int ipnh_list_flush(int argc, char **argv, int action)
 			NEXT_ARG();
 			if (get_unsigned(&id, *argv, 0))
 				invarg("invalid id value", *argv);
-			return ipnh_get_id(id);
+			return ipnh_list_flush_id(id, action);
 		} else if (!matches(*argv, "protocol")) {
 			__u32 proto;
 
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ