@@ -809,6 +809,18 @@ out:
return err;
}
+static int validate_incoming_skb(struct sk_buff *skb)
+{
+ /*
+ * If the SKB is partial then we must be able to setup the
+ * checksum fields in the skb.
+ */
+ if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_setup(skb))
+ return 0;
+
+ return 1;
+}
+
static int handle_incoming_queue(struct net_device *dev,
struct sk_buff_head *rxq)
{
@@ -829,13 +841,11 @@ static int handle_incoming_queue(struct net_device *dev,
/* Ethernet work: Delayed to here as it peeks the header. */
skb->protocol = eth_type_trans(skb, dev);
- if (skb->ip_summed == CHECKSUM_PARTIAL) {
- if (skb_checksum_setup(skb)) {
- kfree_skb(skb);
- packets_dropped++;
- dev->stats.rx_errors++;
- continue;
- }
+ if (!validate_incoming_skb(skb)) {
+ kfree_skb(skb);
+ packets_dropped++;
+ dev->stats.rx_errors++;
+ continue;
}
dev->stats.rx_packets++;
Makes future additional validation clearer. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: xen-devel@lists.xensource.com Cc: netdev@vger.kernel.org --- drivers/net/xen-netfront.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)