From: Tom Herbert <tom@quantonium.net>
To: davem@davemloft.net
Cc: pablo@netfilter.org, laforge@gnumonks.org, aschultz@tpip.net,
netdev@vger.kernel.org, rohit@quantonium.net,
Tom Herbert <tom@quantonium.net>
Subject: [PATCH v6 net-next 02/12] vxlan: Call common functions to get tunnel routes
Date: Thu, 26 Oct 2017 12:09:19 -0700 [thread overview]
Message-ID: <20171026190929.11619-3-tom@quantonium.net> (raw)
In-Reply-To: <20171026190929.11619-1-tom@quantonium.net>
Call ip_tunnel_get_route and ip6_tnl_get_route to handle getting a route
and dealing with the dst_cache.
Signed-off-by: Tom Herbert <tom@quantonium.net>
---
drivers/net/vxlan.c | 84 ++++-------------------------------------------------
1 file changed, 5 insertions(+), 79 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index d7c49cf1d5e9..810caa9adf37 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1867,47 +1867,11 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device
struct dst_cache *dst_cache,
const struct ip_tunnel_info *info)
{
- bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
- struct rtable *rt = NULL;
- struct flowi4 fl4;
-
if (!sock4)
return ERR_PTR(-EIO);
- if (tos && !info)
- use_cache = false;
- if (use_cache) {
- rt = dst_cache_get_ip4(dst_cache, saddr);
- if (rt)
- return rt;
- }
-
- memset(&fl4, 0, sizeof(fl4));
- fl4.flowi4_oif = oif;
- fl4.flowi4_tos = RT_TOS(tos);
- fl4.flowi4_mark = skb->mark;
- fl4.flowi4_proto = IPPROTO_UDP;
- fl4.daddr = daddr;
- fl4.saddr = *saddr;
- fl4.fl4_dport = dport;
- fl4.fl4_sport = sport;
-
- rt = ip_route_output_key(vxlan->net, &fl4);
- if (likely(!IS_ERR(rt))) {
- if (rt->dst.dev == dev) {
- netdev_dbg(dev, "circular route to %pI4\n", &daddr);
- ip_rt_put(rt);
- return ERR_PTR(-ELOOP);
- }
-
- *saddr = fl4.saddr;
- if (use_cache)
- dst_cache_set_ip4(dst_cache, &rt->dst, fl4.saddr);
- } else {
- netdev_dbg(dev, "no route to %pI4\n", &daddr);
- return ERR_PTR(-ENETUNREACH);
- }
- return rt;
+ return ip_tunnel_get_route(dev, skb, IPPROTO_UDP, oif, tos, daddr,
+ saddr, dport, sport, dst_cache, info);
}
#if IS_ENABLED(CONFIG_IPV6)
@@ -1922,50 +1886,12 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
struct dst_cache *dst_cache,
const struct ip_tunnel_info *info)
{
- bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
- struct dst_entry *ndst;
- struct flowi6 fl6;
- int err;
-
if (!sock6)
return ERR_PTR(-EIO);
- if (tos && !info)
- use_cache = false;
- if (use_cache) {
- ndst = dst_cache_get_ip6(dst_cache, saddr);
- if (ndst)
- return ndst;
- }
-
- memset(&fl6, 0, sizeof(fl6));
- fl6.flowi6_oif = oif;
- fl6.daddr = *daddr;
- fl6.saddr = *saddr;
- fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tos), label);
- fl6.flowi6_mark = skb->mark;
- fl6.flowi6_proto = IPPROTO_UDP;
- fl6.fl6_dport = dport;
- fl6.fl6_sport = sport;
-
- err = ipv6_stub->ipv6_dst_lookup(vxlan->net,
- sock6->sock->sk,
- &ndst, &fl6);
- if (unlikely(err < 0)) {
- netdev_dbg(dev, "no route to %pI6\n", daddr);
- return ERR_PTR(-ENETUNREACH);
- }
-
- if (unlikely(ndst->dev == dev)) {
- netdev_dbg(dev, "circular route to %pI6\n", daddr);
- dst_release(ndst);
- return ERR_PTR(-ELOOP);
- }
-
- *saddr = fl6.saddr;
- if (use_cache)
- dst_cache_set_ip6(dst_cache, ndst, saddr);
- return ndst;
+ return ip6_tnl_get_route(dev, skb, sock6->sock->sk, IPPROTO_UDP, oif,
+ tos, label, daddr, saddr, dport, sport,
+ dst_cache, info);
}
#endif
--
2.11.0
next prev parent reply other threads:[~2017-10-26 19:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 19:09 [PATCH v6 net-next 00/12] gtp: Additional feature support - Part I Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 01/12] iptunnel: Add common functions to get a tunnel route Tom Herbert
2017-10-26 19:09 ` Tom Herbert [this message]
2017-10-31 11:40 ` [PATCH v6 net-next 02/12] vxlan: Call common functions to get tunnel routes kbuild test robot
2017-10-26 19:09 ` [PATCH v6 net-next 03/12] gtp: Call common functions to get tunnel routes and add dst_cache Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 04/12] iptunnel: Generalize tunnel update pmtu Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 05/12] gtp: Change to use gro_cells Tom Herbert
2017-10-26 19:35 ` Subash Abhinov Kasiviswanathan
2017-10-26 19:51 ` Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 06/12] gtp: Use goto for exceptions in gtp_udp_encap_recv funcs Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 07/12] gtp: udp recv clean up Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 08/12] gtp: Call function to update path mtu Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 09/12] gtp: Eliminate pktinfo and add port configuration Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 10/12] gtp: Experimental encapsulation of IPv6 packets Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 11/12] gtp: Experimental support encpasulating over IPv6 Tom Herbert
2017-10-26 19:09 ` [PATCH v6 net-next 12/12] gtp: Allow configuring GTP interface as standalone Tom Herbert
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=20171026190929.11619-3-tom@quantonium.net \
--to=tom@quantonium.net \
--cc=aschultz@tpip.net \
--cc=davem@davemloft.net \
--cc=laforge@gnumonks.org \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=rohit@quantonium.net \
/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