From: Donald Sharp Date: Mon, 17 Dec 2018 21:28:47 +0000 (-0500) Subject: zebra: Move sin6_masklen to earlier in the file X-Git-Tag: frr-7.1-dev~74^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9ba0e5706c6206e1ba8035b2ae1aa0136f36f4bb;p=matthieu%2Ffrr.git zebra: Move sin6_masklen to earlier in the file I'm going to rearrage the kernel_rtm_ipv4 and v6 functions so the sin6_masklen needs to be moved a bit earlier. Signed-off-by: Donald Sharp --- diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 38c362a193..d5a4fcb116 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -89,6 +89,30 @@ static int kernel_rtm_add_labels(struct mpls_label_stack *nh_label, } #endif +#ifdef SIN6_LEN +/* Calculate sin6_len value for netmask socket value. */ +static int sin6_masklen(struct in6_addr mask) +{ + struct sockaddr_in6 sin6; + char *p, *lim; + int len; + + if (IN6_IS_ADDR_UNSPECIFIED(&mask)) + return sizeof(long); + + sin6.sin6_addr = mask; + len = sizeof(struct sockaddr_in6); + + lim = (char *)&sin6.sin6_addr; + p = lim + sizeof(sin6.sin6_addr); + + while (*--p == 0 && p >= lim) + len--; + + return len; +} +#endif /* SIN6_LEN */ + /* Interface between zebra message and rtm message. */ static int kernel_rtm_ipv4(int cmd, const struct prefix *p, const struct nexthop_group *ng, uint32_t metric) @@ -253,30 +277,6 @@ static int kernel_rtm_ipv4(int cmd, const struct prefix *p, return 0; /*XXX*/ } -#ifdef SIN6_LEN -/* Calculate sin6_len value for netmask socket value. */ -static int sin6_masklen(struct in6_addr mask) -{ - struct sockaddr_in6 sin6; - char *p, *lim; - int len; - - if (IN6_IS_ADDR_UNSPECIFIED(&mask)) - return sizeof(long); - - sin6.sin6_addr = mask; - len = sizeof(struct sockaddr_in6); - - lim = (char *)&sin6.sin6_addr; - p = lim + sizeof(sin6.sin6_addr); - - while (*--p == 0 && p >= lim) - len--; - - return len; -} -#endif /* SIN6_LEN */ - /* Interface between zebra message and rtm message. */ static int kernel_rtm_ipv6(int cmd, const struct prefix *p, const struct nexthop_group *ng, uint32_t metric)