Commit 926e9878 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

phonet netlink: allow multiple messages per skb in route dump

My previous patch to this file changed the code to be bug-compatible
towards userspace. Unless userspace (which I wasn't able to find)
implements the dump reader by hand in a wrong way, this isn't needed.
If it uses libnl or similar code putting multiple messages into a
single SKB is far more efficient.

Change the code to do this. While at it, also clean it up and don't
use so many variables - just store the address in the callback args
directly.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc834777
...@@ -272,31 +272,23 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -272,31 +272,23 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb) static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
u8 addr, addr_idx = 0, addr_start_idx = cb->args[0]; u8 addr;
rcu_read_lock(); rcu_read_lock();
for (addr = 0; addr < 64; addr++) { for (addr = cb->args[0]; addr < 64; addr++) {
struct net_device *dev; struct net_device *dev = phonet_route_get_rcu(net, addr << 2);
dev = phonet_route_get_rcu(net, addr << 2);
if (!dev) if (!dev)
continue; continue;
if (addr_idx++ < addr_start_idx) if (fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).portid,
continue; cb->nlh->nlmsg_seq, RTM_NEWROUTE) < 0)
fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, RTM_NEWROUTE);
/* fill_route() used to return > 0 (or negative errors) but
* never 0 - ignore the return value and just go out to
* call dumpit again from outside to preserve the behavior
*/
goto out; goto out;
} }
out: out:
rcu_read_unlock(); rcu_read_unlock();
cb->args[0] = addr_idx; cb->args[0] = addr;
cb->args[1] = 0;
return skb->len; return skb->len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment