Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
	John Hurley <john.hurley@netronome.com>
Subject: [PATCH net-next 7/9] nfp: flower: extract ipv4 udp tunnel ttl from route
Date: Fri, 29 Jun 2018 17:04:40 -0700	[thread overview]
Message-ID: <20180630000442.27353-8-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180630000442.27353-1-jakub.kicinski@netronome.com>

From: John Hurley <john.hurley@netronome.com>

Previously the ttl for ipv4 udp tunnels was set to the namespace default.
Modify this to attempt to extract the ttl from a full route lookup on the
tunnel destination. If this is not possible then resort to the default.

Signed-off-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 .../ethernet/netronome/nfp/flower/action.c    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 61ba8d4f99f1..d421b7fbce96 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -236,9 +236,12 @@ nfp_fl_set_ipv4_udp_tun(struct nfp_fl_set_ipv4_udp_tun *set_tun,
 	size_t act_size = sizeof(struct nfp_fl_set_ipv4_udp_tun);
 	struct ip_tunnel_info *ip_tun = tcf_tunnel_info(action);
 	u32 tmp_set_ip_tun_type_index = 0;
+	struct flowi4 flow = {};
 	/* Currently support one pre-tunnel so index is always 0. */
 	int pretun_idx = 0;
+	struct rtable *rt;
 	struct net *net;
+	int err;
 
 	if (ip_tun->options_len)
 		return -EOPNOTSUPP;
@@ -255,7 +258,21 @@ nfp_fl_set_ipv4_udp_tun(struct nfp_fl_set_ipv4_udp_tun *set_tun,
 
 	set_tun->tun_type_index = cpu_to_be32(tmp_set_ip_tun_type_index);
 	set_tun->tun_id = ip_tun->key.tun_id;
-	set_tun->ttl = net->ipv4.sysctl_ip_default_ttl;
+
+	/* Do a route lookup to determine ttl - if fails then use default.
+	 * Note that CONFIG_INET is a requirement of CONFIG_NET_SWITCHDEV so
+	 * must be defined here.
+	 */
+	flow.daddr = ip_tun->key.u.ipv4.dst;
+	flow.flowi4_proto = IPPROTO_UDP;
+	rt = ip_route_output_key(net, &flow);
+	err = PTR_ERR_OR_ZERO(rt);
+	if (!err) {
+		set_tun->ttl = ip4_dst_hoplimit(&rt->dst);
+		ip_rt_put(rt);
+	} else {
+		set_tun->ttl = net->ipv4.sysctl_ip_default_ttl;
+	}
 
 	/* Complete pre_tunnel action. */
 	pre_tun->ipv4_dst = ip_tun->key.u.ipv4.dst;
-- 
2.17.1

  parent reply	other threads:[~2018-06-30  0:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-30  0:04 [PATCH net-next 0/9] nfp: flower updates and netconsole Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 1/9] nfp: expose ring stats of inactive rings via ethtool Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 2/9] nfp: fail probe if serial or interface id is missing Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 3/9] nfp: implement netpoll ndo (thus enabling netconsole) Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 4/9] nfp: make use of napi_consume_skb() Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 5/9] nfp: populate bus-info on representors Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 6/9] nfp: flower: ignore checksum actions when performing pedit actions Jakub Kicinski
2018-06-30  0:04 ` Jakub Kicinski [this message]
2018-06-30  0:04 ` [PATCH net-next 8/9] nfp: flower: offload tos and tunnel flags for ipv4 udp tunnels Jakub Kicinski
2018-06-30  0:04 ` [PATCH net-next 9/9] nfp: flower: enabled offloading of Team LAG Jakub Kicinski
2018-06-30 12:32 ` [PATCH net-next 0/9] nfp: flower updates and netconsole 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=20180630000442.27353-8-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --cc=john.hurley@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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