rtnetlink: move type calculation out of loop
authorChristian Brauner <christian@brauner.io>
Tue, 4 Sep 2018 19:53:51 +0000 (21:53 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Sep 2018 05:27:11 +0000 (22:27 -0700)
I don't see how the type - which is one of
RTM_{GETADDR,GETROUTE,GETNETCONF} - can change. So do the message type
calculation once before entering the for loop.

Signed-off-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index c490972..7110ce3 100644 (file)
@@ -3269,13 +3269,13 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
 {
        int idx;
        int s_idx = cb->family;
+       int type = cb->nlh->nlmsg_type - RTM_BASE;
 
        if (s_idx == 0)
                s_idx = 1;
 
        for (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) {
                struct rtnl_link **tab;
-               int type = cb->nlh->nlmsg_type-RTM_BASE;
                struct rtnl_link *link;
                rtnl_dumpit_func dumpit;