[klibc] [PATCH] Reset ret after packet_peek as the packet is maybe for another device.

Ulrich Dangel uli at spamt.net
Sun Mar 27 17:30:51 PDT 2011


This patch fixes a bug on systems with multiple connected network devices.
As packet_peek uses all devices to receive data instead of a specific
device. As the return value was never reset it was possible that packets
from other devices were returned by packet_peek. As the the ifindex did
not match any ifindex of the specified devices the packet was never
removed and packets for the correct device were never processed.

This patch reset ret before iterating over the available network device to
discard packages from irrelevant network devices. It maybe better to change
packet_peek and packet_discard to work on specific interfaces.
---
 usr/kinit/ipconfig/main.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index d501bec..ea2abc8 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -311,6 +311,9 @@ static int do_pkt_recv(int pkt_fd, time_t now)
 	if (ret == 0)
 		return ret;
 
+	// reset ret
+	ret = 0;
+
 	for (s = slist; s; s = s->next) {
 		if (s->dev->ifindex == ifindex) {
 			ret = process_receive_event(s, now);
-- 
1.7.1



More information about the klibc mailing list