Thread (1 message) 1 message, 1 author, 2010-01-11

Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and netdev stats

From: Wolfgang Grandegger <hidden>
Date: 2010-01-11 19:23:27

Marc Kleine-Budde wrote:
Oliver Hartkopp wrote:
quoted
Wolfgang Grandegger wrote:
quoted
quoted
quoted
 
+	if (skb->len != sizeof(*cf) || cf->can_dlc > 8) {
+		kfree_skb(skb);
+		dev->stats.tx_dropped++;
+		return NETDEV_TX_OK;
+	}
A static inline function "invalid_can_skb(skb)" (or "no_can_skb") would
be handy here:

	if (invalid_can_skb(skb)) {
		kfree_skb(skb);
		dev->stats.tx_dropped++;
		return NETDEV_TX_OK;		
	}
Another idea could be:
quoted
	if (can_dropped_invalid_skb(skb, dev))
		return NETDEV_TX_OK;
quoted
with
quoted
static inline int can_dropped_invalid_skb(struct sk_buff *skb, struct net_device *dev)
{
	const struct can_frame *cf = (struct can_frame *)skb->data;
quoted
	if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) {
		kfree_skb(skb);
		dev->stats.tx_dropped++;
		return 1;
	}
quoted
	return 0;
}
this functions looks nice, but I'd swap its arguments, in order to have
the same signature as the alloc_can_skb() functions
Yep.

Wolfgang.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help