diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index a9732aef2ca..d96eaf0aa6b 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -43,17 +44,6 @@ struct dsmark_qdisc_data { int set_tc_index; }; -static inline int dsmark_valid_indices(u16 indices) -{ - while (indices != 1) { - if (indices & 1) - return 0; - indices >>= 1; - } - - return 1; -} - static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index) { return (index <= p->indices && index > 0); @@ -348,7 +338,8 @@ static int dsmark_init(struct Qdisc *sch, struct rtattr *opt) goto errout; indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]); - if (!indices || !dsmark_valid_indices(indices)) + + if (hweight32(indices) != 1) goto errout; if (tb[TCA_DSMARK_DEFAULT_INDEX-1])