Skip to content

Commit 61b905d

Browse files
Tom Herbertdavem330
authored andcommitted
net: Rename skb->rxhash to skb->hash
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 <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Mahesh Bandewar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e2e865 commit 61b905d

File tree

12 files changed

+49
-49
lines changed

12 files changed

+49
-49
lines changed

arch/arm/net/bpf_jit_32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ static int build_body(struct jit_ctx *ctx)
825825
break;
826826
case BPF_S_ANC_RXHASH:
827827
ctx->seen |= SEEN_SKB;
828-
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
829-
off = offsetof(struct sk_buff, rxhash);
828+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
829+
off = offsetof(struct sk_buff, hash);
830830
emit(ARM_LDR_I(r_A, r_skb, off), ctx);
831831
break;
832832
case BPF_S_ANC_VLAN_TAG:

arch/powerpc/net/bpf_jit_comp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
390390
mark));
391391
break;
392392
case BPF_S_ANC_RXHASH:
393-
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
393+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
394394
PPC_LWZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
395-
rxhash));
395+
hash));
396396
break;
397397
case BPF_S_ANC_VLAN_TAG:
398398
case BPF_S_ANC_VLAN_TAG_PRESENT:

arch/s390/net/bpf_jit_comp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,10 +737,10 @@ load_abs: if ((int) K < 0)
737737
/* icm %r5,3,<d(type)>(%r1) */
738738
EMIT4_DISP(0xbf531000, offsetof(struct net_device, type));
739739
break;
740-
case BPF_S_ANC_RXHASH: /* A = skb->rxhash */
741-
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
742-
/* l %r5,<d(rxhash)>(%r2) */
743-
EMIT4_DISP(0x58502000, offsetof(struct sk_buff, rxhash));
740+
case BPF_S_ANC_RXHASH: /* A = skb->hash */
741+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
742+
/* l %r5,<d(hash)>(%r2) */
743+
EMIT4_DISP(0x58502000, offsetof(struct sk_buff, hash));
744744
break;
745745
case BPF_S_ANC_VLAN_TAG:
746746
case BPF_S_ANC_VLAN_TAG_PRESENT:

arch/sparc/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ void bpf_jit_compile(struct sk_filter *fp)
618618
emit_load16(r_A, struct net_device, type, r_A);
619619
break;
620620
case BPF_S_ANC_RXHASH:
621-
emit_skb_load32(rxhash, r_A);
621+
emit_skb_load32(hash, r_A);
622622
break;
623623
case BPF_S_ANC_VLAN_TAG:
624624
case BPF_S_ANC_VLAN_TAG_PRESENT:

