summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-10-25 22:24:25 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-10-25 22:25:36 +0200
commit61be6e94ab21b6883884e3a6cbbfc5e4e1808bab (patch)
tree56e5fc84e650399c3a13328d8ac8dde056b99bd7
parentlib: convert prefixlen to 16-bit integer (diff)
downloadfrr-61be6e94ab21b6883884e3a6cbbfc5e4e1808bab.tar.xz
frr-61be6e94ab21b6883884e3a6cbbfc5e4e1808bab.zip
bgpd, lib: few more prefixlen updated
* Cast when assigning should be to uint16_t * Restored comment documenting strange behavior * Further increased PREFIX_STRLEN to 80 chars Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_attr_evpn.c4
-rw-r--r--lib/prefix.c4
-rw-r--r--lib/prefix.h5
3 files changed, 8 insertions, 5 deletions
diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c
index 88e520fdc..3e9d05ad9 100644
--- a/bgpd/bgp_attr_evpn.c
+++ b/bgpd/bgp_attr_evpn.c
@@ -267,13 +267,13 @@ extern int bgp_build_evpn_prefix(int evpn_type, uint32_t eth_tag,
memcpy(&p_evpn_p->prefix_addr.ip.ipaddr_v4,
&src->u.prefix4,
sizeof(struct in_addr));
- dst->prefixlen = (uint8_t)PREFIX_LEN_ROUTE_TYPE_5_IPV4;
+ dst->prefixlen = (uint16_t)PREFIX_LEN_ROUTE_TYPE_5_IPV4;
} else {
SET_IPADDR_V6(&p_evpn_p->prefix_addr.ip);
memcpy(&p_evpn_p->prefix_addr.ip.ipaddr_v6,
&src->u.prefix6,
sizeof(struct in6_addr));
- dst->prefixlen = (uint8_t)PREFIX_LEN_ROUTE_TYPE_5_IPV6;
+ dst->prefixlen = (uint16_t)PREFIX_LEN_ROUTE_TYPE_5_IPV6;
}
} else
return -1;
diff --git a/lib/prefix.c b/lib/prefix.c
index f3b707af3..9f0aa5066 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -971,6 +971,10 @@ uint8_t ip_masklen(struct in_addr netmask)
{
uint32_t tmp = ~ntohl(netmask.s_addr);
+ /*
+ * clz: count leading zeroes. sadly, the behaviour of this builtin is
+ * undefined for a 0 argument, even though most CPUs give 32
+ */
return tmp ? __builtin_clz(tmp) : 32;
}
diff --git a/lib/prefix.h b/lib/prefix.h
index 825b8bc75..d6dcb09f2 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -304,9 +304,8 @@ union prefixconstptr {
#define INET6_BUFSIZ 53
#endif /* INET6_BUFSIZ */
-/* Maximum prefix string length (IPv6) */
-/* dead:beef:dead:beef:dead:beef:dead:beef:255.255.255.255 + / + 65535 + \0 */
-#define PREFIX_STRLEN 53
+/* Maximum string length of the result of prefix2str */
+#define PREFIX_STRLEN 80
/* Max bit/byte length of IPv4 address. */
#define IPV4_MAX_BYTELEN 4