summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2012-02-28 15:15:29 +0400
committerDavid Lamparter <equinox@diac24.net>2012-03-12 11:05:45 +0100
commitaee567450eaf32877d00f47c4cc5d05c5fb85a51 (patch)
tree9fb0df5ce6fedc3e403f8b2b4d59ed0e556a1453
parentbd5651f0ec7aa94627a2a6868dd458f016750a35 (diff)
ospfd: reduce ospf_verify_header()
Protocol version checks fits ospf_packet_examin() better (like it is implemented in ospf6d), and packet type check is already there.
-rw-r--r--ospfd/ospf_packet.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 4842c4e2..351fb210 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -2587,6 +2587,12 @@ ospf_packet_examin (struct ospf_header * oh, const unsigned bytesonwire)
/* Now it is safe to access header fields. Performing length check, allow
* for possible extra bytes of crypto auth/padding, which are not counted
* in the OSPF header "length" field. */
+ if (oh->version != OSPF_VERSION)
+ {
+ if (IS_DEBUG_OSPF_PACKET (0, RECV))
+ zlog_debug ("%s: invalid (%u) protocol version", __func__, oh->version);
+ return MSG_NG;
+ }
bytesdeclared = ntohs (oh->length);
if (ntohs (oh->auth_type) != OSPF_AUTH_CRYPTOGRAPHIC)
bytesauth = 0;
@@ -2682,21 +2688,6 @@ static int
ospf_verify_header (struct stream *ibuf, struct ospf_interface *oi,
struct ip *iph, struct ospf_header *ospfh)
{
- /* check version. */
- if (ospfh->version != OSPF_VERSION)
- {
- zlog_warn ("interface %s: ospf_read version number mismatch.",
- IF_NAME (oi));
- return -1;
- }
-
- /* Valid OSPFv2 packet types are 1 through 5 inclusive. */
- if (ospfh->type < 1 || ospfh->type > 5)
- {
- zlog_warn ("interface %s: invalid packet type %u", IF_NAME (oi), ospfh->type);
- return -1;
- }
-
/* Check Area ID. */
if (!ospf_check_area_id (oi, ospfh))
{