summaryrefslogtreecommitdiff
path: root/include/net/route.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2024-04-29 16:30:09 +0300
committerJakub Kicinski <kuba@kernel.org>2024-05-01 04:32:38 +0300
commit05d6d492097c55f2d153fc3fd33cbe78e1e28e0a (patch)
tree9adf856d1bf6bece623d78a5f6412ec337927ec5 /include/net/route.h
parentb45176703647e5302314c740a51e7d1054a7bd3c (diff)
downloadlinux-05d6d492097c55f2d153fc3fd33cbe78e1e28e0a.tar.xz
inet: introduce dst_rtable() helper
I added dst_rt6_info() in commit e8dfd42c17fa ("ipv6: introduce dst_rt6_info() helper") This patch does a similar change for IPv4. Instead of (struct rtable *)dst casts, we can use : #define dst_rtable(_ptr) \ container_of_const(_ptr, struct rtable, dst) Patch is smaller than IPv6 one, because IPv4 has skb_rtable() helper. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://lore.kernel.org/r/20240429133009.1227754-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/route.h b/include/net/route.h
index 630d1ef6868a..93833cfe9c96 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -75,6 +75,17 @@ struct rtable {
rt_pmtu:31;
};
+#define dst_rtable(_ptr) container_of_const(_ptr, struct rtable, dst)
+
+/**
+ * skb_rtable - Returns the skb &rtable
+ * @skb: buffer
+ */
+static inline struct rtable *skb_rtable(const struct sk_buff *skb)
+{
+ return dst_rtable(skb_dst(skb));
+}
+
static inline bool rt_is_input_route(const struct rtable *rt)
{
return rt->rt_is_input != 0;