Skip to content

Commit

Permalink
bgpd: fixing strict aliasing warning in bmp_get_peer_distinguisher
Browse files Browse the repository at this point in the history
bmp_get_peer_distinguisher warning fix
bmp_get_peer_distinguisher use of flag check for prefix_rd

Signed-off-by: Maxence Younsi <[email protected]>
  • Loading branch information
mxyns committed Aug 13, 2022
1 parent c79198f commit efda168
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,25 @@ static inline uint64_t bmp_get_peer_distinguisher(struct bmp *bmp, afi_t afi,

// sending vrf_id or rd could be turned into an option at some point
struct bgp *bgp = bmp->targets->bgp;
struct prefix_rd *prd = &bgp->vpn_policy[afi].tovpn_rd;
/*
* default vrf => can't have RD => 0
* vrf => has RD?
* if yes => use RD value
* else => use vrf_id and convert it so that
* peer_distinguisher is 0::vrf_id
*/
return bgp->inst_type == VRF_DEFAULT
? 0
: prd ? *(uint64_t *)prd->val
: (((uint64_t)htonl(bgp->vrf_id)) << 32);
if (bgp->inst_type == VRF_DEFAULT)
return 0;

struct prefix_rd *prd = &bgp->vpn_policy[afi].tovpn_rd;
if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET)) {
uint64_t peerd = 0;
memcpy(&peerd, prd->val, sizeof(prd->val));
return peerd;
}

uint32_t vrf_id_n = htonl(bgp->vrf_id);
return ((uint64_t)vrf_id_n) << 32;
}

static void bmp_common_hdr(struct stream *s, uint8_t ver, uint8_t type)
Expand Down

0 comments on commit efda168

Please sign in to comment.