From patchwork Wed Dec 15 22:24:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 75695 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id ED54A1007D6 for ; Thu, 16 Dec 2010 09:25:23 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172Ab0LOWYb (ORCPT ); Wed, 15 Dec 2010 17:24:31 -0500 Received: from rere.qmqm.pl ([89.167.52.164]:53548 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834Ab0LOWYa (ORCPT ); Wed, 15 Dec 2010 17:24:30 -0500 Received: by rere.qmqm.pl (Postfix, from userid 1000) id 7F02F13A5D; Wed, 15 Dec 2010 23:24:29 +0100 (CET) Message-Id: <35b79fea5227b5bb1bb734b0188b7ef43cfc9dd6.1292451559.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [RFC PATCH 01/12] net: Move check of checksum features to netdev_fix_features() MIME-Version: 1.0 To: netdev@vger.kernel.org Date: Wed, 15 Dec 2010 23:24:29 +0100 (CET) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Michał Mirosław --- net/core/dev.c | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index f937726..6823275 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5020,6 +5020,23 @@ static void rollback_registered(struct net_device *dev) unsigned long netdev_fix_features(unsigned long features, const char *name) { + /* Fix illegal checksum combinations */ + if ((features & NETIF_F_HW_CSUM) && + (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { + if (name) + printk(KERN_NOTICE "%s: mixed HW and IP checksum settings.\n", + name); + features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); + } + + if ((features & NETIF_F_NO_CSUM) && + (features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { + if (name) + printk(KERN_NOTICE "%s: mixed no checksumming and other settings.\n", + name); + features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM); + } + /* Fix illegal SG+CSUM combinations. */ if ((features & NETIF_F_SG) && !(features & NETIF_F_ALL_CSUM)) { @@ -5195,21 +5212,6 @@ int register_netdevice(struct net_device *dev) if (dev->iflink == -1) dev->iflink = dev->ifindex; - /* Fix illegal checksum combinations */ - if ((dev->features & NETIF_F_HW_CSUM) && - (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { - printk(KERN_NOTICE "%s: mixed HW and IP checksum settings.\n", - dev->name); - dev->features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); - } - - if ((dev->features & NETIF_F_NO_CSUM) && - (dev->features & (NETIF_F_HW_CSUM|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { - printk(KERN_NOTICE "%s: mixed no checksumming and other settings.\n", - dev->name); - dev->features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|NETIF_F_HW_CSUM); - } - dev->features = netdev_fix_features(dev->features, dev->name); /* Enable software GSO if SG is supported. */