Thread (24 messages) flat view 24 messages, 5 authors, 2016-09-09

Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action

From: Jamal Hadi Salim <jhs@mojatatu.com>
Date: 2016-08-29 11:55:39

On 16-08-29 07:40 AM, Jamal Hadi Salim wrote:
On 16-08-29 07:00 AM, Daniel Borkmann wrote:
Sorry missed that. Let me give it an attempt. I think challenge is
going to be what length to use. For now it is ethernet; but i had
a change which swapped VLANs that i took out.
something like this?

-----
/* XXX: if you are going to edit more fields beyond ethernet header
  * (example when you add IP header replacement or vlan swap)
  * then MAX_EDIT_LEN needs to change appropriately
*/
#define MAX_EDIT_LEN ETH_HLEN
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);
         int action = READ_ONCE(d->tcf_action);
         int err;
         u64 flags;

         err = skb_ensure_writable(skb, ETH_HLEN);
         if (unlikely(err)) /* best policy is to drop on the floor */
                 action = TC_ACT_SHOT;

         tcf_lastuse_update(&d->tcf_tm);
         bstats_cpu_update(this_cpu_ptr(d->common.cpu_bstats), skb);
         if (unlikely(action == TC_ACT_SHOT)) {
                 qstats_drop_inc(this_cpu_ptr(d->common.cpu_qstats));
                 return action;
         }
----

cheers,
jamal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help