Re: [ovs-discuss] How to store the tcp_src or tcp_dst field value in a variable and then print in vlogs?

2019-02-21 Thread Krish
Hey Flavio

I am so sorry for the inconvenience caused.
Next time I will take care of it. You have been a great help for me.
I thank you from the bottom of my heart. I was stuck on this part since
last few days.
Now, it has been resolved.

Thanks
Krish

On Wed, Feb 20, 2019 at 8:25 PM Flavio Leitner  wrote:

> On Tue, Feb 19, 2019 at 12:43:08PM +0800, Krish wrote:
> > Hi Flavio,
> >
> > I think I got tcp_src and tcp_dst values, I can also successfully print
> > them.
> > Here is what I did:
> > for(numb=0;numb > {
> >
> > uint8_t nw_proto = 0;
> > packet=packets->packets[numb];
> > size_t size = dp_packet_size(packet);
> > const void *data = dp_packet_data(packet);
> > const char *frame = (const char *)data;
> > dp_packet_reset_offsets(packet);
> > *data_pull(, , ETH_ADDR_LEN * 2);*
> > //dl_type = parse_ether(, );
> > //VLOG_DBG("parse ether type DL TYPE: 0x%4x", dl_type);
> > packet->l3_ofs = (char *)data - frame;
> > const struct ip_header *ip = dp_packet_l3(packet);
> > nw_proto = ip->ip_proto;
> > VLOG_DBG("IP proto---> %d ", nw_proto);
> > int ip_len;
> > ip_len = IP_IHL(ip->ip_ihl_ver) * 4;
> >
> > *data_pull(, , ip_len);*
> > packet->l4_ofs = (char *)data - frame;
> > if(nw_proto == 6)
> > {
> > struct tcp_header *th = dp_packet_l4(packet);
> > VLOG_DBG( "tcp_src ---> %d", ntohs(th->tcp_src));
> > VLOG_DBG( "tcp_dst ---> %d", ntohs(th->tcp_dst));
> >   }
> > }
> >
> >
> > Can you please confirm, if this is the right approach I have used and not
> > seeing the old values like before?
>
> It's hard to read code using html (bold, etc), could you please use
> text only and indent the code properly? It makes our life a lot easier.
>
> When you pull ETH_ADDR_LEN*2, the offset now points to ethernet_type
> which is not the l3_ofs as you set next. I don't think the above code
> works unless you uncomment parse_ethertype() which pulls more 4 bytes.
>
> fbl
>
>
>
> >
> > Thank you so much,
> > Krish
> >
> > On Tue, Feb 19, 2019 at 11:25 AM Krish  wrote:
> >
> > > Flavio,
> > >
> > > Thank you for the clarification. You explained it very well.
> > >
> > > I don't want to wait for the miniflow_extraction, so I am left with
> > > parsing packet myself.
> > >
> > > Here is what I am doing now:
> > >
> > > for(numb=0;numb > > {
> > >
> > > uint8_t nw_proto;
> > > const char *frame;
> > > packet=packets->packets[numb];
> > > const void *data = dp_packet_data(packet);
> > > frame = data;
> > > *dp_packet_reset_offsets(packet);*
> > > * packet->l3_ofs = (char *)data - frame;*
> > > * const struct ip_header *ip = dp_packet_l3(packet);*
> > > nw_proto = ip->ip_proto;
> > > VLOG_DBG("IP proto---> %d ", nw_proto); // This is 0
> > >
> > > }
> > >
> > > I followed almost the same approach of what is going in
> miniflow_extract.
> > > nw_proto(ip protocol) is printing out to be 0.
> > > I am using this code just before emc_processing and inside
> > > dp_netdev_input__.
> > > Can you please help me here?
> > >
> > > Thanks
> > > Krish
> > >
> > >
> > > On Mon, Feb 18, 2019 at 8:11 PM Flavio Leitner 
> wrote:
> > >
> > >> On Mon, Feb 18, 2019 at 11:05:53AM +0800, Krish wrote:
> > >> > Thanks for reply Ben.
> > >> > Does it mean that *miniflow_extract* will also initialize the L3
> header
> > >> > pointer?
> > >>
> > >> If you look at the miniflow_extract(), you  will see that it calls
> > >> dp_packet_reset_offsets(packet) which will set all the header pointers
> > >> to their defaults meaning that they are not pointing to anything real.
> > >>
> > >> These pointers are used by dp_packet_l3 (or 4) functions to locate
> > >> the header.
> > >>
> > >> Then if you continue following the function, you will notice that
> > >> the code parses the packet from the outer header to the inner header
> > >> and as the parser goes, it updates the header offsets, like this line:
> > >>
> > >> packet->l3_ofs = (char *)data - frame;
> > >>
> > >> At this point, you have the pointer to the l3 header and you could use
> > >> dp_packet_l3().
> > >>
> > >>
> > >> > But I am getting the correct values for *nw_proto* from the L3
> header.
> > >> > struct ip_header *ip = dp_packet_l3(packet);
> > >> > nw_proto = ip->ip_proto;
> > >> >
> > >> > Any comments on this? Whether its right or wrong?
> > >>
> > >> When using DPDK, the packet is represented by two parts. One if the
> > >> rte buffer (packet data) that comes from DPDK library and the second
> > >> part is the packet's metadata (the offsets you need). This offsets
> > >> are allocated in the stack at dp_netdev_process_rxq_port(), so most
> > >> probably you are seeing old values from previous packets which
> > >> happens to work, but they are not correct.
> > >>
> > >> As I said above miniflow_extract() initializes those offsets to a
> > >> known state and then parse the packet to update with the correct
> > >> values.
> > >>
> > >> In summary, you will need to either wait for miniflow_extract() or
> > >> parse the packet yourself 

Re: [ovs-discuss] DPDK link state

2019-02-21 Thread Ben Pfaff
On Thu, Feb 21, 2019 at 02:58:16PM +0100, Riccardo Ravaioli wrote:
> Let's say I have a basic setup with a Linux virtual machine with one
> vhostuser interface, a physical interface in DPDK mode, and an OVS switch
> with those two interfaces on it.
> Can the VM know when the link on the physical interface is up or down?

Perhaps it could with help from a controller: a controller could note
the state of one interface (a physical one) and propagate that to
another interface (a virtual one).  However, I do not know whether
taking the host side of a virtual interface down is visible to a guest,
and the answer might differ from one virtualization environment or type
of virtual interface to another.
___
discuss mailing list
disc...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss


Re: [ovs-discuss] DPDK link state

2019-02-21 Thread Riccardo Ravaioli
On Thu, 21 Feb 2019 at 15:08, Flavio Leitner  wrote:

> On Thu, Feb 21, 2019 at 02:58:16PM +0100, Riccardo Ravaioli wrote:

> I see that the command "ovs-ofctl show $bridge" reports this. I'm just not
> > sure if the VM needs to be told explicitly (in which case, the command
> > "ovs-ofctl mod-port $switch $port up/down" doesn't seem to work) or
> instead
> > it has all the necessary means to know this through the DPDK library.
>
> What exactly you're trying to do? The host networking could be seen as
> the network infra outside of the host and in this case the VM link is
> actually the vhost port which is up & running.
>


Right.
I know this is quite unorthodox, but I'm trying to see if I can propagate
the link state of a physical interface to a virtual machine. With a regular
network interface and a virtio interface on the VM, I can listen on a
netlink socket for RTM_NEWLINK messages (on the host) and then run "virsh
domif-setlink $domain $interface up/down": inside the virtual machine, the
link state will change accordingly.

I was wondering if in the case of DPDK + vhostuser I can do something
similar.

Thanks!

Riccardo
___
discuss mailing list
disc...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss


Re: [ovs-discuss] DPDK link state

2019-02-21 Thread Flavio Leitner
On Thu, Feb 21, 2019 at 02:58:16PM +0100, Riccardo Ravaioli wrote:
> Hi,
> 
> Let's say I have a basic setup with a Linux virtual machine with one
> vhostuser interface, a physical interface in DPDK mode, and an OVS switch
> with those two interfaces on it.
> Can the VM know when the link on the physical interface is up or down?

No, but it could ping some other remote host.

> I see that the command "ovs-ofctl show $bridge" reports this. I'm just not
> sure if the VM needs to be told explicitly (in which case, the command
> "ovs-ofctl mod-port $switch $port up/down" doesn't seem to work) or instead
> it has all the necessary means to know this through the DPDK library.

What exactly you're trying to do? The host networking could be seen as
the network infra outside of the host and in this case the VM link is
actually the vhost port which is up & running.

fbl

___
discuss mailing list
disc...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss


[ovs-discuss] DPDK link state

2019-02-21 Thread Riccardo Ravaioli
Hi,

Let's say I have a basic setup with a Linux virtual machine with one
vhostuser interface, a physical interface in DPDK mode, and an OVS switch
with those two interfaces on it.
Can the VM know when the link on the physical interface is up or down?

I see that the command "ovs-ofctl show $bridge" reports this. I'm just not
sure if the VM needs to be told explicitly (in which case, the command
"ovs-ofctl mod-port $switch $port up/down" doesn't seem to work) or instead
it has all the necessary means to know this through the DPDK library.

Thanks!

Riccardo
___
discuss mailing list
disc...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss