From ecd9d441b082e3f24139eb96915b18fc17996c08 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 --- 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 1c6d58159e79..5a99ac05009e 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -253,9 +253,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 659cd66427ac8a6fe705b4a319245b7c88f80c05 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 --- 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 5a99ac05009e..b596d00c5067 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -300,14 +300,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 e41ae0acc1940b568def5018efad3df019023f85 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 --- 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 b596d00c5067..16327e40441c 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -493,23 +493,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 f53dde0e5921aafae0a00d993257ea7423b5ee97 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 --- zebra/zebra_snmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 16327e40441c..4b4f5232532b 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -229,6 +229,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: @@ -237,6 +239,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 */ }