netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Tom Herbert <tom@herbertland.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Simon Horman <simon.horman@netronome.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Dinan Gunawardena <dinan.gunawardena@netronome.com>,
	mlxsw@mellanox.com
Subject: Re: [patch net-next RFC 1/2] flow_dissecror: Move ARP dissection into a separate function
Date: Tue, 21 Feb 2017 22:21:13 +0100	[thread overview]
Message-ID: <20170221212113.GA1767@nanopsycho> (raw)
In-Reply-To: <CALx6S376rJOErGA=OC4UBSQKNZEE1Ape4=9w7p8T+Td8DzajdQ@mail.gmail.com>

Tue, Feb 21, 2017 at 07:50:53PM CET, tom@herbertland.com wrote:
>On Tue, Feb 21, 2017 at 6:33 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>>
>> Make the main flow_dissect function a bit smaller and move the ARP
>> dissection into a separate function. Along with that, do the ARP header
>> processing only in case the flow dissection user requires it.
>>
>
>Acked-by: Tom Herbert <tom@herbertland.com>
>
>GRE might also be a good candidate to get its own function.

Okay. Will look at that. Thanks.



>
>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>>  net/core/flow_dissector.c | 111 ++++++++++++++++++++++++----------------------
>>  1 file changed, 59 insertions(+), 52 deletions(-)
>>
>> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
>> index c35aae1..10dc5bb 100644
>> --- a/net/core/flow_dissector.c
>> +++ b/net/core/flow_dissector.c
>> @@ -113,6 +113,61 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
>>  }
>>  EXPORT_SYMBOL(__skb_flow_get_ports);
>>
>> +static bool __skb_flow_dissect_arp(const struct sk_buff *skb,
>> +                                  struct flow_dissector *flow_dissector,
>> +                                  void *target_container, void *data,
>> +                                  int nhoff, int hlen)
>> +{
>> +       struct flow_dissector_key_arp *key_arp;
>> +       struct {
>> +               unsigned char ar_sha[ETH_ALEN];
>> +               unsigned char ar_sip[4];
>> +               unsigned char ar_tha[ETH_ALEN];
>> +               unsigned char ar_tip[4];
>> +       } *arp_eth, _arp_eth;
>> +       const struct arphdr *arp;
>> +       struct arphdr *_arp;
>> +
>> +       if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ARP))
>> +               return true;
>> +
>> +       arp = __skb_header_pointer(skb, nhoff, sizeof(_arp), data,
>> +                                  hlen, &_arp);
>> +       if (!arp)
>> +               return false;
>> +
>> +       if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
>> +           arp->ar_pro != htons(ETH_P_IP) ||
>> +           arp->ar_hln != ETH_ALEN ||
>> +           arp->ar_pln != 4 ||
>> +           (arp->ar_op != htons(ARPOP_REPLY) &&
>> +            arp->ar_op != htons(ARPOP_REQUEST)))
>> +               return false;
>> +
>> +       arp_eth = __skb_header_pointer(skb, nhoff + sizeof(_arp),
>> +                                      sizeof(_arp_eth), data,
>> +                                      hlen, &_arp_eth);
>> +       if (!arp_eth)
>> +               return false;
>> +
>> +       key_arp = skb_flow_dissector_target(flow_dissector,
>> +                                           FLOW_DISSECTOR_KEY_ARP,
>> +                                           target_container);
>> +
>> +       memcpy(&key_arp->sip, arp_eth->ar_sip, sizeof(key_arp->sip));
>> +       memcpy(&key_arp->tip, arp_eth->ar_tip, sizeof(key_arp->tip));
>> +
>> +       /* Only store the lower byte of the opcode;
>> +        * this covers ARPOP_REPLY and ARPOP_REQUEST.
>> +        */
>> +       key_arp->op = ntohs(arp->ar_op) & 0xff;
>> +
>> +       ether_addr_copy(key_arp->sha, arp_eth->ar_sha);
>> +       ether_addr_copy(key_arp->tha, arp_eth->ar_tha);
>> +
>> +       return true;
>> +}
>> +
>>  /**
>>   * __skb_flow_dissect - extract the flow_keys struct and return it
>>   * @skb: sk_buff to extract the flow from, can be NULL if the rest are specified
>> @@ -138,7 +193,6 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
>>         struct flow_dissector_key_control *key_control;
>>         struct flow_dissector_key_basic *key_basic;
>>         struct flow_dissector_key_addrs *key_addrs;
>> -       struct flow_dissector_key_arp *key_arp;
>>         struct flow_dissector_key_ports *key_ports;
>>         struct flow_dissector_key_icmp *key_icmp;
>>         struct flow_dissector_key_tags *key_tags;
>> @@ -382,59 +436,12 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
>>                 goto out_good;
>>
>>         case htons(ETH_P_ARP):
>> -       case htons(ETH_P_RARP): {
>> -               struct {
>> -                       unsigned char ar_sha[ETH_ALEN];
>> -                       unsigned char ar_sip[4];
>> -                       unsigned char ar_tha[ETH_ALEN];
>> -                       unsigned char ar_tip[4];
>> -               } *arp_eth, _arp_eth;
>> -               const struct arphdr *arp;
>> -               struct arphdr *_arp;
>> -
>> -               arp = __skb_header_pointer(skb, nhoff, sizeof(_arp), data,
>> -                                          hlen, &_arp);
>> -               if (!arp)
>> -                       goto out_bad;
>> -
>> -               if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
>> -                   arp->ar_pro != htons(ETH_P_IP) ||
>> -                   arp->ar_hln != ETH_ALEN ||
>> -                   arp->ar_pln != 4 ||
>> -                   (arp->ar_op != htons(ARPOP_REPLY) &&
>> -                    arp->ar_op != htons(ARPOP_REQUEST)))
>> +       case htons(ETH_P_RARP):
>> +               if (!__skb_flow_dissect_arp(skb, flow_dissector,
>> +                                           target_container, data,
>> +                                           nhoff, hlen))
>>                         goto out_bad;
>> -
>> -               arp_eth = __skb_header_pointer(skb, nhoff + sizeof(_arp),
>> -                                              sizeof(_arp_eth), data,
>> -                                              hlen,
>> -                                              &_arp_eth);
>> -               if (!arp_eth)
>> -                       goto out_bad;
>> -
>> -               if (dissector_uses_key(flow_dissector,
>> -                                      FLOW_DISSECTOR_KEY_ARP)) {
>> -
>> -                       key_arp = skb_flow_dissector_target(flow_dissector,
>> -                                                           FLOW_DISSECTOR_KEY_ARP,
>> -                                                           target_container);
>> -
>> -                       memcpy(&key_arp->sip, arp_eth->ar_sip,
>> -                              sizeof(key_arp->sip));
>> -                       memcpy(&key_arp->tip, arp_eth->ar_tip,
>> -                              sizeof(key_arp->tip));
>> -
>> -                       /* Only store the lower byte of the opcode;
>> -                        * this covers ARPOP_REPLY and ARPOP_REQUEST.
>> -                        */
>> -                       key_arp->op = ntohs(arp->ar_op) & 0xff;
>> -
>> -                       ether_addr_copy(key_arp->sha, arp_eth->ar_sha);
>> -                       ether_addr_copy(key_arp->tha, arp_eth->ar_tha);
>> -               }
>> -
>>                 goto out_good;
>> -       }
>>
>>         default:
>>                 goto out_bad;
>> --
>> 2.7.4
>>

  reply	other threads:[~2017-02-21 21:21 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 10:37 [PATCH/RFC net-next 0/2] net/sched: cls_flower: Support matching on ND Simon Horman
2017-02-02 10:37 ` [PATCH/RFC net-next 1/2] flow dissector: ND support Simon Horman
2017-02-02 12:31   ` Eric Dumazet
2017-02-02 15:58     ` Simon Horman
2017-02-02 17:24       ` Tom Herbert
2017-02-02 17:48         ` Jiri Pirko
2017-02-02 18:36           ` Tom Herbert
2017-02-02 18:56             ` Eric Dumazet
2017-02-02 19:19               ` Tom Herbert
2017-02-06  9:12             ` [oss-drivers] " Simon Horman
2017-02-07 17:36               ` Tom Herbert
2017-02-07 17:38                 ` David Miller
2017-02-08  9:28                   ` Simon Horman
2017-02-08 16:43                     ` Simon Horman
2017-02-08 18:33                     ` [oss-drivers] " Tom Herbert
2017-02-08 18:54                       ` David Miller
2017-02-08 19:10                         ` Tom Herbert
2017-02-08 20:12                           ` Jiri Pirko
2017-02-08 20:33                             ` Tom Herbert
2017-02-08 20:09                         ` Jiri Pirko
2017-02-09  8:25                           ` Simon Horman
2017-02-21 14:31             ` Jiri Pirko
2017-02-21 14:33               ` [patch net-next RFC 1/2] flow_dissecror: Move ARP dissection into a separate function Jiri Pirko
2017-02-21 14:33                 ` [patch net-next RFC 2/2] flow_dissecror: Move MPLS " Jiri Pirko
2017-02-22  8:34                   ` Simon Horman
2017-02-21 18:32                 ` [patch net-next RFC 1/2] flow_dissecror: Move ARP " David Miller
2017-02-22  8:36                   ` Simon Horman
2017-02-21 18:50                 ` Tom Herbert
2017-02-21 21:21                   ` Jiri Pirko [this message]
2017-03-06 15:49                   ` Jiri Pirko
2017-02-22  8:12                 ` Simon Horman
2017-02-21 15:28   ` [PATCH/RFC net-next 1/2] flow dissector: ND support Jiri Pirko
2017-03-10 14:19     ` Simon Horman
2017-03-10 14:27       ` Jiri Pirko
2017-03-10 15:20         ` Simon Horman
2017-03-10 15:26           ` Jiri Pirko
2017-03-13 13:50         ` Simon Horman
2017-03-13 13:53           ` Jiri Pirko
2017-02-02 10:37 ` [PATCH/RFC net-next 2/2] net/sched: cls_flower: Support matching on ND Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170221212113.GA1767@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=dinan.gunawardena@netronome.com \
    --cc=eric.dumazet@gmail.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    --cc=tom@herbertland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).