From: David Ahern <dsa@cumulusnetworks.com>
To: netdev@vger.kernel.org
Cc: nicolas.dichtel@6wind.com, David Ahern <dsa@cumulusnetworks.com>
Subject: [PATCH net-next 5/7] net: ipv6: Add support for RTM_DELNETCONF
Date: Tue, 28 Mar 2017 14:28:05 -0700 [thread overview]
Message-ID: <1490736487-16020-6-git-send-email-dsa@cumulusnetworks.com> (raw)
In-Reply-To: <1490736487-16020-1-git-send-email-dsa@cumulusnetworks.com>
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: David Ahern <dsa@cumulusnetworks.com>
---
net/ipv6/addrconf.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b8442be85e1b..67ec87ea5fb6 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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)
goto nla_put_failure;
+ if (!devconf)
+ goto out;
+
if ((all || type == NETCONFA_FORWARDING) &&
nla_put_s32(skb, NETCONFA_FORWARDING, devconf->forwarding) < 0)
goto nla_put_failure;
@@ -567,6 +570,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
devconf->ignore_routes_with_linkdown) < 0)
goto nla_put_failure;
+out:
nlmsg_end(skb, nlh);
return 0;
@@ -6368,7 +6372,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
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;
@@ -6379,6 +6384,8 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
unregister_net_sysctl_table(p->sysctl_header);
p->sysctl_header = NULL;
kfree(table);
+
+ inet6_netconf_notify_devconf(net, RTM_DELNETCONF, 0, ifindex, NULL);
}
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)
{
- __addrconf_sysctl_unregister(&idev->cnf);
+ __addrconf_sysctl_unregister(dev_net(idev->dev), &idev->cnf,
+ idev->dev->ifindex);
neigh_sysctl_unregister(idev->nd_parms);
}
@@ -6445,7 +6453,7 @@ static int __net_init addrconf_init_net(struct net *net)
#ifdef CONFIG_SYSCTL
err_reg_dflt:
- __addrconf_sysctl_unregister(all);
+ __addrconf_sysctl_unregister(net, all, NETCONFA_IFINDEX_ALL);
err_reg_all:
kfree(dflt);
#endif
@@ -6458,8 +6466,10 @@ static int __net_init addrconf_init_net(struct net *net)
static void __net_exit addrconf_exit_net(struct net *net)
{
#ifdef CONFIG_SYSCTL
- __addrconf_sysctl_unregister(net->ipv6.devconf_dflt);
- __addrconf_sysctl_unregister(net->ipv6.devconf_all);
+ __addrconf_sysctl_unregister(net, net->ipv6.devconf_dflt,
+ NETCONFA_IFINDEX_DEFAULT);
+ __addrconf_sysctl_unregister(net, net->ipv6.devconf_all,
+ NETCONFA_IFINDEX_ALL);
#endif
kfree(net->ipv6.devconf_dflt);
kfree(net->ipv6.devconf_all);
--
2.1.4
next prev parent reply other threads:[~2017-03-28 21:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 21:28 [PATCH net-next 0/7] netconf: Add support for RTM_DELNETCONF David Ahern
2017-03-28 21:28 ` [PATCH net-next 1/7] rtnetlink: Add RTM_DELNETCONF David Ahern
2017-03-28 21:28 ` [PATCH net-next 2/7] net: devinet: Refactor inet_netconf_notify_devconf to take event David Ahern
2017-03-28 21:28 ` [PATCH net-next 3/7] net: devinet: Add support for RTM_DELNETCONF David Ahern
2017-03-28 21:28 ` [PATCH net-next 4/7] net: ipv6: Refactor inet6_netconf_notify_devconf to take event David Ahern
2017-03-28 21:28 ` David Ahern [this message]
2017-03-28 21:28 ` [PATCH net-next 6/7] net:mpls: Refactor mpls_netconf_notify_devconf " David Ahern
2017-03-28 21:28 ` [PATCH net-next 7/7] net: mpls: Send netconf messages on device register and unregister David Ahern
2017-03-29 5:32 ` [PATCH net-next 0/7] netconf: Add support for RTM_DELNETCONF David Miller
2017-03-29 9:36 ` Nicolas Dichtel
2017-03-29 14:13 ` David Ahern
2017-03-29 14:22 ` Nicolas Dichtel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490736487-16020-6-git-send-email-dsa@cumulusnetworks.com \
--to=dsa@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).