linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Bugfix in arch/ppc/8260_io/fcc_enet.c linux-2.4.17
@ 2002-03-08 19:39 David Ashley
  2002-03-09  0:26 ` Amit D. Chaudhary
  0 siblings, 1 reply; 3+ messages in thread
From: David Ashley @ 2002-03-08 19:39 UTC (permalink / raw)
  To: linuxppc-embedded


I found a bug which was manifest when linux boots and lots of ethernet
packets are coming in. I think the problem is because the fcc_enet.c
adds the network device in very early during the boot, and the driver is
happily calling netif_rx() on the received packets even though the interface
isn't officially "up". Linux appears not to like this, and would crash
sporadically, or predictibly if I have a program on another computer running
just blasting packets at the first one.

The fix is to just put an if around this section in fcc_enet_rx:
		skb = dev_alloc_skb(pkt_len-4);

		if (skb == NULL) {
			printk("%s: Memory squeeze, dropping packet.\n", dev->name);
			cep->stats.rx_dropped++;
		}
		else {
			skb->dev = dev;
			skb_put(skb,pkt_len-4);	/* Make room */
			eth_copy_and_sum(skb,
				(unsigned char *)__va(bdp->cbd_bufaddr),
				pkt_len-4, 0);
			skb->protocol=eth_type_trans(skb,dev);
			netif_rx(skb);
		}

So it becomes:
		if(dev->flags & IFF_UP) { /* only do if iface is up */
	                skb = dev_alloc_skb(pkt_len-4);

	                if (skb == NULL) {
	                        printk("%s: Memory squeeze, dropping packet.\n", dev->name);
	                        cep->stats.rx_dropped++;
	                }
	                else {
	                        skb->dev = dev;
	                        skb_put(skb,pkt_len-4); /* Make room */
	                        eth_copy_and_sum(skb,
	                                (unsigned char *)__va(bdp->cbd_bufaddr),
	                                pkt_len-4, 0);
	                        skb->protocol=eth_type_trans(skb,dev);
	                        netif_rx(skb);
	                }
		}

This fixes the crash bug.

-Dave


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bugfix in arch/ppc/8260_io/fcc_enet.c linux-2.4.17
  2002-03-08 19:39 David Ashley
@ 2002-03-09  0:26 ` Amit D. Chaudhary
  0 siblings, 0 replies; 3+ messages in thread
From: Amit D. Chaudhary @ 2002-03-09  0:26 UTC (permalink / raw)
  To: David Ashley; +Cc: linuxppc-embedded


David,

Is there an impact of your change on the board doing a netboot and
loading the rootfs from a nfs mount?

Thanks
Amit

David Ashley wrote:
> I found a bug which was manifest when linux boots and lots of ethernet
> packets are coming in. I think the problem is because the fcc_enet.c
> adds the network device in very early during the boot, and the driver is
> happily calling netif_rx() on the received packets even though the interface
> isn't officially "up". Linux appears not to like this, and would crash
> sporadically, or predictibly if I have a program on another computer running
> just blasting packets at the first one.
>
> The fix is to just put an if around this section in fcc_enet_rx:
> 		skb = dev_alloc_skb(pkt_len-4);
>
> 		if (skb == NULL) {
> 			printk("%s: Memory squeeze, dropping packet.\n", dev->name);
> 			cep->stats.rx_dropped++;
> 		}
> 		else {
> 			skb->dev = dev;
> 			skb_put(skb,pkt_len-4);	/* Make room */
> 			eth_copy_and_sum(skb,
> 				(unsigned char *)__va(bdp->cbd_bufaddr),
> 				pkt_len-4, 0);
> 			skb->protocol=eth_type_trans(skb,dev);
> 			netif_rx(skb);
> 		}
>
> So it becomes:
> 		if(dev->flags & IFF_UP) { /* only do if iface is up */
> 	                skb = dev_alloc_skb(pkt_len-4);
>
> 	                if (skb == NULL) {
> 	                        printk("%s: Memory squeeze, dropping packet.\n", dev->name);
> 	                        cep->stats.rx_dropped++;
> 	                }
> 	                else {
> 	                        skb->dev = dev;
> 	                        skb_put(skb,pkt_len-4); /* Make room */
> 	                        eth_copy_and_sum(skb,
> 	                                (unsigned char *)__va(bdp->cbd_bufaddr),
> 	                                pkt_len-4, 0);
> 	                        skb->protocol=eth_type_trans(skb,dev);
> 	                        netif_rx(skb);
> 	                }
> 		}
>
> This fixes the crash bug.
>
> -Dave
>
>
>
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bugfix in arch/ppc/8260_io/fcc_enet.c linux-2.4.17
@ 2002-03-09  4:19 David Ashley
  0 siblings, 0 replies; 3+ messages in thread
From: David Ashley @ 2002-03-09  4:19 UTC (permalink / raw)
  To: amitc; +Cc: linuxppc-embedded


I don't know, I haven't tried that. I would think that when the netboot
stuff takes effect it will bring the ethernet device in question "up".

I have seen other ethernet drivers that actually deallocate the irq when
they are down, and reallocate it when they are up. That's how I determined
fcc_enet.c had a problem. Even when it is down you can watch the
/proc/interrupts count up. So I knew the interrupt was getting called and
inside the interrupt it was passing the packets onto the linux network
stack.

I think it is a safe bet this change won't hurt anything at all. I believe
all functioning ethernet devices are supposed to have their IFF_UP bit set
in the dev->flags field. I think a better fix would be to disable the
interrupt, or even deallocate/reallocate the irq on down/up. I didn't trace
out what happens when an interface is downed though, I don't know how the
driver knows when its interface goes up or down. I tried
strace ifconfig eth0 down
To see what syscall was doing the magic, but I didn't find it.

-Dave


>David,
>
>Is there an impact of your change on the board doing a netboot and
>loading the rootfs from a nfs mount?
>
>Thanks
>Amit
>
>David Ashley wrote:
>> I found a bug which was manifest when linux boots and lots of ethernet
>> packets are coming in. I think the problem is because the fcc_enet.c

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-03-09  4:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-09  4:19 Bugfix in arch/ppc/8260_io/fcc_enet.c linux-2.4.17 David Ashley
  -- strict thread matches above, loose matches on Subject: below --
2002-03-08 19:39 David Ashley
2002-03-09  0:26 ` Amit D. Chaudhary

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).