Skip to content

Commit

Permalink
net: ipv6/l3mdev: Move host route on saved address if necessary
Browse files Browse the repository at this point in the history
Commit f1705ec allows IPv6 addresses to be retained on a link down.
The address can have a cached host route which can point to the wrong
FIB table if the L3 enslavement is changed (e.g., route can point to local
table instead of VRF table if device is added to an L3 domain).

On link up check the table of the cached host route against the FIB
table associated with the device and correct if needed.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed Mar 1, 2016
1 parent 292264d commit 4f25a11
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3170,9 +3170,35 @@ static void addrconf_gre_config(struct net_device *dev)
}
#endif

#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
/* If the host route is cached on the addr struct make sure it is associated
* with the proper table. e.g., enslavement can change and if so the cached
* host route needs to move to the new table.
*/
static void l3mdev_check_host_rt(struct inet6_dev *idev,
struct inet6_ifaddr *ifp)
{
if (ifp->rt) {
u32 tb_id = l3mdev_fib_table(idev->dev) ? : RT6_TABLE_LOCAL;

if (tb_id != ifp->rt->rt6i_table->tb6_id) {
ip6_del_rt(ifp->rt);
ifp->rt = NULL;
}
}
}
#else
static void l3mdev_check_host_rt(struct inet6_dev *idev,
struct inet6_ifaddr *ifp)
{
}
#endif

static int fixup_permanent_addr(struct inet6_dev *idev,
struct inet6_ifaddr *ifp)
{
l3mdev_check_host_rt(idev, ifp);

if (!ifp->rt) {
struct rt6_info *rt;

Expand Down

0 comments on commit 4f25a11

Please sign in to comment.