Skip to content

Commit 17bfd8c

Browse files
keesdavem330
authored andcommitted
net: af_packet: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Cc: Mike Maloney <maloney@google.com> Cc: Jarno Rajahalme <jarno@ovn.org> Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dda436b commit 17bfd8c

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

net/packet/af_packet.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,8 @@ static void prb_retire_current_block(struct tpacket_kbdq_core *,
201201
static int prb_queue_frozen(struct tpacket_kbdq_core *);
202202
static void prb_open_block(struct tpacket_kbdq_core *,
203203
struct tpacket_block_desc *);
204-
static void prb_retire_rx_blk_timer_expired(unsigned long);
204+
static void prb_retire_rx_blk_timer_expired(struct timer_list *);
205205
static void _prb_refresh_rx_retire_blk_timer(struct tpacket_kbdq_core *);
206-
static void prb_init_blk_timer(struct packet_sock *,
207-
struct tpacket_kbdq_core *,
208-
void (*func) (unsigned long));
209206
static void prb_fill_rxhash(struct tpacket_kbdq_core *, struct tpacket3_hdr *);
210207
static void prb_clear_rxhash(struct tpacket_kbdq_core *,
211208
struct tpacket3_hdr *);
@@ -540,20 +537,14 @@ static void prb_shutdown_retire_blk_timer(struct packet_sock *po,
540537
prb_del_retire_blk_timer(pkc);
541538
}
542539

543-
static void prb_init_blk_timer(struct packet_sock *po,
544-
struct tpacket_kbdq_core *pkc,
545-
void (*func) (unsigned long))
546-
{
547-
setup_timer(&pkc->retire_blk_timer, func, (long)po);
548-
pkc->retire_blk_timer.expires = jiffies;
549-
}
550-
551540
static void prb_setup_retire_blk_timer(struct packet_sock *po)
552541
{
553542
struct tpacket_kbdq_core *pkc;
554543

555544
pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
556-
prb_init_blk_timer(po, pkc, prb_retire_rx_blk_timer_expired);
545+
timer_setup(&pkc->retire_blk_timer, prb_retire_rx_blk_timer_expired,
546+
0);
547+
pkc->retire_blk_timer.expires = jiffies;
557548
}
558549

559550
static int prb_calc_retire_blk_tmo(struct packet_sock *po,
@@ -671,9 +662,10 @@ static void _prb_refresh_rx_retire_blk_timer(struct tpacket_kbdq_core *pkc)
671662
* prb_calc_retire_blk_tmo() calculates the tmo.
672663
*
673664
*/
674-
static void prb_retire_rx_blk_timer_expired(unsigned long data)
665+
static void prb_retire_rx_blk_timer_expired(struct timer_list *t)
675666
{
676-
struct packet_sock *po = (struct packet_sock *)data;
667+
struct packet_sock *po =
668+
from_timer(po, t, rx_ring.prb_bdqc.retire_blk_timer);
677669
struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
678670
unsigned int frozen;
679671
struct tpacket_block_desc *pbd;

0 commit comments

Comments
 (0)