Commit 0c0667a8 authored by Wang Sheng-Hui's avatar Wang Sheng-Hui Committed by David S. Miller

vlan: cleanup the usage of vlan_dev_priv(dev)

This patch cleanup 2 points for the usage of vlan_dev_priv(dev):
* In vlan_dev.c/vlan_dev_hard_header, we should use the var *vlan directly
  after grabing the pointer at the beginning with
        *vlan = vlan_dev_priv(dev);
  when we need to access the fields of *vlan.
* In vlan.c/register_vlan_device, add the var *vlan pointer
        struct vlan_dev_priv *vlan;
to cleanup the code to access the fields of vlan_dev_priv(new_dev).
Signed-off-by: default avatarWang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e9402eb
...@@ -210,6 +210,7 @@ int register_vlan_dev(struct net_device *dev) ...@@ -210,6 +210,7 @@ int register_vlan_dev(struct net_device *dev)
static int register_vlan_device(struct net_device *real_dev, u16 vlan_id) static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
{ {
struct net_device *new_dev; struct net_device *new_dev;
struct vlan_dev_priv *vlan;
struct net *net = dev_net(real_dev); struct net *net = dev_net(real_dev);
struct vlan_net *vn = net_generic(net, vlan_net_id); struct vlan_net *vn = net_generic(net, vlan_net_id);
char name[IFNAMSIZ]; char name[IFNAMSIZ];
...@@ -260,11 +261,12 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id) ...@@ -260,11 +261,12 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
new_dev->mtu = real_dev->mtu; new_dev->mtu = real_dev->mtu;
new_dev->priv_flags |= (real_dev->priv_flags & IFF_UNICAST_FLT); new_dev->priv_flags |= (real_dev->priv_flags & IFF_UNICAST_FLT);
vlan_dev_priv(new_dev)->vlan_proto = htons(ETH_P_8021Q); vlan = vlan_dev_priv(new_dev);
vlan_dev_priv(new_dev)->vlan_id = vlan_id; vlan->vlan_proto = htons(ETH_P_8021Q);
vlan_dev_priv(new_dev)->real_dev = real_dev; vlan->vlan_id = vlan_id;
vlan_dev_priv(new_dev)->dent = NULL; vlan->real_dev = real_dev;
vlan_dev_priv(new_dev)->flags = VLAN_FLAG_REORDER_HDR; vlan->dent = NULL;
vlan->flags = VLAN_FLAG_REORDER_HDR;
new_dev->rtnl_link_ops = &vlan_link_ops; new_dev->rtnl_link_ops = &vlan_link_ops;
err = register_vlan_dev(new_dev); err = register_vlan_dev(new_dev);
......
...@@ -107,10 +107,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, ...@@ -107,10 +107,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
u16 vlan_tci = 0; u16 vlan_tci = 0;
int rc; int rc;
if (!(vlan_dev_priv(dev)->flags & VLAN_FLAG_REORDER_HDR)) { if (!(vlan->flags & VLAN_FLAG_REORDER_HDR)) {
vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN); vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
vlan_tci = vlan_dev_priv(dev)->vlan_id; vlan_tci = vlan->vlan_id;
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb); vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
vhdr->h_vlan_TCI = htons(vlan_tci); vhdr->h_vlan_TCI = htons(vlan_tci);
...@@ -133,7 +133,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, ...@@ -133,7 +133,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
saddr = dev->dev_addr; saddr = dev->dev_addr;
/* Now make the underlying real hard header */ /* Now make the underlying real hard header */
dev = vlan_dev_priv(dev)->real_dev; dev = vlan->real_dev;
rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen); rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
if (rc > 0) if (rc > 0)
rc += vhdrlen; rc += vhdrlen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment