Subject: Re: Trying to implement secondary loopback

From: Benjamin LaHaise <[email-masked]>
Date: Fri, 15 Mar 2013 11:37:40 -0400

On Fri, Mar 15, 2013 at 04:07:32PM +0100, Thomas Martitz wrote:
> Same result. I assumed the kernel treats lo in a special way for 
> localhost-connections and that it would be impossible to achieve the 
> same with a custom interface.
> 
> I did the following:
> 
> ifconfig lo down
> insmod ./mykmod.ko
> ifconfig eth2 up
> ifconfig eth2 127.0.0.1
> 
> At this point ifconfig prints the same information for eth2 that it had 
> printed for lo before (except for the LOOPBACK flag, but I can enable 
> that one as well by adding IFF_LOOPBACK to the interface flags in the 
> module). Yet my test application only works with lo, not eth2.

Don't use loopback ip addresses; it makes no sense to do so.  I've worked  
on a couple opf nic implementations on FPGAs for a while now (a gige 
implementation that works, and now a 10G nic), and it's easy enough to 
develop it as a regular ethernet driver.  You can write test programs that 
use raw sockets to send/receive packets over the ethernet device, or use 
pktgen to send packets.  You don't even need to configure an ip address for 
testing with raw packets.  Testing with IP is a lot harder during early 
bring-up of your hardware as it requires everything to work (that is, you 
need ARP to work successfully before IP can work).  Just stick to simple 
packet injection initially, and don't confuse yourself by thinking about 
the loopback device.

		-ben
-- 
"Thought is the essence of where you are now."