tree:
https://github.com/dsahern/linux nexthops/del-group-03
head: b8c06bc47e0a04603de20861b8d5f7291ff0bc12
commit: 063512a047f24cd25298dbb37ae1247a407dbdde [4/7] ipv4: Refactor nhc evaluation in
fib_table_lookup
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (
https://github.com/llvm/llvm-project
3393cc4cebf9969db94dc424b7a2b6195589c33b)
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
git checkout 063512a047f24cd25298dbb37ae1247a407dbdde
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
> net/ipv4/fib_trie.c:1559:8: warning: variable 'nhsel' is
used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (nhc)
^~~
net/ipv4/fib_trie.c:1575:18: note: uninitialized use occurs here
res->nh_sel = nhsel;
^~~~~
net/ipv4/fib_trie.c:1559:4: note: remove the 'if' if its condition is always
false
if (nhc)
^~~~~~~~
net/ipv4/fib_trie.c:1527:12: note: initialize the variable 'nhsel' to silence this
warning
int nhsel, err;
^
= 0
1 warning generated.
vim +1559 net/ipv4/fib_trie.c
1420
1421 /* Step 1: Travel to the longest prefix match in the trie */
1422 for (;;) {
1423 index = get_cindex(key, n);
1424
1425 /* This bit of code is a bit tricky but it combines multiple
1426 * checks into a single check. The prefix consists of the
1427 * prefix plus zeros for the "bits" in the prefix. The index
1428 * is the difference between the key and this value. From
1429 * this we can actually derive several pieces of data.
1430 * if (index >= (1ul << bits))
1431 * we have a mismatch in skip bits and failed
1432 * else
1433 * we know the value is cindex
1434 *
1435 * This check is safe even if bits == KEYLENGTH due to the
1436 * fact that we can only allocate a node with 32 bits if a
1437 * long is greater than 32 bits.
1438 */
1439 if (index >= (1ul << n->bits))
1440 break;
1441
1442 /* we have found a leaf. Prefixes have already been compared */
1443 if (IS_LEAF(n))
1444 goto found;
1445
1446 /* only record pn and cindex if we are going to be chopping
1447 * bits later. Otherwise we are just wasting cycles.
1448 */
1449 if (n->slen > n->pos) {
1450 pn = n;
1451 cindex = index;
1452 }
1453
1454 n = get_child_rcu(n, index);
1455 if (unlikely(!n))
1456 goto backtrace;
1457 }
1458
1459 /* Step 2: Sort out leaves and begin backtracing for longest prefix */
1460 for (;;) {
1461 /* record the pointer where our next node pointer is stored */
1462 struct key_vector __rcu **cptr = n->tnode;
1463
1464 /* This test verifies that none of the bits that differ
1465 * between the key and the prefix exist in the region of
1466 * the lsb and higher in the prefix.
1467 */
1468 if (unlikely(prefix_mismatch(key, n)) || (n->slen == n->pos))
1469 goto backtrace;
1470
1471 /* exit out and process leaf */
1472 if (unlikely(IS_LEAF(n)))
1473 break;
1474
1475 /* Don't bother recording parent info. Since we are in
1476 * prefix match mode we will have to come back to wherever
1477 * we started this traversal anyway
1478 */
1479
1480 while ((n = rcu_dereference(*cptr)) == NULL) {
1481 backtrace:
1482 #ifdef CONFIG_IP_FIB_TRIE_STATS
1483 if (!n)
1484 this_cpu_inc(stats->null_node_hit);
1485 #endif
1486 /* If we are at cindex 0 there are no more bits for
1487 * us to strip at this level so we must ascend back
1488 * up one level to see if there are any more bits to
1489 * be stripped there.
1490 */
1491 while (!cindex) {
1492 t_key pkey = pn->key;
1493
1494 /* If we don't have a parent then there is
1495 * nothing for us to do as we do not have any
1496 * further nodes to parse.
1497 */
1498 if (IS_TRIE(pn)) {
1499 trace_fib_table_lookup(tb->tb_id, flp,
1500 NULL, -EAGAIN);
1501 return -EAGAIN;
1502 }
1503 #ifdef CONFIG_IP_FIB_TRIE_STATS
1504 this_cpu_inc(stats->backtrack);
1505 #endif
1506 /* Get Child's index */
1507 pn = node_parent_rcu(pn);
1508 cindex = get_index(pkey, pn);
1509 }
1510
1511 /* strip the least significant bit from the cindex */
1512 cindex &= cindex - 1;
1513
1514 /* grab pointer for next child node */
1515 cptr = &pn->tnode[cindex];
1516 }
1517 }
1518
1519 found:
1520 /* this line carries forward the xor from earlier in the function */
1521 index = key ^ n->key;
1522
1523 /* Step 3: Process the leaf, if that fails fall back to backtracing */
1524 hlist_for_each_entry_rcu(fa, &n->leaf, fa_list) {
1525 struct fib_info *fi = fa->fa_info;
1526 struct fib_nh_common *nhc;
1527 int nhsel, err;
1528
1529 if ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen < KEYLENGTH)) {
1530 if (index >= (1ul << fa->fa_slen))
1531 continue;
1532 }
1533 if (fa->fa_tos && fa->fa_tos != flp->flowi4_tos)
1534 continue;
1535 if (fi->fib_dead)
1536 continue;
1537 if (fa->fa_info->fib_scope < flp->flowi4_scope)
1538 continue;
1539 fib_alias_accessed(fa);
1540 err = fib_props[fa->fa_type].error;
1541 if (unlikely(err < 0)) {
1542 out_reject:
1543 #ifdef CONFIG_IP_FIB_TRIE_STATS
1544 this_cpu_inc(stats->semantic_match_passed);
1545 #endif
1546 trace_fib_table_lookup(tb->tb_id, flp, NULL, err);
1547 return err;
1548 }
1549 if (fi->fib_flags & RTNH_F_DEAD)
1550 continue;
1551
1552 if (unlikely(fi->nh)) {
1553 if (nexthop_is_blackhole(fi->nh)) {
1554 err = fib_props[RTN_BLACKHOLE].error;
1555 goto out_reject;
1556 }
1557
1558 nhc = nexthop_get_nhc_lookup(fi->nh, fib_flags, flp);
1559 if (nhc)
1560 goto set_result;
1561 goto miss;
1562 }
1563
1564 for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) {
1565 nhc = fib_info_nhc(fi, nhsel);
1566
1567 if (!fib_lookup_good_nhc(nhc, fib_flags, flp))
1568 continue;
1569 set_result:
1570 if (!(fib_flags & FIB_LOOKUP_NOREF))
1571 refcount_inc(&fi->fib_clntref);
1572
1573 res->prefix = htonl(n->key);
1574 res->prefixlen = KEYLENGTH - fa->fa_slen;
1575 res->nh_sel = nhsel;
1576 res->nhc = nhc;
1577 res->type = fa->fa_type;
1578 res->scope = fi->fib_scope;
1579 res->fi = fi;
1580 res->table = tb;
1581 res->fa_head = &n->leaf;
1582 #ifdef CONFIG_IP_FIB_TRIE_STATS
1583 this_cpu_inc(stats->semantic_match_passed);
1584 #endif
1585 trace_fib_table_lookup(tb->tb_id, flp, nhc, err);
1586
1587 return err;
1588 }
1589 }
1590 miss:
1591 #ifdef CONFIG_IP_FIB_TRIE_STATS
1592 this_cpu_inc(stats->semantic_match_miss);
1593 #endif
1594 goto backtrace;
1595 }
1596 EXPORT_SYMBOL_GPL(fib_table_lookup);
1597
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org