summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorgdt <gdt>2005-01-10 14:20:43 +0000
committergdt <gdt>2005-01-10 14:20:43 +0000
commit86f1fd9615391485baf37afe1055b7d8bf64b4a8 (patch)
tree3a18671a9a94e952fabcb5ecca70c0bc80bcb523 /ospfd
parent220d0c0ea3a3aab81836a6aad4137aa40270512d (diff)
2005-01-10 Greg Troxel <gdt@fnord.ir.bbn.com>
* ospf_packet.h: Remove commented out definition of OSPF_MAX_PACKET; neither it or the uncommented one are used any more. * ospf_packet.c (ospf_make_ls_upd): Leave room for authentication when deciding if an update will fit. (ospf_packet_authspace): Factor out calculation of size required for authentication. (ospf_make_db_desc): Use ospf_max_packet, not OSPF_MAX_PACKET. Don't confuse readers that there is a macro.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog12
-rw-r--r--ospfd/ospf_packet.c36
-rw-r--r--ospfd/ospf_packet.h4
3 files changed, 38 insertions, 14 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index c7075623..df87b11e 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,15 @@
+2005-01-10 Greg Troxel <gdt@fnord.ir.bbn.com>
+
+ * ospf_packet.h: Remove commented out definition of
+ OSPF_MAX_PACKET; neither it or the uncommented one are used any more.
+
+ * ospf_packet.c (ospf_make_ls_upd): Leave room for authentication
+ when deciding if an update will fit.
+ (ospf_packet_authspace): Factor out calculation of size required
+ for authentication.
+ (ospf_make_db_desc): Use ospf_max_packet, not OSPF_MAX_PACKET.
+ Don't confuse readers that there is a macro.
+
2004-12-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf_network.c: Improve all setsockopt error messages to give detailed
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 6eb6651f..f636e2be 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -241,16 +241,25 @@ ospf_packet_dup (struct ospf_packet *op)
return new;
}
+/* XXX inline */
+unsigned int
+ospf_packet_authspace (struct ospf_interface *oi)
+{
+ int auth = 0;
+
+ if ( ospf_auth_type (oi) == OSPF_AUTH_CRYPTOGRAPHIC)
+ auth = OSPF_AUTH_MD5_SIZE;
+
+ return auth;
+}
+
unsigned int
ospf_packet_max (struct ospf_interface *oi)
{
int max;
- if ( ospf_auth_type (oi) == OSPF_AUTH_CRYPTOGRAPHIC)
- max = oi->ifp->mtu - OSPF_AUTH_MD5_SIZE;
- else
- max = oi->ifp->mtu;
-
+ max = oi->ifp->mtu - ospf_packet_authspace(oi);
+
max -= (OSPF_HEADER_SIZE + sizeof (struct ip));
return max;
@@ -1410,8 +1419,8 @@ ospf_ls_req (struct ip *iph, struct ospf_header *ospfh,
return;
}
- /* Packet overflows MTU size, send immediatly. */
- if (length + ntohs (find->data->length) > OSPF_PACKET_MAX (oi))
+ /* Packet overflows MTU size, send immediately. */
+ if (length + ntohs (find->data->length) > ospf_packet_max (oi))
{
if (oi->type == OSPF_IFTYPE_NBMA)
ospf_ls_upd_send (nbr, ls_upd, OSPF_SEND_PACKET_DIRECT);
@@ -2735,7 +2744,7 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr,
u_int16_t ls_age;
/* DD packet overflows interface MTU. */
- if (length + OSPF_LSA_HEADER_SIZE > OSPF_PACKET_MAX (oi))
+ if (length + OSPF_LSA_HEADER_SIZE > ospf_packet_max (oi))
break;
/* Keep pointer to LS age. */
@@ -2770,7 +2779,7 @@ ospf_make_ls_req_func (struct stream *s, u_int16_t *length,
oi = nbr->oi;
/* LS Request packet overflows interface MTU. */
- if (*length + delta > OSPF_PACKET_MAX(oi))
+ if (*length + delta > ospf_packet_max(oi))
return 0;
stream_putl (s, lsa->data->type);
@@ -2827,6 +2836,7 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
struct ospf_lsa *lsa;
struct listnode *node;
u_int16_t length = OSPF_LS_UPD_MIN_SIZE;
+ unsigned int size_noauth;
unsigned long delta = stream_get_putp (s);
unsigned long pp;
int count = 0;
@@ -2837,6 +2847,9 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
pp = stream_get_putp (s);
ospf_output_forward (s, OSPF_LS_UPD_MIN_SIZE);
+ /* Calculate amount of packet usable for data. */
+ size_noauth = stream_get_size(s) - ospf_packet_authspace(oi);
+
while ((node = listhead (update)) != NULL)
{
struct lsa_header *lsah;
@@ -2850,7 +2863,7 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
assert (lsa->data);
/* Will it fit? */
- if (length + delta + ntohs (lsa->data->length) > stream_get_size (s))
+ if (length + delta + ntohs (lsa->data->length) > size_noauth)
break;
/* Keep pointer to LS age. */
@@ -2899,7 +2912,7 @@ ospf_make_ls_ack (struct ospf_interface *oi, struct list *ack, struct stream *s)
lsa = getdata (node);
assert (lsa);
- if (length + delta > OSPF_PACKET_MAX (oi))
+ if (length + delta > ospf_packet_max (oi))
break;
stream_put (s, lsa->data, OSPF_LSA_HEADER_SIZE);
@@ -3264,6 +3277,7 @@ ospf_ls_upd_packet_new (struct list *update, struct ospf_interface *oi)
else
size = oi->ifp->mtu;
+ /* XXX Should this be - sizeof(struct ip)?? -gdt */
if (size > OSPF_MAX_PACKET_SIZE)
{
zlog_warn ("ospf_ls_upd_packet_new: oversized LSA id:%s too big,"
diff --git a/ospfd/ospf_packet.h b/ospfd/ospf_packet.h
index 8de0bfbe..af9e634b 100644
--- a/ospfd/ospf_packet.h
+++ b/ospfd/ospf_packet.h
@@ -119,10 +119,8 @@ struct ospf_db_desc
/* Macros. */
+/* XXX Perhaps obsolete; function in ospf_packet.c */
#define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
-/*
-#define OSPF_PACKET_MAX(oi) (((oi)->ifp->mtu - ((oi)->auth_md5 ? OSPF_AUTH_MD5_SIZE : 0)) - 88)
-*/
#define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
#define OSPF_OUTPUT_LENGTH(S) ((S)->endp)