* [linux-review:UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800 1/1] net/ipv6/addrconf.c:1347:17: sparse: sparse: context imbalance in 'ipv6_create_tempaddr' - unexpected unlock
@ 2020-11-12 15:04 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-11-12 15:04 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 15153 bytes --]
tree: https://github.com/0day-ci/linux/commits/UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800
head: b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
commit: b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a [1/1] net: Variable SLAAC: SLAAC with prefixes of arbitrary length in PIO
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: i386-randconfig-s002-20201111 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-106-gd020cf33-dirty
# https://github.com/0day-ci/linux/commit/b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800
git checkout b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
>> net/ipv6/addrconf.c:1347:17: sparse: sparse: context imbalance in 'ipv6_create_tempaddr' - unexpected unlock
vim +/ipv6_create_tempaddr +1347 net/ipv6/addrconf.c
^1da177e4c3f415 Linus Torvalds 2005-04-16 1313
969c54646af0d7d Fernando Gont 2020-05-01 1314 static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1315 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1316 struct inet6_dev *idev = ifp->idev;
e6464b8c6361962 David Ahern 2018-05-27 1317 unsigned long tmp_tstamp, age;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1318 unsigned long regen_advance;
76f793e3a47139d Lorenzo Colitti 2011-07-26 1319 unsigned long now = jiffies;
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1320 s32 cnf_temp_preferred_lft;
969c54646af0d7d Fernando Gont 2020-05-01 1321 struct inet6_ifaddr *ift;
969c54646af0d7d Fernando Gont 2020-05-01 1322 struct ifa6_config cfg;
969c54646af0d7d Fernando Gont 2020-05-01 1323 long max_desync_factor;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1324
969c54646af0d7d Fernando Gont 2020-05-01 1325 struct in6_addr addr;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1326
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1327 int ret;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1328 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1329 __int128 host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1330 __int128 net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1331 __int128 ipv6addr;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1332 __int128 mask_128;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1333 __int128 mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1334 __int128 mask_net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1335 struct in6_addr temp;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1336 int i;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1337 unsigned char mask_host_id_arr[128];
969c54646af0d7d Fernando Gont 2020-05-01 1338
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1339
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1340 memset(&mask_128, 0xFF, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1341 write_lock_bh(&idev->lock);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1342 #endif
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1343 ret = 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1344 retry:
^1da177e4c3f415 Linus Torvalds 2005-04-16 1345 in6_dev_hold(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1346 if (idev->cnf.use_tempaddr <= 0) {
53bd674915379d9 Jiri Pirko 2013-12-06 @1347 write_unlock_bh(&idev->lock);
f32138319ca6541 Joe Perches 2012-05-15 1348 pr_info("%s: use_tempaddr is disabled\n", __func__);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1349 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1350 ret = -1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1351 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1352 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1353 spin_lock_bh(&ifp->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1354 if (ifp->regen_count++ >= idev->cnf.regen_max_retry) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1355 idev->cnf.use_tempaddr = -1; /*XXX*/
^1da177e4c3f415 Linus Torvalds 2005-04-16 1356 spin_unlock_bh(&ifp->lock);
53bd674915379d9 Jiri Pirko 2013-12-06 1357 write_unlock_bh(&idev->lock);
f32138319ca6541 Joe Perches 2012-05-15 1358 pr_warn("%s: regeneration time exceeded - disabled temporary address support\n",
f32138319ca6541 Joe Perches 2012-05-15 1359 __func__);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1360 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1361 ret = -1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1362 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1363 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1364 in6_ifa_hold(ifp);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1365
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1366 if (ifp->prefix_len == 64) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1367 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
969c54646af0d7d Fernando Gont 2020-05-01 1368 ipv6_gen_rnd_iid(&addr);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1369 } else if (ifp->prefix_len > 0 && ifp->prefix_len <= 128) {
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1370 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1371 memcpy(addr.s6_addr, ifp->addr.s6_addr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1372 get_random_bytes(temp.s6_addr32, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1373
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1374 memcpy(&host_id, temp.s6_addr32, sizeof(host_id));
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1375 memcpy(&net_prfx, addr.s6_addr, sizeof(net_prfx));
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1376
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1377 mask_host_id = ifp->prefix_len != 128 ? (mask_128 << ifp->prefix_len) : 0x0;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1378 memcpy(mask_host_id_arr, &mask_host_id, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1379 for (i = 0; i < 128; i++)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1380 mask_host_id_arr[i] = reverse_bits(mask_host_id_arr[i]);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1381 memcpy(&mask_host_id, mask_host_id_arr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1382 host_id = host_id & mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1383
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1384 mask_net_prfx = mask_128 ^ mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1385 net_prfx = net_prfx & mask_net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1386
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1387 ipv6addr = net_prfx | host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1388 memcpy(addr.s6_addr, &ipv6addr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1389 #endif
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1390 }
76f793e3a47139d Lorenzo Colitti 2011-07-26 1391 age = (now - ifp->tstamp) / HZ;
76506a986dc3139 Jiri Bohac 2016-10-13 1392
76506a986dc3139 Jiri Bohac 2016-10-13 1393 regen_advance = idev->cnf.regen_max_retry *
76506a986dc3139 Jiri Bohac 2016-10-13 1394 idev->cnf.dad_transmits *
19e16d220f0adbf Hangbin Liu 2020-04-01 1395 max(NEIGH_VAR(idev->nd_parms, RETRANS_TIME), HZ/100) / HZ;
76506a986dc3139 Jiri Bohac 2016-10-13 1396
76506a986dc3139 Jiri Bohac 2016-10-13 1397 /* recalculate max_desync_factor each time and update
76506a986dc3139 Jiri Bohac 2016-10-13 1398 * idev->desync_factor if it's larger
76506a986dc3139 Jiri Bohac 2016-10-13 1399 */
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1400 cnf_temp_preferred_lft = READ_ONCE(idev->cnf.temp_prefered_lft);
76506a986dc3139 Jiri Bohac 2016-10-13 1401 max_desync_factor = min_t(__u32,
76506a986dc3139 Jiri Bohac 2016-10-13 1402 idev->cnf.max_desync_factor,
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1403 cnf_temp_preferred_lft - regen_advance);
76506a986dc3139 Jiri Bohac 2016-10-13 1404
76506a986dc3139 Jiri Bohac 2016-10-13 1405 if (unlikely(idev->desync_factor > max_desync_factor)) {
76506a986dc3139 Jiri Bohac 2016-10-13 1406 if (max_desync_factor > 0) {
76506a986dc3139 Jiri Bohac 2016-10-13 1407 get_random_bytes(&idev->desync_factor,
76506a986dc3139 Jiri Bohac 2016-10-13 1408 sizeof(idev->desync_factor));
76506a986dc3139 Jiri Bohac 2016-10-13 1409 idev->desync_factor %= max_desync_factor;
76506a986dc3139 Jiri Bohac 2016-10-13 1410 } else {
76506a986dc3139 Jiri Bohac 2016-10-13 1411 idev->desync_factor = 0;
76506a986dc3139 Jiri Bohac 2016-10-13 1412 }
76506a986dc3139 Jiri Bohac 2016-10-13 1413 }
76506a986dc3139 Jiri Bohac 2016-10-13 1414
3f2d67b6bd24c61 David Ahern 2018-06-11 1415 memset(&cfg, 0, sizeof(cfg));
e6464b8c6361962 David Ahern 2018-05-27 1416 cfg.valid_lft = min_t(__u32, ifp->valid_lft,
7a876b0efcba380 Glenn Wurster 2010-09-27 1417 idev->cnf.temp_valid_lft + age);
e6464b8c6361962 David Ahern 2018-05-27 1418 cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor;
e6464b8c6361962 David Ahern 2018-05-27 1419 cfg.preferred_lft = min_t(__u32, ifp->prefered_lft, cfg.preferred_lft);
e6464b8c6361962 David Ahern 2018-05-27 1420
e6464b8c6361962 David Ahern 2018-05-27 1421 cfg.plen = ifp->prefix_len;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1422 tmp_tstamp = ifp->tstamp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1423 spin_unlock_bh(&ifp->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1424
53bd674915379d9 Jiri Pirko 2013-12-06 1425 write_unlock_bh(&idev->lock);
95c385b4d5a71b8 Neil Horman 2007-04-25 1426
eac55bf97094f6b Benoit Boissinot 2008-04-02 1427 /* A temporary address is created only if this calculated Preferred
eac55bf97094f6b Benoit Boissinot 2008-04-02 1428 * Lifetime is greater than REGEN_ADVANCE time units. In particular,
eac55bf97094f6b Benoit Boissinot 2008-04-02 1429 * an implementation must not create a temporary address with a zero
eac55bf97094f6b Benoit Boissinot 2008-04-02 1430 * Preferred Lifetime.
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1431 * Use age calculation as in addrconf_verify to avoid unnecessary
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1432 * temporary addresses being generated.
eac55bf97094f6b Benoit Boissinot 2008-04-02 1433 */
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1434 age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
e6464b8c6361962 David Ahern 2018-05-27 1435 if (cfg.preferred_lft <= regen_advance + age) {
eac55bf97094f6b Benoit Boissinot 2008-04-02 1436 in6_ifa_put(ifp);
eac55bf97094f6b Benoit Boissinot 2008-04-02 1437 in6_dev_put(idev);
eac55bf97094f6b Benoit Boissinot 2008-04-02 1438 ret = -1;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1439 goto out;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1440 }
eac55bf97094f6b Benoit Boissinot 2008-04-02 1441
e6464b8c6361962 David Ahern 2018-05-27 1442 cfg.ifa_flags = IFA_F_TEMPORARY;
95c385b4d5a71b8 Neil Horman 2007-04-25 1443 /* set in addrconf_prefix_rcv() */
95c385b4d5a71b8 Neil Horman 2007-04-25 1444 if (ifp->flags & IFA_F_OPTIMISTIC)
e6464b8c6361962 David Ahern 2018-05-27 1445 cfg.ifa_flags |= IFA_F_OPTIMISTIC;
e6464b8c6361962 David Ahern 2018-05-27 1446
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1447 if (in6_pton("::", -1, addr.s6_addr, -1, NULL)) {
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1448 ret = -1;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1449 goto out;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1450 }
e6464b8c6361962 David Ahern 2018-05-27 1451 cfg.pfx = &addr;
e6464b8c6361962 David Ahern 2018-05-27 1452 cfg.scope = ipv6_addr_scope(cfg.pfx);
95c385b4d5a71b8 Neil Horman 2007-04-25 1453
e6464b8c6361962 David Ahern 2018-05-27 1454 ift = ipv6_add_addr(idev, &cfg, block, NULL);
4b08a8f1bd8cb45 Hannes Frederic Sowa 2013-08-16 1455 if (IS_ERR(ift)) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1456 in6_ifa_put(ifp);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1457 in6_dev_put(idev);
f32138319ca6541 Joe Perches 2012-05-15 1458 pr_info("%s: retry temporary address regeneration\n", __func__);
53bd674915379d9 Jiri Pirko 2013-12-06 1459 write_lock_bh(&idev->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1460 goto retry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1461 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1462
^1da177e4c3f415 Linus Torvalds 2005-04-16 1463 spin_lock_bh(&ift->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1464 ift->ifpub = ifp;
76f793e3a47139d Lorenzo Colitti 2011-07-26 1465 ift->cstamp = now;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1466 ift->tstamp = tmp_tstamp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1467 spin_unlock_bh(&ift->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1468
cf22f9a2b83e720 David S. Miller 2012-04-14 1469 addrconf_dad_start(ift);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1470 in6_ifa_put(ift);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1471 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1472 out:
^1da177e4c3f415 Linus Torvalds 2005-04-16 1473 return ret;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1474 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1475
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37688 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* [linux-review:UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800 1/1] net/ipv6/addrconf.c:1347:17: sparse: sparse: context imbalance in 'ipv6_create_tempaddr' - unexpected unlock
@ 2020-11-12 0:01 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-11-12 0:01 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 15257 bytes --]
CC: kbuild-all(a)lists.01.org
TO: Dmytro Shytyi <dmytro@shytyi.net>
CC: 0day robot <lkp@intel.com>
tree: https://github.com/0day-ci/linux/commits/UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800
head: b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
commit: b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a [1/1] net: Variable SLAAC: SLAAC with prefixes of arbitrary length in PIO
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: i386-randconfig-s002-20201111 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-106-gd020cf33-dirty
# https://github.com/0day-ci/linux/commit/b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800
git checkout b4fa8b6e31c8016e8ea9614264f2e38bae6ddf4a
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
>> net/ipv6/addrconf.c:1347:17: sparse: sparse: context imbalance in 'ipv6_create_tempaddr' - unexpected unlock
vim +/ipv6_create_tempaddr +1347 net/ipv6/addrconf.c
^1da177e4c3f415 Linus Torvalds 2005-04-16 1313
969c54646af0d7d Fernando Gont 2020-05-01 1314 static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1315 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1316 struct inet6_dev *idev = ifp->idev;
e6464b8c6361962 David Ahern 2018-05-27 1317 unsigned long tmp_tstamp, age;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1318 unsigned long regen_advance;
76f793e3a47139d Lorenzo Colitti 2011-07-26 1319 unsigned long now = jiffies;
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1320 s32 cnf_temp_preferred_lft;
969c54646af0d7d Fernando Gont 2020-05-01 1321 struct inet6_ifaddr *ift;
969c54646af0d7d Fernando Gont 2020-05-01 1322 struct ifa6_config cfg;
969c54646af0d7d Fernando Gont 2020-05-01 1323 long max_desync_factor;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1324
969c54646af0d7d Fernando Gont 2020-05-01 1325 struct in6_addr addr;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1326
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1327 int ret;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1328 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1329 __int128 host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1330 __int128 net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1331 __int128 ipv6addr;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1332 __int128 mask_128;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1333 __int128 mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1334 __int128 mask_net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1335 struct in6_addr temp;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1336 int i;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1337 unsigned char mask_host_id_arr[128];
969c54646af0d7d Fernando Gont 2020-05-01 1338
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1339
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1340 memset(&mask_128, 0xFF, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1341 write_lock_bh(&idev->lock);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1342 #endif
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1343 ret = 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1344 retry:
^1da177e4c3f415 Linus Torvalds 2005-04-16 1345 in6_dev_hold(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1346 if (idev->cnf.use_tempaddr <= 0) {
53bd674915379d9 Jiri Pirko 2013-12-06 @1347 write_unlock_bh(&idev->lock);
f32138319ca6541 Joe Perches 2012-05-15 1348 pr_info("%s: use_tempaddr is disabled\n", __func__);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1349 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1350 ret = -1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1351 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1352 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1353 spin_lock_bh(&ifp->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1354 if (ifp->regen_count++ >= idev->cnf.regen_max_retry) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1355 idev->cnf.use_tempaddr = -1; /*XXX*/
^1da177e4c3f415 Linus Torvalds 2005-04-16 1356 spin_unlock_bh(&ifp->lock);
53bd674915379d9 Jiri Pirko 2013-12-06 1357 write_unlock_bh(&idev->lock);
f32138319ca6541 Joe Perches 2012-05-15 1358 pr_warn("%s: regeneration time exceeded - disabled temporary address support\n",
f32138319ca6541 Joe Perches 2012-05-15 1359 __func__);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1360 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1361 ret = -1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1362 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1363 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1364 in6_ifa_hold(ifp);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1365
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1366 if (ifp->prefix_len == 64) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1367 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
969c54646af0d7d Fernando Gont 2020-05-01 1368 ipv6_gen_rnd_iid(&addr);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1369 } else if (ifp->prefix_len > 0 && ifp->prefix_len <= 128) {
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1370 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1371 memcpy(addr.s6_addr, ifp->addr.s6_addr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1372 get_random_bytes(temp.s6_addr32, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1373
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1374 memcpy(&host_id, temp.s6_addr32, sizeof(host_id));
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1375 memcpy(&net_prfx, addr.s6_addr, sizeof(net_prfx));
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1376
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1377 mask_host_id = ifp->prefix_len != 128 ? (mask_128 << ifp->prefix_len) : 0x0;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1378 memcpy(mask_host_id_arr, &mask_host_id, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1379 for (i = 0; i < 128; i++)
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1380 mask_host_id_arr[i] = reverse_bits(mask_host_id_arr[i]);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1381 memcpy(&mask_host_id, mask_host_id_arr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1382 host_id = host_id & mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1383
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1384 mask_net_prfx = mask_128 ^ mask_host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1385 net_prfx = net_prfx & mask_net_prfx;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1386
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1387 ipv6addr = net_prfx | host_id;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1388 memcpy(addr.s6_addr, &ipv6addr, 16);
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1389 #endif
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1390 }
76f793e3a47139d Lorenzo Colitti 2011-07-26 1391 age = (now - ifp->tstamp) / HZ;
76506a986dc3139 Jiri Bohac 2016-10-13 1392
76506a986dc3139 Jiri Bohac 2016-10-13 1393 regen_advance = idev->cnf.regen_max_retry *
76506a986dc3139 Jiri Bohac 2016-10-13 1394 idev->cnf.dad_transmits *
19e16d220f0adbf Hangbin Liu 2020-04-01 1395 max(NEIGH_VAR(idev->nd_parms, RETRANS_TIME), HZ/100) / HZ;
76506a986dc3139 Jiri Bohac 2016-10-13 1396
76506a986dc3139 Jiri Bohac 2016-10-13 1397 /* recalculate max_desync_factor each time and update
76506a986dc3139 Jiri Bohac 2016-10-13 1398 * idev->desync_factor if it's larger
76506a986dc3139 Jiri Bohac 2016-10-13 1399 */
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1400 cnf_temp_preferred_lft = READ_ONCE(idev->cnf.temp_prefered_lft);
76506a986dc3139 Jiri Bohac 2016-10-13 1401 max_desync_factor = min_t(__u32,
76506a986dc3139 Jiri Bohac 2016-10-13 1402 idev->cnf.max_desync_factor,
7aa8e63f0d0f2e0 Jiri Bohac 2016-10-20 1403 cnf_temp_preferred_lft - regen_advance);
76506a986dc3139 Jiri Bohac 2016-10-13 1404
76506a986dc3139 Jiri Bohac 2016-10-13 1405 if (unlikely(idev->desync_factor > max_desync_factor)) {
76506a986dc3139 Jiri Bohac 2016-10-13 1406 if (max_desync_factor > 0) {
76506a986dc3139 Jiri Bohac 2016-10-13 1407 get_random_bytes(&idev->desync_factor,
76506a986dc3139 Jiri Bohac 2016-10-13 1408 sizeof(idev->desync_factor));
76506a986dc3139 Jiri Bohac 2016-10-13 1409 idev->desync_factor %= max_desync_factor;
76506a986dc3139 Jiri Bohac 2016-10-13 1410 } else {
76506a986dc3139 Jiri Bohac 2016-10-13 1411 idev->desync_factor = 0;
76506a986dc3139 Jiri Bohac 2016-10-13 1412 }
76506a986dc3139 Jiri Bohac 2016-10-13 1413 }
76506a986dc3139 Jiri Bohac 2016-10-13 1414
3f2d67b6bd24c61 David Ahern 2018-06-11 1415 memset(&cfg, 0, sizeof(cfg));
e6464b8c6361962 David Ahern 2018-05-27 1416 cfg.valid_lft = min_t(__u32, ifp->valid_lft,
7a876b0efcba380 Glenn Wurster 2010-09-27 1417 idev->cnf.temp_valid_lft + age);
e6464b8c6361962 David Ahern 2018-05-27 1418 cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor;
e6464b8c6361962 David Ahern 2018-05-27 1419 cfg.preferred_lft = min_t(__u32, ifp->prefered_lft, cfg.preferred_lft);
e6464b8c6361962 David Ahern 2018-05-27 1420
e6464b8c6361962 David Ahern 2018-05-27 1421 cfg.plen = ifp->prefix_len;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1422 tmp_tstamp = ifp->tstamp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1423 spin_unlock_bh(&ifp->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1424
53bd674915379d9 Jiri Pirko 2013-12-06 1425 write_unlock_bh(&idev->lock);
95c385b4d5a71b8 Neil Horman 2007-04-25 1426
eac55bf97094f6b Benoit Boissinot 2008-04-02 1427 /* A temporary address is created only if this calculated Preferred
eac55bf97094f6b Benoit Boissinot 2008-04-02 1428 * Lifetime is greater than REGEN_ADVANCE time units. In particular,
eac55bf97094f6b Benoit Boissinot 2008-04-02 1429 * an implementation must not create a temporary address with a zero
eac55bf97094f6b Benoit Boissinot 2008-04-02 1430 * Preferred Lifetime.
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1431 * Use age calculation as in addrconf_verify to avoid unnecessary
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1432 * temporary addresses being generated.
eac55bf97094f6b Benoit Boissinot 2008-04-02 1433 */
ecab67015ef6e3f Heiner Kallweit 2014-03-12 1434 age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
e6464b8c6361962 David Ahern 2018-05-27 1435 if (cfg.preferred_lft <= regen_advance + age) {
eac55bf97094f6b Benoit Boissinot 2008-04-02 1436 in6_ifa_put(ifp);
eac55bf97094f6b Benoit Boissinot 2008-04-02 1437 in6_dev_put(idev);
eac55bf97094f6b Benoit Boissinot 2008-04-02 1438 ret = -1;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1439 goto out;
eac55bf97094f6b Benoit Boissinot 2008-04-02 1440 }
eac55bf97094f6b Benoit Boissinot 2008-04-02 1441
e6464b8c6361962 David Ahern 2018-05-27 1442 cfg.ifa_flags = IFA_F_TEMPORARY;
95c385b4d5a71b8 Neil Horman 2007-04-25 1443 /* set in addrconf_prefix_rcv() */
95c385b4d5a71b8 Neil Horman 2007-04-25 1444 if (ifp->flags & IFA_F_OPTIMISTIC)
e6464b8c6361962 David Ahern 2018-05-27 1445 cfg.ifa_flags |= IFA_F_OPTIMISTIC;
e6464b8c6361962 David Ahern 2018-05-27 1446
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1447 if (in6_pton("::", -1, addr.s6_addr, -1, NULL)) {
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1448 ret = -1;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1449 goto out;
b4fa8b6e31c8016 Dmytro Shytyi 2020-11-11 1450 }
e6464b8c6361962 David Ahern 2018-05-27 1451 cfg.pfx = &addr;
e6464b8c6361962 David Ahern 2018-05-27 1452 cfg.scope = ipv6_addr_scope(cfg.pfx);
95c385b4d5a71b8 Neil Horman 2007-04-25 1453
e6464b8c6361962 David Ahern 2018-05-27 1454 ift = ipv6_add_addr(idev, &cfg, block, NULL);
4b08a8f1bd8cb45 Hannes Frederic Sowa 2013-08-16 1455 if (IS_ERR(ift)) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1456 in6_ifa_put(ifp);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1457 in6_dev_put(idev);
f32138319ca6541 Joe Perches 2012-05-15 1458 pr_info("%s: retry temporary address regeneration\n", __func__);
53bd674915379d9 Jiri Pirko 2013-12-06 1459 write_lock_bh(&idev->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1460 goto retry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1461 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1462
^1da177e4c3f415 Linus Torvalds 2005-04-16 1463 spin_lock_bh(&ift->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1464 ift->ifpub = ifp;
76f793e3a47139d Lorenzo Colitti 2011-07-26 1465 ift->cstamp = now;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1466 ift->tstamp = tmp_tstamp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1467 spin_unlock_bh(&ift->lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1468
cf22f9a2b83e720 David S. Miller 2012-04-14 1469 addrconf_dad_start(ift);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1470 in6_ifa_put(ift);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1471 in6_dev_put(idev);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1472 out:
^1da177e4c3f415 Linus Torvalds 2005-04-16 1473 return ret;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1474 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1475
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37688 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-12 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 15:04 [linux-review:UPDATE-20201112-044033/Dmytro-Shytyi/Re-PATCH-net-next-net-Variable-SLAAC-SLAAC-with-prefixes-of-arbitrary-length-in-PIO/20201111-014800 1/1] net/ipv6/addrconf.c:1347:17: sparse: sparse: context imbalance in 'ipv6_create_tempaddr' - unexpected unlock kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2020-11-12 0:01 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.