diff mbox

firewire net: Ensure checksumming in upper layer.

Message ID 50FBA02C.9030203@linux-ipv6.org
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

YOSHIFUJI Hideaki / 吉藤英明 Jan. 20, 2013, 7:43 a.m. UTC
It is wrong to set skb->ip_summed to CHECKSUM_UNNECESSARY unless
the device has already checked it.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
 drivers/firewire/net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Richter Jan. 20, 2013, 9:50 a.m. UTC | #1
On Jan 20 YOSHIFUJI Hideaki wrote:
> It is wrong to set skb->ip_summed to CHECKSUM_UNNECESSARY unless
> the device has already checked it.
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> ---
>  drivers/firewire/net.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index e7a711f5..df6a1ca 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -520,7 +520,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
>  	dev = netdev_priv(net);
>  	/* Write metadata, and then pass to the receive level */
>  	skb->dev = net;
> -	skb->ip_summed = CHECKSUM_UNNECESSARY;  /* don't check it */
> +	skb->ip_summed = CHECKSUM_NONE;
>  
>  	/*
>  	 * Parse the encapsulation header. This actually does the job of

Indeed neither the device nor the lower drivers check protocol checksums.
But the CRCs of the encapsulating 1394 packets are checked in hardware.
Shall protocol checksums be verified regardless?
YOSHIFUJI Hideaki / 吉藤英明 Jan. 20, 2013, 10:37 a.m. UTC | #2
Stefan Richter wrote:
> On Jan 20 YOSHIFUJI Hideaki wrote:
>> It is wrong to set skb->ip_summed to CHECKSUM_UNNECESSARY unless
>> the device has already checked it.
>>
>> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>> ---
>>  drivers/firewire/net.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
>> index e7a711f5..df6a1ca 100644
>> --- a/drivers/firewire/net.c
>> +++ b/drivers/firewire/net.c
>> @@ -520,7 +520,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
>>  	dev = netdev_priv(net);
>>  	/* Write metadata, and then pass to the receive level */
>>  	skb->dev = net;
>> -	skb->ip_summed = CHECKSUM_UNNECESSARY;  /* don't check it */
>> +	skb->ip_summed = CHECKSUM_NONE;
>>  
>>  	/*
>>  	 * Parse the encapsulation header. This actually does the job of
> 
> Indeed neither the device nor the lower drivers check protocol checksums.
> But the CRCs of the encapsulating 1394 packets are checked in hardware.
> Shall protocol checksums be verified regardless?

Yes, because packets may come from off-link source.

--yoshfuji
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephan Gatzka Jan. 20, 2013, 2:46 p.m. UTC | #3
>> Indeed neither the device nor the lower drivers check protocol checksums.
>> But the CRCs of the encapsulating 1394 packets are checked in hardware.
>> Shall protocol checksums be verified regardless?
>
> Yes, because packets may come from off-link source.
>

Hm, I can't see any off-link packets coming from 
fwnet_finish_incoming_packet()

So I wont verify checksums in the driver.

Stephan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
YOSHIFUJI Hideaki / 吉藤英明 Jan. 20, 2013, 3:10 p.m. UTC | #4
Stephan Gatzka wrote:
> 
>>> Indeed neither the device nor the lower drivers check protocol checksums.
>>> But the CRCs of the encapsulating 1394 packets are checked in hardware.
>>> Shall protocol checksums be verified regardless?
>>
>> Yes, because packets may come from off-link source.
>>
> 
> Hm, I can't see any off-link packets coming from fwnet_finish_incoming_packet()
> 
> So I wont verify checksums in the driver.

"Off-link source" means the source exists on the different L2
network.  In other words, source is connected via router(s).

         ethernet             firewire
 Host -------------- Router ------------ Host

--yoshfuji
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephan Gatzka Jan. 20, 2013, 3:17 p.m. UTC | #5
> "Off-link source" means the source exists on the different L2
> network.  In other words, source is connected via router(s).
>
>           ethernet             firewire
>   Host -------------- Router ------------ Host
>

O.k., understood. But the receiving router verifies the checksum of 
incoming packets and sends them on the firewire link. On firewire we 
have CRC checksums to ensure the integrity of packets.

I agree with your patch but I don't see why we should check them in the 
driver. I thought your patch will ensure that the checksums will be 
verified in the upper layers.

Stephan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
YOSHIFUJI Hideaki / 吉藤英明 Jan. 20, 2013, 3:48 p.m. UTC | #6
Stephan Gatzka wrote:
> 
>> "Off-link source" means the source exists on the different L2
>> network.  In other words, source is connected via router(s).
>>
>>           ethernet             firewire
>>   Host -------------- Router ------------ Host
>>
> 
> O.k., understood. But the receiving router verifies the checksum of incoming packets and sends them on the firewire link. On firewire we have CRC checksums to ensure the integrity of packets.
> 
> I agree with your patch but I don't see why we should check them in the driver. I thought your patch will ensure that the checksums will be verified in the upper layers.

Routers do not inspect whole packet.
For IPv4, we have IP checksum, but routers (usually) do not check
upper-layer (e.g. UDP) checksum.
For IPv6, we do not have IP checksum.

CHECKSUM_UNNECESSARY means the driver has verified upper layer
(e.g. TCP/UDP) checksum.  Modern hardware can perform upper-layer
checksumming as well. But of course, not all drivers are required
to verify the upper-layer checksum; if the driver do not verify
checksum in the packet, just say CHECKSUM_NONE.

Regards,

--yoshfuji
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 21, 2013, 4:16 a.m. UTC | #7
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Sun, 20 Jan 2013 16:43:40 +0900

> It is wrong to set skb->ip_summed to CHECKSUM_UNNECESSARY unless
> the device has already checked it.
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index e7a711f5..df6a1ca 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -520,7 +520,7 @@  static int fwnet_finish_incoming_packet(struct net_device *net,
 	dev = netdev_priv(net);
 	/* Write metadata, and then pass to the receive level */
 	skb->dev = net;
-	skb->ip_summed = CHECKSUM_UNNECESSARY;  /* don't check it */
+	skb->ip_summed = CHECKSUM_NONE;
 
 	/*
 	 * Parse the encapsulation header. This actually does the job of