[ovs-discuss] Way to distinguish different packets rather than parsing a packet?

Ben Pfaff blp at ovn.org
Tue Jan 15 06:07:34 UTC 2019


The Ethertype and IP protocol are in different layers.  Parsing the
Ethertype does not determine the IP protocol.

On Tue, Jan 15, 2019 at 01:46:04PM +0800, Krish wrote:
> Thanks Ben for the response.
> 
> I just want to distinguish it for some testing purposes.
> 
> Can you please explain a bit about the following behavior?
> 
> I want to get the **ip_proto** from a packet. In ****dp_netdev_input__**, *
> *ip_proto** is always 0.
> 
> But when I debugged *miniflow_extract*, *ip_proto* was filled only
> after *dl_type
> = parse_ethertype(&data, &size);*
> 
> Before *parse_ehertype* *ip_proto* is initialized to 0.
> I tried the following way also to retrieve proto type of a packet in ***
> *dp_netdev_input__** inside dpif-netdev.c but it is always coming out to be
> 0:
> 
> /*Retrieving packets from a batch*/
> for(numb=0;numb<cnt; numb++)
> {
> packet=packets->packets[numb];
>            dl_type = just_parse(packet); //I defined this method in flow.c
> which is calling *parse_ethertype*
> const struct ip_header *nh = data;
> nw_proto = nh->ip_proto;
> VLOG_DBG("NETWORK PROTO ---> %d", nw_proto); // always 0 for every packet
> }
> 
> /*In flow.c*/
> ovs_be16 just_parse(struct dp_packet *packet)
> {
> ovs_be16 dl_type;
> const void *data = dp_packet_data(packet);
> size_t length= dp_packet_size(packet);
> dl_type = parse_ethertype(&data,&length);
> return dl_type;
> }
> 
> 
> I don't know where I am going wrong.
> I would really appreciate your help on this.
> 
> 
> Thank You
> 
> 
> 
> On Fri, Jan 11, 2019 at 2:42 AM Ben Pfaff <blp at ovn.org> wrote:
> 
> > On Thu, Jan 10, 2019 at 02:34:47PM +0800, Krish wrote:
> > > Is there any other way to distinguish different types of packets/flows
> > when
> > > they enter dp_netdev_input__ and processed further(EMC,fastpath etc)?
> > >
> > > As of now, I have to *flow_extract* the packets using *struct flow flow*:
> > >
> > > if (flow.nw_proto == IPPROTO_TCP && l4_size >= TCP_HEADER_LEN) I want to
> > > distinguish different packets like udp,icmp,tcp etc. Parsing packets is
> > > time consuming. OR Another idea is to extract 5_tuple_fields from the
> > > packet and calculate hash on these fields without *miniflow_extract*, Can
> > > anyone help me pointing to the right direction of where or how I can
> > > extract these fields without miniflow or flow extract? Any help would be
> > > highly appreciated Thank You
> >
> > You can distinguish packets any way you like, but if you don't extract
> > the flow you probably won't be able to take advantage of the usual
> > features of OVS, which are all flow-based.
> >


More information about the discuss mailing list