From: Ido Schimmel <idosch@mellanox.com>
To: David Ahern <dsahern@kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Jiri Pirko <jiri@mellanox.com>, David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH net-next 11/18] ipv4: Add helpers for neigh lookup for nexthop
Date: Fri, 5 Apr 2019 14:48:38 +0000 [thread overview]
Message-ID: <20190405144834.GA20588@splinter> (raw)
In-Reply-To: <20190404175007.8150-12-dsahern@kernel.org>
On Thu, Apr 04, 2019 at 10:50:00AM -0700, David Ahern wrote:
> From: David Ahern <dsahern@gmail.com>
>
> A common them in the output path is looking up a neigh entry for a
s/them/theme/
> nexthop, either the gateway in an rtable or a fallback to the daddr
> in the skb:
>
> nexthop = (__force u32)rt_nexthop(rt, ip_hdr(skb)->daddr);
> neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
> if (unlikely(!neigh))
> neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
>
> To allow the nexthop to be an IPv6 address we need to consider the
> family of the nexthop and then call __ipv*_neigh_lookup_noref based
> on it.
>
> To make this simpler, add a ip_neigh_gw4 helper similar to ip_neigh_gw6
> which handles:
>
> neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
> if (unlikely(!neigh))
> neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
>
> And then add a second one, ip_neigh_for_gw, that calls either
> ip_neigh_gw4 or ip_neigh_gw6 based on the address family of the gateway.
>
> Update the output paths in the VRF driver and core v4 code to use
> ip_neigh_for_gw simplifying the family based lookup and making both
> ready for a v6 nexthop.
>
> ipv4_neigh_lookup has a different need - the potential to resolve a
> passed in address in addition to any gateway in the rtable or skb. Since
> this is a one-off, add ip_neigh_gw4 and ip_neigh_gw6 diectly. The
> difference between __neigh_create used by the helpers and neigh_create
> called by ipv4_neigh_lookup is taking a refcount, so add rcu_read_lock_bh
> and bump the refcnt on the neigh entry.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Looks good to me. A couple of nits below.
> @@ -572,13 +572,11 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
>
> rcu_read_lock_bh();
>
> - nexthop = (__force u32)rt_nexthop(rt, ip_hdr(skb)->daddr);
> - neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
> - if (unlikely(!neigh))
> - neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
> + neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
> if (!IS_ERR(neigh)) {
> sock_confirm_neigh(skb, neigh);
> - ret = neigh_output(neigh, skb, false);
> + /* if crossing protocols, can not used the cached header */
s/used/use/
> + ret = neigh_output(neigh, skb, is_v6gw);
> rcu_read_unlock_bh();
> return ret;
> }
...
> @@ -218,16 +218,13 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s
> }
>
> rcu_read_lock_bh();
> - nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr);
> - neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
> - if (unlikely(!neigh))
> - neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
> + neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
> if (!IS_ERR(neigh)) {
> int res;
>
> sock_confirm_neigh(skb, neigh);
> - res = neigh_output(neigh, skb, false);
> -
> + /* if crossing protocols, can not used the cached header */
s/used/use/
> + res = neigh_output(neigh, skb, is_v6gw);
> rcu_read_unlock_bh();
> return res;
> }
next prev parent reply other threads:[~2019-04-05 14:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 17:49 [PATCH net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes David Ahern
2019-04-04 17:49 ` [PATCH net-next 01/18] ipv6: Add fib6_nh_init and release to stubs David Ahern
2019-04-05 12:46 ` Ido Schimmel
2019-04-05 14:49 ` David Ahern
2019-04-04 17:49 ` [PATCH net-next 02/18] ipv6: Add neighbor helpers that use the ipv6 stub David Ahern
2019-04-05 12:53 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 03/18] net: Replace nhc_has_gw with nhc_gw_family David Ahern
2019-04-05 13:04 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 04/18] ipv4: Prepare rtable for IPv6 gateway David Ahern
2019-04-05 13:13 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 05/18] ipv4: Prepare fib_config " David Ahern
2019-04-05 13:38 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 06/18] ipv4: Add support to rtable for ipv6 gateway David Ahern
2019-04-05 13:48 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 07/18] ipv4: Add support to fib_config for IPv6 gateway David Ahern
2019-04-05 14:00 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 08/18] ipv4: Refactor fib_check_nh David Ahern
2019-04-05 14:11 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 09/18] ipv4: Add fib_check_nh_v6_gw David Ahern
2019-04-05 14:18 ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 10/18] neighbor: Add skip_cache argument to neigh_output David Ahern
2019-04-04 17:50 ` [PATCH net-next 11/18] ipv4: Add helpers for neigh lookup for nexthop David Ahern
2019-04-05 14:48 ` Ido Schimmel [this message]
2019-04-04 17:50 ` [PATCH net-next 12/18] bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookup David Ahern
2019-04-04 17:50 ` [PATCH net-next 13/18] ipv4: Handle ipv6 gateway in ipv4_confirm_neigh David Ahern
2019-04-04 17:50 ` [PATCH net-next 14/18] ipv4: Handle ipv6 gateway in fib_detect_death David Ahern
2019-04-04 17:50 ` [PATCH net-next 15/18] ipv4: Handle ipv6 gateway in fib_good_nh David Ahern
2019-04-04 17:50 ` [PATCH net-next 16/18] ipv4: Flag fib_info with a fib_nh using IPv6 gateway David Ahern
2019-04-05 14:54 ` Ido Schimmel
2019-04-04 17:50 ` [PATCH net-next 17/18] ipv4: Allow ipv6 gateway with ipv4 routes David Ahern
2019-04-04 17:50 ` [PATCH net-next 18/18] selftests: fib_tests: Add tests for ipv6 gateway with ipv4 route David Ahern
2019-04-05 15:56 ` [PATCH net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes Ido Schimmel
2019-04-05 23:38 ` David Ahern
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=20190405144834.GA20588@splinter \
--to=idosch@mellanox.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=dsahern@kernel.org \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
/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).