]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
macvlan: introduce macvlan_dev_real_dev() helper function
authorMichal Kubeček <mkubecek@suse.cz>
Fri, 15 Nov 2013 05:18:40 +0000 (06:18 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Nov 2013 22:55:48 +0000 (17:55 -0500)
Introduce helper function macvlan_dev_real_dev which returns the
underlying device of a macvlan device, similar to vlan_dev_real_dev()
for 802.1q VLAN devices.

v2: IFF_MACVLAN flag and equivalent of is_macvlan_dev() were
introduced in the meantime

v3: do BUG() if compiled without macvlan support

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_macvlan.h

index c2702856295ebaaa06db6dddb7106a53d2e71315..84ba5ac39e039f80da563305155800cd1332782c 100644 (file)
@@ -119,4 +119,21 @@ extern int macvlan_link_register(struct rtnl_link_ops *ops);
 extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
                                      struct net_device *dev);
 
+#if IS_ENABLED(CONFIG_MACVLAN)
+static inline struct net_device *
+macvlan_dev_real_dev(const struct net_device *dev)
+{
+       struct macvlan_dev *macvlan = netdev_priv(dev);
+
+       return macvlan->lowerdev;
+}
+#else
+static inline struct net_device *
+macvlan_dev_real_dev(const struct net_device *dev)
+{
+       BUG();
+       return NULL;
+}
+#endif
+
 #endif /* _LINUX_IF_MACVLAN_H */