Commit db46edc6 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[RTNETLINK] Cleanup rtnetlink_link tables

Converts remaining rtnetlink_link tables to use c99 designated
initializers to make greping a little bit easier.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f90a0a74
...@@ -93,6 +93,8 @@ enum { ...@@ -93,6 +93,8 @@ enum {
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
}; };
#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2) #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
/* /*
......
...@@ -86,7 +86,7 @@ struct sock *rtnl; ...@@ -86,7 +86,7 @@ struct sock *rtnl;
struct rtnetlink_link * rtnetlink_links[NPROTO]; struct rtnetlink_link * rtnetlink_links[NPROTO];
static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] = static const int rtm_min[RTM_NR_FAMILIES] =
{ {
[RTM_FAM(RTM_NEWLINK)] = NLMSG_LENGTH(sizeof(struct ifinfomsg)), [RTM_FAM(RTM_NEWLINK)] = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
[RTM_FAM(RTM_NEWADDR)] = NLMSG_LENGTH(sizeof(struct ifaddrmsg)), [RTM_FAM(RTM_NEWADDR)] = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
...@@ -102,7 +102,7 @@ static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] = ...@@ -102,7 +102,7 @@ static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] =
[RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)), [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
}; };
static const int rta_max[(RTM_MAX+1-RTM_BASE)/4] = static const int rta_max[RTM_NR_FAMILIES] =
{ {
[RTM_FAM(RTM_NEWLINK)] = IFLA_MAX, [RTM_FAM(RTM_NEWLINK)] = IFLA_MAX,
[RTM_FAM(RTM_NEWADDR)] = IFA_MAX, [RTM_FAM(RTM_NEWADDR)] = IFA_MAX,
...@@ -641,7 +641,7 @@ static void rtnetlink_rcv(struct sock *sk, int len) ...@@ -641,7 +641,7 @@ static void rtnetlink_rcv(struct sock *sk, int len)
} while (rtnl && rtnl->sk_receive_queue.qlen); } while (rtnl && rtnl->sk_receive_queue.qlen);
} }
static struct rtnetlink_link link_rtnetlink_table[RTM_MAX-RTM_BASE+1] = static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
{ {
[RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo }, [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo },
[RTM_SETLINK - RTM_BASE] = { .doit = do_setlink }, [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink },
......
...@@ -1411,21 +1411,22 @@ static struct file_operations dn_dev_seq_fops = { ...@@ -1411,21 +1411,22 @@ static struct file_operations dn_dev_seq_fops = {
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
static struct rtnetlink_link dnet_rtnetlink_table[RTM_MAX-RTM_BASE+1] = static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
{ {
[4] = { .doit = dn_dev_rtm_newaddr, }, [RTM_NEWADDR - RTM_BASE] = { .doit = dn_dev_rtm_newaddr, },
[5] = { .doit = dn_dev_rtm_deladdr, }, [RTM_DELADDR - RTM_BASE] = { .doit = dn_dev_rtm_deladdr, },
[6] = { .dumpit = dn_dev_dump_ifaddr, }, [RTM_GETADDR - RTM_BASE] = { .dumpit = dn_dev_dump_ifaddr, },
#ifdef CONFIG_DECNET_ROUTER #ifdef CONFIG_DECNET_ROUTER
[8] = { .doit = dn_fib_rtm_newroute, }, [RTM_NEWROUTE - RTM_BASE] = { .doit = dn_fib_rtm_newroute, },
[9] = { .doit = dn_fib_rtm_delroute, }, [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, },
[10] = { .doit = dn_cache_getroute, .dumpit = dn_fib_dump, }, [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
[16] = { .doit = dn_fib_rtm_newrule, }, .dumpit = dn_fib_dump, },
[17] = { .doit = dn_fib_rtm_delrule, }, [RTM_NEWRULE - RTM_BASE] = { .doit = dn_fib_rtm_newrule, },
[18] = { .dumpit = dn_fib_dump_rules, }, [RTM_DELRULE - RTM_BASE] = { .doit = dn_fib_rtm_delrule, },
[RTM_GETRULE - RTM_BASE] = { .dumpit = dn_fib_dump_rules, },
#else #else
[10] = { .doit = dn_cache_getroute, .dumpit = dn_cache_dump, }, [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
.dumpit = dn_cache_dump,
#endif #endif
}; };
......
...@@ -1107,17 +1107,18 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa) ...@@ -1107,17 +1107,18 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
} }
} }
static struct rtnetlink_link inet_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {
[4] = { .doit = inet_rtm_newaddr, }, [RTM_NEWADDR - RTM_BASE] = { .doit = inet_rtm_newaddr, },
[5] = { .doit = inet_rtm_deladdr, }, [RTM_DELADDR - RTM_BASE] = { .doit = inet_rtm_deladdr, },
[6] = { .dumpit = inet_dump_ifaddr, }, [RTM_GETADDR - RTM_BASE] = { .dumpit = inet_dump_ifaddr, },
[8] = { .doit = inet_rtm_newroute, }, [RTM_NEWROUTE - RTM_BASE] = { .doit = inet_rtm_newroute, },
[9] = { .doit = inet_rtm_delroute, }, [RTM_DELROUTE - RTM_BASE] = { .doit = inet_rtm_delroute, },
[10] = { .doit = inet_rtm_getroute, .dumpit = inet_dump_fib, }, [RTM_GETROUTE - RTM_BASE] = { .doit = inet_rtm_getroute,
.dumpit = inet_dump_fib, },
#ifdef CONFIG_IP_MULTIPLE_TABLES #ifdef CONFIG_IP_MULTIPLE_TABLES
[16] = { .doit = inet_rtm_newrule, }, [RTM_NEWRULE - RTM_BASE] = { .doit = inet_rtm_newrule, },
[17] = { .doit = inet_rtm_delrule, }, [RTM_DELRULE - RTM_BASE] = { .doit = inet_rtm_delrule, },
[18] = { .dumpit = inet_dump_rules, }, [RTM_GETRULE - RTM_BASE] = { .dumpit = inet_dump_rules, },
#endif #endif
}; };
......
...@@ -3076,7 +3076,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev, ...@@ -3076,7 +3076,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC); netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC);
} }
static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { static struct rtnetlink_link inet6_rtnetlink_table[RTM_NR_MSGTYPES] = {
[RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, }, [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, },
[RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, }, [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, },
[RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, }, [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, },
......
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