TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
);
-#define _trace_xdp_redirect(dev, xdp, to, err) \
- trace_xdp_redirect(dev, xdp, to, err, NULL, 0);
+DEFINE_EVENT(xdp_redirect_template, xdp_redirect_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)
+);
+
+#define _trace_xdp_redirect(dev, xdp, to) \
+ trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
+
+#define _trace_xdp_redirect_err(dev, xdp, to, err) \
+ trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
+
+#define trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
+ trace_xdp_redirect(dev, xdp, fwd ? fwd->ifindex : 0, 0, map, idx);
-#define trace_xdp_redirect_map(dev, xdp, fwd, err, map, idx) \
- trace_xdp_redirect(dev, xdp, fwd ? fwd->ifindex : 0, err, map, idx);
+#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);
#endif /* _TRACE_XDP_H */
fwd = __dev_map_lookup_elem(map, index);
if (!fwd) {
err = -EINVAL;
- goto out;
+ goto err;
}
if (ri->map_to_flush && ri->map_to_flush != map)
xdp_do_flush_map();
err = __bpf_tx_xdp(fwd, map, xdp, index);
- if (likely(!err))
- ri->map_to_flush = map;
-out:
- trace_xdp_redirect_map(dev, xdp_prog, fwd, err, map, index);
+ if (unlikely(err))
+ goto err;
+
+ ri->map_to_flush = map;
+ trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index);
+ return 0;
+err:
+ trace_xdp_redirect_map_err(dev, xdp_prog, fwd, map, index, err);
return err;
}
ri->ifindex = 0;
if (unlikely(!fwd)) {
err = -EINVAL;
- goto out;
+ goto err;
}
err = __bpf_tx_xdp(fwd, NULL, xdp, 0);
-out:
- _trace_xdp_redirect(dev, xdp_prog, index, err);
+ if (unlikely(err))
+ goto err;
+
+ _trace_xdp_redirect(dev, xdp_prog, index);
+ return 0;
+err:
+ _trace_xdp_redirect_err(dev, xdp_prog, index, err);
return err;
}
EXPORT_SYMBOL_GPL(xdp_do_redirect);
ri->ifindex = 0;
if (unlikely(!fwd)) {
err = -EINVAL;
- goto out;
+ goto err;
}
if (unlikely(!(fwd->flags & IFF_UP))) {
err = -ENETDOWN;
- goto out;
+ goto err;
}
len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN;
if (skb->len > len) {
err = -EMSGSIZE;
- goto out;
+ goto err;
}
skb->dev = fwd;
-out:
- _trace_xdp_redirect(dev, xdp_prog, index, err);
+ _trace_xdp_redirect(dev, xdp_prog, index);
+ return 0;
+err:
+ _trace_xdp_redirect_err(dev, xdp_prog, index, err);
return err;
}
EXPORT_SYMBOL_GPL(xdp_do_generic_redirect);