Skip to content

Commit

Permalink
dev: update __dev_notify_flags() to send rtnl msg
Browse files Browse the repository at this point in the history
This patch only prepares the next one, there is no functional change.
Now, __dev_notify_flags() can also be used to notify flags changes via
rtnetlink.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nicolas Dichtel authored and David S. Miller committed Sep 30, 2013
1 parent e058495 commit a528c21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,9 @@ extern int dev_ethtool(struct net *net, struct ifreq *);
extern unsigned int dev_get_flags(const struct net_device *);
extern int __dev_change_flags(struct net_device *, unsigned int flags);
extern int dev_change_flags(struct net_device *, unsigned int);
extern void __dev_notify_flags(struct net_device *, unsigned int old_flags);
void __dev_notify_flags(struct net_device *,
unsigned int old_flags,
unsigned int gchanges);
extern int dev_change_name(struct net_device *, const char *);
extern int dev_set_alias(struct net_device *, const char *, size_t);
extern int dev_change_net_namespace(struct net_device *,
Expand Down
11 changes: 6 additions & 5 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5235,10 +5235,14 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags)
return ret;
}

void __dev_notify_flags(struct net_device *dev, unsigned int old_flags)
void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
unsigned int gchanges)
{
unsigned int changes = dev->flags ^ old_flags;

if (gchanges)
rtmsg_ifinfo(RTM_NEWLINK, dev, gchanges);

if (changes & IFF_UP) {
if (dev->flags & IFF_UP)
call_netdevice_notifiers(NETDEV_UP, dev);
Expand Down Expand Up @@ -5274,10 +5278,7 @@ int dev_change_flags(struct net_device *dev, unsigned int flags)
return ret;

changes = old_flags ^ dev->flags;
if (changes)
rtmsg_ifinfo(RTM_NEWLINK, dev, changes);

__dev_notify_flags(dev, old_flags);
__dev_notify_flags(dev, old_flags, changes);
return ret;
}
EXPORT_SYMBOL(dev_change_flags);
Expand Down
3 changes: 1 addition & 2 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,9 +1647,8 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
}

dev->rtnl_link_state = RTNL_LINK_INITIALIZED;
rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);

__dev_notify_flags(dev, old_flags);
__dev_notify_flags(dev, old_flags, ~0U);
return 0;
}
EXPORT_SYMBOL(rtnl_configure_link);
Expand Down

0 comments on commit a528c21

Please sign in to comment.