From 00a43bb9590163fce26316bef09793ac4d9aa8b3 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Sep 2024 12:06:29 -0400 Subject: [PATCH 1/4] zebra: Fix snmp walk of zebra rib The snmp walk of the zebra rib was skipping entries because in_addr_cmp was replaced with a prefix_cmp which worked slightly differently causing parts of the zebra rib tree to be skipped. Signed-off-by: Donald Sharp (cherry picked from commit ecd9d441b082e3f24139eb96915b18fc17996c08) --- zebra/zebra_snmp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index e06733cb8c68..84f976038ceb 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -251,9 +251,11 @@ static void check_replace(struct route_node *np2, struct route_entry *re2, return; } - if (prefix_cmp(&(*np)->p, &np2->p) < 0) + if (in_addr_cmp((uint8_t *)&(*np)->p.u.prefix4, + (uint8_t *)&np2->p.u.prefix4) < 0) return; - if (prefix_cmp(&(*np)->p, &np2->p) > 0) { + if (in_addr_cmp((uint8_t *)&(*np)->p.u.prefix4, + (uint8_t *)&np2->p.u.prefix4) > 0) { *np = np2; *re = re2; return; From 13457fd8c1a91c0c3fd244974ded5a4a217f5ca2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Sep 2024 12:08:03 -0400 Subject: [PATCH 2/4] zebra: Let's use memset instead of walking bytes and setting to 0 Signed-off-by: Donald Sharp (cherry picked from commit 659cd66427ac8a6fe705b4a319245b7c88f80c05) --- zebra/zebra_snmp.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 84f976038ceb..b6ef6fc519e3 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -298,14 +298,8 @@ static void get_fwtable_route_node(struct variable *v, oid objid[], int i; /* Init index variables */ - - pnt = (uint8_t *)&dest; - for (i = 0; i < 4; i++) - *pnt++ = 0; - - pnt = (uint8_t *)&nexthop; - for (i = 0; i < 4; i++) - *pnt++ = 0; + memset(&dest, 0, sizeof(dest)); + memset(&nexthop, 0, sizeof(nexthop)); proto = 0; policy = 0; From addf6c53028f43ccbbea007b52a7824449cc8b3e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Sep 2024 12:09:40 -0400 Subject: [PATCH 3/4] zebra: Correctly report metrics Report the routes metric in IPFORWARDMETRIC1 and return -1 for the other metrics as required by the IP-FORWARD-MIB. inetCidrRouteMetric2 OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-create STATUS current DESCRIPTION "An alternate routing metric for this route. The semantics of this metric are determined by the routing- protocol specified in the route's inetCidrRouteProto value. If this metric is not used, its value should be set to -1." DEFVAL { -1 } ::= { inetCidrRouteEntry 13 } I've included metric2 but it's the same for all of them. Signed-off-by: Donald Sharp (cherry picked from commit e41ae0acc1940b568def5018efad3df019023f85) --- zebra/zebra_snmp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index b6ef6fc519e3..ee21724e8c99 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -490,23 +490,23 @@ static uint8_t *ipFwTable(struct variable *v, oid objid[], size_t *objid_len, *val_len = sizeof(int); return (uint8_t *)&result; case IPFORWARDMETRIC1: - result = 0; + result = re->metric; *val_len = sizeof(int); return (uint8_t *)&result; case IPFORWARDMETRIC2: - result = 0; + result = -1; *val_len = sizeof(int); return (uint8_t *)&result; case IPFORWARDMETRIC3: - result = 0; + result = -1; *val_len = sizeof(int); return (uint8_t *)&result; case IPFORWARDMETRIC4: - result = 0; + result = -1; *val_len = sizeof(int); return (uint8_t *)&result; case IPFORWARDMETRIC5: - result = 0; + result = -1; *val_len = sizeof(int); return (uint8_t *)&result; default: From 707dfd0d948109e6ced5d55de47f4b1ff839cde8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 25 Sep 2024 12:14:50 -0400 Subject: [PATCH 4/4] zebra: Add missing proto translations Add missing isis and eigrp proto translations. Signed-off-by: Donald Sharp (cherry picked from commit f53dde0e5921aafae0a00d993257ea7423b5ee97) --- zebra/zebra_snmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index ee21724e8c99..bb66f35afa11 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -227,6 +227,8 @@ static int proto_trans(int type) return 3; /* static route */ case ZEBRA_ROUTE_RIP: return 8; /* rip */ + case ZEBRA_ROUTE_ISIS: + return 9; case ZEBRA_ROUTE_RIPNG: return 1; /* shouldn't happen */ case ZEBRA_ROUTE_OSPF: @@ -235,6 +237,8 @@ static int proto_trans(int type) return 1; /* shouldn't happen */ case ZEBRA_ROUTE_BGP: return 14; /* bgp */ + case ZEBRA_ROUTE_EIGRP: + return 16; default: return 1; /* other */ }