net: Rename skb->rxhash to skb->hash
authorTom Herbert <therbert@google.com>
Mon, 24 Mar 2014 22:34:47 +0000 (15:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Mar 2014 19:58:20 +0000 (15:58 -0400)
The packet hash can be considered a property of the packet, not just
on RX path.

This patch changes name of rxhash and l4_rxhash skbuff fields to be
hash and l4_hash respectively. This includes changing uses of the
field in the code which don't call the access functions.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
arch/arm/net/bpf_jit_32.c
arch/powerpc/net/bpf_jit_comp.c
arch/s390/net/bpf_jit_comp.c
arch/sparc/net/bpf_jit_comp.c
arch/x86/net/bpf_jit_comp.c
include/linux/skbuff.h
include/net/sock.h
include/trace/events/net.h
net/core/dev.c
net/core/filter.c
net/core/flow_dissector.c
net/packet/af_packet.c

index 271b5e9715682ab40869a1ea8a02c9696eaebf07..7ddb9c83cdfc6c13c8d12848d6737a42f727f40b 100644 (file)
@@ -825,8 +825,8 @@ b_epilogue:
                        break;
                case BPF_S_ANC_RXHASH:
                        ctx->seen |= SEEN_SKB;
-                       BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
-                       off = offsetof(struct sk_buff, rxhash);
+                       BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
+                       off = offsetof(struct sk_buff, hash);
                        emit(ARM_LDR_I(r_A, r_skb, off), ctx);
                        break;
                case BPF_S_ANC_VLAN_TAG:
index 555034f8505e8d1d83bfeef3480a9bc058499754..4afad6c17d501be6e47e1399edc8cc9baea18ea1 100644 (file)
@@ -390,9 +390,9 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
                                                          mark));
                        break;
                case BPF_S_ANC_RXHASH:
-                       BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
+                       BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
                        PPC_LWZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
-                                                         rxhash));
+                                                         hash));
                        break;
                case BPF_S_ANC_VLAN_TAG:
                case BPF_S_ANC_VLAN_TAG_PRESENT:
index 708d60e4006676486b3892195b165ede007d2544..153f8f2cfd561cadca4c8bc1104424cbd12129d8 100644 (file)
@@ -737,10 +737,10 @@ call_fn:  /* lg %r1,<d(function)>(%r13) */
                /* icm  %r5,3,<d(type)>(%r1) */
                EMIT4_DISP(0xbf531000, offsetof(struct net_device, type));
                break;
-       case BPF_S_ANC_RXHASH: /* A = skb->rxhash */
-               BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
-               /* l %r5,<d(rxhash)>(%r2) */
-               EMIT4_DISP(0x58502000, offsetof(struct sk_buff, rxhash));
+       case BPF_S_ANC_RXHASH: /* A = skb->hash */
+               BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
+               /* l %r5,<d(hash)>(%r2) */
+               EMIT4_DISP(0x58502000, offsetof(struct sk_buff, hash));
                break;
        case BPF_S_ANC_VLAN_TAG:
        case BPF_S_ANC_VLAN_TAG_PRESENT:
index 01fe9946d388de469e140532b3f973f8a6db28fb..d96d2a7c78eef85f3406f7450f065d93cc67024b 100644 (file)
@@ -618,7 +618,7 @@ void bpf_jit_compile(struct sk_filter *fp)
                                emit_load16(r_A, struct net_device, type, r_A);
                                break;
                        case BPF_S_ANC_RXHASH:
-                               emit_skb_load32(rxhash, r_A);
+                               emit_skb_load32(hash, r_A);
                                break;
                        case BPF_S_ANC_VLAN_TAG:
                        case BPF_S_ANC_VLAN_TAG_PRESENT:
index 4ed75dd81d052ff96cc832702d174ad4d63bffec..293c57b74edcc3401067ee1f29e07bf3cdafad6e 100644 (file)
@@ -553,13 +553,13 @@ void bpf_jit_compile(struct sk_filter *fp)
                                }
                                break;
                        case BPF_S_ANC_RXHASH:
