Commit 59a30896 authored by Jesper Dangaard Brouer's avatar Jesper Dangaard Brouer Committed by David S. Miller

xdp: separate xdp_redirect tracepoint in map case

Creating as specific xdp_redirect_map variant of the xdp tracepoints
allow users to write simpler/faster BPF progs that get attached to
these tracepoints.

Goal is to still keep the tracepoints in xdp_redirect and xdp_redirect_map
similar enough, that a tool can read the top part of the TP_STRUCT and
produce similar monitor statistics.
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5836ca5
...@@ -77,13 +77,11 @@ DECLARE_EVENT_CLASS(xdp_redirect_template, ...@@ -77,13 +77,11 @@ DECLARE_EVENT_CLASS(xdp_redirect_template,
__entry->map_index = map_index; __entry->map_index = map_index;
), ),
TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d" TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
" map_id=%d map_index=%d",
__entry->prog_id, __entry->prog_id,
__print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
__entry->ifindex, __entry->to_ifindex, __entry->ifindex, __entry->to_ifindex,
__entry->err, __entry->err)
__entry->map_id, __entry->map_index)
); );
DEFINE_EVENT(xdp_redirect_template, xdp_redirect, DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
...@@ -108,11 +106,43 @@ DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err, ...@@ -108,11 +106,43 @@ DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
#define _trace_xdp_redirect_err(dev, xdp, to, err) \ #define _trace_xdp_redirect_err(dev, xdp, to, err) \
trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0); trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
#define trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \ DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
trace_xdp_redirect(dev, xdp, fwd ? fwd->ifindex : 0, 0, map, idx); TP_PROTO(const struct net_device *dev,
const struct bpf_prog *xdp,
int to_ifindex, int err,
const struct bpf_map *map, u32 map_index),
TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
" map_id=%d map_index=%d",
__entry->prog_id,
__print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
__entry->ifindex, __entry->to_ifindex,
__entry->err,
__entry->map_id, __entry->map_index)
);
DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map_err,
TP_PROTO(const struct net_device *dev,
const struct bpf_prog *xdp,
int to_ifindex, int err,
const struct bpf_map *map, u32 map_index),
TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
" map_id=%d map_index=%d",
__entry->prog_id,
__print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
__entry->ifindex, __entry->to_ifindex,
__entry->err,
__entry->map_id, __entry->map_index)
);
#define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
trace_xdp_redirect_map(dev, xdp, fwd ? fwd->ifindex : 0, \
0, map, idx);
#define trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \ #define _trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \
trace_xdp_redirect_err(dev, xdp, fwd ? fwd->ifindex : 0, err, map, idx); trace_xdp_redirect_map_err(dev, xdp, fwd ? fwd->ifindex : 0, \
err, map, idx);
#endif /* _TRACE_XDP_H */ #endif /* _TRACE_XDP_H */
......
...@@ -2525,10 +2525,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, ...@@ -2525,10 +2525,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
goto err; goto err;
ri->map_to_flush = map; ri->map_to_flush = map;
trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index); _trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index);
return 0; return 0;
err: err:
trace_xdp_redirect_map_err(dev, xdp_prog, fwd, map, index, err); _trace_xdp_redirect_map_err(dev, xdp_prog, fwd, map, index, err);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment