Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: GRE: Add is_gretap_dev, is_ip6gretap_dev

Determining whether a device is a GRE device is easily done by
inspecting struct net_device.type. However, for the tap variants, the
type is just ARPHRD_ETHER.

Therefore introduce two predicate functions that use netdev_ops to tell
the tap devices.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
d1b2a6c4 8897207c

+15
+3
include/net/gre.h
··· 37 37 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, 38 38 bool *csum_err, __be16 proto, int nhs); 39 39 40 + bool is_gretap_dev(const struct net_device *dev); 41 + bool is_ip6gretap_dev(const struct net_device *dev); 42 + 40 43 static inline int gre_calc_hlen(__be16 o_flags) 41 44 { 42 45 int addend = 4;
+6
net/ipv4/ip_gre.c
··· 1323 1323 ip_tunnel_setup(dev, gre_tap_net_id); 1324 1324 } 1325 1325 1326 + bool is_gretap_dev(const struct net_device *dev) 1327 + { 1328 + return dev->netdev_ops == &gre_tap_netdev_ops; 1329 + } 1330 + EXPORT_SYMBOL_GPL(is_gretap_dev); 1331 + 1326 1332 static int ipgre_newlink(struct net *src_net, struct net_device *dev, 1327 1333 struct nlattr *tb[], struct nlattr *data[], 1328 1334 struct netlink_ext_ack *extack)
+6
net/ipv6/ip6_gre.c
··· 1785 1785 netif_keep_dst(dev); 1786 1786 } 1787 1787 1788 + bool is_ip6gretap_dev(const struct net_device *dev) 1789 + { 1790 + return dev->netdev_ops == &ip6gre_tap_netdev_ops; 1791 + } 1792 + EXPORT_SYMBOL_GPL(is_ip6gretap_dev); 1793 + 1788 1794 static bool ip6gre_netlink_encap_parms(struct nlattr *data[], 1789 1795 struct ip_tunnel_encap *ipencap) 1790 1796 {