mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-18 09:51:26 +00:00
108 lines
3.2 KiB
Diff
108 lines
3.2 KiB
Diff
From 5d862370f5fecb81263a48f4bac600d3e7441591 Mon Sep 17 00:00:00 2001
|
|
From: Swati Singh <quic_swasing@quicinc.com>
|
|
Date: Wed, 24 Aug 2022 09:37:33 -0700
|
|
Subject: [PATCH] net:gre: Adding support to detect fb netdev
|
|
|
|
adding support to detect whether the
|
|
given netdevice is fallback device
|
|
for gretap and ipv6 tunnel.
|
|
|
|
Change-Id: Idf275af604ea56061e48f45c89154ef1d20c902a
|
|
Signed-off-by: Swati Singh <quic_swasing@quicinc.com>
|
|
---
|
|
include/net/gre.h | 1 +
|
|
include/net/ip_tunnels.h | 3 +++
|
|
net/ipv4/ip_gre.c | 20 ++++++++++++++++++++
|
|
net/ipv6/ip6_tunnel.c | 20 ++++++++++++++++++++
|
|
4 files changed, 44 insertions(+)
|
|
|
|
diff --git a/include/net/gre.h b/include/net/gre.h
|
|
index c09155581240..2e4a694c017b 100644
|
|
--- a/include/net/gre.h
|
|
+++ b/include/net/gre.h
|
|
@@ -31,6 +31,7 @@ struct gre_protocol {
|
|
|
|
int gre_add_protocol(const struct gre_protocol *proto, u8 version);
|
|
int gre_del_protocol(const struct gre_protocol *proto, u8 version);
|
|
+bool gre_tunnel_is_fallback_dev(struct net_device *dev);
|
|
|
|
struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
|
|
u8 name_assign_type);
|
|
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
|
|
index fca357679816..803ccbb72934 100644
|
|
--- a/include/net/ip_tunnels.h
|
|
+++ b/include/net/ip_tunnels.h
|
|
@@ -554,4 +554,7 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
|
|
|
|
#endif /* CONFIG_INET */
|
|
|
|
+void ipip6_update_offload_stats(struct net_device *dev, void *ptr);
|
|
+void ip6_update_offload_stats(struct net_device *dev, void *ptr);
|
|
+bool ip6_tunnel_is_fallback_dev(struct net_device *dev);
|
|
#endif /* __NET_IP_TUNNELS_H */
|
|
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
|
|
index 5704ade7779c..e8d3936347ce 100644
|
|
--- a/net/ipv4/ip_gre.c
|
|
+++ b/net/ipv4/ip_gre.c
|
|
@@ -454,6 +454,26 @@ static int gre_rcv(struct sk_buff *skb)
|
|
return 0;
|
|
}
|
|
|
|
+bool gre_tunnel_is_fallback_dev(struct net_device *dev)
|
|
+{
|
|
+ struct net *net;
|
|
+ struct ip_tunnel_net *itn;
|
|
+ struct net_device *fb_tunnel_dev;
|
|
+
|
|
+ net = dev_net(dev);
|
|
+ if (!net)
|
|
+ return false;
|
|
+
|
|
+ itn = net_generic(net, gre_tap_net_id);
|
|
+ if (!itn)
|
|
+ return false;
|
|
+
|
|
+ fb_tunnel_dev = itn->fb_tunnel_dev;
|
|
+
|
|
+ return (fb_tunnel_dev == dev);
|
|
+}
|
|
+EXPORT_SYMBOL(gre_tunnel_is_fallback_dev);
|
|
+
|
|
static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
|
|
const struct iphdr *tnl_params,
|
|
__be16 proto)
|
|
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
|
|
index b83031a12d17..8f3ee2ae7e19 100644
|
|
--- a/net/ipv6/ip6_tunnel.c
|
|
+++ b/net/ipv6/ip6_tunnel.c
|
|
@@ -2406,6 +2406,26 @@ struct net *ip6_tnl_get_link_net(const struct net_device *dev)
|
|
}
|
|
EXPORT_SYMBOL(ip6_tnl_get_link_net);
|
|
|
|
+bool ip6_tunnel_is_fallback_dev(struct net_device *dev)
|
|
+{
|
|
+ struct net *net;
|
|
+ struct ip6_tnl_net *ip6n;
|
|
+ struct net_device *fb_tnl_dev;
|
|
+
|
|
+ net = dev_net(dev);
|
|
+ if (!net)
|
|
+ return false;
|
|
+
|
|
+ ip6n = net_generic(net, ip6_tnl_net_id);
|
|
+ if (!ip6n)
|
|
+ return false;
|
|
+
|
|
+ fb_tnl_dev = ip6n->fb_tnl_dev;
|
|
+
|
|
+ return (fb_tnl_dev == dev);
|
|
+}
|
|
+EXPORT_SYMBOL(ip6_tunnel_is_fallback_dev);
|
|
+
|
|
static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
|
|
[IFLA_IPTUN_LINK] = { .type = NLA_U32 },
|
|
[IFLA_IPTUN_LOCAL] = { .len = sizeof(struct in6_addr) },
|
|
--
|
|
2.34.1
|
|
|