net: add netif_is_geneve()
authorJohn Hurley <john.hurley@netronome.com>
Wed, 7 Nov 2018 18:32:48 +0000 (18:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Nov 2018 07:00:23 +0000 (23:00 -0800)
Add a helper function to determine if the type of a netdev is geneve based
on its rtnl_link_ops. This allows drivers that may wish to offload tunnels
to check the underlying type of the device.

A recent patch added a similar helper to vxlan.h

Signed-off-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/geneve.h

index a7600ed55ea31fc680c6ec0952cb7dc86c0dd28f..fc6a7e0a874a9ff9da0f4eb023b1394723311b09 100644 (file)
@@ -60,6 +60,12 @@ struct genevehdr {
        struct geneve_opt options[];
 };
 
+static inline bool netif_is_geneve(const struct net_device *dev)
+{
+       return dev->rtnl_link_ops &&
+              !strcmp(dev->rtnl_link_ops->kind, "geneve");
+}
+
 #ifdef CONFIG_INET
 struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
                                        u8 name_assign_type, u16 dst_port);