arch/x86/net/bpf_jit_comp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ void bpf_jit_compile(struct sk_filter *fp)
553553
}
554554
break;
555555
case BPF_S_ANC_RXHASH:
556-
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
557-
if (is_imm8(offsetof(struct sk_buff, rxhash))) {
556+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
557+
if (is_imm8(offsetof(struct sk_buff, hash))) {
558558
/* mov off8(%rdi),%eax */
559-
EMIT3(0x8b, 0x47, offsetof(struct sk_buff, rxhash));
559+
EMIT3(0x8b, 0x47, offsetof(struct sk_buff, hash));
560560
} else {
561561
EMIT2(0x8b, 0x87);
562-
EMIT(offsetof(struct sk_buff, rxhash), 4);
562+
EMIT(offsetof(struct sk_buff, hash), 4);
563563
}
564564
break;
565565
case BPF_S_ANC_QUEUE:

include/linux/skbuff.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
444444
* @skb_iif: ifindex of device we arrived on
445445
* @tc_index: Traffic control index
446446
* @tc_verd: traffic control verdict
447-
* @rxhash: the packet hash computed on receive
447+
* @hash: the packet hash
448448
* @queue_mapping: Queue mapping for multiqueue devices
449449
* @ndisc_nodetype: router type (from link layer)
450450
* @ooo_okay: allow the mapping of a socket to a queue to be changed
451-
* @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport
451+
* @l4_hash: indicate hash is a canonical 4-tuple hash over transport
452452
* ports.
453453
* @wifi_acked_valid: wifi_acked was set
454454
* @wifi_acked: whether frame was acked on wifi or not
@@ -537,7 +537,7 @@ struct sk_buff {
537537

538538
int skb_iif;
539539

540-
__u32 rxhash;
540+
__u32 hash;
541541

542542
__be16 vlan_proto;
543543
__u16 vlan_tci;
@@ -556,7 +556,7 @@ struct sk_buff {
556556
#endif
557557
__u8 pfmemalloc:1;
558558
__u8 ooo_okay:1;
559-
__u8 l4_rxhash:1;
559+
__u8 l4_hash:1;
560560
__u8 wifi_acked_valid:1;
561561
__u8 wifi_acked:1;
562562
__u8 no_fcs:1;
@@ -815,40 +815,40 @@ enum pkt_hash_types {
815815
static inline void
816816
skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
817817
{
818-
skb->l4_rxhash = (type == PKT_HASH_TYPE_L4);
819-
skb->rxhash = hash;
818+
skb->l4_hash = (type == PKT_HASH_TYPE_L4);
819+
skb->hash = hash;
820820
}
821821

822822
void __skb_get_hash(struct sk_buff *skb);
823823
static inline __u32 skb_get_hash(struct sk_buff *skb)
824824
{
825-
if (!skb->l4_rxhash)
825+
if (!skb->l4_hash)
826826
__skb_get_hash(skb);
827827

828-
return skb->rxhash;
828+
return skb->hash;
829829
}
830830

831831
static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
832832
{
833-
return skb->rxhash;
833+
return skb->hash;
834834
}
835835

836836
static inline void skb_clear_hash(struct sk_buff *skb)
837837
{
838-
skb->rxhash = 0;
839-
skb->l4_rxhash = 0;
838+
skb->hash = 0;
839+
skb->l4_hash = 0;
840840
}
841841

842842
static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
843843
{
844-
if (!skb->l4_rxhash)
844+
if (!skb->l4_hash)
845845
skb_clear_hash(skb);
846846
}
847847

848848
static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
849849
{
850-
to->rxhash = from->rxhash;
851-
to->l4_rxhash = from->l4_rxhash;
850+
to->hash = from->hash;
851+
to->l4_hash = from->l4_hash;
852852
};
853853

854854
#ifdef NET_SKBUFF_DATA_USES_OFFSET

include/net/sock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,9 @@ static inline void sock_rps_save_rxhash(struct sock *sk,
862862
const struct sk_buff *skb)
863863
{
864864
#ifdef CONFIG_RPS
865-
if (unlikely(sk->sk_rxhash != skb->rxhash)) {
865+
if (unlikely(sk->sk_rxhash != skb->hash)) {
866866
sock_rps_reset_flow(sk);
867-
sk->sk_rxhash = skb->rxhash;
867+
sk->sk_rxhash = skb->hash;
868868
}
869869
#endif
870870
}

include/trace/events/net.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
153153
__field( u16, vlan_tci )
154154
__field( u16, protocol )
155155
__field( u8, ip_summed )
156-
__field( u32, rxhash )
157-
__field( bool, l4_rxhash )
156+
__field( u32, hash )
157+
__field( bool, l4_hash )
158158
__field( unsigned int, len )
159159
__field( unsigned int, data_len )
160160
__field( unsigned int, truesize )
@@ -179,8 +179,8 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
179179
__entry->vlan_tci = vlan_tx_tag_get(skb);
180180
__entry->protocol = ntohs(skb->protocol);
181181
__entry->ip_summed = skb->ip_summed;
182-
__entry->rxhash = skb->rxhash;
183-
__entry->l4_rxhash = skb->l4_rxhash;
182+
__entry->hash = skb->hash;
183+
__entry->l4_hash = skb->l4_hash;
184184
__entry->len = skb->len;
185185
__entry->data_len = skb->data_len;
186186
__entry->truesize = skb->truesize;
@@ -191,11 +191,11 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
191191
__entry->gso_type = skb_shinfo(skb)->gso_type;
192192
),
193193

194-
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",
194+
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",
195195
__get_str(name), __entry->napi_id, __entry->queue_mapping,
196196
__entry->skbaddr, __entry->vlan_tagged, __entry->vlan_proto,
197197
__entry->vlan_tci, __entry->protocol, __entry->ip_summed,
198-
__entry->rxhash, __entry->l4_rxhash, __entry->len,
198+
__entry->hash, __entry->l4_hash, __entry->len,
199199
__entry->data_len, __entry->truesize,
200200
__entry->mac_header_valid, __entry->mac_header,
201201
__entry->nr_frags, __entry->gso_size, __entry->gso_type)

net/core/dev.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
29522952
flow_table = rcu_dereference(rxqueue->rps_flow_table);
29532953
if (!flow_table)
29542954
goto out;
2955-
flow_id = skb->rxhash & flow_table->mask;
2955+
flow_id = skb_get_hash(skb) & flow_table->mask;
29562956
rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
29572957
rxq_index, flow_id);
29582958
if (rc < 0)
@@ -2986,6 +2986,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
29862986
struct rps_sock_flow_table *sock_flow_table;
29872987
int cpu = -1;
29882988
u16 tcpu;
2989+
u32 hash;
29892990

29902991
if (skb_rx_queue_recorded(skb)) {
29912992
u16 index = skb_get_rx_queue(skb);
@@ -3014,7 +3015,8 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
30143015
}
30153016

30163017
skb_reset_network_header(skb);
3017-
if (!skb_get_hash(skb))
3018+
hash = skb_get_hash(skb);
3019+
if (!hash)
30183020
goto done;
30193021

30203022
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,
30233025
u16 next_cpu;
30243026
struct rps_dev_flow *rflow;
30253027

3026-
rflow = &flow_table->flows[skb->rxhash & flow_table->mask];
3028+
rflow = &flow_table->flows[hash & flow_table->mask];
30273029
tcpu = rflow->cpu;
30283030

3029-
next_cpu = sock_flow_table->ents[skb->rxhash &
3030-
sock_flow_table->mask];
3031+
next_cpu = sock_flow_table->ents[hash & sock_flow_table->mask];
30313032

30323033
/*
30333034
* 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,
30563057
}
30573058

30583059
if (map) {
3059-
tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
3060+
tcpu = map->cpus[((u64) hash * map->len) >> 32];
30603061

30613062
if (cpu_online(tcpu)) {
30623063
cpu = tcpu;

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
336336
A = skb->dev->type;
337337
continue;
338338
case BPF_S_ANC_RXHASH:
339-
A = skb->rxhash;
339+
A = skb->hash;
340340
continue;
341341
case BPF_S_ANC_CPU:
342342
A = raw_smp_processor_id();

net/core/flow_dissector.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ static __always_inline u32 __flow_hash_1word(u32 a)
203203

204204
/*
205205
* __skb_get_hash: calculate a flow hash based on src/dst addresses
206-
* and src/dst port numbers. Sets rxhash in skb to non-zero hash value
207-
* on success, zero indicates no valid hash. Also, sets l4_rxhash in skb
206+
* and src/dst port numbers. Sets hash in skb to non-zero hash value
207+
* on success, zero indicates no valid hash. Also, sets l4_hash in skb
208208
* if hash is a canonical 4-tuple hash over transport ports.
209209
*/
210210
void __skb_get_hash(struct sk_buff *skb)
@@ -216,7 +216,7 @@ void __skb_get_hash(struct sk_buff *skb)
216216
return;
217217

218218
if (keys.ports)
219-
skb->l4_rxhash = 1;
219+
skb->l4_hash = 1;
220220

221221
/* get a consistent hash (same value on both flow directions) */
222222
if (((__force u32)keys.dst < (__force u32)keys.src) ||
@@ -232,7 +232,7 @@ void __skb_get_hash(struct sk_buff *skb)
232232
if (!hash)
233233
hash = 1;
234234

235-
skb->rxhash = hash;
235+
skb->hash = hash;
236236
}
237237
EXPORT_SYMBOL(__skb_get_hash);
238238

@@ -344,7 +344,7 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
344344
hash = skb->sk->sk_hash;
345345
else
346346
hash = (__force u16) skb->protocol ^
347-
skb->rxhash;
347+
skb->hash;
348348
hash = __flow_hash_1word(hash);
349349
queue_index = map->queues[
350350
((u64)hash * map->len) >> 32];

net/packet/af_packet.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
12771277
struct sk_buff *skb,
12781278
unsigned int num)
12791279
{
1280-
return reciprocal_scale(skb->rxhash, num);
1280+
return reciprocal_scale(skb_get_hash(skb), num);
12811281
}
12821282

12831283
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,
13621362
if (!skb)
13631363
return 0;
13641364
}
1365-
skb_get_hash(skb);
13661365
idx = fanout_demux_hash(f, skb, num);
13671366
break;
13681367
case PACKET_FANOUT_LB:

0 commit comments

Comments
 (0)