/* * From lib/bitmap.c * Helper functions for bitmap.h. * * This source code is licensed under the GNU General Public License, * Version 2. See the file COPYING for more details. */ #include int __bitmap_weight(const unsigned long *bitmap, int bits) { int k, w = 0, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; k++) w += hweight_long(bitmap[k]); if (bits % BITS_PER_LONG) w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); return w; } void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k; int nr = BITS_TO_LONGS(bits); for (k = 0; k < nr; k++) dst[k] = bitmap1[k] | bitmap2[k]; } size_t bitmap_scnprintf(unsigned long *bitmap, int nbits, char *buf, size_t size) { /* current bit is 'cur', most recently seen range is [rbot, rtop] */ int cur, rbot, rtop; bool first = true; size_t ret = 0; rbot = cur = find_first_bit(bitmap, nbits); while (cur < nbits) { rtop = cur; cur = find_next_bit(bitmap, nbits, cur + 1); if (cur < nbits && cur <= rtop + 1) continue; if (!first) ret += scnprintf(buf + ret, size - ret, ","); first = false; ret += scnprintf(buf + ret, size - ret, "%d", rbot); if (rbot < rtop) ret += scnprintf(buf + ret, size - ret, "-%d", rtop); rbot = cur; } return ret; } int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int bits) { unsigned int k; unsigned int lim = bits/BITS_PER_LONG; unsigned long result = 0; for (k = 0; k < lim; k++) result |= (dst[k] = bitmap1[k] & bitmap2[k]); if (bits % BITS_PER_LONG) result |= (dst[k] = bitmap1[k] & bitmap2[k] & BITMAP_LAST_WORD_MASK(bits)); return result != 0; } 5'>refslogtreecommitdiff
path: root/tools/testing/selftests/ipc
diff options
context:
space:
mode:
authorSimon Horman <simon.horman@netronome.com>2017-01-30 16:19:02 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-30 16:42:09 -0500
commit040587af31228d82c52267f717c9fcdb65f36335 (patch)
treeb681c1594f967396fcf3ce80f17444183bb37900 /tools/testing/selftests/ipc
parent0d29ed28da63dd893395c343c7e78b078de93ceb (diff)
net/sched: cls_flower: Correct matching on ICMPv6 code
When matching on the ICMPv6 code ICMPV6_CODE rather than ICMPV4_CODE attributes should be used. This corrects what appears to be a typo. Sample usage: tc qdisc add dev eth0 ingress tc filter add dev eth0 protocol ipv6 parent ffff: flower \ indev eth0 ip_proto icmpv6 type 128 code 0 action drop Without this change the code parameter above is effectively ignored. Fixes: 7b684884fbfa ("net/sched: cls_flower: Support matching on ICMP type and code") Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/ipc')