On Mon, 2016-09-12 at 16:46 -0400, Jamal Hadi Salim wrote:
> +
> +static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a,
> + int bind, int ref)
> +{
> + struct tcf_skbmod *d = to_skbmod(a);
> + unsigned char *b = skb_tail_pointer(skb);
> + struct tcf_skbmod_params *p = rtnl_dereference(d->skbmod_p);
> + struct tc_skbmod opt = {
> + .index = d->tcf_index,
> + .refcnt = d->tcf_refcnt - ref,
> + .bindcnt = d->tcf_bindcnt - bind,
> + .action = d->tcf_action,
> + };
> + struct tcf_t t;
> +
> + rcu_read_lock();
You do not need rcu read lock protection here, RTNL is enough.
> +
> + opt.flags = p->flags;
> + if (nla_put(skb, TCA_SKBMOD_PARMS, sizeof(opt), &opt))
> + goto nla_put_failure;
> + if ((p->flags & SKBMOD_F_DMAC) &&
> + nla_put(skb, TCA_SKBMOD_DMAC, ETH_ALEN, p->eth_dst))
> + goto nla_put_failure;
> + if ((p->flags & SKBMOD_F_SMAC) &&
> + nla_put(skb, TCA_SKBMOD_SMAC, ETH_ALEN, p->eth_src))
> + goto nla_put_failure;
> + if ((p->flags & SKBMOD_F_ETYPE) &&
> + nla_put_u16(skb, TCA_SKBMOD_ETYPE, ntohs(p->eth_type)))
> + goto nla_put_failure;
> +
> + tcf_tm_dump(&t, &d->tcf_tm);
> + if (nla_put_64bit(skb, TCA_SKBMOD_TM, sizeof(t), &t, TCA_SKBMOD_PAD))
> + goto nla_put_failure;
> +
> + rcu_read_unlock();
> +
> + return skb->len;
> +nla_put_failure:
> + rcu_read_unlock();
> + nlmsg_trim(skb, b);
> + return -1;
> +}
> +