2016-12-25 19:11:34 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
|
|
|
Subject: net: replace GRO optimization patch with a new one that supports VLANs/bridges with different MAC addresses
|
2017-01-27 13:32:10 +00:00
|
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
2016-12-25 19:11:34 +00:00
|
|
|
---
|
|
|
|
include/linux/netdevice.h | 2 ++
|
|
|
|
include/linux/skbuff.h | 3 ++-
|
|
|
|
net/core/dev.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
net/ethernet/eth.c | 18 +++++++++++++++++-
|
|
|
|
4 files changed, 69 insertions(+), 2 deletions(-)
|
2017-01-27 13:32:10 +00:00
|
|
|
|
2016-12-25 19:11:34 +00:00
|
|
|
--- a/include/linux/netdevice.h
|
|
|
|
+++ b/include/linux/netdevice.h
|
2019-02-07 10:32:51 +00:00
|
|
|
@@ -1752,6 +1752,8 @@ struct net_device {
|
2016-12-25 19:11:34 +00:00
|
|
|
struct netdev_hw_addr_list mc;
|
|
|
|
struct netdev_hw_addr_list dev_addrs;
|
|
|
|
|
|
|
|
+ unsigned char local_addr_mask[MAX_ADDR_LEN];
|
|
|
|
+
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
|
|
struct kset *queues_kset;
|
|
|
|
#endif
|
|
|
|
--- a/include/linux/skbuff.h
|
|
|
|
+++ b/include/linux/skbuff.h
|
2018-10-18 09:58:32 +00:00
|
|
|
@@ -747,7 +747,8 @@ struct sk_buff {
|
2016-12-25 19:11:34 +00:00
|
|
|
#ifdef CONFIG_NET_SWITCHDEV
|
|
|
|
__u8 offload_fwd_mark:1;
|
|
|
|
#endif
|
|
|
|
- /* 2, 4 or 5 bit hole */
|
|
|
|
+ __u8 gro_skip:1;
|
|
|
|
+ /* 1, 3 or 4 bit hole */
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_SCHED
|
|
|
|
__u16 tc_index; /* traffic control index */
|
2017-01-27 13:32:10 +00:00
|
|
|
--- a/net/core/dev.c
|
|
|
|
+++ b/net/core/dev.c
|
2018-10-18 09:58:32 +00:00
|
|
|
@@ -4572,6 +4572,9 @@ static enum gro_result dev_gro_receive(s
|
2017-01-27 13:32:10 +00:00
|
|
|
enum gro_result ret;
|
|
|
|
int grow;
|
|
|
|
|
|
|
|
+ if (skb->gro_skip)
|
|
|
|
+ goto normal;
|
|
|
|
+
|
|
|
|
if (!(skb->dev->features & NETIF_F_GRO))
|
|
|
|
goto normal;
|
|
|
|
|
2018-12-06 09:48:21 +00:00
|
|
|
@@ -5864,6 +5867,48 @@ static void __netdev_adjacent_dev_unlink
|
2017-01-27 13:32:10 +00:00
|
|
|
&upper_dev->adj_list.lower);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void __netdev_addr_mask(unsigned char *mask, const unsigned char *addr,
|
|
|
|
+ struct net_device *dev)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < dev->addr_len; i++)
|
|
|
|
+ mask[i] |= addr[i] ^ dev->dev_addr[i];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void __netdev_upper_mask(unsigned char *mask, struct net_device *dev,
|
|
|
|
+ struct net_device *lower)
|
|
|
|
+{
|
|
|
|
+ struct net_device *cur;
|
|
|
|
+ struct list_head *iter;
|
|
|
|
+
|
|
|
|
+ netdev_for_each_upper_dev_rcu(dev, cur, iter) {
|
|
|
|
+ __netdev_addr_mask(mask, cur->dev_addr, lower);
|
|
|
|
+ __netdev_upper_mask(mask, cur, lower);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void __netdev_update_addr_mask(struct net_device *dev)
|
|
|
|
+{
|
|
|
|
+ unsigned char mask[MAX_ADDR_LEN];
|
|
|
|
+ struct net_device *cur;
|
|
|
|
+ struct list_head *iter;
|
|
|
|
+
|
|
|
|
+ memset(mask, 0, sizeof(mask));
|
|
|
|
+ __netdev_upper_mask(mask, dev, dev);
|
|
|
|
+ memcpy(dev->local_addr_mask, mask, dev->addr_len);
|
|
|
|
+
|
|
|
|
+ netdev_for_each_lower_dev(dev, cur, iter)
|
|
|
|
+ __netdev_update_addr_mask(cur);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void netdev_update_addr_mask(struct net_device *dev)
|
|
|
|
+{
|
|
|
|
+ rcu_read_lock();
|
|
|
|
+ __netdev_update_addr_mask(dev);
|
|
|
|
+ rcu_read_unlock();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int __netdev_upper_dev_link(struct net_device *dev,
|
|
|
|
struct net_device *upper_dev, bool master,
|
|
|
|
void *upper_priv, void *upper_info)
|
2018-12-06 09:48:21 +00:00
|
|
|
@@ -5936,6 +5981,7 @@ static int __netdev_upper_dev_link(struc
|
2018-02-24 11:47:59 +00:00
|
|
|
goto rollback_lower_mesh;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ netdev_update_addr_mask(dev);
|
|
|
|
ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
|
|
|
|
&changeupper_info.info);
|
|
|
|
ret = notifier_to_errno(ret);
|
2018-12-06 09:48:21 +00:00
|
|
|
@@ -6062,6 +6108,7 @@ void netdev_upper_dev_unlink(struct net_
|
2017-01-27 13:32:10 +00:00
|
|
|
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
|
|
|
|
__netdev_adjacent_dev_unlink(dev, i->dev, i->ref_nr);
|
|
|
|
|
|
|
|
+ netdev_update_addr_mask(dev);
|
|
|
|
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
|
|
|
|
&changeupper_info.info);
|
|
|
|
}
|
2018-12-06 09:48:21 +00:00
|
|
|
@@ -6664,6 +6711,7 @@ int dev_set_mac_address(struct net_devic
|
2017-01-27 13:32:10 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
dev->addr_assign_type = NET_ADDR_SET;
|
|
|
|
+ netdev_update_addr_mask(dev);
|
|
|
|
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
|
|
|
|
add_device_randomness(dev->dev_addr, dev->addr_len);
|
|
|
|
return 0;
|
|
|
|
--- a/net/ethernet/eth.c
|
|
|
|
+++ b/net/ethernet/eth.c
|
2017-08-17 08:51:05 +00:00
|
|
|
@@ -143,6 +143,18 @@ u32 eth_get_headlen(void *data, unsigned
|
2017-01-27 13:32:10 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(eth_get_headlen);
|
|
|
|
|
|
|
|
+static inline bool
|
|
|
|
+eth_check_local_mask(const void *addr1, const void *addr2, const void *mask)
|
|
|
|
+{
|
|
|
|
+ const u16 *a1 = addr1;
|
|
|
|
+ const u16 *a2 = addr2;
|
|
|
|
+ const u16 *m = mask;
|
|
|
|
+
|
|
|
|
+ return (((a1[0] ^ a2[0]) & ~m[0]) |
|
|
|
|
+ ((a1[1] ^ a2[1]) & ~m[1]) |
|
|
|
|
+ ((a1[2] ^ a2[2]) & ~m[2]));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* eth_type_trans - determine the packet's protocol ID.
|
|
|
|
* @skb: received socket data
|
2017-08-17 08:51:05 +00:00
|
|
|
@@ -171,8 +183,12 @@ __be16 eth_type_trans(struct sk_buff *sk
|
2017-01-27 13:32:10 +00:00
|
|
|
skb->pkt_type = PACKET_MULTICAST;
|
|
|
|
}
|
|
|
|
else if (unlikely(!ether_addr_equal_64bits(eth->h_dest,
|
|
|
|
- dev->dev_addr)))
|
|
|
|
+ dev->dev_addr))) {
|
|
|
|
skb->pkt_type = PACKET_OTHERHOST;
|
|
|
|
+ if (eth_check_local_mask(eth->h_dest, dev->dev_addr,
|
|
|
|
+ dev->local_addr_mask))
|
|
|
|
+ skb->gro_skip = 1;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some variants of DSA tagging don't have an ethertype field
|