include: net: add static inline dst_dev_overhead() to dst.h
authorJustin Iurman <justin.iurman@uliege.be>
Tue, 3 Dec 2024 12:49:42 +0000 (13:49 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 5 Dec 2024 10:15:56 +0000 (11:15 +0100)
Add static inline dst_dev_overhead() function to include/net/dst.h. This
helper function is used by ioam6_iptunnel, rpl_iptunnel and
seg6_iptunnel to get the dev's overhead based on a cache entry
(dst_entry). If the cache is empty, the default and generic value
skb->mac_len is returned. Otherwise, LL_RESERVED_SPACE() over dst's dev
is returned.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/dst.h

index 0f303cc602520ec2c51a717be2f7ed8c46d05cf3..08647c99d79c9a621976a69a8972f474d8ee61fd 100644 (file)
@@ -440,6 +440,15 @@ static inline void dst_set_expires(struct dst_entry *dst, int timeout)
                dst->expires = expires;
 }
 
+static inline unsigned int dst_dev_overhead(struct dst_entry *dst,
+                                           struct sk_buff *skb)
+{
+       if (likely(dst))
+               return LL_RESERVED_SPACE(dst->dev);
+
+       return skb->mac_len;
+}
+
 INDIRECT_CALLABLE_DECLARE(int ip6_output(struct net *, struct sock *,
                                         struct sk_buff *));
 INDIRECT_CALLABLE_DECLARE(int ip_output(struct net *, struct sock *,