netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 10/18] neighbor: Add skip_cache argument to neigh_output
Date: Fri,  5 Apr 2019 16:30:33 -0700	[thread overview]
Message-ID: <20190405233041.30775-11-dsahern@kernel.org> (raw)
In-Reply-To: <20190405233041.30775-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail.com>

A later patch allows an IPv6 gateway with an IPv4 route. The neighbor
entry will exist in the v6 ndisc table and the cached header will contain
the ipv6 protocol which is wrong for an IPv4 packet. For an IPv4 packet to
use the v6 neighbor entry, neigh_output needs to skip the cached header
and just use the output callback for the neigh entry.

A future patchset can look at expanding the hh_cache to handle 2
protocols. For now, IPv6 gateways with an IPv4 route will take the
extra overhead of generating the header.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 drivers/net/vrf.c       | 4 ++--
 include/net/neighbour.h | 5 +++--
 net/ipv4/ip_output.c    | 2 +-
 net/ipv6/ip6_output.c   | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 6d1a1abbed27..fd1337736aa0 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -370,7 +370,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,
 		neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
 	if (!IS_ERR(neigh)) {
 		sock_confirm_neigh(skb, neigh);
-		ret = neigh_output(neigh, skb);
+		ret = neigh_output(neigh, skb, false);
 		rcu_read_unlock_bh();
 		return ret;
 	}
@@ -578,7 +578,7 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
 		neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
 	if (!IS_ERR(neigh)) {
 		sock_confirm_neigh(skb, neigh);
-		ret = neigh_output(neigh, skb);
+		ret = neigh_output(neigh, skb, false);
 		rcu_read_unlock_bh();
 		return ret;
 	}
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 7c1ab9edba03..3e5438bd0101 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -498,11 +498,12 @@ static inline int neigh_hh_output(const struct hh_cache *hh, struct sk_buff *skb
 	return dev_queue_xmit(skb);
 }
 
-static inline int neigh_output(struct neighbour *n, struct sk_buff *skb)
+static inline int neigh_output(struct neighbour *n, struct sk_buff *skb,
+			       bool skip_cache)
 {
 	const struct hh_cache *hh = &n->hh;
 
-	if ((n->nud_state & NUD_CONNECTED) && hh->hh_len)
+	if ((n->nud_state & NUD_CONNECTED) && hh->hh_len && !skip_cache)
 		return neigh_hh_output(hh, skb);
 	else
 		return n->output(n, skb);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index a2bd4a6d9e6b..cca4892b8cb2 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -226,7 +226,7 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s
 		int res;
 
 		sock_confirm_neigh(skb, neigh);
-		res = neigh_output(neigh, skb);
+		res = neigh_output(neigh, skb, false);
 
 		rcu_read_unlock_bh();
 		return res;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e51f3c648b09..adef2236abe2 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -117,7 +117,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *
 		neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
 	if (!IS_ERR(neigh)) {
 		sock_confirm_neigh(skb, neigh);
-		ret = neigh_output(neigh, skb);
+		ret = neigh_output(neigh, skb, false);
 		rcu_read_unlock_bh();
 		return ret;
 	}
-- 
2.11.0


  parent reply	other threads:[~2019-04-05 23:30 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 ` [PATCH v2 net-next 02/18] ipv6: Add neighbor helpers that use the ipv6 stub David Ahern
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 ` David Ahern [this message]
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-11-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).