diff options
-rw-r--r-- | drivers/net/macvlan.c | 24 | ||||
-rw-r--r-- | include/linux/netdevice.h | 3 | ||||
-rw-r--r-- | net/8021q/vlan.c | 29 | ||||
-rw-r--r-- | net/core/dev.c | 27 |
4 files changed, 37 insertions, 46 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 93c3e6edf702..21a9c9ab4b34 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -582,25 +582,6 @@ static void macvlan_port_destroy(struct net_device *dev) | |||
582 | kfree(port); | 582 | kfree(port); |
583 | } | 583 | } |
584 | 584 | ||
585 | static void macvlan_transfer_operstate(struct net_device *dev) | ||
586 | { | ||
587 | struct macvlan_dev *vlan = netdev_priv(dev); | ||
588 | const struct net_device *lowerdev = vlan->lowerdev; | ||
589 | |||
590 | if (lowerdev->operstate == IF_OPER_DORMANT) | ||
591 | netif_dormant_on(dev); | ||
592 | else | ||
593 | netif_dormant_off(dev); | ||
594 | |||
595 | if (netif_carrier_ok(lowerdev)) { | ||
596 | if (!netif_carrier_ok(dev)) | ||
597 | netif_carrier_on(dev); | ||
598 | } else { | ||
599 | if (netif_carrier_ok(dev)) | ||
600 | netif_carrier_off(dev); | ||
601 | } | ||
602 | } | ||
603 | |||
604 | static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[]) | 585 | static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[]) |
605 | { | 586 | { |
606 | if (tb[IFLA_ADDRESS]) { | 587 | if (tb[IFLA_ADDRESS]) { |
@@ -693,7 +674,7 @@ static int macvlan_newlink(struct net *src_net, struct net_device *dev, | |||
693 | return err; | 674 | return err; |
694 | 675 | ||
695 | list_add_tail(&vlan->list, &port->vlans); | 676 | list_add_tail(&vlan->list, &port->vlans); |
696 | macvlan_transfer_operstate(dev); | 677 | netif_stacked_transfer_operstate(lowerdev, dev); |
697 | return 0; | 678 | return 0; |
698 | } | 679 | } |
699 | 680 | ||
@@ -768,7 +749,8 @@ static int macvlan_device_event(struct notifier_block *unused, | |||
768 | switch (event) { | 749 | switch (event) { |
769 | case NETDEV_CHANGE: | 750 | case NETDEV_CHANGE: |
770 | list_for_each_entry(vlan, &port->vlans, list) | 751 | list_for_each_entry(vlan, &port->vlans, list) |
771 | macvlan_transfer_operstate(vlan->dev); | 752 | netif_stacked_transfer_operstate(vlan->lowerdev, |
753 | vlan->dev); | ||
772 | break; | 754 | break; |
773 | case NETDEV_FEAT_CHANGE: | 755 | case NETDEV_FEAT_CHANGE: |
774 | list_for_each_entry(vlan, &port->vlans, list) { | 756 | list_for_each_entry(vlan, &port->vlans, list) { |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index daf13d367498..a3fccc85b1a0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1981,6 +1981,9 @@ unsigned long netdev_increment_features(unsigned long all, unsigned long one, | |||
1981 | unsigned long mask); | 1981 | unsigned long mask); |
1982 | unsigned long netdev_fix_features(unsigned long features, const char *name); | 1982 | unsigned long netdev_fix_features(unsigned long features, const char *name); |
1983 | 1983 | ||
1984 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | ||
1985 | struct net_device *dev); | ||
1986 | |||
1984 | static inline int net_gso_ok(int features, int gso_type) | 1987 | static inline int net_gso_ok(int features, int gso_type) |
1985 | { | 1988 | { |
1986 | int feature = gso_type << NETIF_F_GSO_SHIFT; | 1989 | int feature = gso_type << NETIF_F_GSO_SHIFT; |
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index ec3769295dac..33f90e7362cc 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -184,27 +184,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) | |||
184 | dev_put(real_dev); | 184 | dev_put(real_dev); |
185 | } | 185 | } |
186 | 186 | ||
187 | static void vlan_transfer_operstate(const struct net_device *dev, | ||
188 | struct net_device *vlandev) | ||
189 | { | ||
190 | /* Have to respect userspace enforced dormant state | ||
191 | * of real device, also must allow supplicant running | ||
192 | * on VLAN device | ||
193 | */ | ||
194 | if (dev->operstate == IF_OPER_DORMANT) | ||
195 | netif_dormant_on(vlandev); | ||
196 | else | ||
197 | netif_dormant_off(vlandev); | ||
198 | |||
199 | if (netif_carrier_ok(dev)) { | ||
200 | if (!netif_carrier_ok(vlandev)) | ||
201 | netif_carrier_on(vlandev); | ||
202 | } else { | ||
203 | if (netif_carrier_ok(vlandev)) | ||
204 | netif_carrier_off(vlandev); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) | 187 | int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) |
209 | { | 188 | { |
210 | const char *name = real_dev->name; | 189 | const char *name = real_dev->name; |
@@ -262,7 +241,7 @@ int register_vlan_dev(struct net_device *dev) | |||
262 | /* Account for reference in struct vlan_dev_info */ | 241 | /* Account for reference in struct vlan_dev_info */ |
263 | dev_hold(real_dev); | 242 | dev_hold(real_dev); |
264 | 243 | ||
265 | vlan_transfer_operstate(real_dev, dev); | 244 | netif_stacked_transfer_operstate(real_dev, dev); |
266 | linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */ | 245 | linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */ |
267 | 246 | ||
268 | /* So, got the sucker initialized, now lets place | 247 | /* So, got the sucker initialized, now lets place |
@@ -453,7 +432,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
453 | if (!vlandev) | 432 | if (!vlandev) |
454 | continue; | 433 | continue; |
455 | 434 | ||
456 | vlan_transfer_operstate(dev, vlandev); | 435 | netif_stacked_transfer_operstate(dev, vlandev); |
457 | } | 436 | } |
458 | break; | 437 | break; |
459 | 438 | ||
@@ -511,7 +490,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
511 | vlan = vlan_dev_info(vlandev); | 490 | vlan = vlan_dev_info(vlandev); |
512 | if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) | 491 | if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) |
513 | dev_change_flags(vlandev, flgs & ~IFF_UP); | 492 | dev_change_flags(vlandev, flgs & ~IFF_UP); |
514 | vlan_transfer_operstate(dev, vlandev); | 493 | netif_stacked_transfer_operstate(dev, vlandev); |
515 | } | 494 | } |
516 | break; | 495 | break; |
517 | 496 | ||
@@ -529,7 +508,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
529 | vlan = vlan_dev_info(vlandev); | 508 | vlan = vlan_dev_info(vlandev); |
530 | if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) | 509 | if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) |
531 | dev_change_flags(vlandev, flgs | IFF_UP); | 510 | dev_change_flags(vlandev, flgs | IFF_UP); |
532 | vlan_transfer_operstate(dev, vlandev); | 511 | netif_stacked_transfer_operstate(dev, vlandev); |
533 | } | 512 | } |
534 | break; | 513 | break; |
535 | 514 | ||
diff --git a/net/core/dev.c b/net/core/dev.c index 0913a08a87d6..c36a17aafcf3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4901,6 +4901,33 @@ unsigned long netdev_fix_features(unsigned long features, const char *name) | |||
4901 | EXPORT_SYMBOL(netdev_fix_features); | 4901 | EXPORT_SYMBOL(netdev_fix_features); |
4902 | 4902 | ||
4903 | /** | 4903 | /** |
4904 | * netif_stacked_transfer_operstate - transfer operstate | ||
4905 | * @rootdev: the root or lower level device to transfer state from | ||
4906 | * @dev: the device to transfer operstate to | ||
4907 | * | ||
4908 | * Transfer operational state from root to device. This is normally | ||
4909 | * called when a stacking relationship exists between the root | ||
4910 | * device and the device(a leaf device). | ||
4911 | */ | ||
4912 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | ||
4913 | struct net_device *dev) | ||
4914 | { | ||
4915 | if (rootdev->operstate == IF_OPER_DORMANT) | ||
4916 | netif_dormant_on(dev); | ||
4917 | else | ||
4918 | netif_dormant_off(dev); | ||
4919 | |||
4920 | if (netif_carrier_ok(rootdev)) { | ||
4921 | if (!netif_carrier_ok(dev)) | ||
4922 | netif_carrier_on(dev); | ||
4923 | } else { | ||
4924 | if (netif_carrier_ok(dev)) | ||
4925 | netif_carrier_off(dev); | ||
4926 | } | ||
4927 | } | ||
4928 | EXPORT_SYMBOL(netif_stacked_transfer_operstate); | ||
4929 | |||
4930 | /** | ||
4904 | * register_netdevice - register a network device | 4931 | * register_netdevice - register a network device |
4905 | * @dev: device to register | 4932 | * @dev: device to register |
4906 | * | 4933 | * |