Skip to content

Commit ebc4ecd

Browse files
Björn Töpelborkmann
authored andcommitted
bpf: {cpu,dev}map: Change various functions return type from int to void
The functions bq_enqueue(), bq_flush_to_queue(), and bq_xmit_all() in {cpu,dev}map.c always return zero. Changing the return type from int to void makes the code easier to follow. Suggested-by: David Ahern <dsahern@gmail.com> Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/bpf/20200901083928.6199-1-bjorn.topel@gmail.com
1 parent f56407f commit ebc4ecd

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

‎kernel/bpf/cpumap.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ struct bpf_cpu_map {
7979

8080
static DEFINE_PER_CPU(struct list_head, cpu_map_flush_list);
8181

82-
static int bq_flush_to_queue(struct xdp_bulk_queue *bq);
83-
8482
static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
8583
{
8684
u32 value_size = attr->value_size;
@@ -670,7 +668,7 @@ const struct bpf_map_ops cpu_map_ops = {
670668
.map_btf_id = &cpu_map_btf_id,
671669
};
672670

673-
static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
671+
static void bq_flush_to_queue(struct xdp_bulk_queue *bq)
674672
{
675673
struct bpf_cpu_map_entry *rcpu = bq->obj;
676674
unsigned int processed = 0, drops = 0;
@@ -679,7 +677,7 @@ static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
679677
int i;
680678

681679
if (unlikely(!bq->count))
682-
return 0;
680+
return;
683681

684682
q = rcpu->queue;
685683
spin_lock(&q->producer_lock);
@@ -702,13 +700,12 @@ static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
702700

703701
/* Feedback loop via tracepoints */
704702
trace_xdp_cpumap_enqueue(rcpu->map_id, processed, drops, to_cpu);
705-
return 0;
706703
}
707704

708705
/* Runs under RCU-read-side, plus in softirq under NAPI protection.
709706
* Thus, safe percpu variable access.
710707
*/
711-
static int bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
708+
static void bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
712709
{
713710
struct list_head *flush_list = this_cpu_ptr(&cpu_map_flush_list);
714711
struct xdp_bulk_queue *bq = this_cpu_ptr(rcpu->bulkq);
@@ -729,8 +726,6 @@ static int bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
729726

730727
if (!bq->flush_node.prev)
731728
list_add(&bq->flush_node, flush_list);
732-
733-
return 0;
734729
}
735730

736731
int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,

‎kernel/bpf/devmap.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,14 @@ bool dev_map_can_have_prog(struct bpf_map *map)
341341
return false;
342342
}
343343

344-
static int bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
344+
static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
345345
{
346346
struct net_device *dev = bq->dev;
347347
int sent = 0, drops = 0, err = 0;
348348
int i;
349349

350350
if (unlikely(!bq->count))
351-
return 0;
351+
return;
352352

353353
for (i = 0; i < bq->count; i++) {
354354
struct xdp_frame *xdpf = bq->q[i];
@@ -369,7 +369,7 @@ static int bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
369369
trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, drops, err);
370370
bq->dev_rx = NULL;
371371
__list_del_clearprev(&bq->flush_node);
372-
return 0;
372+
return;
373373
error:
374374
/* If ndo_xdp_xmit fails with an errno, no frames have been
375375
* xmit'ed and it's our responsibility to them free all.
@@ -421,8 +421,8 @@ struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key)
421421
/* Runs under RCU-read-side, plus in softirq under NAPI protection.
422422
* Thus, safe percpu variable access.
423423
*/
424-
static int bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
425-
struct net_device *dev_rx)
424+
static void bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
425+
struct net_device *dev_rx)
426426
{
427427
struct list_head *flush_list = this_cpu_ptr(&dev_flush_list);
428428
struct xdp_dev_bulk_queue *bq = this_cpu_ptr(dev->xdp_bulkq);
@@ -441,8 +441,6 @@ static int bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
441441

442442
if (!bq->flush_node.prev)
443443
list_add(&bq->flush_node, flush_list);
444-
445-
return 0;
446444
}
447445

448446
static inline int __xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
@@ -462,7 +460,8 @@ static inline int __xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
462460
if (unlikely(!xdpf))
463461
return -EOVERFLOW;
464462

465-
return bq_enqueue(dev, xdpf, dev_rx);
463+
bq_enqueue(dev, xdpf, dev_rx);
464+
return 0;
466465
}
467466

468467
static struct xdp_buff *dev_map_run_prog(struct net_device *dev,

0 commit comments

Comments
 (0)