diff options
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 8c971a2efe2a..27da9cdec6a8 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -437,7 +437,7 @@ static void copy_rtnl_link_stats(struct rtnl_link_stats *a, | |||
437 | a->tx_compressed = b->tx_compressed; | 437 | a->tx_compressed = b->tx_compressed; |
438 | }; | 438 | }; |
439 | 439 | ||
440 | static inline size_t if_nlmsg_size(int iwbuflen) | 440 | static inline size_t if_nlmsg_size(void) |
441 | { | 441 | { |
442 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) | 442 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) |
443 | + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ | 443 | + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ |
@@ -452,13 +452,12 @@ static inline size_t if_nlmsg_size(int iwbuflen) | |||
452 | + nla_total_size(4) /* IFLA_LINK */ | 452 | + nla_total_size(4) /* IFLA_LINK */ |
453 | + nla_total_size(4) /* IFLA_MASTER */ | 453 | + nla_total_size(4) /* IFLA_MASTER */ |
454 | + nla_total_size(1) /* IFLA_OPERSTATE */ | 454 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
455 | + nla_total_size(1) /* IFLA_LINKMODE */ | 455 | + nla_total_size(1); /* IFLA_LINKMODE */ |
456 | + nla_total_size(iwbuflen); | ||
457 | } | 456 | } |
458 | 457 | ||
459 | static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | 458 | static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, |
460 | void *iwbuf, int iwbuflen, int type, u32 pid, | 459 | int type, u32 pid, u32 seq, u32 change, |
461 | u32 seq, u32 change, unsigned int flags) | 460 | unsigned int flags) |
462 | { | 461 | { |
463 | struct ifinfomsg *ifm; | 462 | struct ifinfomsg *ifm; |
464 | struct nlmsghdr *nlh; | 463 | struct nlmsghdr *nlh; |
@@ -523,9 +522,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | |||
523 | } | 522 | } |
524 | } | 523 | } |
525 | 524 | ||
526 | if (iwbuf) | ||
527 | NLA_PUT(skb, IFLA_WIRELESS, iwbuflen, iwbuf); | ||
528 | |||
529 | return nlmsg_end(skb, nlh); | 525 | return nlmsg_end(skb, nlh); |
530 | 526 | ||
531 | nla_put_failure: | 527 | nla_put_failure: |
@@ -543,7 +539,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
543 | for_each_netdev(dev) { | 539 | for_each_netdev(dev) { |
544 | if (idx < s_idx) | 540 | if (idx < s_idx) |
545 | goto cont; | 541 | goto cont; |
546 | if (rtnl_fill_ifinfo(skb, dev, NULL, 0, RTM_NEWLINK, | 542 | if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, |
547 | NETLINK_CB(cb->skb).pid, | 543 | NETLINK_CB(cb->skb).pid, |
548 | cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0) | 544 | cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0) |
549 | break; | 545 | break; |
@@ -689,8 +685,15 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
689 | } | 685 | } |
690 | 686 | ||
691 | 687 | ||
692 | if (ifm->ifi_flags) | 688 | if (ifm->ifi_flags || ifm->ifi_change) { |
693 | dev_change_flags(dev, ifm->ifi_flags); | 689 | unsigned int flags = ifm->ifi_flags; |
690 | |||
691 | /* bugwards compatibility: ifi_change == 0 is treated as ~0 */ | ||
692 | if (ifm->ifi_change) | ||
693 | flags = (flags & ifm->ifi_change) | | ||
694 | (dev->flags & ~ifm->ifi_change); | ||
695 | dev_change_flags(dev, flags); | ||
696 | } | ||
694 | 697 | ||
695 | if (tb[IFLA_TXQLEN]) | 698 | if (tb[IFLA_TXQLEN]) |
696 | dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); | 699 | dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); |
@@ -730,8 +733,6 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
730 | struct nlattr *tb[IFLA_MAX+1]; | 733 | struct nlattr *tb[IFLA_MAX+1]; |
731 | struct net_device *dev = NULL; | 734 | struct net_device *dev = NULL; |
732 | struct sk_buff *nskb; | 735 | struct sk_buff *nskb; |
733 | char *iw_buf = NULL, *iw = NULL; | ||
734 | int iw_buf_len = 0; | ||
735 | int err; | 736 | int err; |
736 | 737 | ||
737 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); | 738 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); |
@@ -746,14 +747,14 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
746 | } else | 747 | } else |
747 | return -EINVAL; | 748 | return -EINVAL; |
748 | 749 | ||
749 | nskb = nlmsg_new(if_nlmsg_size(iw_buf_len), GFP_KERNEL); | 750 | nskb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL); |
750 | if (nskb == NULL) { | 751 | if (nskb == NULL) { |
751 | err = -ENOBUFS; | 752 | err = -ENOBUFS; |
752 | goto errout; | 753 | goto errout; |
753 | } | 754 | } |
754 | 755 | ||
755 | err = rtnl_fill_ifinfo(nskb, dev, iw, iw_buf_len, RTM_NEWLINK, | 756 | err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).pid, |
756 | NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0, 0); | 757 | nlh->nlmsg_seq, 0, 0); |
757 | if (err < 0) { | 758 | if (err < 0) { |
758 | /* -EMSGSIZE implies BUG in if_nlmsg_size */ | 759 | /* -EMSGSIZE implies BUG in if_nlmsg_size */ |
759 | WARN_ON(err == -EMSGSIZE); | 760 | WARN_ON(err == -EMSGSIZE); |
@@ -762,7 +763,6 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
762 | } | 763 | } |
763 | err = rtnl_unicast(nskb, NETLINK_CB(skb).pid); | 764 | err = rtnl_unicast(nskb, NETLINK_CB(skb).pid); |
764 | errout: | 765 | errout: |
765 | kfree(iw_buf); | ||
766 | dev_put(dev); | 766 | dev_put(dev); |
767 | 767 | ||
768 | return err; | 768 | return err; |
@@ -797,11 +797,11 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) | |||
797 | struct sk_buff *skb; | 797 | struct sk_buff *skb; |
798 | int err = -ENOBUFS; | 798 | int err = -ENOBUFS; |
799 | 799 | ||
800 | skb = nlmsg_new(if_nlmsg_size(0), GFP_KERNEL); | 800 | skb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL); |
801 | if (skb == NULL) | 801 | if (skb == NULL) |
802 | goto errout; | 802 | goto errout; |
803 | 803 | ||
804 | err = rtnl_fill_ifinfo(skb, dev, NULL, 0, type, 0, 0, change, 0); | 804 | err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0); |
805 | if (err < 0) { | 805 | if (err < 0) { |
806 | /* -EMSGSIZE implies BUG in if_nlmsg_size() */ | 806 | /* -EMSGSIZE implies BUG in if_nlmsg_size() */ |
807 | WARN_ON(err == -EMSGSIZE); | 807 | WARN_ON(err == -EMSGSIZE); |