rtnetlink.c (5d5eacb34c9e1fdc0a47b885d832eaa4de860dc7) rtnetlink.c (5e6d243587990a588143b9da3974833649595587)
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>

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

2530out:
2531 netif_addr_unlock_bh(dev);
2532 return idx;
2533}
2534EXPORT_SYMBOL(ndo_dflt_fdb_dump);
2535
2536static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
2537{
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>

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

2530out:
2531 netif_addr_unlock_bh(dev);
2532 return idx;
2533}
2534EXPORT_SYMBOL(ndo_dflt_fdb_dump);
2535
2536static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
2537{
2538 int idx = 0;
2539 struct net *net = sock_net(skb->sk);
2540 struct net_device *dev;
2538 struct net_device *dev;
2539 struct nlattr *tb[IFLA_MAX+1];
2540 struct net_device *bdev = NULL;
2541 struct net_device *br_dev = NULL;
2542 const struct net_device_ops *ops = NULL;
2543 const struct net_device_ops *cops = NULL;
2544 struct ifinfomsg *ifm = nlmsg_data(cb->nlh);
2545 struct net *net = sock_net(skb->sk);
2546 int brport_idx = 0;
2547 int br_idx = 0;
2548 int idx = 0;
2541
2549
2542 rcu_read_lock();
2543 for_each_netdev_rcu(net, dev) {
2544 if (dev->priv_flags & IFF_BRIDGE_PORT) {
2545 struct net_device *br_dev;
2546 const struct net_device_ops *ops;
2550 if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
2551 ifla_policy) == 0) {
2552 if (tb[IFLA_MASTER])
2553 br_idx = nla_get_u32(tb[IFLA_MASTER]);
2554 }
2547
2555
2548 br_dev = netdev_master_upper_dev_get(dev);
2549 ops = br_dev->netdev_ops;
2550 if (ops->ndo_fdb_dump)
2551 idx = ops->ndo_fdb_dump(skb, cb, dev, NULL,
2552 idx);
2556 brport_idx = ifm->ifi_index;
2557
2558 if (br_idx) {
2559 br_dev = __dev_get_by_index(net, br_idx);
2560 if (!br_dev)
2561 return -ENODEV;
2562
2563 ops = br_dev->netdev_ops;
2564 bdev = br_dev;
2565 }
2566
2567 for_each_netdev(net, dev) {
2568 if (brport_idx && (dev->ifindex != brport_idx))
2569 continue;
2570
2571 if (!br_idx) { /* user did not specify a specific bridge */
2572 if (dev->priv_flags & IFF_BRIDGE_PORT) {
2573 br_dev = netdev_master_upper_dev_get(dev);
2574 cops = br_dev->netdev_ops;
2575 }
2576
2577 bdev = dev;
2578 } else {
2579 if (dev != br_dev &&
2580 !(dev->priv_flags & IFF_BRIDGE_PORT))
2581 continue;
2582
2583 if (br_dev != netdev_master_upper_dev_get(dev) &&
2584 !(dev->priv_flags & IFF_EBRIDGE))
2585 continue;
2586
2587 bdev = br_dev;
2588 cops = ops;
2553 }
2554
2589 }
2590
2591 if (dev->priv_flags & IFF_BRIDGE_PORT) {
2592 if (cops && cops->ndo_fdb_dump)
2593 idx = cops->ndo_fdb_dump(skb, cb, br_dev, dev,
2594 idx);
2595 }
2596
2597 idx = ndo_dflt_fdb_dump(skb, cb, dev, NULL, idx);
2555 if (dev->netdev_ops->ndo_fdb_dump)
2598 if (dev->netdev_ops->ndo_fdb_dump)
2556 idx = dev->netdev_ops->ndo_fdb_dump(skb, cb, dev, NULL,
2599 idx = dev->netdev_ops->ndo_fdb_dump(skb, cb, bdev, dev,
2557 idx);
2600 idx);
2558 else
2559 idx = ndo_dflt_fdb_dump(skb, cb, dev, NULL, idx);
2601
2602 cops = NULL;
2560 }
2603 }
2561 rcu_read_unlock();
2562
2563 cb->args[0] = idx;
2564 return skb->len;
2565}
2566
2567int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
2568 struct net_device *dev, u16 mode)
2569{

--- 432 unchanged lines hidden ---
2604
2605 cb->args[0] = idx;
2606 return skb->len;
2607}
2608
2609int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
2610 struct net_device *dev, u16 mode)
2611{

--- 432 unchanged lines hidden ---