On all OS 0 is disabled and >0 is enabled.
So return -1 on any error which is returned to the main process so
we could log a diagnostic in the future.
While where allow privsep to actually get the sysctl for Capsicum.
int
ip6_forwarding(__unused const char *ifname)
{
- int val;
#ifdef IPV6CTL_FORWARDING
- val = get_inet6_sysctl(IPV6CTL_FORWARDING);
+ return get_inet6_sysctl(IPV6CTL_FORWARDING);
#else
- val = get_inet6_sysctlbyname("net.inet6.ip6.forwarding");
+ return get_inet6_sysctlbyname("net.inet6.ip6.forwarding");
#endif
- return val < 0 ? 0 : val;
}
#ifdef SIOCIFAFATTACH
ifname = "all";
snprintf(path, sizeof(path), "%s/%s/forwarding", p_conf, ifname);
if (readfile(path, buf, sizeof(buf)) == -1)
- return 0;
+ return -1;
i = (int)strtoi(buf, NULL, 0, INT_MIN, INT_MAX, &error);
if (error != 0 && error != ENOTSUP)
- return 0;
+ return -1;
return i;
}
* Per interface only affects IsRouter of NA messages. */
#ifdef PRIVSEP_SYSCTL
if (IN_PRIVSEP(sifp->ctx))
- forwarding = ps_root_ip6forwarding(sifp->ctx, NULL) != 0;
+ forwarding = ps_root_ip6forwarding(sifp->ctx, NULL) > 0;
else
#endif
- forwarding = ip6_forwarding(NULL) != 0;
+ forwarding = ip6_forwarding(NULL) > 0;
if (!forwarding)
return NULL;
na->nd_na_flags_reserved |= ND_NA_FLAG_ROUTER;
} else
#endif
- if (ip6_forwarding(ifp->name) != 0)
+ if (ip6_forwarding(ifp->name) > 0)
na->nd_na_flags_reserved |= ND_NA_FLAG_ROUTER;
na->nd_na_target = ia->addr;
free_rdata = true;
break;
#endif
-#if defined(INET6) && (defined(__linux__) || defined(HAVE_PLEDGE))
+#if defined(INET6) && defined(PRIVSEP_SYSCTL)
case PS_IP6FORWARDING:
err = ip6_forwarding(data);
break;