Commit 23452170 authored by David Ahern's avatar David Ahern Committed by David S. Miller

net: ipv6: Add support for RTM_DELNETCONF

Send RTM_DELNETCONF notifications when a device is deleted. The message only
needs the device index, so modify inet6_netconf_fill_devconf to skip devconf
references if it is NULL.

Allows a userspace cache to remove entries as devices are deleted.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 85b3daad
...@@ -549,6 +549,9 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex, ...@@ -549,6 +549,9 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
if (nla_put_s32(skb, NETCONFA_IFINDEX, ifindex) < 0) if (nla_put_s32(skb, NETCONFA_IFINDEX, ifindex) < 0)
goto nla_put_failure; goto nla_put_failure;
if (!devconf)
goto out;
if ((all || type == NETCONFA_FORWARDING) && if ((all || type == NETCONFA_FORWARDING) &&
nla_put_s32(skb, NETCONFA_FORWARDING, devconf->forwarding) < 0) nla_put_s32(skb, NETCONFA_FORWARDING, devconf->forwarding) < 0)
goto nla_put_failure; goto nla_put_failure;
...@@ -567,6 +570,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex, ...@@ -567,6 +570,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
devconf->ignore_routes_with_linkdown) < 0) devconf->ignore_routes_with_linkdown) < 0)
goto nla_put_failure; goto nla_put_failure;
out:
nlmsg_end(skb, nlh); nlmsg_end(skb, nlh);
return 0; return 0;
...@@ -6368,7 +6372,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, ...@@ -6368,7 +6372,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
return -ENOBUFS; return -ENOBUFS;
} }
static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) static void __addrconf_sysctl_unregister(struct net *net,
struct ipv6_devconf *p, int ifindex)
{ {
struct ctl_table *table; struct ctl_table *table;
...@@ -6379,6 +6384,8 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) ...@@ -6379,6 +6384,8 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
unregister_net_sysctl_table(p->sysctl_header); unregister_net_sysctl_table(p->sysctl_header);
p->sysctl_header = NULL; p->sysctl_header = NULL;
kfree(table); kfree(table);
inet6_netconf_notify_devconf(net, RTM_DELNETCONF, 0, ifindex, NULL);
} }
static int addrconf_sysctl_register(struct inet6_dev *idev) static int addrconf_sysctl_register(struct inet6_dev *idev)
...@@ -6402,7 +6409,8 @@ static int addrconf_sysctl_register(struct inet6_dev *idev) ...@@ -6402,7 +6409,8 @@ static int addrconf_sysctl_register(struct inet6_dev *idev)
static void addrconf_sysctl_unregister(struct inet6_dev *idev) static void addrconf_sysctl_unregister(struct inet6_dev *idev)
{ {
__addrconf_sysctl_unregister(&idev->cnf); __addrconf_sysctl_unregister(dev_net(idev->dev), &idev->cnf,
idev->dev->ifindex);
neigh_sysctl_unregister(idev->nd_parms); neigh_sysctl_unregister(idev->nd_parms);
} }
...@@ -6445,7 +6453,7 @@ static int __net_init addrconf_init_net(struct net *net) ...@@ -6445,7 +6453,7 @@ static int __net_init addrconf_init_net(struct net *net)
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
err_reg_dflt: err_reg_dflt:
__addrconf_sysctl_unregister(all); __addrconf_sysctl_unregister(net, all, NETCONFA_IFINDEX_ALL);
err_reg_all: err_reg_all:
kfree(dflt); kfree(dflt);
#endif #endif
...@@ -6458,8 +6466,10 @@ static int __net_init addrconf_init_net(struct net *net) ...@@ -6458,8 +6466,10 @@ static int __net_init addrconf_init_net(struct net *net)
static void __net_exit addrconf_exit_net(struct net *net) static void __net_exit addrconf_exit_net(struct net *net)
{ {
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
__addrconf_sysctl_unregister(net->ipv6.devconf_dflt); __addrconf_sysctl_unregister(net, net->ipv6.devconf_dflt,
__addrconf_sysctl_unregister(net->ipv6.devconf_all); NETCONFA_IFINDEX_DEFAULT);
__addrconf_sysctl_unregister(net, net->ipv6.devconf_all,
NETCONFA_IFINDEX_ALL);
#endif #endif
kfree(net->ipv6.devconf_dflt); kfree(net->ipv6.devconf_dflt);
kfree(net->ipv6.devconf_all); kfree(net->ipv6.devconf_all);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment