Skip to content

Commit e74de52

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
xdp/trace: extend tracepoint in devmap with an err
Extending tracepoint xdp:xdp_devmap_xmit in devmap with an err code allow people to easier identify the reason behind the ndo_xdp_xmit call to a given driver is failing. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 735fc40 commit e74de52

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/trace/events/xdp.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ TRACE_EVENT(xdp_devmap_xmit,
234234
TP_PROTO(const struct bpf_map *map, u32 map_index,
235235
int sent, int drops,
236236
const struct net_device *from_dev,
237-
const struct net_device *to_dev),
237+
const struct net_device *to_dev, int err),
238238

239-
TP_ARGS(map, map_index, sent, drops, from_dev, to_dev),
239+
TP_ARGS(map, map_index, sent, drops, from_dev, to_dev, err),
240240

241241
TP_STRUCT__entry(
242242
__field(int, map_id)
@@ -246,6 +246,7 @@ TRACE_EVENT(xdp_devmap_xmit,
246246
__field(int, sent)
247247
__field(int, from_ifindex)
248248
__field(int, to_ifindex)
249+
__field(int, err)
249250
),
250251

251252
TP_fast_assign(
@@ -256,16 +257,17 @@ TRACE_EVENT(xdp_devmap_xmit,
256257
__entry->sent = sent;
257258
__entry->from_ifindex = from_dev->ifindex;
258259
__entry->to_ifindex = to_dev->ifindex;
260+
__entry->err = err;
259261
),
260262

261263
TP_printk("ndo_xdp_xmit"
262264
" map_id=%d map_index=%d action=%s"
263265
" sent=%d drops=%d"
264-
" from_ifindex=%d to_ifindex=%d",
266+
" from_ifindex=%d to_ifindex=%d err=%d",
265267
__entry->map_id, __entry->map_index,
266268
__print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
267269
__entry->sent, __entry->drops,
268-
__entry->from_ifindex, __entry->to_ifindex)
270+
__entry->from_ifindex, __entry->to_ifindex, __entry->err)
269271
);
270272

271273
#endif /* _TRACE_XDP_H */

kernel/bpf/devmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int bq_xmit_all(struct bpf_dtab_netdev *obj,
220220
struct xdp_bulk_queue *bq)
221221
{
222222
struct net_device *dev = obj->dev;
223-
int sent = 0, drops = 0;
223+
int sent = 0, drops = 0, err = 0;
224224
int i;
225225

226226
if (unlikely(!bq->count))
@@ -234,6 +234,7 @@ static int bq_xmit_all(struct bpf_dtab_netdev *obj,
234234

235235
sent = dev->netdev_ops->ndo_xdp_xmit(dev, bq->count, bq->q);
236236
if (sent < 0) {
237+
err = sent;
237238
sent = 0;
238239
goto error;
239240
}
@@ -242,7 +243,7 @@ static int bq_xmit_all(struct bpf_dtab_netdev *obj,
242243
bq->count = 0;
243244

244245
trace_xdp_devmap_xmit(&obj->dtab->map, obj->bit,
245-
sent, drops, bq->dev_rx, dev);
246+
sent, drops, bq->dev_rx, dev, err);
246247
bq->dev_rx = NULL;
247248
return 0;
248249
error:

0 commit comments

Comments
 (0)