]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd, lib: few more prefixlen updated
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 25 Oct 2018 20:24:25 +0000 (20:24 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 25 Oct 2018 20:25:36 +0000 (20:25 +0000)
* 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>
bgpd/bgp_attr_evpn.c
lib/prefix.c
lib/prefix.h

index 88e520fdc508c24de4fdd1014124cd9cf3dee105..3e9d05ad978c905a4d14005890530500e698b0eb 100644 (file)
@@ -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;
index f3b707af3a94bc0c14fab840784ef7d5b1e64a89..9f0aa506658c9b53999fc99b43dae14060cc848b 100644 (file)
@@ -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;
 }
 
index 825b8bc75d3438bc3221b150c41fc443b54ab9f7..d6dcb09f263cb5b75c0620153763fb53724b82ad 100644 (file)
@@ -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