mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 05:31:15 +00:00
vlan: Avoid hash table lookup to find group.
A struct net_device always maps to zero or one vlan groups and we always know the device when we are looking up a group. We currently do a hash table lookup on the device to find the group but it is much simpler to just store a pointer. Signed-off-by: Jesse Gross <jesse@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7b9c609037
commit
65ac6a5fa6
5 changed files with 34 additions and 73 deletions
|
@ -16,6 +16,7 @@
|
|||
#ifdef __KERNEL__
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header)
|
||||
* that VLAN requires.
|
||||
|
@ -114,6 +115,18 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
|
|||
#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
|
||||
|
||||
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
|
||||
/* Must be invoked with rcu_read_lock or with RTNL. */
|
||||
static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
|
||||
u16 vlan_id)
|
||||
{
|
||||
struct vlan_group *grp = rcu_dereference_rtnl(real_dev->vlgrp);
|
||||
|
||||
if (grp)
|
||||
return vlan_group_get_device(grp, vlan_id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
|
||||
extern u16 vlan_dev_vlan_id(const struct net_device *dev);
|
||||
|
||||
|
@ -128,6 +141,12 @@ vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
|
|||
unsigned int vlan_tci);
|
||||
|
||||
#else
|
||||
static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
|
||||
u16 vlan_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
|
||||
{
|
||||
BUG();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue