Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action
From: Eric Dumazet <hidden>
Date: 2016-08-28 16:07:49
On Sun, 2016-08-28 at 08:19 -0400, Jamal Hadi Salim wrote:
From: Jamal Hadi Salim <jhs@mojatatu.com>
...
+static int tcf_skbmod_run(struct sk_buff *skb, const struct tc_action *a,
+ struct tcf_result *res)
+{
+ struct tcf_skbmod *d = to_skbmod(a);
+
+ spin_lock(&d->tcf_lock);
+ tcf_lastuse_update(&d->tcf_tm);
+ bstats_update(&d->tcf_bstats, skb);
+
+ if (d->flags & SKBMOD_F_DMAC)
+ ether_addr_copy(eth_hdr(skb)->h_dest, d->eth_dst);
+ if (d->flags & SKBMOD_F_SMAC)
+ ether_addr_copy(eth_hdr(skb)->h_source, d->eth_src);
+ if (d->flags & SKBMOD_F_ETYPE)
+ eth_hdr(skb)->h_proto = d->eth_type;
+ if (d->flags & SKBMOD_F_SWAPMAC) {
+ u8 tmpaddr[ETH_ALEN];
+ /*XXX: I am sure we can come up with something more efficient */
+ ether_addr_copy(tmpaddr, eth_hdr(skb)->h_dest);
+ ether_addr_copy(eth_hdr(skb)->h_dest, eth_hdr(skb)->h_source);
+ ether_addr_copy(eth_hdr(skb)->h_source, tmpaddr);
+ }
+
+ spin_unlock(&d->tcf_lock);
+ return d->tcf_action;
+}Adding an action with a spinlock held in fast path in 2016 is a way to tell people : It is a toy, do not use it for real. Sorry guys. Friends do not let friends do that anymore.