diff options
author | Eric Dumazet <edumazet@google.com> | 2023-03-16 04:10:11 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-03-17 11:52:05 +0300 |
commit | 164bddace2e03f6005e650cb88f101a66ebdc05a (patch) | |
tree | 862fb745ff1aa864b0f0b3f46d2b39f6c8bd1f48 /net/packet/af_packet.c | |
parent | 7438344660fa55b33b8234c1797c886eb73667a7 (diff) | |
download | linux-164bddace2e03f6005e650cb88f101a66ebdc05a.tar.xz |
net/packet: convert po->tp_loss to an atomic flag
tp_loss can be read locklessly.
Convert it to an atomic flag to avoid races.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 7800dc622ff3..119063c8a1c5 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2843,7 +2843,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) if (unlikely(tp_len < 0)) { tpacket_error: - if (po->tp_loss) { + if (packet_sock_flag(po, PACKET_SOCK_TP_LOSS)) { __packet_set_status(po, ph, TP_STATUS_AVAILABLE); packet_increment_head(&po->tx_ring); @@ -3886,7 +3886,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval, if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { ret = -EBUSY; } else { - po->tp_loss = !!val; + packet_sock_flag_set(po, PACKET_SOCK_TP_LOSS, val); ret = 0; } release_sock(sk); @@ -4095,7 +4095,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, val = po->tp_reserve; break; case PACKET_LOSS: - val = po->tp_loss; + val = packet_sock_flag(po, PACKET_SOCK_TP_LOSS); break; case PACKET_TIMESTAMP: val = READ_ONCE(po->tp_tstamp); |