Merge tag 'tty-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[firefly-linux-kernel-4.4.55.git] / net / packet / af_packet.c
index 20e8c40da90d6454d5a0d326337dc7d5c849dfc2..c9e8741226c6d8785e89532aa09e029c3fd9e487 100644 (file)
@@ -543,15 +543,11 @@ static void prb_init_blk_timer(struct packet_sock *po,
        pkc->retire_blk_timer.expires = jiffies;
 }
 
-static void prb_setup_retire_blk_timer(struct packet_sock *po, int tx_ring)
+static void prb_setup_retire_blk_timer(struct packet_sock *po)
 {
        struct tpacket_kbdq_core *pkc;
 
-       if (tx_ring)
-               BUG();
-
-       pkc = tx_ring ? GET_PBDQC_FROM_RB(&po->tx_ring) :
-                       GET_PBDQC_FROM_RB(&po->rx_ring);
+       pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
        prb_init_blk_timer(po, pkc, prb_retire_rx_blk_timer_expired);
 }
 
@@ -607,7 +603,7 @@ static void prb_init_ft_ops(struct tpacket_kbdq_core *p1,
 static void init_prb_bdqc(struct packet_sock *po,
                        struct packet_ring_buffer *rb,
                        struct pgv *pg_vec,
-                       union tpacket_req_u *req_u, int tx_ring)
+                       union tpacket_req_u *req_u)
 {
        struct tpacket_kbdq_core *p1 = GET_PBDQC_FROM_RB(rb);
        struct tpacket_block_desc *pbd;
@@ -634,7 +630,7 @@ static void init_prb_bdqc(struct packet_sock *po,
 
        p1->max_frame_len = p1->kblk_size - BLK_PLUS_PRIV(p1->blk_sizeof_priv);
        prb_init_ft_ops(p1, req_u);
-       prb_setup_retire_blk_timer(po, tx_ring);
+       prb_setup_retire_blk_timer(po);
        prb_open_block(p1, pbd);
 }
 
@@ -1326,16 +1322,6 @@ static void packet_sock_destruct(struct sock *sk)
        sk_refcnt_debug_dec(sk);
 }
 
-static int fanout_rr_next(struct packet_fanout *f, unsigned int num)
-{
-       int x = atomic_read(&f->rr_cur) + 1;
-
-       if (x >= num)
-               x = 0;
-
-       return x;
-}
-
 static bool fanout_flow_is_huge(struct packet_sock *po, struct sk_buff *skb)
 {
        u32 rxhash;
@@ -1361,13 +1347,9 @@ static unsigned int fanout_demux_lb(struct packet_fanout *f,
                                    struct sk_buff *skb,
                                    unsigned int num)
 {
-       int cur, old;
+       unsigned int val = atomic_inc_return(&f->rr_cur);
 
-       cur = atomic_read(&f->rr_cur);
-       while ((old = atomic_cmpxchg(&f->rr_cur, cur,
-                                    fanout_rr_next(f, num))) != cur)
-               cur = old;
-       return cur;
+       return val % num;
 }
 
 static unsigned int fanout_demux_cpu(struct packet_fanout *f,
@@ -1439,7 +1421,7 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
                             struct packet_type *pt, struct net_device *orig_dev)
 {
        struct packet_fanout *f = pt->af_packet_priv;
-       unsigned int num = f->num_members;
+       unsigned int num = READ_ONCE(f->num_members);
        struct packet_sock *po;
        unsigned int idx;
 
@@ -4002,7 +3984,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
                 * it above but just being paranoid
                 */
                        if (!tx_ring)
-                               init_prb_bdqc(po, rb, pg_vec, req_u, tx_ring);
+                               init_prb_bdqc(po, rb, pg_vec, req_u);
                        break;
                default:
                        break;