diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-09-30 06:07:12 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-30 06:40:33 +0300 |
commit | ee15ee5d94f5837260e7fa539ffd1b50952079c4 (patch) | |
tree | c31649b7367fd733d7f316b5b9217ef015a95496 /drivers/net/vrf.c | |
parent | 1b69c6d0ae90b7f1a4f61d5c8209d5cb7a55f849 (diff) | |
download | linux-ee15ee5d94f5837260e7fa539ffd1b50952079c4.tar.xz |
net: Add support for l3mdev ops to VRF driver
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vrf.c')
-rw-r--r-- | drivers/net/vrf.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 2d7418e0b908..72f1892ebad0 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -35,6 +35,7 @@ #include <net/route.h> #include <net/addrconf.h> #include <net/vrf.h> +#include <net/l3mdev.h> #define DRV_NAME "vrf" #define DRV_VERSION "1.0" @@ -529,6 +530,33 @@ static const struct net_device_ops vrf_netdev_ops = { .ndo_del_slave = vrf_del_slave, }; +static u32 vrf_fib_table(const struct net_device *dev) +{ + struct net_vrf *vrf = netdev_priv(dev); + + return vrf->tb_id; +} + +static struct rtable *vrf_get_rtable(const struct net_device *dev, + const struct flowi4 *fl4) +{ + struct rtable *rth = NULL; + + if (!(fl4->flowi4_flags & FLOWI_FLAG_VRFSRC)) { + struct net_vrf *vrf = netdev_priv(dev); + + rth = vrf->rth; + atomic_inc(&rth->dst.__refcnt); + } + + return rth; +} + +static const struct l3mdev_ops vrf_l3mdev_ops = { + .l3mdev_fib_table = vrf_fib_table, + .l3mdev_get_rtable = vrf_get_rtable, +}; + static void vrf_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -546,6 +574,7 @@ static void vrf_setup(struct net_device *dev) /* Initialize the device structure. */ dev->netdev_ops = &vrf_netdev_ops; + dev->l3mdev_ops = &vrf_l3mdev_ops; dev->ethtool_ops = &vrf_ethtool_ops; dev->destructor = free_netdev; |