mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 14:50:58 +00:00
lib: Add support for IPv6 ttl security
* sockunion.c: (sockopt_minttl) Add IPv6 support for min hop count. The kernel support is Linux kernel 2.6.35 or later.
This commit is contained in:
parent
89b6d1f8e2
commit
d876bdf4a8
@ -541,22 +541,30 @@ int
|
|||||||
sockopt_minttl (int family, int sock, int minttl)
|
sockopt_minttl (int family, int sock, int minttl)
|
||||||
{
|
{
|
||||||
#ifdef IP_MINTTL
|
#ifdef IP_MINTTL
|
||||||
int ret;
|
if (family == AF_INET)
|
||||||
|
|
||||||
ret = setsockopt (sock, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl));
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
|
int ret = setsockopt (sock, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl));
|
||||||
|
if (ret < 0)
|
||||||
zlog (NULL, LOG_WARNING,
|
zlog (NULL, LOG_WARNING,
|
||||||
"can't set sockopt IP_MINTTL to %d on socket %d: %s",
|
"can't set sockopt IP_MINTTL to %d on socket %d: %s",
|
||||||
minttl, sock, safe_strerror (errno));
|
minttl, sock, safe_strerror (errno));
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* IP_MINTTL */
|
||||||
|
#ifdef IPV6_MINHOPCNT
|
||||||
|
if (family == AF_INET6)
|
||||||
|
{
|
||||||
|
int ret = setsockopt (sock, IPPROTO_IPV6, IPV6_MINHOPCNT, &minttl, sizeof(minttl));
|
||||||
|
if (ret < 0)
|
||||||
|
zlog (NULL, LOG_WARNING,
|
||||||
|
"can't set sockopt IPV6_MINHOPCNT to %d on socket %d: %s",
|
||||||
|
minttl, sock, safe_strerror (errno));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
errno = EOPNOTSUPP;
|
errno = EOPNOTSUPP;
|
||||||
return -1;
|
return -1;
|
||||||
#endif /* IP_MINTTL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If same family and same prefix return 1. */
|
/* If same family and same prefix return 1. */
|
||||||
|
Loading…
Reference in New Issue
Block a user