瀏覽代碼

hoffmeis: Fixing situation where absence of a newdata() handler for UDP

connections might break things. Only-sending applications like syslog()
do not need a newdata() handler, so added a check if that handler exists.
tags/v0.9.3
Anselm Martin Hoffmeister 17 年之前
父節點
當前提交
ff5aac826a
共有 1 個檔案被更改,包括 10 行新增5 行删除
  1. 10
    5
      src/net/udp.c

+ 10
- 5
src/net/udp.c 查看文件

@@ -260,7 +260,7 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
260 260
 	struct udp_connection *conn;
261 261
 	size_t ulen;
262 262
 	uint16_t csum;
263
-	int rc;
263
+	int rc = 0;
264 264
 
265 265
 	/* Sanity check packet */
266 266
 	if ( pkb_len ( pkb ) < sizeof ( *udphdr ) ) {
@@ -314,11 +314,16 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
314 314
 	}
315 315
 
316 316
 	/* Pass data to application */
317
-	rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
317
+	if ( conn->udp_op->newdata ) {
318
+		rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
318 319
 				     st_src, st_dest );
319
-	if ( rc != 0 ) {
320
-		DBGC ( conn, "UDP %p application rejected packet: %s\n",
321
-		       conn, strerror ( rc ) );
320
+		if ( rc != 0 ) {
321
+			DBGC ( conn, "UDP %p application rejected packet: %s\n",
322
+			       conn, strerror ( rc ) );
323
+		}
324
+	} else {
325
+		DBGC ( conn, "UDP %p application has no newdata handler for " \
326
+			"incoming packet\n", conn );
322 327
 	}
323 328
 
324 329
  done:

Loading…
取消
儲存