rtnetlink.c (ba67cf5cf2ce10ad86a212b70f8c7c75d93a5016) rtnetlink.c (e67f88dd12f610da98ca838822f2c9b4e7c6100e)
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>

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

1002 int idx = 0, s_idx;
1003 struct net_device *dev;
1004 struct hlist_head *head;
1005 struct hlist_node *node;
1006
1007 s_h = cb->args[0];
1008 s_idx = cb->args[1];
1009
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>

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

1002 int idx = 0, s_idx;
1003 struct net_device *dev;
1004 struct hlist_head *head;
1005 struct hlist_node *node;
1006
1007 s_h = cb->args[0];
1008 s_idx = cb->args[1];
1009
1010 rcu_read_lock();
1010 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
1011 idx = 0;
1012 head = &net->dev_index_head[h];
1011 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
1012 idx = 0;
1013 head = &net->dev_index_head[h];
1013 hlist_for_each_entry(dev, node, head, index_hlist) {
1014 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
1014 if (idx < s_idx)
1015 goto cont;
1016 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
1017 NETLINK_CB(cb->skb).pid,
1018 cb->nlh->nlmsg_seq, 0,
1019 NLM_F_MULTI) <= 0)
1020 goto out;
1021cont:
1022 idx++;
1023 }
1024 }
1025out:
1015 if (idx < s_idx)
1016 goto cont;
1017 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
1018 NETLINK_CB(cb->skb).pid,
1019 cb->nlh->nlmsg_seq, 0,
1020 NLM_F_MULTI) <= 0)
1021 goto out;
1022cont:
1023 idx++;
1024 }
1025 }
1026out:
1027 rcu_read_unlock();
1026 cb->args[1] = idx;
1027 cb->args[0] = h;
1028
1029 return skb->len;
1030}
1031
1032const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1033 [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 },

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

1874static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1875{
1876 struct net *net = sock_net(skb->sk);
1877 rtnl_doit_func doit;
1878 int sz_idx, kind;
1879 int min_len;
1880 int family;
1881 int type;
1028 cb->args[1] = idx;
1029 cb->args[0] = h;
1030
1031 return skb->len;
1032}
1033
1034const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1035 [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 },

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

1876static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1877{
1878 struct net *net = sock_net(skb->sk);
1879 rtnl_doit_func doit;
1880 int sz_idx, kind;
1881 int min_len;
1882 int family;
1883 int type;
1882 int err;
1883
1884 type = nlh->nlmsg_type;
1885 if (type > RTM_MAX)
1886 return -EOPNOTSUPP;
1887
1888 type -= RTM_BASE;
1889
1890 /* All the messages must have at least 1 byte length */

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

1901 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
1902 struct sock *rtnl;
1903 rtnl_dumpit_func dumpit;
1904
1905 dumpit = rtnl_get_dumpit(family, type);
1906 if (dumpit == NULL)
1907 return -EOPNOTSUPP;
1908
1884
1885 type = nlh->nlmsg_type;
1886 if (type > RTM_MAX)
1887 return -EOPNOTSUPP;
1888
1889 type -= RTM_BASE;
1890
1891 /* All the messages must have at least 1 byte length */

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

1902 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
1903 struct sock *rtnl;
1904 rtnl_dumpit_func dumpit;
1905
1906 dumpit = rtnl_get_dumpit(family, type);
1907 if (dumpit == NULL)
1908 return -EOPNOTSUPP;
1909
1909 __rtnl_unlock();
1910 rtnl = net->rtnl;
1910 rtnl = net->rtnl;
1911 err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
1912 rtnl_lock();
1913 return err;
1911 return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
1914 }
1915
1916 memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
1917
1918 min_len = rtm_min[sz_idx];
1919 if (nlh->nlmsg_len < min_len)
1920 return -EINVAL;
1921

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

1975 .notifier_call = rtnetlink_event,
1976};
1977
1978
1979static int __net_init rtnetlink_net_init(struct net *net)
1980{
1981 struct sock *sk;
1982 sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX,
1912 }
1913
1914 memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
1915
1916 min_len = rtm_min[sz_idx];
1917 if (nlh->nlmsg_len < min_len)
1918 return -EINVAL;
1919

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

1973 .notifier_call = rtnetlink_event,
1974};
1975
1976
1977static int __net_init rtnetlink_net_init(struct net *net)
1978{
1979 struct sock *sk;
1980 sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX,
1983 rtnetlink_rcv, &rtnl_mutex, THIS_MODULE);
1981 rtnetlink_rcv, NULL, THIS_MODULE);
1984 if (!sk)
1985 return -ENOMEM;
1986 net->rtnl = sk;
1987 return 0;
1988}
1989
1990static void __net_exit rtnetlink_net_exit(struct net *net)
1991{

--- 36 unchanged lines hidden ---
1982 if (!sk)
1983 return -ENOMEM;
1984 net->rtnl = sk;
1985 return 0;
1986}
1987
1988static void __net_exit rtnetlink_net_exit(struct net *net)
1989{

--- 36 unchanged lines hidden ---