From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, jiri@mellanox.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH v2 net-next 02/18] ipv6: Add neighbor helpers that use the ipv6 stub
Date: Fri, 5 Apr 2019 16:30:25 -0700 [thread overview]
Message-ID: <20190405233041.30775-3-dsahern@kernel.org> (raw)
In-Reply-To: <20190405233041.30775-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Add ipv6 helpers to handle ndisc references via the stub. Update
bpf_ipv6_fib_lookup to use __ipv6_neigh_lookup_noref_stub instead of
the open code ___neigh_lookup_noref with the stub.
Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
---
include/net/ndisc.h | 40 ++++++++++++++++++++++++++++++++++++++++
net/core/filter.c | 6 ++----
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index ddfbb591e2c5..366150053043 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -2,6 +2,8 @@
#ifndef _NDISC_H
#define _NDISC_H
+#include <net/ipv6_stubs.h>
+
/*
* ICMP codes for neighbour discovery messages
*/
@@ -379,6 +381,14 @@ static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev
return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev);
}
+static inline
+struct neighbour *__ipv6_neigh_lookup_noref_stub(struct net_device *dev,
+ const void *pkey)
+{
+ return ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128,
+ ndisc_hashfn, pkey, dev);
+}
+
static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey)
{
struct neighbour *n;
@@ -409,6 +419,36 @@ static inline void __ipv6_confirm_neigh(struct net_device *dev,
rcu_read_unlock_bh();
}
+static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
+ const void *pkey)
+{
+ struct neighbour *n;
+
+ rcu_read_lock_bh();
+ n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
+ if (n) {
+ unsigned long now = jiffies;
+
+ /* avoid dirtying neighbour */
+ if (n->confirmed != now)
+ n->confirmed = now;
+ }
+ rcu_read_unlock_bh();
+}
+
+/* uses ipv6_stub and is meant for use outside of IPv6 core */
+static inline struct neighbour *ip_neigh_gw6(struct net_device *dev,
+ const void *addr)
+{
+ struct neighbour *neigh;
+
+ neigh = __ipv6_neigh_lookup_noref_stub(dev, addr);
+ if (unlikely(!neigh))
+ neigh = __neigh_create(ipv6_stub->nd_tbl, addr, dev, false);
+
+ return neigh;
+}
+
int ndisc_init(void);
int ndisc_late_init(void);
diff --git a/net/core/filter.c b/net/core/filter.c
index 8904e3407163..26d9cd785ae2 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4759,11 +4759,9 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
params->rt_metric = f6i->fib6_metric;
/* xdp and cls_bpf programs are run in RCU-bh so rcu_read_lock_bh is
- * not needed here. Can not use __ipv6_neigh_lookup_noref here
- * because we need to get nd_tbl via the stub
+ * not needed here.
*/
- neigh = ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128,
- ndisc_hashfn, dst, dev);
+ neigh = __ipv6_neigh_lookup_noref_stub(dev, dst);
if (!neigh)
return BPF_FIB_LKUP_RET_NO_NEIGH;
--
2.11.0
next prev parent reply other threads:[~2019-04-05 23:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 23:30 [PATCH v2 net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 01/18] ipv6: Add fib6_nh_init and release to stubs David Ahern
2019-04-05 23:30 ` David Ahern [this message]
2019-04-05 23:30 ` [PATCH v2 net-next 03/18] net: Replace nhc_has_gw with nhc_gw_family David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 04/18] ipv4: Prepare rtable for IPv6 gateway David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 05/18] ipv4: Prepare fib_config " David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 06/18] ipv4: Add support to rtable for ipv6 gateway David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 07/18] ipv4: Add support to fib_config for IPv6 gateway David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 08/18] ipv4: Refactor fib_check_nh David Ahern
2019-04-10 0:08 ` Govindarajulu Varadarajan
2019-04-10 0:43 ` David Ahern
2019-04-10 2:13 ` David Ahern
2019-04-10 5:31 ` Govindarajulu Varadarajan
2019-04-10 15:44 ` David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 09/18] ipv4: Add fib_check_nh_v6_gw David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 10/18] neighbor: Add skip_cache argument to neigh_output David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 11/18] ipv4: Add helpers for neigh lookup for nexthop David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 12/18] bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookup David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 13/18] ipv4: Handle ipv6 gateway in ipv4_confirm_neigh David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 14/18] ipv4: Handle ipv6 gateway in fib_detect_death David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 15/18] ipv4: Handle ipv6 gateway in fib_good_nh David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 16/18] ipv4: Flag fib_info with a fib_nh using IPv6 gateway David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 17/18] ipv4: Allow ipv6 gateway with ipv4 routes David Ahern
2019-04-05 23:30 ` [PATCH v2 net-next 18/18] selftests: fib_tests: Add tests for ipv6 gateway with ipv4 route David Ahern
2019-04-08 22:24 ` [PATCH v2 net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes David Miller
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=20190405233041.30775-3-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--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).