[linux-yocto] [V2][PATCH 1/1] net: Rename skb->hash to skb->rxhash
Bruce Ashfield
bruce.ashfield at windriver.com
Fri Sep 12 12:16:31 PDT 2014
On 14-09-10 11:13 PM, zhe.he at windriver.com wrote:
> From: He Zhe <zhe.he at windriver.com>
>
> This is used to undo the previous commit "net: Rename skb->rxhash to skb->hash"
> which introduces unnecessary renamings for BPF. Build will fail if related
> drivers are enabled but do not get updated accordingly. Since the context has
> been changed by other commits in the BPF set, some fixes need to be done as
> follow.
merged.
Bruce
>
> - Renaming for net/core/filter.c has been removed by "net: filter:
> rework/optimize internal BPF interpreter's instruction set"
> Nothing to undo
>
> - Renaming for arch/x86/net/bpf_jit_comp.c has been removed by "net: filter:
> x86: internal BPF JIT"
> Nothing to undo
>
> - Some more references to "hash" in net/core/filter.c are introduced by "net:
> filter: make BPF conversion more readable"
> Rename hash to rxhash
>
> Signed-off-by: He Zhe <zhe.he at windriver.com>
> ---
> arch/arm/net/bpf_jit_32.c | 4 ++--
> arch/powerpc/net/bpf_jit_comp.c | 4 ++--
> arch/s390/net/bpf_jit_comp.c | 8 ++++----
> arch/sparc/net/bpf_jit_comp.c | 2 +-
> include/linux/skbuff.h | 28 ++++++++++++++--------------
> include/net/sock.h | 4 ++--
> include/trace/events/net.h | 12 ++++++------
> net/core/dev.c | 13 ++++++-------
> net/core/filter.c | 4 ++--
> net/core/flow_dissector.c | 10 +++++-----
> net/packet/af_packet.c | 3 ++-
> 11 files changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> index 6f879c3..e72ff51 100644
> --- a/arch/arm/net/bpf_jit_32.c
> +++ b/arch/arm/net/bpf_jit_32.c
> @@ -825,8 +825,8 @@ b_epilogue:
> break;
> case BPF_S_ANC_RXHASH:
> ctx->seen |= SEEN_SKB;
> - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
> - off = offsetof(struct sk_buff, hash);
> + BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
> + off = offsetof(struct sk_buff, rxhash);
> emit(ARM_LDR_I(r_A, r_skb, off), ctx);
> break;
> case BPF_S_ANC_VLAN_TAG:
> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index 808ce1c..c0c5fcb 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -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, hash) != 4);
> + BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
> PPC_LWZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
> - hash));
> + rxhash));
> break;
> case BPF_S_ANC_VLAN_TAG:
> case BPF_S_ANC_VLAN_TAG_PRESENT:
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index e9f8fa9..44f224b 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -736,10 +736,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->hash */
> - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
> - /* l %r5,<d(hash)>(%r2) */
> - EMIT4_DISP(0x58502000, offsetof(struct sk_buff, hash));
> + 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));
> break;
> case BPF_S_ANC_VLAN_TAG:
> case BPF_S_ANC_VLAN_TAG_PRESENT:
> diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
> index 49cee4a..b85e223 100644
> --- a/arch/sparc/net/bpf_jit_comp.c
> +++ b/arch/sparc/net/bpf_jit_comp.c
> @@ -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(hash, r_A);
> + emit_skb_load32(rxhash, r_A);
> break;
> case BPF_S_ANC_VLAN_TAG:
> case BPF_S_ANC_VLAN_TAG_PRESENT:
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 69d3749..15ede6a 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -392,11 +392,11 @@ typedef unsigned char *sk_buff_data_t;
> * @skb_iif: ifindex of device we arrived on
> * @tc_index: Traffic control index
> * @tc_verd: traffic control verdict
> - * @hash: the packet hash
> + * @rxhash: the packet hash computed on receive
> * @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_hash: indicate hash is a canonical 4-tuple hash over transport
> + * @l4_rxhash: indicate rxhash 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
> @@ -482,7 +482,7 @@ struct sk_buff {
>
> int skb_iif;
>
> - __u32 hash;
> + __u32 rxhash;
>
> __be16 vlan_proto;
> __u16 vlan_tci;
> @@ -501,7 +501,7 @@ struct sk_buff {
> #endif
> __u8 pfmemalloc:1;
> __u8 ooo_okay:1;
> - __u8 l4_hash:1;
> + __u8 l4_rxhash:1;
> __u8 wifi_acked_valid:1;
> __u8 wifi_acked:1;
> __u8 no_fcs:1;
> @@ -758,40 +758,40 @@ enum pkt_hash_types {
> static inline void
> skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
> {
> - skb->l4_hash = (type == PKT_HASH_TYPE_L4);
> - skb->hash = hash;
> + skb->l4_rxhash = (type == PKT_HASH_TYPE_L4);
> + skb->rxhash = hash;
> }
>
> void __skb_get_hash(struct sk_buff *skb);
> static inline __u32 skb_get_hash(struct sk_buff *skb)
> {
> - if (!skb->l4_hash)
> + if (!skb->l4_rxhash)
> __skb_get_hash(skb);
>
> - return skb->hash;
> + return skb->rxhash;
> }
>
> static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
> {
> - return skb->hash;
> + return skb->rxhash;
> }
>
> static inline void skb_clear_hash(struct sk_buff *skb)
> {
> - skb->hash = 0;
> - skb->l4_hash = 0;
> + skb->rxhash = 0;
> + skb->l4_rxhash = 0;
> }
>
> static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
> {
> - if (!skb->l4_hash)
> + if (!skb->l4_rxhash)
> skb_clear_hash(skb);
> }
>
> static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
> {
> - to->hash = from->hash;
> - to->l4_hash = from->l4_hash;
> + to->rxhash = from->rxhash;
> + to->l4_rxhash = from->l4_rxhash;
> };
>
> #ifdef NET_SKBUFF_DATA_USES_OFFSET
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 547e4e5..e2a51ab 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -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->hash)) {
> + if (unlikely(sk->sk_rxhash != skb->rxhash)) {
> sock_rps_reset_flow(sk);
> - sk->sk_rxhash = skb->hash;
> + sk->sk_rxhash = skb->rxhash;
> }
> #endif
> }
> diff --git a/include/trace/events/net.h b/include/trace/events/net.h
> index 1de256b..a34f27b 100644
> --- a/include/trace/events/net.h
> +++ b/include/trace/events/net.h
> @@ -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, hash )
> - __field( bool, l4_hash )
> + __field( u32, rxhash )
> + __field( bool, l4_rxhash )
> __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->hash = skb->hash;
> - __entry->l4_hash = skb->l4_hash;
> + __entry->rxhash = skb->rxhash;
> + __entry->l4_rxhash = skb->l4_rxhash;
> __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 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",
> + 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",
> __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->hash, __entry->l4_hash, __entry->len,
> + __entry->rxhash, __entry->l4_rxhash, __entry->len,
> __entry->data_len, __entry->truesize,
> __entry->mac_header_valid, __entry->mac_header,
> __entry->nr_frags, __entry->gso_size, __entry->gso_type)
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 20247e5..37bddf7 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2964,7 +2964,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_get_hash(skb) & flow_table->mask;
> + flow_id = skb->rxhash & flow_table->mask;
> rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
> rxq_index, flow_id);
> if (rc < 0)
> @@ -2998,7 +2998,6 @@ 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);
> @@ -3027,8 +3026,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
> }
>
> skb_reset_network_header(skb);
> - hash = skb_get_hash(skb);
> - if (!hash)
> + if (!skb_get_hash(skb))
> goto done;
>
> flow_table = rcu_dereference(rxqueue->rps_flow_table);
> @@ -3037,10 +3035,11 @@ 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[hash & flow_table->mask];
> + rflow = &flow_table->flows[skb->rxhash & flow_table->mask];
> tcpu = rflow->cpu;
>
> - next_cpu = sock_flow_table->ents[hash & sock_flow_table->mask];
> + next_cpu = sock_flow_table->ents[skb->rxhash &
> + sock_flow_table->mask];
>
> /*
> * If the desired CPU (where last recvmsg was done) is
> @@ -3069,7 +3068,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
> }
>
> if (map) {
> - tcpu = map->cpus[((u64) hash * map->len) >> 32];
> + tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
>
> if (cpu_online(tcpu)) {
> cpu = tcpu;
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 32c5b44..ac88686 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -729,10 +729,10 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
> break;
>
> case SKF_AD_OFF + SKF_AD_RXHASH:
> - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
> + BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
>
> *insn = BPF_LDX_MEM(BPF_W, BPF_REG_A, BPF_REG_CTX,
> - offsetof(struct sk_buff, hash));
> + offsetof(struct sk_buff, rxhash));
> break;
>
> case SKF_AD_OFF + SKF_AD_QUEUE:
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 8808dcd..e29e810 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -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 hash in skb to non-zero hash value
> - * on success, zero indicates no valid hash. Also, sets l4_hash in skb
> + * 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
> * 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_hash = 1;
> + skb->l4_rxhash = 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->hash = hash;
> + skb->rxhash = 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->hash;
> + skb->rxhash;
> hash = __flow_hash_1word(hash);
> queue_index = map->queues[
> ((u64)hash * map->len) >> 32];
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 3a1521f..48a6a93 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -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_get_hash(skb), num);
> + return reciprocal_scale(skb->rxhash, num);
> }
>
> static unsigned int fanout_demux_lb(struct packet_fanout *f,
> @@ -1362,6 +1362,7 @@ 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:
>
More information about the linux-yocto
mailing list