summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
Diffstat (limited to 'net/core')
-rw-r--r--net/core/pktgen.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 5403a9f61178..7f81aed46672 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -566,6 +566,7 @@ static const struct proc_ops pktgen_proc_ops = {
static int pktgen_if_show(struct seq_file *seq, void *v)
{
const struct pktgen_dev *pkt_dev = seq->private;
+ unsigned int cflows = READ_ONCE(pkt_dev->cflows);
ktime_t stopped;
unsigned int i;
u64 idle;
@@ -590,7 +591,7 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
pkt_dev->nfrags, (unsigned long long) pkt_dev->delay,
pkt_dev->clone_skb, pkt_dev->odevname);
- seq_printf(seq, " flows: %u flowlen: %u\n", pkt_dev->cflows,
+ seq_printf(seq, " flows: %u flowlen: %u\n", cflows,
pkt_dev->lflow);
seq_printf(seq,
@@ -675,7 +676,7 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
for (i = 0; i < NR_PKT_FLAGS; i++) {
if (i == FLOW_SEQ_SHIFT)
- if (!pkt_dev->cflows)
+ if (!cflows)
continue;
if (pkt_dev->flags & (1 << i)) {
@@ -1632,8 +1633,8 @@ static ssize_t pktgen_if_write(struct file *file,
if (value > MAX_CFLOWS)
value = MAX_CFLOWS;
- pkt_dev->cflows = value;
- sprintf(pg_result, "OK: flows=%u", pkt_dev->cflows);
+ WRITE_ONCE(pkt_dev->cflows, value);
+ sprintf(pg_result, "OK: flows=%u", (unsigned int)value);
return count;
}
#ifdef CONFIG_XFRM
@@ -2373,7 +2374,7 @@ static inline int f_seen(const struct pktgen_dev *pkt_dev, int flow)
return !!(pkt_dev->flows[flow].flags & F_INIT);
}
-static inline int f_pick(struct pktgen_dev *pkt_dev)
+static inline int f_pick(struct pktgen_dev *pkt_dev, unsigned int cflows)
{
int flow = pkt_dev->curfl;
@@ -2383,11 +2384,11 @@ static inline int f_pick(struct pktgen_dev *pkt_dev)
pkt_dev->flows[flow].count = 0;
pkt_dev->flows[flow].flags = 0;
pkt_dev->curfl += 1;
- if (pkt_dev->curfl >= pkt_dev->cflows)
+ if (pkt_dev->curfl >= cflows)
pkt_dev->curfl = 0; /*reset */
}
} else {
- flow = get_random_u32_below(pkt_dev->cflows);
+ flow = get_random_u32_below(cflows);
pkt_dev->curfl = flow;
if (pkt_dev->flows[flow].count > pkt_dev->lflow) {
@@ -2461,12 +2462,14 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev)
*/
static void mod_cur_headers(struct pktgen_dev *pkt_dev)
{
+ unsigned int cflows;
__u32 imn;
__u32 imx;
int flow = 0;
- if (pkt_dev->cflows)
- flow = f_pick(pkt_dev);
+ cflows = READ_ONCE(pkt_dev->cflows);
+ if (cflows)
+ flow = f_pick(pkt_dev, cflows);
/* Deal with source MAC */
if (pkt_dev->src_mac_count > 1) {
@@ -2582,7 +2585,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
pkt_dev->cur_saddr = htonl(t);
}
- if (pkt_dev->cflows && f_seen(pkt_dev, flow)) {
+ if (cflows && f_seen(pkt_dev, flow)) {
pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr;
} else {
imn = ntohl(pkt_dev->daddr_min);
@@ -2611,7 +2614,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
pkt_dev->cur_daddr = htonl(t);
}
}
- if (pkt_dev->cflows) {
+ if (cflows) {
pkt_dev->flows[flow].flags |= F_INIT;
pkt_dev->flows[flow].cur_daddr =
pkt_dev->cur_daddr;