X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=f38210a4720556cf53784008850dcc4858e4fb67;hp=a0531e9d351d094e138600e3b24945c9b27d1f60;hb=af30be0d252d0f38c40bff7178a00addecdd1bb1;hpb=3ea9de913739667e2131d67d979ff175ec394e67 diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index a0531e9..f38210a 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -2757,7 +2757,7 @@ int sif6addr (int unit, eui64_t our_eui64, eui64_t his_eui64) memset(&ifr6, 0, sizeof(ifr6)); IN6_LLADDR_FROM_EUI64(ifr6.ifr6_addr, our_eui64); ifr6.ifr6_ifindex = ifr.ifr_ifindex; - ifr6.ifr6_prefixlen = 10; + ifr6.ifr6_prefixlen = 128; if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6) < 0) { error("sif6addr: ioctl(SIOCSIFADDR): %m (line %d)", __LINE__); @@ -2768,7 +2768,7 @@ int sif6addr (int unit, eui64_t our_eui64, eui64_t his_eui64) memset(&rt6, 0, sizeof(rt6)); IN6_LLADDR_FROM_EUI64(rt6.rtmsg_dst, his_eui64); rt6.rtmsg_flags = RTF_UP; - rt6.rtmsg_dst_len = 10; + rt6.rtmsg_dst_len = 128; rt6.rtmsg_ifindex = ifr.ifr_ifindex; rt6.rtmsg_metric = 1; @@ -2805,7 +2805,7 @@ int cif6addr (int unit, eui64_t our_eui64, eui64_t his_eui64) memset(&ifr6, 0, sizeof(ifr6)); IN6_LLADDR_FROM_EUI64(ifr6.ifr6_addr, our_eui64); ifr6.ifr6_ifindex = ifr.ifr_ifindex; - ifr6.ifr6_prefixlen = 10; + ifr6.ifr6_prefixlen = 128; if (ioctl(sock6_fd, SIOCDIFADDR, &ifr6) < 0) { if (errno != EADDRNOTAVAIL) { @@ -3165,3 +3165,38 @@ ether_to_eui64(eui64_t *p_eui64) return 1; } #endif + +/******************************************************************** + * + * get_time - Get current time, monotonic if possible. + */ +int +get_time(struct timeval *tv) +{ +/* Old glibc (< 2.3.4) does define CLOCK_MONOTONIC, but kernel may have it. + * Runtime checking makes it safe. */ +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC 1 +#endif + static int monotonic = -1; + struct timespec ts; + int ret; + + if (monotonic) { + ret = clock_gettime(CLOCK_MONOTONIC, &ts); + if (ret == 0) { + monotonic = 1; + if (tv) { + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; + } + return ret; + } else if (monotonic > 0) + return ret; + + monotonic = 0; + warn("Couldn't use monotonic clock source: %m"); + } + + return gettimeofday(tv, NULL); +}