[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM0EoMnRkScQbp6eNDADZkOX-tgL__ZMcATwUyBQYnet8PzN8A@mail.gmail.com>
Date: Wed, 16 Aug 2023 07:09:06 -0400
From: Jamal Hadi Salim <jhs@...atatu.com>
To: Simon Horman <horms@...nel.org>
Cc: jiri@...nulli.us, xiyou.wangcong@...il.com, netdev@...r.kernel.org,
vladbu@...dia.com, mleitner@...hat.com, Victor Nogueira <victor@...atatu.com>,
Pedro Tammela <pctammela@...atatu.com>
Subject: Re: [PATCH RFC net-next 3/3] Introduce blockcast tc action
On Wed, Aug 16, 2023 at 5:07 AM Simon Horman <horms@...nel.org> wrote:
>
> On Tue, Aug 15, 2023 at 12:25:30PM -0400, Jamal Hadi Salim wrote:
> > This action takes advantage of the presence of tc block ports set in the
> > datapath and broadcast a packet to all ports on that set with exception of
> > the port in which it arrived on..
> >
> > Example usage:
> > $ tc qdisc add dev ens7 ingress block 22
> > $ tc qdisc add dev ens8 ingress block 22
> >
> > Now we can add a filter using the block index:
> > $ tc filter add block 22 protocol ip pref 25 \
> > flower dst_ip 192.168.0.0/16 action blockcast
> >
> > Co-developed-by: Victor Nogueira <victor@...atatu.com>
> > Signed-off-by: Victor Nogueira <victor@...atatu.com>
> > Co-developed-by: Pedro Tammela <pctammela@...atatu.com>
> > Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
> > Signed-off-by: Jamal Hadi Salim <jhs@...atatu.com>
>
> ...
>
> > +//XXX: Refactor mirred code and reuse here before final version
> > +static int cast_one(struct sk_buff *skb, const u32 ifindex)
> > +{
> > + struct sk_buff *skb2 = skb;
> > + int retval = TC_ACT_PIPE;
> > + struct net_device *dev;
> > + unsigned int rec_level;
> > + bool expects_nh;
> > + int mac_len;
> > + bool at_nh;
> > + int err;
> > +
> > + rec_level = __this_cpu_inc_return(redirect_rec_level);
> > + if (unlikely(rec_level > CAST_RECURSION_LIMIT)) {
> > + net_warn_ratelimited("blockcast: exceeded redirect recursion limit on dev %s\n",
> > + netdev_name(skb->dev));
> > + __this_cpu_dec(redirect_rec_level);
> > + return TC_ACT_SHOT;
> > + }
> > +
> > + dev = dev_get_by_index_rcu(dev_net(skb->dev), ifindex);
> > + if (unlikely(!dev)) {
> > + pr_notice_once("blockcast: target device %s is gone\n",
> > + dev->name);
>
> Hi Jamal,
>
> This code is only executed if dev is NULL, but dev is dereferenced.
>
good catch;-> Cutnpaste thing..
cheers,
jamal
> > + __this_cpu_dec(redirect_rec_level);
> > + return TC_ACT_SHOT;
> > + }
>
> ...
Powered by blists - more mailing lists