[<prev] [next>] [day] [month] [year] [list]
Date: Thu, 1 Jan 2009 10:54:28 +1030
From: Mark Smith <ipng@...06e6720323030352d30312d31340a.nosense.org>
To: netdev@...r.kernel.org
Subject: Correct use of NET_RX_SUCCESS, NET_RX_DROP or NET_RX_BAD?
Hi,
I'm a bit confused as to when to return either NET_RX_SUCCESS or
NET_RX_DROP in a protocol rcv() function.
I've been following the use in IPv4's ip_rcv()/ip_rcv_finish()
routines. It seems that any time the incoming skb fails a test the
return is NET_RX_DROP e.g. from 2.6.28:
if (skb->pkt_type == PACKET_OTHERHOST)
goto drop;
...
drop:
kfree_skb(skb);
out:
return NET_RX_DROP;
However, looking at protocol rcv functions for other protocols, such as
IPv6, IPX and CAN, it seems that they're returning NET_RX_SUCCESS in
the same or similar situations e.g. in ipv6_rcv():
if (skb->pkt_type == PACKET_OTHERHOST) {
kfree_skb(skb);
return 0;
}
where 0 corresponds to NET_RX_SUCCESS.
The comment in netdevice.h seems to suggest that these return values
are related to the kernel's internal congestion management. The
protocol I'm working on doesn't have any specific congestion condition,
the only thing that might indicate congestion is a failure of the
routine to create a new SKB for transmitting a packet in response to a
received one. So should I have my rcv() routine and all other routines
return NET_RX_SUCCESS, and return NET_RX_DROP if the kernel fails to
create a new SKB for a packet to be transmitted? It seems that
NET_RX_BAD - "/* packet dropped due to kernel error */" might also be a
correct alternative return for a failed SKB allocation.
Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists