From a46a2e9b4e8de782ac07e01429a80ed7ec167dcb Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 31 Jul 2017 21:37:46 -0300 Subject: [PATCH] bgpd: don't make any assumptions about the size of an enum The size of an enum is compiler dependent and thus we shouldn't use enums inside structures that represent fields of a packet. Problem detected by the 'test_capability' unit test. The problem was not apparent before because the 'iana_safi_t' enum didn't exist and 'safi_t' was a typedef to uint8_t. Now we have two different enums, 'iana_afi_t' and 'iana_safi_t', and both need to be encoded in different ways on the wire (2 bytes vs 1 byte). Signed-off-by: Renato Westphal --- bgpd/bgp_open.h | 4 ++-- bgpd/bgpd.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h index 6b92e6e38..83b79a589 100644 --- a/bgpd/bgp_open.h +++ b/bgpd/bgp_open.h @@ -29,9 +29,9 @@ struct capability_header { /* Generic MP capability data */ struct capability_mp_data { - iana_afi_t afi; + uint16_t afi; /* iana_afi_t */ u_char reserved; - iana_safi_t safi; + uint8_t safi; /* iana_safi_t */ }; struct capability_as4 { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index ff15115e0..250ee5f4e 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -922,10 +922,10 @@ DECLARE_QOBJ_TYPE(peer) stream. */ struct bgp_nlri { /* AFI. */ - afi_t afi; + uint16_t afi; /* iana_afi_t */ /* SAFI. */ - safi_t safi; + uint8_t safi; /* iana_safi_t */ /* Pointer to NLRI byte stream. */ u_char *nlri; -- 2.39.2