rtnetlink.c (aaa8c4e05e3295d5c62163ca25776c83541764ef) rtnetlink.c (eeb85a14ee3494febb85ccfbee0772eda0823b13)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Routing netlink socket interface: protocol independent part.
8 *

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

2261 nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
2262 return -EINVAL;
2263
2264 if (tb[IFLA_BROADCAST] &&
2265 nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
2266 return -EINVAL;
2267 }
2268
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Routing netlink socket interface: protocol independent part.
8 *

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

2261 nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
2262 return -EINVAL;
2263
2264 if (tb[IFLA_BROADCAST] &&
2265 nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
2266 return -EINVAL;
2267 }
2268
2269 if (tb[IFLA_NEW_IFINDEX] && nla_get_s32(tb[IFLA_NEW_IFINDEX]) <= 0)
2270 return -EINVAL;
2271
2269 if (tb[IFLA_AF_SPEC]) {
2270 struct nlattr *af;
2271 int rem, err;
2272
2273 nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
2274 const struct rtnl_af_ops *af_ops;
2275
2276 rcu_read_lock();

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

2598 const struct net_device_ops *ops = dev->netdev_ops;
2599 int err;
2600
2601 err = validate_linkmsg(dev, tb);
2602 if (err < 0)
2603 return err;
2604
2605 if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD] || tb[IFLA_TARGET_NETNSID]) {
2272 if (tb[IFLA_AF_SPEC]) {
2273 struct nlattr *af;
2274 int rem, err;
2275
2276 nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
2277 const struct rtnl_af_ops *af_ops;
2278
2279 rcu_read_lock();

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

2601 const struct net_device_ops *ops = dev->netdev_ops;
2602 int err;
2603
2604 err = validate_linkmsg(dev, tb);
2605 if (err < 0)
2606 return err;
2607
2608 if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD] || tb[IFLA_TARGET_NETNSID]) {
2606 struct net *net = rtnl_link_get_net_capable(skb, dev_net(dev),
2607 tb, CAP_NET_ADMIN);
2609 struct net *net;
2610 int new_ifindex;
2611
2612 net = rtnl_link_get_net_capable(skb, dev_net(dev),
2613 tb, CAP_NET_ADMIN);
2608 if (IS_ERR(net)) {
2609 err = PTR_ERR(net);
2610 goto errout;
2611 }
2612
2614 if (IS_ERR(net)) {
2615 err = PTR_ERR(net);
2616 goto errout;
2617 }
2618
2613 err = dev_change_net_namespace(dev, net, ifname);
2619 if (tb[IFLA_NEW_IFINDEX])
2620 new_ifindex = nla_get_s32(tb[IFLA_NEW_IFINDEX]);
2621 else
2622 new_ifindex = 0;
2623
2624 err = dev_change_net_namespace(dev, net, ifname, new_ifindex);
2614 put_net(net);
2615 if (err)
2616 goto errout;
2617 status |= DO_SETLINK_MODIFIED;
2618 }
2619
2620 if (tb[IFLA_MAP]) {
2621 struct rtnl_link_ifmap *u_map;

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

3447 free_netdev(dev);
3448 goto out;
3449 }
3450
3451 err = rtnl_configure_link(dev, ifm);
3452 if (err < 0)
3453 goto out_unregister;
3454 if (link_net) {
2625 put_net(net);
2626 if (err)
2627 goto errout;
2628 status |= DO_SETLINK_MODIFIED;
2629 }
2630
2631 if (tb[IFLA_MAP]) {
2632 struct rtnl_link_ifmap *u_map;

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

3458 free_netdev(dev);
3459 goto out;
3460 }
3461
3462 err = rtnl_configure_link(dev, ifm);
3463 if (err < 0)
3464 goto out_unregister;
3465 if (link_net) {
3455 err = dev_change_net_namespace(dev, dest_net, ifname);
3466 err = dev_change_net_namespace(dev, dest_net, ifname, 0);
3456 if (err < 0)
3457 goto out_unregister;
3458 }
3459 if (tb[IFLA_MASTER]) {
3460 err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
3461 if (err)
3462 goto out_unregister;
3463 }

--- 2214 unchanged lines hidden ---
3467 if (err < 0)
3468 goto out_unregister;
3469 }
3470 if (tb[IFLA_MASTER]) {
3471 err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
3472 if (err)
3473 goto out_unregister;
3474 }

--- 2214 unchanged lines hidden ---