From cf680c38a91f92f3389c08b947faa37a16f08076 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 10 Aug 2021 19:21:19 -0400 Subject: [PATCH 1/2] ospfd: Ensure we have some non header lsa data In some cases FRR is receiving a lsa data packet with a length set to the length of the header only. If we are expecting data from a peer in the form of lsa data. Let's enforce it. Signed-off-by: Donald Sharp --- ospfd/ospf_opaque.h | 2 ++ ospfd/ospf_packet.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index 7d401c3dcc..aeaeea9189 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -77,6 +77,8 @@ #define OPAQUE_TYPE_RANGE_RESERVED(type) (127 < (type) && (type) <= 255) +#define OSPF_OPAQUE_LSA_MIN_SIZE 4U + #define VALID_OPAQUE_INFO_LEN(lsahdr) \ ((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \ && ((ntohs((lsahdr)->length) < OSPF_MAX_LSA_SIZE)) \ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 1efdfee3b4..7c32c18d4c 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -108,9 +108,9 @@ static const uint16_t ospf_lsa_minlen[] = { 0, OSPF_AS_EXTERNAL_LSA_MIN_SIZE, 0, - 0, - 0, - 0, + OSPF_OPAQUE_LSA_MIN_SIZE, + OSPF_OPAQUE_LSA_MIN_SIZE, + OSPF_OPAQUE_LSA_MIN_SIZE, }; /* for ospf_check_auth() */ From 07a62e585db76d93487279d48b6d15e6b8e1a54a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 14 Sep 2021 13:13:32 -0400 Subject: [PATCH 2/2] ospfd: Add some small doc to what each one is for future people min lsa packet sizes are not always directly corresponding to the actual LSA. Add a bit of comments so it's easier for future people to figure out. Signed-off-by: Donald Sharp --- ospfd/ospf_packet.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 7c32c18d4c..44f547b369 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -99,18 +99,18 @@ static const uint16_t ospf_packet_minlen[] = { /* Minimum (besides OSPF_LSA_HEADER_SIZE) lengths for LSAs of particular types, offset is the "LSA type" field. */ static const uint16_t ospf_lsa_minlen[] = { - 0, - OSPF_ROUTER_LSA_MIN_SIZE, - OSPF_NETWORK_LSA_MIN_SIZE, - OSPF_SUMMARY_LSA_MIN_SIZE, - OSPF_SUMMARY_LSA_MIN_SIZE, - OSPF_AS_EXTERNAL_LSA_MIN_SIZE, - 0, - OSPF_AS_EXTERNAL_LSA_MIN_SIZE, - 0, - OSPF_OPAQUE_LSA_MIN_SIZE, - OSPF_OPAQUE_LSA_MIN_SIZE, - OSPF_OPAQUE_LSA_MIN_SIZE, + 0, /* OSPF_UNKNOWN_LSA */ + OSPF_ROUTER_LSA_MIN_SIZE, /* OSPF_ROUTER_LSA */ + OSPF_NETWORK_LSA_MIN_SIZE, /* OSPF_NETWORK_LSA */ + OSPF_SUMMARY_LSA_MIN_SIZE, /* OSPF_SUMMARY_LSA */ + OSPF_SUMMARY_LSA_MIN_SIZE, /* OSPF_ASBR_SUMMARY_LSA */ + OSPF_AS_EXTERNAL_LSA_MIN_SIZE, /* OSPF_AS_EXTERNAL_LSA */ + 0, /* Unsupported, OSPF_GROUP_MEMBER_LSA */ + OSPF_AS_EXTERNAL_LSA_MIN_SIZE, /* OSPF_AS_NSSA_LSA */ + 0, /* Unsupported, OSPF_EXTERNAL_ATTRIBURES_LSA */ + OSPF_OPAQUE_LSA_MIN_SIZE, /* OSPF_OPAQUE_LINK_LSA */ + OSPF_OPAQUE_LSA_MIN_SIZE, /* OSPF_OPAQUE_AREA_LSA */ + OSPF_OPAQUE_LSA_MIN_SIZE, /* OSPF_OPAQUE_AS_LSA */ }; /* for ospf_check_auth() */