mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 12:48:43 +00:00
Use IPv6 checksums in OSPFv3.
This commit is contained in:
parent
3f22fa9e74
commit
4ac7c8341c
@ -60,6 +60,10 @@ int sk_setup_multicast(sock *s);
|
||||
int sk_join_group(sock *s, ip_addr maddr);
|
||||
int sk_leave_group(sock *s, ip_addr maddr);
|
||||
|
||||
#ifdef IPV6
|
||||
int sk_set_ipv6_checksum(sock *s, int offset);
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
sk_send_buffer_empty(sock *sk)
|
||||
{
|
||||
|
@ -89,6 +89,12 @@ ospf_open_socket(struct ospf_iface *ifa, int mc)
|
||||
if (sk_open(ipsk) != 0)
|
||||
goto err;
|
||||
|
||||
#ifdef OSPFv3
|
||||
/* 12 is an offset of the checksum in an OSPF packet */
|
||||
if (sk_set_ipv6_checksum(ipsk, 12) < 0)
|
||||
goto err;
|
||||
#endif
|
||||
|
||||
if (mc)
|
||||
{
|
||||
if (sk_setup_multicast(ipsk) < 0)
|
||||
|
@ -320,7 +320,6 @@ ospf_rx_hook(sock * sk, int size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* FIXME - handle checksums in OSPFv3 */
|
||||
#ifdef OSPFv2
|
||||
if ((ps->autype != htons(OSPF_AUTH_CRYPT)) &&
|
||||
(!ipsum_verify(ps, 16, (void *) ps + sizeof(struct ospf_packet),
|
||||
|
@ -782,12 +782,29 @@ int
|
||||
sk_set_broadcast(sock *s, int enable)
|
||||
{
|
||||
if (setsockopt(s->fd, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(enable)) < 0)
|
||||
log(L_ERR "sk_set_broadcast: SO_BROADCAST: %m");
|
||||
{
|
||||
log(L_ERR "sk_set_broadcast: SO_BROADCAST: %m");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef IPV6
|
||||
|
||||
int
|
||||
sk_set_ipv6_checksum(sock *s, int offset)
|
||||
{
|
||||
if (setsockopt(s->fd, IPPROTO_IPV6, IPV6_CHECKSUM, &offset, sizeof(offset)) < 0)
|
||||
{
|
||||
log(L_ERR "sk_set_ipv6_checksum: IPV6_CHECKSUM: %m");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sk_setup_multicast(sock *s)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user