Ospfd cored because of an assert when we try to write more than the MTU
size to the ospf packet buffer stream. The problem is - we allocate only MTU
sized buffer. The expectation is that Hello packets are never large
enough to approach MTU. Instead of crashing, this fix discards hello and
logs an error. One should not have so many neighbors behind an
interface.
Ticket: CM-22380
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8204
.description = "OSPF has attempted to change states when it should not be able to",
.suggestion = "Gather log files and open an issue",
},
+ {
+ .code = EC_OSPF_LARGE_HELLO,
+ .title = "OSPF Encountered a Large Hello",
+ .description = "OSPF attempted to send a Hello larger than MTU "
+ "but did not",
+ .suggestion = "Too many neighbors configured on a single interface."
+ " Suggestion is to decrease the number of neighbors on"
+ " a single interface/subnet"
+ },
{
.code = END_FERR,
}
EC_OSPF_LSA_MISSING,
EC_OSPF_PTP_NEIGHBOR,
EC_OSPF_LSA_SIZE,
+ EC_OSPF_LARGE_HELLO,
};
extern void ospf_error_init(void);
.prefix4))
flag = 1;
+ /* Hello packet overflows interface MTU. */
+ if (length + sizeof(uint32_t)
+ > ospf_packet_max(oi)) {
+ flog_err(
+ EC_OSPF_LARGE_HELLO,
+ "Oversized Hello packet!"
+ " Larger than MTU. Not sending it out");
+ return 0;
+ }
+
stream_put_ipv4(
s,
nbr->router_id
/* Prepare OSPF Hello body. */
length += ospf_make_hello(oi, op->s);
+ if (length == OSPF_HEADER_SIZE) {
+ /* Hello overshooting MTU */
+ ospf_packet_free(op);
+ return;
+ }
/* Fill OSPF header. */
ospf_fill_header(oi, op->s, length);