devinet.c (c33078e3dfb194489b2f0875f078dc76647cfecf) | devinet.c (addd383f5a0ba9bf8336be3cc8b7a2916c08a77a) |
---|---|
1/* 2 * NET3 IP device support routines. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 2072 unchanged lines hidden (view full) --- 2081 err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid); 2082errout: 2083 return err; 2084} 2085 2086static int inet_netconf_dump_devconf(struct sk_buff *skb, 2087 struct netlink_callback *cb) 2088{ | 1/* 2 * NET3 IP device support routines. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 2072 unchanged lines hidden (view full) --- 2081 err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid); 2082errout: 2083 return err; 2084} 2085 2086static int inet_netconf_dump_devconf(struct sk_buff *skb, 2087 struct netlink_callback *cb) 2088{ |
2089 const struct nlmsghdr *nlh = cb->nlh; |
|
2089 struct net *net = sock_net(skb->sk); 2090 int h, s_h; 2091 int idx, s_idx; 2092 struct net_device *dev; 2093 struct in_device *in_dev; 2094 struct hlist_head *head; 2095 | 2090 struct net *net = sock_net(skb->sk); 2091 int h, s_h; 2092 int idx, s_idx; 2093 struct net_device *dev; 2094 struct in_device *in_dev; 2095 struct hlist_head *head; 2096 |
2097 if (cb->strict_check) { 2098 struct netlink_ext_ack *extack = cb->extack; 2099 struct netconfmsg *ncm; 2100 2101 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ncm))) { 2102 NL_SET_ERR_MSG(extack, "ipv4: Invalid header for netconf dump request"); 2103 return -EINVAL; 2104 } 2105 2106 if (nlmsg_attrlen(nlh, sizeof(*ncm))) { 2107 NL_SET_ERR_MSG(extack, "ipv4: Invalid data after header in netconf dump request"); 2108 return -EINVAL; 2109 } 2110 } 2111 |
|
2096 s_h = cb->args[0]; 2097 s_idx = idx = cb->args[1]; 2098 2099 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { 2100 idx = 0; 2101 head = &net->dev_index_head[h]; 2102 rcu_read_lock(); 2103 cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^ 2104 net->dev_base_seq; 2105 hlist_for_each_entry_rcu(dev, head, index_hlist) { 2106 if (idx < s_idx) 2107 goto cont; 2108 in_dev = __in_dev_get_rcu(dev); 2109 if (!in_dev) 2110 goto cont; 2111 2112 if (inet_netconf_fill_devconf(skb, dev->ifindex, 2113 &in_dev->cnf, 2114 NETLINK_CB(cb->skb).portid, | 2112 s_h = cb->args[0]; 2113 s_idx = idx = cb->args[1]; 2114 2115 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { 2116 idx = 0; 2117 head = &net->dev_index_head[h]; 2118 rcu_read_lock(); 2119 cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^ 2120 net->dev_base_seq; 2121 hlist_for_each_entry_rcu(dev, head, index_hlist) { 2122 if (idx < s_idx) 2123 goto cont; 2124 in_dev = __in_dev_get_rcu(dev); 2125 if (!in_dev) 2126 goto cont; 2127 2128 if (inet_netconf_fill_devconf(skb, dev->ifindex, 2129 &in_dev->cnf, 2130 NETLINK_CB(cb->skb).portid, |
2115 cb->nlh->nlmsg_seq, | 2131 nlh->nlmsg_seq, |
2116 RTM_NEWNETCONF, 2117 NLM_F_MULTI, 2118 NETCONFA_ALL) < 0) { 2119 rcu_read_unlock(); 2120 goto done; 2121 } 2122 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 2123cont: 2124 idx++; 2125 } 2126 rcu_read_unlock(); 2127 } 2128 if (h == NETDEV_HASHENTRIES) { 2129 if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_ALL, 2130 net->ipv4.devconf_all, 2131 NETLINK_CB(cb->skb).portid, | 2132 RTM_NEWNETCONF, 2133 NLM_F_MULTI, 2134 NETCONFA_ALL) < 0) { 2135 rcu_read_unlock(); 2136 goto done; 2137 } 2138 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 2139cont: 2140 idx++; 2141 } 2142 rcu_read_unlock(); 2143 } 2144 if (h == NETDEV_HASHENTRIES) { 2145 if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_ALL, 2146 net->ipv4.devconf_all, 2147 NETLINK_CB(cb->skb).portid, |
2132 cb->nlh->nlmsg_seq, | 2148 nlh->nlmsg_seq, |
2133 RTM_NEWNETCONF, NLM_F_MULTI, 2134 NETCONFA_ALL) < 0) 2135 goto done; 2136 else 2137 h++; 2138 } 2139 if (h == NETDEV_HASHENTRIES + 1) { 2140 if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_DEFAULT, 2141 net->ipv4.devconf_dflt, 2142 NETLINK_CB(cb->skb).portid, | 2149 RTM_NEWNETCONF, NLM_F_MULTI, 2150 NETCONFA_ALL) < 0) 2151 goto done; 2152 else 2153 h++; 2154 } 2155 if (h == NETDEV_HASHENTRIES + 1) { 2156 if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_DEFAULT, 2157 net->ipv4.devconf_dflt, 2158 NETLINK_CB(cb->skb).portid, |
2143 cb->nlh->nlmsg_seq, | 2159 nlh->nlmsg_seq, |
2144 RTM_NEWNETCONF, NLM_F_MULTI, 2145 NETCONFA_ALL) < 0) 2146 goto done; 2147 else 2148 h++; 2149 } 2150done: 2151 cb->args[0] = h; --- 469 unchanged lines hidden --- | 2160 RTM_NEWNETCONF, NLM_F_MULTI, 2161 NETCONFA_ALL) < 0) 2162 goto done; 2163 else 2164 h++; 2165 } 2166done: 2167 cb->args[0] = h; --- 469 unchanged lines hidden --- |