-                               BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
-                               if (is_imm8(offsetof(struct sk_buff, rxhash))) {
+                               BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
+                               if (is_imm8(offsetof(struct sk_buff, hash))) {
                                        /* mov off8(%rdi),%eax */
-                                       EMIT3(0x8b, 0x47, offsetof(struct sk_buff, rxhash));
+                                       EMIT3(0x8b, 0x47, offsetof(struct sk_buff, hash));
                                } else {
                                        EMIT2(0x8b, 0x87);
-                                       EMIT(offsetof(struct sk_buff, rxhash), 4);
+                                       EMIT(offsetof(struct sk_buff, hash), 4);
                                }
                                break;
                        case BPF_S_ANC_QUEUE:
index 03db95ab8a8cdeea706b37ce2654442230952388..aa2c22cb8158b98ea8bc45a00393782a477bd790 100644 (file)
@@ -444,11 +444,11 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
  *     @skb_iif: ifindex of device we arrived on
  *     @tc_index: Traffic control index
  *     @tc_verd: traffic control verdict
- *     @rxhash: the packet hash computed on receive
+ *     @hash: the packet hash
  *     @queue_mapping: Queue mapping for multiqueue devices
  *     @ndisc_nodetype: router type (from link layer)
  *     @ooo_okay: allow the mapping of a socket to a queue to be changed
- *     @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport
+ *     @l4_hash: indicate hash is a canonical 4-tuple hash over transport
  *             ports.
  *     @wifi_acked_valid: wifi_acked was set
  *     @wifi_acked: whether frame was acked on wifi or not
@@ -537,7 +537,7 @@ struct sk_buff {
 
        int                     skb_iif;
 
-       __u32                   rxhash;
+       __u32                   hash;
 
        __be16                  vlan_proto;
        __u16                   vlan_tci;
@@ -556,7 +556,7 @@ struct sk_buff {
 #endif
        __u8                    pfmemalloc:1;
        __u8                    ooo_okay:1;
-       __u8                    l4_rxhash:1;
+       __u8                    l4_hash:1;
        __u8                    wifi_acked_valid:1;
        __u8                    wifi_acked:1;
        __u8                    no_fcs:1;
@@ -815,40 +815,40 @@ enum pkt_hash_types {
 static inline void
 skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
 {
-       skb->l4_rxhash = (type == PKT_HASH_TYPE_L4);
-       skb->rxhash = hash;
+       skb->l4_hash = (type == PKT_HASH_TYPE_L4);
+       skb->hash = hash;
 }
 
 void __skb_get_hash(struct sk_buff *skb);
 static inline __u32 skb_get_hash(struct sk_buff *skb)
 {
-       if (!skb->l4_rxhash)
+       if (!skb->l4_hash)
                __skb_get_hash(skb);
 
-       return skb->rxhash;
+       return skb->hash;
 }
 
 static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
 {
-       return skb->rxhash;
+       return skb->hash;
 }
 
 static inline void skb_clear_hash(struct sk_buff *skb)
 {
-       skb->rxhash = 0;
-       skb->l4_rxhash = 0;
+       skb->hash = 0;
+       skb->l4_hash = 0;
 }
 
 static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
 {
-       if (!skb->l4_rxhash)
+       if (!skb->l4_hash)
                skb_clear_hash(skb);
 }
 
 static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
 {
-       to->rxhash = from->rxhash;
-       to->l4_rxhash = from->l4_rxhash;
+       to->hash = from->hash;
+       to->l4_hash = from->l4_hash;
 };
 
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
index 625e65b12366dd9503cd504cb699b2b8fb883a79..8d7c431a06602e53ede4ceeaa7e34b82c1bf8d48 100644 (file)
@@ -862,9 +862,9 @@ static inline void sock_rps_save_rxhash(struct sock *sk,
                                        const struct sk_buff *skb)
 {
 #ifdef CONFIG_RPS
-       if (unlikely(sk->sk_rxhash != skb->rxhash)) {
+       if (unlikely(sk->sk_rxhash != skb->hash)) {
                sock_rps_reset_flow(sk);
-               sk->sk_rxhash = skb->rxhash;
+               sk->sk_rxhash = skb->hash;
        }
 #endif
 }
index a34f27b2e394ef1ebdb7148b69ac573df85b6502..1de256b358074b6b3486e4e1b4686f9ecace6320 100644 (file)
@@ -153,8 +153,8 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
                __field(        u16,                    vlan_tci        )
                __field(        u16,                    protocol        )
                __field(        u8,                     ip_summed       )
-               __field(        u32,                    rxhash          )
-               __field(        bool,                   l4_rxhash       )
+               __field(        u32,                    hash            )
+               __field(        bool,                   l4_hash         )
                __field(        unsigned int,           len             )
                __field(        unsigned int,           data_len        )
                __field(        unsigned int,           truesize        )
@@ -179,8 +179,8 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
                __entry->vlan_tci = vlan_tx_tag_get(skb);
                __entry->protocol = ntohs(skb->protocol);
                __entry->ip_summed = skb->ip_summed;
-               __entry->rxhash = skb->rxhash;
-               __entry->l4_rxhash = skb->l4_rxhash;
+               __entry->hash = skb->hash;
+               __entry->l4_hash = skb->l4_hash;
                __entry->len = skb->len;
                __entry->data_len = skb->data_len;
                __entry->truesize = skb->truesize;
@@ -191,11 +191,11 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
                __entry->gso_type = skb_shinfo(skb)->gso_type;
        ),
 
-       TP_printk("dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d rxhash=0x%08x l4_rxhash=%d len=%u data_len=%u truesize=%u mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x",
+       TP_printk("dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x",
                  __get_str(name), __entry->napi_id, __entry->queue_mapping,
                  __entry->skbaddr, __entry->vlan_tagged, __entry->vlan_proto,
                  __entry->vlan_tci, __entry->protocol, __entry->ip_summed,
-                 __entry->rxhash, __entry->l4_rxhash, __entry->len,
+                 __entry->hash, __entry->l4_hash, __entry->len,
                  __entry->data_len, __entry->truesize,
                  __entry->mac_header_valid, __entry->mac_header,
                  __entry->nr_frags, __entry->gso_size, __entry->gso_type)
index 55f8e64c03a2cb8aa5364addc2ac7908f754f20a..48dd323d59183a9904e35fdcd31b39981b626495 100644 (file)
@@ -2952,7 +2952,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
                flow_table = rcu_dereference(rxqueue->rps_flow_table);
                if (!flow_table)
                        goto out;
-               flow_id = skb->rxhash & flow_table->mask;
+               flow_id = skb_get_hash(skb) & flow_table->mask;
                rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
                                                        rxq_index, flow_id);
                if (rc < 0)
@@ -2986,6 +2986,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
        struct rps_sock_flow_table *sock_flow_table;
        int cpu = -1;
        u16 tcpu;
+       u32 hash;
 
        if (skb_rx_queue_recorded(skb)) {
                u16 index = skb_get_rx_queue(skb);
@@ -3014,7 +3015,8 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
        }
 
        skb_reset_network_header(skb);
-       if (!skb_get_hash(skb))
+       hash = skb_get_hash(skb);
+       if (!hash)
                goto done;
 
        flow_table = rcu_dereference(rxqueue->rps_flow_table);
@@ -3023,11 +3025,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
                u16 next_cpu;
                struct rps_dev_flow *rflow;
 
-               rflow = &flow_table->flows[skb->rxhash & flow_table->mask];
+               rflow = &flow_table->flows[hash & flow_table->mask];
                tcpu = rflow->cpu;
 
-               next_cpu = sock_flow_table->ents[skb->rxhash &
-                   sock_flow_table->mask];
+               next_cpu = sock_flow_table->ents[hash & sock_flow_table->mask];
 
                /*
                 * If the desired CPU (where last recvmsg was done) is
@@ -3056,7 +3057,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
        }
 
        if (map) {
-               tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
+               tcpu = map->cpus[((u64) hash * map->len) >> 32];
 
                if (cpu_online(tcpu)) {
                        cpu = tcpu;
index ad30d626a5bd3f5cbd585d0641ab79aa29c3c446..65b75966e206acd95b280dff282aa882542c1250 100644 (file)
@@ -336,7 +336,7 @@ load_b:
                        A = skb->dev->type;
                        continue;
                case BPF_S_ANC_RXHASH:
-                       A = skb->rxhash;
+                       A = skb->hash;
                        continue;
                case BPF_S_ANC_CPU:
                        A = raw_smp_processor_id();
index 80201bf69d598c05bc2f454fdca5a2a149cee292..107ed12a5323ab20e796042ae671e7b60ac0b488 100644 (file)
@@ -203,8 +203,8 @@ static __always_inline u32 __flow_hash_1word(u32 a)
 
 /*
  * __skb_get_hash: calculate a flow hash based on src/dst addresses
- * and src/dst port numbers.  Sets rxhash in skb to non-zero hash value
- * on success, zero indicates no valid hash.  Also, sets l4_rxhash in skb
+ * and src/dst port numbers.  Sets hash in skb to non-zero hash value
+ * on success, zero indicates no valid hash.  Also, sets l4_hash in skb
  * if hash is a canonical 4-tuple hash over transport ports.
  */
 void __skb_get_hash(struct sk_buff *skb)
@@ -216,7 +216,7 @@ void __skb_get_hash(struct sk_buff *skb)
                return;
 
        if (keys.ports)
-               skb->l4_rxhash = 1;
+               skb->l4_hash = 1;
 
        /* get a consistent hash (same value on both flow directions) */
        if (((__force u32)keys.dst < (__force u32)keys.src) ||
@@ -232,7 +232,7 @@ void __skb_get_hash(struct sk_buff *skb)
        if (!hash)
                hash = 1;
 
-       skb->rxhash = hash;
+       skb->hash = hash;
 }
 EXPORT_SYMBOL(__skb_get_hash);
 
@@ -344,7 +344,7 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
                                        hash = skb->sk->sk_hash;
                                else
                                        hash = (__force u16) skb->protocol ^
-                                           skb->rxhash;
+                                           skb->hash;
                                hash = __flow_hash_1word(hash);
                                queue_index = map->queues[
                                    ((u64)hash * map->len) >> 32];
index 292304404fda1696f6cc8c4165a6ff183255fc80..097a354ec8cd98cd64d828f2e50c2d91546a4e6e 100644 (file)
@@ -1277,7 +1277,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
                                      struct sk_buff *skb,
                                      unsigned int num)
 {
-       return reciprocal_scale(skb->rxhash, num);
+       return reciprocal_scale(skb_get_hash(skb), num);
 }
 
 static unsigned int fanout_demux_lb(struct packet_fanout *f,
@@ -1362,7 +1362,6 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
                        if (!skb)
                                return 0;
                }
-               skb_get_hash(skb);
                idx = fanout_demux_hash(f, skb, num);
                break;
        case PACKET_FANOUT_LB: