Commit bd1cc1a7 authored by David S. Miller's avatar David S. Miller

Merge branch 'xdp-adjust-xdp-redirect-tracepoint'

Jesper Dangaard Brouer says:

====================
xdp: adjust xdp redirect tracepoint

Working on streamlining the tracepoints for XDP.  The eBPF programs
and XDP have no flow-control or queueing.  Investigating using
tracepoint to provide a feedback on XDP_REDIRECT xmit overflow events.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3de42f56 4c03bdd7
...@@ -9860,7 +9860,7 @@ static int ixgbe_xdp_xmit(struct net_device *dev, struct xdp_buff *xdp) ...@@ -9860,7 +9860,7 @@ static int ixgbe_xdp_xmit(struct net_device *dev, struct xdp_buff *xdp)
err = ixgbe_xmit_xdp_ring(adapter, xdp); err = ixgbe_xmit_xdp_ring(adapter, xdp);
if (err != IXGBE_XDP_TX) if (err != IXGBE_XDP_TX)
return -ENOMEM; return -ENOSPC;
return 0; return 0;
} }
......
...@@ -53,15 +53,16 @@ TRACE_EVENT(xdp_redirect, ...@@ -53,15 +53,16 @@ TRACE_EVENT(xdp_redirect,
TP_PROTO(const struct net_device *from, TP_PROTO(const struct net_device *from,
const struct net_device *to, const struct net_device *to,
const struct bpf_prog *xdp, u32 act), const struct bpf_prog *xdp, u32 act, int err),
TP_ARGS(from, to, xdp, act), TP_ARGS(from, to, xdp, act, err),
TP_STRUCT__entry( TP_STRUCT__entry(
__string(name_from, from->name) __string(name_from, from->name)
__string(name_to, to->name) __string(name_to, to->name)
__array(u8, prog_tag, 8) __array(u8, prog_tag, 8)
__field(u32, act) __field(u32, act)
__field(int, err)
), ),
TP_fast_assign( TP_fast_assign(
...@@ -70,12 +71,14 @@ TRACE_EVENT(xdp_redirect, ...@@ -70,12 +71,14 @@ TRACE_EVENT(xdp_redirect,
__assign_str(name_from, from->name); __assign_str(name_from, from->name);
__assign_str(name_to, to->name); __assign_str(name_to, to->name);
__entry->act = act; __entry->act = act;
__entry->err = err;
), ),
TP_printk("prog=%s from=%s to=%s action=%s", TP_printk("prog=%s from=%s to=%s action=%s err=%d",
__print_hex_str(__entry->prog_tag, 8), __print_hex_str(__entry->prog_tag, 8),
__get_str(name_from), __get_str(name_to), __get_str(name_from), __get_str(name_to),
__print_symbolic(__entry->act, __XDP_ACT_SYM_TAB)) __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
__entry->err)
); );
#endif /* _TRACE_XDP_H */ #endif /* _TRACE_XDP_H */
......
...@@ -2535,14 +2535,16 @@ int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, ...@@ -2535,14 +2535,16 @@ int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
struct bpf_map *map = ri->map; struct bpf_map *map = ri->map;
u32 index = ri->ifindex; u32 index = ri->ifindex;
struct net_device *fwd; struct net_device *fwd;
int err = -EINVAL; int err;
ri->ifindex = 0; ri->ifindex = 0;
ri->map = NULL; ri->map = NULL;
fwd = __dev_map_lookup_elem(map, index); fwd = __dev_map_lookup_elem(map, index);
if (!fwd) if (!fwd) {
err = -EINVAL;
goto out; goto out;
}
if (ri->map_to_flush && (ri->map_to_flush != map)) if (ri->map_to_flush && (ri->map_to_flush != map))
xdp_do_flush_map(); xdp_do_flush_map();
...@@ -2552,7 +2554,7 @@ int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, ...@@ -2552,7 +2554,7 @@ int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
ri->map_to_flush = map; ri->map_to_flush = map;
out: out:
trace_xdp_redirect(dev, fwd, xdp_prog, XDP_REDIRECT); trace_xdp_redirect(dev, fwd, xdp_prog, XDP_REDIRECT, err);
return err; return err;
} }
...@@ -2562,6 +2564,7 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp, ...@@ -2562,6 +2564,7 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,
struct redirect_info *ri = this_cpu_ptr(&redirect_info); struct redirect_info *ri = this_cpu_ptr(&redirect_info);
struct net_device *fwd; struct net_device *fwd;
u32 index = ri->ifindex; u32 index = ri->ifindex;
int err;
if (ri->map) if (ri->map)
return xdp_do_redirect_map(dev, xdp, xdp_prog); return xdp_do_redirect_map(dev, xdp, xdp_prog);
...@@ -2570,12 +2573,14 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp, ...@@ -2570,12 +2573,14 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,
ri->ifindex = 0; ri->ifindex = 0;
if (unlikely(!fwd)) { if (unlikely(!fwd)) {
bpf_warn_invalid_xdp_redirect(index); bpf_warn_invalid_xdp_redirect(index);
return -EINVAL; err = -EINVAL;
goto out;
} }
trace_xdp_redirect(dev, fwd, xdp_prog, XDP_REDIRECT); err = __bpf_tx_xdp(fwd, NULL, xdp, 0);
out:
return __bpf_tx_xdp(fwd, NULL, xdp, 0); trace_xdp_redirect(dev, fwd, xdp_prog, XDP_REDIRECT, err);
return err;
} }
EXPORT_SYMBOL_GPL(xdp_do_redirect); EXPORT_SYMBOL_GPL(xdp_do_redirect);
......
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