diff options
author | Pat Ruddy <pat@voltanet.io> | 2021-03-25 15:39:07 +0100 |
---|---|---|
committer | Pat Ruddy <pat@voltanet.io> | 2021-03-25 16:24:50 +0100 |
commit | 9e26322126ed6daef7ae16b4c9a547ae28a02226 (patch) | |
tree | 2b80ff835e5368b6a70fe7cc87da585eeeca5c80 /bgpd | |
parent | Merge pull request #8318 from qlyoung/improve-lua-autoconf-detection (diff) | |
download | frr-9e26322126ed6daef7ae16b4c9a547ae28a02226.tar.xz frr-9e26322126ed6daef7ae16b4c9a547ae28a02226.zip |
lib, bgpd: add a specific oid_copy function for IPv6 addrs
Do not overload the v4 oid_copy_addr function for ipv6
coverity does not like this kind of thing.
Signed-off-by: Pat Ruddy <pat@voltanet.io>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_mplsvpn_snmp.c | 25 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 14 |
2 files changed, 20 insertions, 19 deletions
diff --git a/bgpd/bgp_mplsvpn_snmp.c b/bgpd/bgp_mplsvpn_snmp.c index b74cf37ac..6f75856d5 100644 --- a/bgpd/bgp_mplsvpn_snmp.c +++ b/bgpd/bgp_mplsvpn_snmp.c @@ -1478,10 +1478,16 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[], oid_copy_str(&name[namelen], (*l3vpn_bgp)->name, vrf_name_len); oid_index = namelen + vrf_name_len; - name[oid_index++] = - v4 ? INETADDRESSTYPEIPV4 : INETADDRESSTYPEIPV6; - oid_copy_addr(&name[oid_index], &p->u.prefix4, - addr_len); + if (v4) { + name[oid_index++] = INETADDRESSTYPEIPV4; + oid_copy_in_addr(&name[oid_index], + &p->u.prefix4); + } else { + name[oid_index++] = INETADDRESSTYPEIPV6; + oid_copy_in6_addr(&name[oid_index], + &p->u.prefix6); + } + oid_index += addr_len; name[oid_index++] = p->prefixlen; name[oid_index++] = *policy >> 8; @@ -1493,9 +1499,8 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[], INETADDRESSTYPEUNKNOWN; else { name[oid_index++] = INETADDRESSTYPEIPV4; - oid_copy_addr(&name[oid_index], - &attr->nexthop, - sizeof(struct in_addr)); + oid_copy_in_addr(&name[oid_index], + &attr->nexthop); oid_index += sizeof(struct in_addr); } } else { @@ -1505,11 +1510,9 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[], INETADDRESSTYPEUNKNOWN; else { name[oid_index++] = INETADDRESSTYPEIPV6; - oid_copy_addr( + oid_copy_in6_addr( &name[oid_index], - (struct in_addr *)&attr - ->mp_nexthop_global, - sizeof(struct in6_addr)); + &attr->mp_nexthop_global); oid_index += sizeof(struct in6_addr); } } diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index bc26314b5..3afdbea90 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -435,7 +435,7 @@ static struct peer *bgpPeerTable_lookup(struct variable *v, oid name[], if (peer == NULL) return NULL; - oid_copy_addr(name + namelen, addr, sizeof(struct in_addr)); + oid_copy_in_addr(name + namelen, addr); *length = sizeof(struct in_addr) + namelen; return peer; @@ -767,14 +767,12 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[], v->namelen + BGP_PATHATTR_ENTRY_OFFSET; offset = name + v->namelen; - oid_copy_addr(offset, &rn_p->u.prefix4, - IN_ADDR_SIZE); + oid_copy_in_addr(offset, &rn_p->u.prefix4); offset += IN_ADDR_SIZE; *offset = rn_p->prefixlen; offset++; - oid_copy_addr(offset, - &min->peer->su.sin.sin_addr, - IN_ADDR_SIZE); + oid_copy_in_addr(offset, + &min->peer->su.sin.sin_addr); addr->prefix = rn_p->u.prefix4; addr->prefixlen = rn_p->prefixlen; @@ -868,7 +866,7 @@ static int bgpTrapEstablished(struct peer *peer) if (ret == 0) return 0; - oid_copy_addr(index, &addr, IN_ADDR_SIZE); + oid_copy_in_addr(index, &addr); smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid, array_size(bgp_trap_oid), bgp_oid, @@ -887,7 +885,7 @@ static int bgpTrapBackwardTransition(struct peer *peer) if (ret == 0) return 0; - oid_copy_addr(index, &addr, IN_ADDR_SIZE); + oid_copy_in_addr(index, &addr); smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid, array_size(bgp_trap_oid), bgp_oid, |