Query on operstatus for link, can I change it?

2015-07-14 Thread Amit Agarwal

Hi,

I am looking for a way to change the operstatus shown for the network
interface.

Problem:
I have an extra interface on the machine that I would like to use for some
program like tcpreplay and tcpdump/wireshark. So, I would like to play a pcap
file on this interface and then capture on the same interface with wireshark.
Now the problem with this is that unless a cable is plugged in I do not see
any packets in wireshark, although I do not see any failures in sending the
packets. I would like to do this without any cable being
plugged in as I do not intend to send the packets out, is this possible?

The reason I cannot use lo interface for doing this is: there will be other
packets on the lo interface and I want to capture only the packets in the pcap
file that I am playing with tcpreplay.

Thanks in advance for any advice on this.

-- 
 Thanks,
-aka

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: Query on operstatus for link, can I change it?

2015-07-14 Thread Jeff Haran
 -Original Message-
 From: kernelnewbies-boun...@kernelnewbies.org [mailto:kernelnewbies-
 boun...@kernelnewbies.org] On Behalf Of Amit Agarwal
 Sent: Tuesday, July 14, 2015 5:14 AM
 To: Kernelnewbies
 Subject: Query on operstatus for link, can I change it?
 
 
 Hi,
 
 I am looking for a way to change the operstatus shown for the network
 interface.
 
 Problem:
 I have an extra interface on the machine that I would like to use for some
 program like tcpreplay and tcpdump/wireshark. So, I would like to play a pcap
 file on this interface and then capture on the same interface with wireshark.
 Now the problem with this is that unless a cable is plugged in I do not see 
 any
 packets in wireshark, although I do not see any failures in sending the
 packets. I would like to do this without any cable being plugged in as I do 
 not
 intend to send the packets out, is this possible?
 
 The reason I cannot use lo interface for doing this is: there will be other
 packets on the lo interface and I want to capture only the packets in the pcap
 file that I am playing with tcpreplay.
 
 Thanks in advance for any advice on this.
 
 --
  Thanks,
 -aka

You might be able to make something like this work using network namespaces and 
veth devices. Depends on whether you really need to use your extra physical 
interface as the tcpreplay device.

Jeff Haran


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: Query on operstatus for link, can I change it?

2015-07-14 Thread Jeff Haran
 -Original Message-
 From: kernelnewbies-bounces+jharan=bytemobile@kernelnewbies.org
 [mailto:kernelnewbies-
 bounces+jharan=bytemobile@kernelnewbies.org] On Behalf Of Amit
 Agarwal
 Sent: Tuesday, July 14, 2015 12:54 PM
 To: Kernelnewbies
 Subject: Re: Query on operstatus for link, can I change it?
 
... 
 One last query on this, does this interface receive any packet by default of
 any protocol.

I think of the two virtual interfaces as real NICs with a cable between them. I 
am pretty sure they are protocol agnostic.

 If so, how do I make sure that no packets other than one
 injected by me are seen on this interface. Sorry, if this sounds too stupid, 
 but
 I am noob in this area.

That's what routing tables are for. 8^)

Jeff Haran


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Query on operstatus for link, can I change it?

2015-07-14 Thread Amit Agarwal
On 15-07-14 20:38:49, Jeff Haran wrote:
  -Original Message-
 
 I think of the two virtual interfaces as real NICs with a cable between them. 
 I am pretty sure they are protocol agnostic.
Yes, pretty much that.

 
  If so, how do I make sure that no packets other than one
  injected by me are seen on this interface. Sorry, if this sounds too 
  stupid, but
  I am noob in this area.
 
 That's what routing tables are for. 8^)
right :)

Thanks a ton Jeff. With your advice and some google, I think I can settle for
dummy interface which is similar to veth - only difference being it creates one
interface. Commands remain the same and I have to change only veth to dummy
for type in the ip command.

Also I found that I can set netmask to /32, turn off multicast and arp which
should get me to what I wanted. Thanks again.

-- 
 Thanks,
-aka

Beware of Programmers who carry screwdrivers.
-- Leonard Brandwein

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Query on operstatus for link, can I change it?

2015-07-14 Thread Amit Agarwal
On 15-07-14 19:34:42, Jeff Haran wrote:
 
 The last time I looked into this (and this was quite a while ago so take this 
 with much salt) the lo device was not a regular network device. The stack 
 sets up an instance of lo in every network name space created, more or less 
 automatically via the registration of its init routine in a struct 
 pernet_operations. So lo doesn't initialize like most other network devices. 
 You might have issues there. I know I did last time I tried to borrow 
 loopback.c to do something similar for some prototyping I was doing.

Realized that while looking at this code. But thankd for pointing this.


 
 If you are willing to monkey with kernel code, it might be easier to just 
 twiddle the link sense routine in driver for the other NIC you were 
 planning to use to always report the link as up regardless of what the PHY 
 says.

This too is good option. 

Found anther option that looks like should solve the problem I am after. veth
device - as you suggested earlier. So, as I understand veth device creates a
sender and receiver. So, if I send on veth0, I will receive on veth1. So, the
steps that I would need is (using iproute2 utility):

ip link add type veth name veth0 peer name veth1
ip link set dev veth0 up
ip link set dev veth1 up
and then add the address to what ever I require.

I quickly tested and seems that I am able to play on veth0 and receive on
veth1.

One last query on this, does this interface receive any packet by default of
any protocol. If so, how do I make sure that no packets other than one
injected by me are seen on this interface. Sorry, if this sounds too stupid,
but I am noob in this area.



 

-- 
 Thanks,
-aka


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Query on operstatus for link, can I change it?

2015-07-14 Thread Amit Agarwal
Hi Jeff,
On 15-07-14 16:06:39, Jeff Haran wrote:
  -Original Message-
 
 You might be able to make something like this work using network namespaces 
 and veth devices. Depends on whether you really need to use your extra 
 physical interface as the tcpreplay device.

Thanks for this pointer. I will check if I can achieve what I want with netns.

Also, I was wondering if I can just copy the loopback.c file, build it as
module and do insmod after changing the network name from lo to something
else, will that work?

-- 
 Thanks,
-aka


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies