From: dsahern@kernel.org
To: netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH RFC net-next 3/9] net/ipv6: Remove temp variables in ipv6_create_tempaddr
Date: Wed, 23 May 2018 15:57:21 -0700 [thread overview]
Message-ID: <20180523225727.11386-4-dsahern@kernel.org> (raw)
In-Reply-To: <20180523225727.11386-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Remove temp variables in favor of ifa6_config struct.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/ipv6/addrconf.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index eff925b2064e..4988f2265882 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1258,12 +1258,10 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
{
struct inet6_dev *idev = ifp->idev;
struct in6_addr addr, *tmpaddr;
- unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age;
+ unsigned long tmp_tstamp, age;
unsigned long regen_advance;
struct ifa6_config cfg;
- int tmp_plen;
int ret = 0;
- u32 addr_flags;
unsigned long now = jiffies;
long max_desync_factor;
s32 cnf_temp_preferred_lft;
@@ -1325,13 +1323,12 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
}
}
- tmp_valid_lft = min_t(__u32,
- ifp->valid_lft,
+ cfg.valid_lft = min_t(__u32, ifp->valid_lft,
idev->cnf.temp_valid_lft + age);
- tmp_prefered_lft = cnf_temp_preferred_lft + age -
- idev->desync_factor;
- tmp_prefered_lft = min_t(__u32, ifp->prefered_lft, tmp_prefered_lft);
- tmp_plen = ifp->prefix_len;
+ cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor;
+ cfg.preferred_lft = min_t(__u32, ifp->prefered_lft, cfg.preferred_lft);
+
+ cfg.plen = ifp->prefix_len;
tmp_tstamp = ifp->tstamp;
spin_unlock_bh(&ifp->lock);
@@ -1345,24 +1342,19 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
* temporary addresses being generated.
*/
age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
- if (tmp_prefered_lft <= regen_advance + age) {
+ if (cfg.preferred_lft <= regen_advance + age) {
in6_ifa_put(ifp);
in6_dev_put(idev);
ret = -1;
goto out;
}
- addr_flags = IFA_F_TEMPORARY;
+ cfg.ifa_flags = IFA_F_TEMPORARY;
/* set in addrconf_prefix_rcv() */
if (ifp->flags & IFA_F_OPTIMISTIC)
- addr_flags |= IFA_F_OPTIMISTIC;
+ cfg.ifa_flags |= IFA_F_OPTIMISTIC;
cfg.pfx = &addr;
- cfg.plen = tmp_plen;
- cfg.peer_pfx = NULL;
- cfg.ifa_flags = addr_flags;
- cfg.preferred_lft = tmp_prefered_lft;
- cfg.valid_lft = tmp_valid_lft;
cfg.scope = ipv6_addr_scope(cfg.pfx);
ift = ipv6_add_addr(idev, &cfg, block, NULL);
--
2.11.0
next prev parent reply other threads:[~2018-05-23 22:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 22:57 [PATCH RFC net-next 0/9] net: Add address attribute to control metric of prefix route dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 1/9] net/ipv6: Introduce ifa6_config struct dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 2/9] net/ipv6: Convert ipv6_add_addr to struct ifa6_config dsahern
2018-05-23 22:57 ` dsahern [this message]
2018-05-23 22:57 ` [PATCH RFC net-next 4/9] net/ipv6: Pass ifa6_config struct to inet6_addr_add dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 5/9] net/ipv6: Pass ifa6_config struct to inet6_addr_modify dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 6/9] net: Add IFA_RT_PRIORITY address attribute dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 7/9] net/ipv4: Add support for specifying metric of connected routes dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 8/9] net/ipv6: " dsahern
2018-05-23 22:57 ` [PATCH RFC net-next 9/9] selftests: fib_tests: Add prefix route tests with metric dsahern
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=20180523225727.11386-4-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.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).