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]
Date:   Wed, 29 Sep 2021 18:28:41 +0300
From:   Nikolay Aleksandrov <razor@...ckwall.org>
To:     netdev@...r.kernel.org
Cc:     roopa@...dia.com, donaldsharp72@...il.com, dsahern@...il.com,
        idosch@...sch.org, Nikolay Aleksandrov <nikolay@...dia.com>
Subject: [RFC iproute2-next 04/11] ip: nexthop: parse resilient nexthop group attribute into structure

From: Nikolay Aleksandrov <nikolay@...dia.com>

Add a structure which describes resilient nexthop groups and parse such
attributes into it.

Signed-off-by: Nikolay Aleksandrov <nikolay@...dia.com>
---
 ip/ipnexthop.c | 32 ++++++++++++++++++++++++++++++++
 ip/nh_common.h | 10 ++++++++++
 2 files changed, 42 insertions(+)

diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index be8541476fa6..9340d8941277 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -272,6 +272,33 @@ static void print_nh_group_type(FILE *fp, const struct rtattr *grp_type_attr)
 	print_string(PRINT_ANY, "type", "type %s ", nh_group_type_name(type));
 }
 
+static void parse_nh_res_group_rta(const struct rtattr *res_grp_attr,
+				   struct nha_res_grp *res_grp)
+{
+	struct rtattr *tb[NHA_RES_GROUP_MAX + 1];
+	struct rtattr *rta;
+
+	parse_rtattr_nested(tb, NHA_RES_GROUP_MAX, res_grp_attr);
+
+	if (tb[NHA_RES_GROUP_BUCKETS])
+		res_grp->buckets = rta_getattr_u16(tb[NHA_RES_GROUP_BUCKETS]);
+
+	if (tb[NHA_RES_GROUP_IDLE_TIMER]) {
+		rta = tb[NHA_RES_GROUP_IDLE_TIMER];
+		res_grp->idle_timer = rta_getattr_u32(rta);
+	}
+
+	if (tb[NHA_RES_GROUP_UNBALANCED_TIMER]) {
+		rta = tb[NHA_RES_GROUP_UNBALANCED_TIMER];
+		res_grp->unbalanced_timer = rta_getattr_u32(rta);
+	}
+
+	if (tb[NHA_RES_GROUP_UNBALANCED_TIME]) {
+		rta = tb[NHA_RES_GROUP_UNBALANCED_TIME];
+		res_grp->unbalanced_time = rta_getattr_u64(rta);
+	}
+}
+
 static void print_nh_res_group(FILE *fp, const struct rtattr *res_grp_attr)
 {
 	struct rtattr *tb[NHA_RES_GROUP_MAX + 1];
@@ -408,6 +435,11 @@ static int ipnh_parse_nhmsg(FILE *fp, const struct nhmsg *nhm, int len,
 		       RTA_PAYLOAD(tb[NHA_GROUP]));
 	}
 
+	if (tb[NHA_RES_GROUP]) {
+		parse_nh_res_group_rta(tb[NHA_RES_GROUP], &nhe->nh_res_grp);
+		nhe->nh_has_res_grp = true;
+	}
+
 	nhe->nh_blackhole = !!tb[NHA_BLACKHOLE];
 	nhe->nh_fdb = !!tb[NHA_FDB];
 
diff --git a/ip/nh_common.h b/ip/nh_common.h
index f2ff0e6532d3..8c96f9993562 100644
--- a/ip/nh_common.h
+++ b/ip/nh_common.h
@@ -2,6 +2,13 @@
 #ifndef __NH_COMMON_H__
 #define __NH_COMMON_H__ 1
 
+struct nha_res_grp {
+	__u16			buckets;
+	__u32			idle_timer;
+	__u32			unbalanced_timer;
+	__u64			unbalanced_time;
+};
+
 struct nh_entry {
 	__u32			nh_id;
 	__u32			nh_oif;
@@ -26,6 +33,9 @@ struct nh_entry {
 		__u8		_buf[RTA_LENGTH(sizeof(__u16))];
 	}			nh_encap_type;
 
+	bool			nh_has_res_grp;
+	struct nha_res_grp	nh_res_grp;
+
 	int			nh_groups_cnt;
 	struct nexthop_grp	*nh_groups;
 };
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