Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dcb: For wild-card lookups, use priority -1, not 0

The function dcb_app_lookup walks the list of specified DCB APP entries,
looking for one that matches a given criteria: ifindex, selector,
protocol ID and optionally also priority. The "don't care" value for
priority is set to 0, because that priority has not been allowed under
CEE regime, which predates the IEEE standardization.

Under IEEE, 0 is a valid priority number. But because dcb_app_lookup
considers zero a wild card, attempts to add an APP entry with priority 0
fail when other entries exist for a given ifindex / selector / PID
triplet.

Fix by changing the wild-card value to -1.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
08193d1a 1f3ed383

+7 -4
+7 -4
net/dcb/dcbnl.c
··· 1786 1786 if (itr->app.selector == app->selector && 1787 1787 itr->app.protocol == app->protocol && 1788 1788 itr->ifindex == ifindex && 1789 - (!prio || itr->app.priority == prio)) 1789 + ((prio == -1) || itr->app.priority == prio)) 1790 1790 return itr; 1791 1791 } 1792 1792 ··· 1821 1821 u8 prio = 0; 1822 1822 1823 1823 spin_lock_bh(&dcb_lock); 1824 - if ((itr = dcb_app_lookup(app, dev->ifindex, 0))) 1824 + itr = dcb_app_lookup(app, dev->ifindex, -1); 1825 + if (itr) 1825 1826 prio = itr->app.priority; 1826 1827 spin_unlock_bh(&dcb_lock); 1827 1828 ··· 1850 1849 1851 1850 spin_lock_bh(&dcb_lock); 1852 1851 /* Search for existing match and replace */ 1853 - if ((itr = dcb_app_lookup(new, dev->ifindex, 0))) { 1852 + itr = dcb_app_lookup(new, dev->ifindex, -1); 1853 + if (itr) { 1854 1854 if (new->priority) 1855 1855 itr->app.priority = new->priority; 1856 1856 else { ··· 1884 1882 u8 prio = 0; 1885 1883 1886 1884 spin_lock_bh(&dcb_lock); 1887 - if ((itr = dcb_app_lookup(app, dev->ifindex, 0))) 1885 + itr = dcb_app_lookup(app, dev->ifindex, -1); 1886 + if (itr) 1888 1887 prio |= 1 << itr->app.priority; 1889 1888 spin_unlock_bh(&dcb_lock); 1890 1889