Skip to content

Commit bdef7de

Browse files
committed
net: Add priority to packet_offload objects.
When we scan a packet for GRO processing, we want to see the most common packet types in the front of the offload_base list. So add a priority field so we can handle this properly. IPv4/IPv6 get the highest priority with the implicit zero priority field. Next comes ethernet with a priority of 10, and then we have the MPLS types with a priority of 15. Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Suggested-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 493be55 commit bdef7de

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,7 @@ struct offload_callbacks {
19971997

19981998
struct packet_offload {
19991999
__be16 type; /* This is really htons(ether_type). */
2000+
u16 priority;
20002001
struct offload_callbacks callbacks;
20012002
struct list_head list;
20022003
};

net/core/dev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,14 @@ EXPORT_SYMBOL(dev_remove_pack);
469469
*/
470470
void dev_add_offload(struct packet_offload *po)
471471
{
472-
struct list_head *head = &offload_base;
472+
struct packet_offload *elem;
473473

474474
spin_lock(&offload_lock);
475-
list_add_rcu(&po->list, head);
475+
list_for_each_entry(elem, &offload_base, list) {
476+
if (po->priority < elem->priority)
477+
break;
478+
}
479+
list_add_rcu(&po->list, elem->list.prev);
476480
spin_unlock(&offload_lock);
477481
}
478482
EXPORT_SYMBOL(dev_add_offload);

net/ethernet/eth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ EXPORT_SYMBOL(eth_gro_complete);
470470

471471
static struct packet_offload eth_packet_offload __read_mostly = {
472472
.type = cpu_to_be16(ETH_P_TEB),
473+
.priority = 10,
473474
.callbacks = {
474475
.gro_receive = eth_gro_receive,
475476
.gro_complete = eth_gro_complete,

net/mpls/mpls_gso.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
6262

6363
static struct packet_offload mpls_mc_offload __read_mostly = {
6464
.type = cpu_to_be16(ETH_P_MPLS_MC),
65+
.priority = 15,
6566
.callbacks = {
6667
.gso_segment = mpls_gso_segment,
6768
},
6869
};
6970

7071
static struct packet_offload mpls_uc_offload __read_mostly = {
7172
.type = cpu_to_be16(ETH_P_MPLS_UC),
73+
.priority = 15,
7274
.callbacks = {
7375
.gso_segment = mpls_gso_segment,
7476
},

0 commit comments

Comments
 (0)