rtnetlink.c (0a3abcf75bf391fec4e32356ab5ddb8f5d2e6b41) rtnetlink.c (93b2d4a208eeb19bff95e98c34503ce4b03cd0f9)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Routing netlink socket interface: protocol independent part.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 490 unchanged lines hidden (view full) ---

499 if (expires)
500 ci.rta_expires = jiffies_to_clock_t(expires);
501
502 return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci);
503}
504
505EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo);
506
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Routing netlink socket interface: protocol independent part.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 490 unchanged lines hidden (view full) ---

499 if (expires)
500 ci.rta_expires = jiffies_to_clock_t(expires);
501
502 return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci);
503}
504
505EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo);
506
507static int set_operstate(struct net_device *dev, unsigned char transition, bool send_notification)
507static void set_operstate(struct net_device *dev, unsigned char transition)
508{
509 unsigned char operstate = dev->operstate;
510
511 switch(transition) {
512 case IF_OPER_UP:
513 if ((operstate == IF_OPER_DORMANT ||
514 operstate == IF_OPER_UNKNOWN) &&
515 !netif_dormant(dev))

--- 6 unchanged lines hidden (view full) ---

522 operstate = IF_OPER_DORMANT;
523 break;
524 }
525
526 if (dev->operstate != operstate) {
527 write_lock_bh(&dev_base_lock);
528 dev->operstate = operstate;
529 write_unlock_bh(&dev_base_lock);
508{
509 unsigned char operstate = dev->operstate;
510
511 switch(transition) {
512 case IF_OPER_UP:
513 if ((operstate == IF_OPER_DORMANT ||
514 operstate == IF_OPER_UNKNOWN) &&
515 !netif_dormant(dev))

--- 6 unchanged lines hidden (view full) ---

522 operstate = IF_OPER_DORMANT;
523 break;
524 }
525
526 if (dev->operstate != operstate) {
527 write_lock_bh(&dev_base_lock);
528 dev->operstate = operstate;
529 write_unlock_bh(&dev_base_lock);
530
531 if (send_notification)
532 netdev_state_change(dev);
533 return 1;
534 } else
535 return 0;
530 netdev_state_change(dev);
531 }
536}
537
538static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
539 struct net_device_stats *b)
540{
541 a->rx_packets = b->rx_packets;
542 a->tx_packets = b->tx_packets;
543 a->rx_bytes = b->rx_bytes;

--- 277 unchanged lines hidden (view full) ---

821 if (err < 0)
822 goto errout;
823 modified = 1;
824 }
825
826 if (tb[IFLA_BROADCAST]) {
827 nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len);
828 send_addr_notify = 1;
532}
533
534static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
535 struct net_device_stats *b)
536{
537 a->rx_packets = b->rx_packets;
538 a->tx_packets = b->tx_packets;
539 a->rx_bytes = b->rx_bytes;

--- 277 unchanged lines hidden (view full) ---

817 if (err < 0)
818 goto errout;
819 modified = 1;
820 }
821
822 if (tb[IFLA_BROADCAST]) {
823 nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len);
824 send_addr_notify = 1;
829 modified = 1;
830 }
831
832 if (ifm->ifi_flags || ifm->ifi_change) {
833 unsigned int flags = ifm->ifi_flags;
834
835 /* bugwards compatibility: ifi_change == 0 is treated as ~0 */
836 if (ifm->ifi_change)
837 flags = (flags & ifm->ifi_change) |
838 (dev->flags & ~ifm->ifi_change);
839 dev_change_flags(dev, flags);
840 }
841
825 }
826
827 if (ifm->ifi_flags || ifm->ifi_change) {
828 unsigned int flags = ifm->ifi_flags;
829
830 /* bugwards compatibility: ifi_change == 0 is treated as ~0 */
831 if (ifm->ifi_change)
832 flags = (flags & ifm->ifi_change) |
833 (dev->flags & ~ifm->ifi_change);
834 dev_change_flags(dev, flags);
835 }
836
842 if (tb[IFLA_TXQLEN]) {
843 if (dev->tx_queue_len != nla_get_u32(tb[IFLA_TXQLEN])) {
844 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
845 modified = 1;
846 }
847 }
837 if (tb[IFLA_TXQLEN])
838 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
848
849 if (tb[IFLA_OPERSTATE])
839
840 if (tb[IFLA_OPERSTATE])
850 modified |= set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]), false);
841 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
851
852 if (tb[IFLA_LINKMODE]) {
842
843 if (tb[IFLA_LINKMODE]) {
853 if (dev->link_mode != nla_get_u8(tb[IFLA_LINKMODE])) {
854 write_lock_bh(&dev_base_lock);
855 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
856 write_lock_bh(&dev_base_lock);
857 modified = 1;
858 }
844 write_lock_bh(&dev_base_lock);
845 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
846 write_unlock_bh(&dev_base_lock);
859 }
860
861 err = 0;
862
863errout:
864 if (err < 0 && modified && net_ratelimit())
865 printk(KERN_WARNING "A link change request failed with "
866 "some changes comitted already. Interface %s may "
867 "have been left with an inconsistent configuration, "
868 "please check.\n", dev->name);
869
870 if (send_addr_notify)
871 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
847 }
848
849 err = 0;
850
851errout:
852 if (err < 0 && modified && net_ratelimit())
853 printk(KERN_WARNING "A link change request failed with "
854 "some changes comitted already. Interface %s may "
855 "have been left with an inconsistent configuration, "
856 "please check.\n", dev->name);
857
858 if (send_addr_notify)
859 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
872
873 if (modified)
874 netdev_state_change(dev);
875
876 return err;
877}
878
879static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
880{
881 struct net *net = skb->sk->sk_net;
882 struct ifinfomsg *ifm;
883 struct net_device *dev;

--- 101 unchanged lines hidden (view full) ---

985 memcpy(dev->dev_addr, nla_data(tb[IFLA_ADDRESS]),
986 nla_len(tb[IFLA_ADDRESS]));
987 if (tb[IFLA_BROADCAST])
988 memcpy(dev->broadcast, nla_data(tb[IFLA_BROADCAST]),
989 nla_len(tb[IFLA_BROADCAST]));
990 if (tb[IFLA_TXQLEN])
991 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
992 if (tb[IFLA_OPERSTATE])
860 return err;
861}
862
863static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
864{
865 struct net *net = skb->sk->sk_net;
866 struct ifinfomsg *ifm;
867 struct net_device *dev;

--- 101 unchanged lines hidden (view full) ---

969 memcpy(dev->dev_addr, nla_data(tb[IFLA_ADDRESS]),
970 nla_len(tb[IFLA_ADDRESS]));
971 if (tb[IFLA_BROADCAST])
972 memcpy(dev->broadcast, nla_data(tb[IFLA_BROADCAST]),
973 nla_len(tb[IFLA_BROADCAST]));
974 if (tb[IFLA_TXQLEN])
975 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
976 if (tb[IFLA_OPERSTATE])
993 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]), true);
977 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
994 if (tb[IFLA_LINKMODE])
995 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
996
997 return dev;
998
999err_free:
1000 free_netdev(dev);
1001err:

--- 396 unchanged lines hidden ---
978 if (tb[IFLA_LINKMODE])
979 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
980
981 return dev;
982
983err_free:
984 free_netdev(dev);
985err:

--- 396 unchanged lines hidden ---