Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vlan: introduce vlan_dev_free_egress_priority

This patch is to introduce vlan_dev_free_egress_priority() to
free egress priority for vlan dev, and keep vlan_dev_uninit()
static as .ndo_uninit. It makes the code more clear and safer
when adding new code in vlan_dev_uninit() in the future.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
37aa50c5 feef318c

+11 -5
+1 -1
net/8021q/vlan.h
··· 129 129 u32 skb_prio, u16 vlan_prio); 130 130 int vlan_dev_set_egress_priority(const struct net_device *dev, 131 131 u32 skb_prio, u16 vlan_prio); 132 + void vlan_dev_free_egress_priority(const struct net_device *dev); 132 133 int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask); 133 134 void vlan_dev_get_realdev_name(const struct net_device *dev, char *result, 134 135 size_t size); ··· 140 139 void vlan_setup(struct net_device *dev); 141 140 int register_vlan_dev(struct net_device *dev, struct netlink_ext_ack *extack); 142 141 void unregister_vlan_dev(struct net_device *dev, struct list_head *head); 143 - void vlan_dev_uninit(struct net_device *dev); 144 142 bool vlan_dev_inherit_address(struct net_device *dev, 145 143 struct net_device *real_dev); 146 144
+6 -1
net/8021q/vlan_dev.c
··· 622 622 } 623 623 624 624 /* Note: this function might be called multiple times for the same device. */ 625 - void vlan_dev_uninit(struct net_device *dev) 625 + void vlan_dev_free_egress_priority(const struct net_device *dev) 626 626 { 627 627 struct vlan_priority_tci_mapping *pm; 628 628 struct vlan_dev_priv *vlan = vlan_dev_priv(dev); ··· 634 634 kfree(pm); 635 635 } 636 636 } 637 + } 638 + 639 + static void vlan_dev_uninit(struct net_device *dev) 640 + { 641 + vlan_dev_free_egress_priority(dev); 637 642 } 638 643 639 644 static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
+4 -3
net/8021q/vlan_netlink.c
··· 183 183 return -EINVAL; 184 184 185 185 err = vlan_changelink(dev, tb, data, extack); 186 - if (!err) 187 - err = register_vlan_dev(dev, extack); 188 186 if (err) 189 - vlan_dev_uninit(dev); 187 + return err; 188 + err = register_vlan_dev(dev, extack); 189 + if (err) 190 + vlan_dev_free_egress_priority(dev); 190 191 return err; 191 192 } 192 193