netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: pshelar@nicira.com
Cc: jbenc@redhat.com, netdev@vger.kernel.org, jesse@nicira.com
Subject: Re: [PATCH net v2 2/2] vxlan: support ndo_fill_metadata_dst also for IPv6
Date: Fri, 04 Dec 2015 14:28:38 -0500 (EST)	[thread overview]
Message-ID: <20151204.142838.797312333399556109.davem@davemloft.net> (raw)
In-Reply-To: <CALnjE+qX=sv2wgT=HQ1kfmxVj1KAWe5rWuEEMeNbDr_seBxLqw@mail.gmail.com>

From: Pravin Shelar <pshelar@nicira.com>
Date: Fri, 4 Dec 2015 10:49:37 -0800

> On Thu, Dec 3, 2015 at 2:41 AM, Jiri Benc <jbenc@redhat.com> wrote:
>> Fill the metadata correctly even when tunneling over IPv6. Also, check that
>> the provided metadata is of an address family that is supported by the
>> tunnel.
>>
>> Signed-off-by: Jiri Benc <jbenc@redhat.com>
>> ---
>> v2: fixed unused variable warning when building without IPv6
>> ---
>>  drivers/net/vxlan.c | 26 ++++++++++++++++++++++++--
>>  1 file changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
>> index 5a38558da157..d3594de3ad07 100644
>> --- a/drivers/net/vxlan.c
>> +++ b/drivers/net/vxlan.c
>> @@ -2413,15 +2413,37 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
>>  {
>>         struct vxlan_dev *vxlan = netdev_priv(dev);
>>         struct ip_tunnel_info *info = skb_tunnel_info(skb);
>> +#if IS_ENABLED(CONFIG_IPV6)
>> +       struct dst_entry *ndst;
>> +#endif
>>         __be16 sport, dport;
>>
>>         sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min,
>>                                   vxlan->cfg.port_max, true);
>>         dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
>>
>> -       if (ip_tunnel_info_af(info) == AF_INET)
>> +       if (ip_tunnel_info_af(info) == AF_INET) {
>> +               if (!vxlan->vn4_sock)
>> +                       return -EINVAL;
>>                 return egress_ipv4_tun_info(dev, skb, info, sport, dport);
>> -       return -EINVAL;
>> +       } else {
>> +               if (!IS_ENABLED(CONFIG_IPV6))
>> +                       return -EPFNOSUPPORT;
>> +
>> +#if IS_ENABLED(CONFIG_IPV6)
>> +               if (!vxlan->vn6_sock)
>> +                       return -EINVAL;
>> +               ndst = vxlan6_get_route(vxlan, skb, 0,
>> +                                       &info->key.u.ipv6.dst,
>> +                                       &info->key.u.ipv6.src);
>> +               if (IS_ERR(ndst))
>> +                       return PTR_ERR(ndst);
>> +               dst_release(ndst);
>> +#endif
> 
> Rather than checking IS_ENABLED(CONFIG_IPV6) three separate times, all
> code can is restructured in one #if #else block by moving the ndst
> definition to IPv6 local block.

Agreed, you should be putting variable definitions into the deepest most
containing scope anyways.  So if you declare 'ndst' inside of the else
branch you'll be doing that plus decreasing the amount of CPP tests in
this file.

  reply	other threads:[~2015-12-04 19:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 10:41 [PATCH net v2 0/2] vxlan: IPv6 fill_metadata_dst support Jiri Benc
2015-12-03 10:41 ` [PATCH net v2 1/2] vxlan: move IPv6 outpute route calculation to a function Jiri Benc
2015-12-04 18:47   ` Pravin Shelar
2015-12-03 10:41 ` [PATCH net v2 2/2] vxlan: support ndo_fill_metadata_dst also for IPv6 Jiri Benc
2015-12-04 18:49   ` Pravin Shelar
2015-12-04 19:28     ` David Miller [this message]
2015-12-07 10:19       ` Jiri Benc

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=20151204.142838.797312333399556109.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=jbenc@redhat.com \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.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).