summaryrefslogtreecommitdiff
path: root/include/net/ip.h
diff options
context:
space:
mode:
authorGuillaume Nault <gnault@redhat.com>2023-05-22 16:37:57 +0200
committerDavid S. Miller <davem@davemloft.net>2023-05-24 08:22:06 +0100
commit726de790f66029a7654b3e748f8d3e7888a30ae5 (patch)
tree14046deecb8d8f6b2a4a06e0bd6c458f2a1510d2 /include/net/ip.h
parenta695641c8eaac268ad7e373c7e33c00b88b2bcbf (diff)
ping: Stop using RTO_ONLINK.
Define a new helper to figure out the correct route scope to use on TX, depending on socket configuration, ancillary data and send flags. Use this new helper to properly initialise the scope in flowi4_init_output(), instead of overriding tos with the RTO_ONLINK flag. The objective is to eventually remove RTO_ONLINK, which will allow converting .flowi4_tos to dscp_t. Signed-off-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip.h')
-rw-r--r--include/net/ip.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index 7627a4df893b..f1cb28d649e4 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -240,6 +240,19 @@ static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
}
+/* Get the route scope that should be used when sending a packet. */
+static inline u8 ip_sendmsg_scope(const struct inet_sock *inet,
+ const struct ipcm_cookie *ipc,
+ const struct msghdr *msg)
+{
+ if (sock_flag(&inet->sk, SOCK_LOCALROUTE) ||
+ msg->msg_flags & MSG_DONTROUTE ||
+ (ipc->opt && ipc->opt->opt.is_strictroute))
+ return RT_SCOPE_LINK;
+
+ return RT_SCOPE_UNIVERSE;
+}
+
static inline __u8 get_rttos(struct ipcm_cookie* ipc, struct inet_sock *inet)
{
return (ipc->tos != -1) ? RT_TOS(ipc->tos) : RT_TOS(inet->tos);