ospf6d: check MTU with message header size in mind
* ospf6_message.c: (ospf6_packet_max): new function, return maximum IPv6
payload on an interface; (ospf6_hello_send, ospf6_dbdesc_send,
ospf6_dbdesc_send_newone, ospf6_lsreq_send, ospf6_lsupdate_send_neighbor,
ospf6_lsupdate_send_interface, ospf6_lsack_send_neighbor,
ospf6_lsack_send_interface): compare message size with the maximum
payload instead of the MTU.
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index f40ad4b..42521a2 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -47,6 +47,8 @@
#include "ospf6_flood.h"
#include "ospf6d.h"
+#include <netinet/ip6.h>
+
unsigned char conf_debug_ospf6_message[6] = {0x03, 0, 0, 0, 0, 0};
const char *ospf6_message_type_str[] =
{ "Unknown", "Hello", "DbDesc", "LSReq", "LSUpdate", "LSAck" };
@@ -1774,6 +1776,12 @@
zlog_err ("Could not send entire message");
}
+static int
+ospf6_packet_max(struct ospf6_interface *oi)
+{
+ return oi->ifmtu - sizeof(struct ip6_hdr);
+}
+
int
ospf6_hello_send (struct thread *thread)
{
@@ -1820,7 +1828,7 @@
if (on->state < OSPF6_NEIGHBOR_INIT)
continue;
- if (p - sendbuf + sizeof (u_int32_t) > oi->ifmtu)
+ if (p - sendbuf + sizeof (u_int32_t) > ospf6_packet_max(oi))
{
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_HELLO, SEND))
zlog_debug ("sending Hello message: exceeds I/F MTU");
@@ -1896,7 +1904,7 @@
/* MTU check */
if (p - sendbuf + sizeof (struct ospf6_lsa_header) >
- on->ospf6_if->ifmtu)
+ ospf6_packet_max(on->ospf6_if))
{
ospf6_lsa_unlock (lsa);
break;
@@ -1930,7 +1938,7 @@
for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
lsa = ospf6_lsdb_next (lsa))
{
- if (size + sizeof (struct ospf6_lsa_header) > on->ospf6_if->ifmtu)
+ if (size + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if))
{
ospf6_lsa_unlock (lsa);
break;
@@ -1997,7 +2005,7 @@
lsa = ospf6_lsdb_next (lsa))
{
/* MTU check */
- if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > on->ospf6_if->ifmtu)
+ if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > ospf6_packet_max(on->ospf6_if))
{
ospf6_lsa_unlock (lsa);
break;
@@ -2066,7 +2074,7 @@
{
/* MTU check */
if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
- > on->ospf6_if->ifmtu)
+ > ospf6_packet_max(on->ospf6_if))
{
ospf6_lsa_unlock (lsa);
break;
@@ -2086,7 +2094,7 @@
{
/* MTU check */
if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
- > on->ospf6_if->ifmtu)
+ > ospf6_packet_max(on->ospf6_if))
{
ospf6_lsa_unlock (lsa);
break;
@@ -2159,7 +2167,7 @@
{
/* MTU check */
if ( (p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE (lsa->header)))
- > oi->ifmtu)
+ > ospf6_packet_max(oi))
{
ospf6_lsa_unlock (lsa);
break;
@@ -2226,7 +2234,7 @@
lsa = ospf6_lsdb_next (lsa))
{
/* MTU check */
- if (p - sendbuf + sizeof (struct ospf6_lsa_header) > on->ospf6_if->ifmtu)
+ if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if))
{
/* if we run out of packet size/space here,
better to try again soon. */
@@ -2286,7 +2294,7 @@
lsa = ospf6_lsdb_next (lsa))
{
/* MTU check */
- if (p - sendbuf + sizeof (struct ospf6_lsa_header) > oi->ifmtu)
+ if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(oi))
{
/* if we run out of packet size/space here,
better to try again soon. */