[netflow-tools] "Fatal error - exiting immediately"

Damien Miller djm at mindrot.org
Thu Nov 17 11:38:12 EST 2005


On Thu, 17 Nov 2005, Damien Miller wrote:

> If you want to dive into the code, search for return(PP_MALLOC_FAIL)
> statements and insert some logging around them so you can see exactly
> which allocation failed.

Like the attached patch does...

-d
-------------- next part --------------
Index: softflowd.c
===================================================================
RCS file: /var/cvs/softflowd/softflowd.c,v
retrieving revision 1.84
diff -u -p -r1.84 softflowd.c
--- softflowd.c	1 Oct 2005 00:14:21 -0000	1.84
+++ softflowd.c	17 Nov 2005 00:34:30 -0000
@@ -533,8 +533,11 @@ process_packet(struct FLOWTRACK *ft, con
 	/* If a matching flow does not exist, create and insert one */
 	if ((flow = FLOW_FIND(FLOWS, &ft->flows, &tmp)) == NULL) {
 		/* Allocate and fill in the flow */
-		if ((flow = malloc(sizeof(*flow))) == NULL)
+		if ((flow = malloc(sizeof(*flow))) == NULL) {
+			logit(LOG_ERR, "process_packet: flow malloc(%u) fail",
+			    sizeof(*flow));
 			return (PP_MALLOC_FAIL);
+		}
 		memcpy(flow, &tmp, sizeof(*flow));
 		memcpy(&flow->flow_start, received_time,
 		    sizeof(flow->flow_start));
@@ -542,8 +545,11 @@ process_packet(struct FLOWTRACK *ft, con
 		FLOW_INSERT(FLOWS, &ft->flows, flow);
 
 		/* Allocate and fill in the associated expiry event */
-		if ((flow->expiry = malloc(sizeof(*flow->expiry))) == NULL)
+		if ((flow->expiry = malloc(sizeof(*flow->expiry))) == NULL) {
+			logit(LOG_ERR, "process_packet: expiry malloc(%u) fail",
+			    sizeof(*flow->expiry));
 			return (PP_MALLOC_FAIL);
+		}
 		flow->expiry->flow = flow;
 		/* Must be non-zero (0 means expire immediately) */
 		flow->expiry->expires_at = 1;


More information about the netflow-tools mailing list