From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Tariq Toukan" <tariqt@mellanox.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
brouer@redhat.com
Subject: Re: [PATCHv2 bpf-next] samples/bpf: add xdp program on egress for xdp_redirect_map
Date: Thu, 26 Nov 2020 11:51:19 +0100 [thread overview]
Message-ID: <20201126115119.20f82cba@carbon> (raw)
In-Reply-To: <20201126084325.477470-1-liuhangbin@gmail.com>
On Thu, 26 Nov 2020 16:43:25 +0800
Hangbin Liu <liuhangbin@gmail.com> wrote:
> Current sample test xdp_redirect_map only count pkts on ingress. But we
> can't know whether the pkts are redirected or dropped. So add a counter
> on egress interface so we could know how many pkts are redirect in fact.
This is not true.
The 2nd devmap XDP-prog will run in the same RX-context, so it doesn't
tell us if the redirect was successful. I looked up the code, and the
2nd XDP-prog is even allowed to run when the egress driver doesn't
support the NDO to xmit (dev->netdev_ops->ndo_xdp_xmit), which is very
misleading, if you place a output counter here.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
static inline int __xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
struct net_device *dev_rx)
{
struct xdp_frame *xdpf;
int err;
if (!dev->netdev_ops->ndo_xdp_xmit)
return -EOPNOTSUPP;
err = xdp_ok_fwd_dev(dev, xdp->data_end - xdp->data);
if (unlikely(err))
return err;
xdpf = xdp_convert_buff_to_frame(xdp);
if (unlikely(!xdpf))
return -EOVERFLOW;
bq_enqueue(dev, xdpf, dev_rx);
return 0;
}
static struct xdp_buff *dev_map_run_prog(struct net_device *dev,
struct xdp_buff *xdp,
struct bpf_prog *xdp_prog)
{
struct xdp_txq_info txq = { .dev = dev };
u32 act;
xdp_set_data_meta_invalid(xdp);
xdp->txq = &txq;
act = bpf_prog_run_xdp(xdp_prog, xdp);
switch (act) {
case XDP_PASS:
return xdp;
case XDP_DROP:
break;
default:
bpf_warn_invalid_xdp_action(act);
fallthrough;
case XDP_ABORTED:
trace_xdp_exception(dev, xdp_prog, act);
break;
}
xdp_return_buff(xdp);
return NULL;
}
int dev_xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
struct net_device *dev_rx)
{
return __xdp_enqueue(dev, xdp, dev_rx);
}
int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
struct net_device *dev_rx)
{
struct net_device *dev = dst->dev;
if (dst->xdp_prog) {
xdp = dev_map_run_prog(dev, xdp, dst->xdp_prog);
if (!xdp)
return 0;
}
return __xdp_enqueue(dev, xdp, dev_rx);
}
next prev parent reply other threads:[~2020-11-26 10:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 12:46 [PATCH bpf-next] samples/bpf: add xdp_redirect_map with xdp_prog support Hangbin Liu
2020-11-10 14:25 ` Jesper Dangaard Brouer
2020-11-10 15:24 ` Maciej Fijalkowski
2020-11-11 1:12 ` Hangbin Liu
2020-11-26 8:43 ` [PATCHv2 bpf-next] samples/bpf: add xdp program on egress for xdp_redirect_map Hangbin Liu
2020-11-26 10:51 ` Jesper Dangaard Brouer [this message]
2020-11-26 14:19 ` Hangbin Liu
2020-11-27 6:31 ` Yonghong Song
2020-11-30 7:51 ` Hangbin Liu
2020-11-30 9:32 ` Jesper Dangaard Brouer
2020-11-30 13:10 ` Hangbin Liu
2020-11-30 15:12 ` Jesper Dangaard Brouer
2020-11-30 16:07 ` Toke Høiland-Jørgensen
2020-12-08 8:18 ` [PATCHv3 " Hangbin Liu
2020-12-08 10:39 ` Jesper Dangaard Brouer
2020-12-08 11:11 ` Hangbin Liu
2020-12-08 12:01 ` [PATCHv4 " Hangbin Liu
2020-12-11 0:15 ` Daniel Borkmann
2020-12-11 2:40 ` [PATCHv5 " Hangbin Liu
2021-01-14 14:27 ` [PATCHv6 " Hangbin Liu
2021-01-14 21:01 ` Yonghong Song
2021-01-15 4:17 ` Hangbin Liu
2021-01-15 6:24 ` [PATCHv7 " Hangbin Liu
2021-01-15 16:57 ` Yonghong Song
2021-01-18 22:46 ` Daniel Borkmann
2021-01-19 3:12 ` [PATCHv8 " Hangbin Liu
2021-01-19 14:51 ` Jesper Dangaard Brouer
2021-01-20 4:16 ` Hangbin Liu
2021-01-21 13:06 ` [PATCHv9 " Hangbin Liu
2021-01-21 15:05 ` Jesper Dangaard Brouer
2021-01-22 2:50 ` [PATCHv10 " Hangbin Liu
2021-01-22 10:32 ` Jesper Dangaard Brouer
2021-01-22 23:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201126115119.20f82cba@carbon \
--to=brouer@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=liuhangbin@gmail.com \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=tariqt@mellanox.com \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).