From: Thomas Haller <thaller@redhat.com>
To: jiri@resnulli.us, netdev@vger.kernel.org
Cc: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, kaber@trash.net, thaller@redhat.com,
stephen@networkplumber.org, hannes@stressinduktion.org,
vyasevich@gmail.com, dcbw@redhat.com
Subject: [PATCH 1/1] fixup! ipv6 addrconf: introduce IFA_F_MANAGETEMPADDR to tell kernel to manage temporary addresses
Date: Fri, 15 Nov 2013 18:48:46 +0100 [thread overview]
Message-ID: <1384537726-14079-1-git-send-email-thaller@redhat.com> (raw)
In-Reply-To: <1384181359-23199-3-git-send-email-jiri@resnulli.us>
Handle IFA_F_MANAGETEMPADDR flag when modifying existing addresses too.
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
Hi,
I'd like to suggest this change, I think it makes it easier for the user space
application to set this flag of (potentially) existing addresses.
Note, that if the flag gets cleared if the ifa had it set before
and the temporary addresses will exprire immediatly. This makes sense
for me.
Or if we don't want this, then the command should fail (EEXIST?) when trying
to set MANAGETEMPADDR for an existing address that doesn't have the flag already.
Thomas
net/ipv6/addrconf.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9e217b8..9e726c8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3613,20 +3613,21 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
return inet6_addr_del(net, ifm->ifa_index, pfx, ifm->ifa_prefixlen);
}
static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags,
u32 prefered_lft, u32 valid_lft)
{
u32 flags;
clock_t expires;
unsigned long timeout;
+ int mngtmp;
if (!valid_lft || (prefered_lft > valid_lft))
return -EINVAL;
timeout = addrconf_timeout_fixup(valid_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
expires = jiffies_to_clock_t(timeout * HZ);
valid_lft = timeout;
flags = RTF_EXPIRES;
} else {
@@ -3636,35 +3637,48 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags,
}
timeout = addrconf_timeout_fixup(prefered_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
if (timeout == 0)
ifa_flags |= IFA_F_DEPRECATED;
prefered_lft = timeout;
}
spin_lock_bh(&ifp->lock);
- ifp->flags = (ifp->flags & ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | IFA_F_HOMEADDRESS)) | ifa_flags;
+ if (ifa_flags & IFA_F_MANAGETEMPADDR &&
+ (ifp->prefix_len != 64 || ifp->flags & IFA_F_TEMPORARY)) {
+ spin_unlock_bh(&ifp->lock);
+ return -EEXIST;
+ }
+ mngtmp = ifp->flags & IFA_F_MANAGETEMPADDR;
+ ifp->flags = (ifp->flags & ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | IFA_F_HOMEADDRESS |
+ IFA_F_MANAGETEMPADDR)) | ifa_flags;
ifp->tstamp = jiffies;
ifp->valid_lft = valid_lft;
ifp->prefered_lft = prefered_lft;
spin_unlock_bh(&ifp->lock);
if (!(ifp->flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ifp);
addrconf_prefix_route(&ifp->addr, ifp->prefix_len, ifp->idev->dev,
expires, flags);
- if (ifp->flags & IFA_F_MANAGETEMPADDR)
- manage_tempaddrs(ifp->idev, ifp, valid_lft, prefered_lft,
+ if (mngtmp && !(ifa_flags & IFA_F_MANAGETEMPADDR)) {
+ /* expire the life time of the temporary addresses */
+ manage_tempaddrs(ifp->idev, ifp, 0, 0,
false, jiffies);
+ } else if (ifa_flags & IFA_F_MANAGETEMPADDR) {
+ /* if we did not yet mngtmp, create temporary addresses */
+ manage_tempaddrs(ifp->idev, ifp, valid_lft, prefered_lft,
+ !mngtmp, jiffies);
+ }
addrconf_verify(0);
return 0;
}
static int
inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
{
struct net *net = sock_net(skb->sk);
@@ -3710,23 +3724,20 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
if (ifa == NULL) {
/*
* It would be best to check for !NLM_F_CREATE here but
* userspace alreay relies on not having to provide this.
*/
return inet6_addr_add(net, ifm->ifa_index, pfx, peer_pfx,
ifm->ifa_prefixlen, ifa_flags,
preferred_lft, valid_lft);
}
- /* We ignore IFA_F_MANAGETEMPADDR for modify. */
- ifa_flags &= ~IFA_F_MANAGETEMPADDR;
-
if (nlh->nlmsg_flags & NLM_F_EXCL ||
!(nlh->nlmsg_flags & NLM_F_REPLACE))
err = -EEXIST;
else
err = inet6_addr_modify(ifa, ifa_flags, preferred_lft, valid_lft);
in6_ifa_put(ifa);
return err;
}
--
1.8.4.1.559.gdb9bdfb
next prev parent reply other threads:[~2013-11-15 17:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 14:49 [patch net-next RFC 0/2] ipv6: allow temporary address management for user-created addresses Jiri Pirko
2013-11-11 14:49 ` [patch net-next RFC 1/2] ipv6 addrconf: extend ifa_flags to u32 Jiri Pirko
2013-11-11 15:07 ` David Laight
2013-11-11 15:12 ` Jiri Pirko
2013-11-11 14:49 ` [patch net-next RFC 2/2] ipv6 addrconf: introduce IFA_F_MANAGETEMPADDR to tell kernel to manage temporary addresses Jiri Pirko
2013-11-15 17:48 ` Thomas Haller [this message]
2013-11-18 10:23 ` [PATCH 1/1] fixup! " Jiri Pirko
2013-11-15 18:04 ` [patch net-next RFC 2/2] " Thomas Haller
2013-11-11 14:50 ` [patch iproute2 RFC 1/2] add support for extended ifa_flags Jiri Pirko
2013-11-11 14:50 ` [patch iproute2 RFC 2/2] add support for IFA_F_MANAGETEMPADDR Jiri Pirko
2013-11-11 18:42 ` [patch net-next RFC 0/2] ipv6: allow temporary address management for user-created addresses David Miller
2013-11-11 19:49 ` Jiri Pirko
2013-11-11 20:01 ` David Miller
2013-11-11 21:04 ` Jiri Pirko
2013-11-11 23:03 ` David Miller
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=1384537726-14079-1-git-send-email-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=davem@davemloft.net \
--cc=dcbw@redhat.com \
--cc=hannes@stressinduktion.org \
--cc=jiri@resnulli.us \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=vyasevich@gmail.com \
--cc=yoshfuji@linux-ipv6.org \
/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).