HundredGigabitEthernet12/0/0 (sw_if_index=1) has the ip address 192.168.198.2. 
The calculation shown in your original email is producing 192.168.198.2, which 
seems right to me.

You’ve looked up the ip address of the rx interface, which may not be what you 
had in mind.

The packet got nowhere near ip4-lookup -> ip4-rewrite, which would set 
vlib_buffer(b)->sw_if_index[VLIB_TX] to the tx interface sw_if_index.

HTH... Dave

From: RaviKiran Veldanda <ravi.jup...@gmail.com>
Sent: Friday, June 19, 2020 1:47 PM
To: Dave Barach (dbarach) <dbar...@cisco.com>
Subject: Re: [discuss] sw_if_index in vent_buffer giving wrong IP address with 
ip_interface_address_get_address

Yes Dave,
I did all the things you suggested and the packet is coming on  
HundredGigabitEthernet12/0/0 and I am just getting the packets for that 
interface only.
Please find details below:
Packet 1

00:02:29:382622: dpdk-input
  HundredGigabitEthernet12/0/0 rx queue 0
  buffer 0x92556: current data 0, length 60, buffer-pool 0, ref-count 1, 
totlen-nifb 0, trace handle 0x0
                  ext-hdr-valid
                  l4-cksum-computed l4-cksum-correct
  PKT MBUF: port 0, nb_segs 1, pkt_len 60
    buf_len 2176, data_len 60, ol_flags 0x0, data_off 128, phys_addr 0x88895600
    packet_type 0x1 l2_len 0 l3_len 0 outer_l2_len 0 outer_l3_len 0
    rss 0x0 fdir.hi 0x0 fdir.lo 0x0
    Packet Types
      RTE_PTYPE_L2_ETHER (0x0001) Ethernet packet
  0x0027: 3c:2c:30:65:54:31 -> 01:80:c2:00:00:00
00:02:29:437741: ipgw_ent
  IPGW_ENT: sw_if_index 1, next index 0
  new src 3c:2c:30:65:54:31 -> new dst 01:80:c2:00:00:00
00:02:29:437762: ethernet-input
  0x0027: 3c:2c:30:65:54:31 -> 01:80:c2:00:00:00
00:02:29:437764: llc-input
  LLC bpdu -> bpdu
00:02:29:437770: error-drop
  rx:HundredGigabitEthernet12/0/0
00:02:29:437771: drop
  llc-input: unknown llc ssap/dsap

The Commands:

set interface ip add HundredGigabitEthernet12/0/0 
192.168.198.2/24<http://192.168.198.2/24>
 set interface state HundredGigabitEthernet12/0/0 up
 set interface ip addr HundredGigabitEthernet12/0/0 2001:5b0:ffff:7cf0::98fc/64
 create interface memif id 0 socket-id 0 master
 set interface state memif0/0 up
 set interface ip add memif0/0 192.168.1.3/24<http://192.168.1.3/24>
 set interface ip addr memif0/0 2001:5b0:ffff:7cf1::98fc/64

I believe there is some problem with this index in code.Please let us know your 
views.

//Ravi

On Fri, Jun 19, 2020 at 10:38 AM Dave Barach (dbarach) 
<dbar...@cisco.com<mailto:dbar...@cisco.com>> wrote:
If the packet was received on HundredGigabitEthernet12/0/0, you should get 
192.168.198.2. If it was received on memif0/0 you should get 192.168.1.3. 
"trace add dpdk-input" [or send pkts, then "show trace". If that produces 
nothing, s/dpdk-input/memif-input/ or whatever the memif input node is called.

Use "show int addr" / "show int" to determine the sw_if_index to name mapping, 
and to display the interface ip addresses.

________________________________
From: disc...@lists.fd.io<mailto:disc...@lists.fd.io> 
<disc...@lists.fd.io<mailto:disc...@lists.fd.io>> on behalf of 
ravi.jup...@gmail.com<mailto:ravi.jup...@gmail.com> 
<ravi.jup...@gmail.com<mailto:ravi.jup...@gmail.com>>
Sent: Thursday, June 18, 2020 3:54 PM
To: disc...@lists.fd.io<mailto:disc...@lists.fd.io> 
<disc...@lists.fd.io<mailto:disc...@lists.fd.io>>
Subject: [discuss] sw_if_index in vent_buffer giving wrong IP address with 
ip_interface_address_get_address


[Edited Message Follows]
Hi Team,
I am writing a plugin and my plugin is attached to device_input, so that I can 
receive all the traffic.
In my plugin, I am checking the headers and deciding to forward to my 
application or to the Native VPP. This is working fine, However ICMP case I 
have one requirement to check is it destined to Interface I attached my plugin 
or some other IP, So to check that I am using following APIs,
I am receiving packets and doing following things to get the IP address,
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
ip4_main_t *im = &ip4_main;
 ip_lookup_main_t *lm = &im->lookup_main;
 ip_interface_address_t *if_add = pool_elt_at_index (lm->if_address_pool, 
if_index);
 ip4_address_t *if_ip = ip_interface_address_get_address (lm, if_add);
I am getting IP Address but the IP Address I am getting is something different,
For Example:
In VPPCTL If I create the interfaces in the following order:
 set interface ip add HundredGigabitEthernet12/0/0 
192.168.198.2/24<http://192.168.198.2/24>
 set interface state HundredGigabitEthernet12/0/0 up
 set interface ip addr HundredGigabitEthernet12/0/0 2001:5b0:ffff:7cf0::98fc/64
 create interface memif id 0 socket-id 0 master
 set interface state memif0/0 up
 set interface ip add memif0/0 192.168.1.3/24<http://192.168.1.3/24>
 set interface ip addr memif0/0 2001:5b0:ffff:7cf1::98fc/64
  I am getting IP Address as 192.168.1.3.
If I am creating interfaces in the following order:
 create interface memif id 0 socket-id 0 master
 set interface state memif0/0 up
 set interface ip add memif0/0 192.168.1.3/24<http://192.168.1.3/24>
 set interface ip addr memif0/0 2001:5b0:ffff:7cf1::98fc/64
  set interface ip add HundredGigabitEthernet12/0/0 192.168.198.2/24
 set interface state HundredGigabitEthernet12/0/0 up
 set interface ip addr HundredGigabitEthernet12/0/0 2001:5b0:ffff:7cf0::98fc/64

I am getting IP Address as 192.168.198.2.

But in both cases the sw_if_index is same and my plugin attached to the 
HundredGigabitEthernet12/0/0 only. I am expecting IP address of this but its 
getting the order I created.
So My questions are
1> How to get IP address of a interface from sw_if_index0?
2> Can you please let me know if you find any issue in my code to get the IP 
Address?
3> Is there any better method to get IP address from the buffer using any other 
parameter? I needed IP address of interface the packet received.

Regards,
Ravi.
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16768): https://lists.fd.io/g/vpp-dev/message/16768
Mute This Topic: https://lists.fd.io/mt/74986450/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to