]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd, lib: add oid2in6_addr utility and use it
authorPat Ruddy <pat@voltanet.io>
Sun, 14 Feb 2021 12:09:55 +0000 (12:09 +0000)
committerPat Ruddy <pat@voltanet.io>
Wed, 17 Feb 2021 13:35:31 +0000 (13:35 +0000)
The existing code was using the oid2in_addr API to copy IPv6
addresses passing an IPv6 length. Create a utility to do this
properly and avoid annoying coverity with type checking.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
bgpd/bgp_mplsvpn_snmp.c
lib/smux.h
lib/snmp.c

index 7047607e5daef0fa78f5b2d1b8eda03ed695cfef..b74cf37ac7c4c3bcce5514edb3b145e45bdce9b4 100644 (file)
@@ -1411,8 +1411,7 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[],
                        break;
                case INETADDRESSTYPEIPV6:
                        prefix.family = AF_INET6;
-                       oid2in_addr(&name[i], sizeof(struct in6_addr),
-                                   &prefix.u.prefix4); /* sic */
+                       oid2in6_addr(&name[i], &prefix.u.prefix6);
                        i += sizeof(struct in6_addr);
                        break;
                }
@@ -1434,8 +1433,7 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[],
                        break;
                case INETADDRESSTYPEIPV6:
                        nexthop.ipa_type = IPADDR_V6;
-                       oid2in_addr(&name[i], sizeof(struct in6_addr),
-                                   &nexthop.ip._v4_addr); /* sic */
+                       oid2in6_addr(&name[i], &nexthop.ip._v6_addr);
                        /* i += sizeof(struct in6_addr); */
                        break;
                }
index e07df2369f5bd946d2cbe91661ed3d6a1e0a0d58..11c1becd6066799dba5eee9a87bd90f4ac192256 100644 (file)
@@ -143,6 +143,7 @@ extern int smux_trap_multi_index(struct variable *vp, size_t vp_len,
                                 size_t trapobjlen, uint8_t sptrap);
 extern int oid_compare(const oid *, int, const oid *, int);
 extern void oid2in_addr(oid[], int, struct in_addr *);
+extern void oid2in6_addr(oid oid[], struct in6_addr *addr);
 extern void oid2int(oid oid[], int *dest);
 extern void *oid_copy(void *, const void *, size_t);
 extern void oid_copy_addr(oid[], const struct in_addr *, int);
index e92f622bb95642ba3cdcc7d35c7595e830ab7681..17a4ed4a1dfd4e8ca0462ba50229c33be77200dd 100644 (file)
@@ -64,6 +64,17 @@ void oid2in_addr(oid oid[], int len, struct in_addr *addr)
                *pnt++ = oid[i];
 }
 
+void oid2in6_addr(oid oid[], struct in6_addr *addr)
+{
+       unsigned int i;
+       uint8_t *pnt;
+
+       pnt = (uint8_t *)addr;
+
+       for (i = 0; i < sizeof(struct in6_addr); i++)
+               *pnt++ = oid[i];
+}
+
 void oid2int(oid oid[], int *dest)
 {
        uint8_t i;