From c8733a9be9731a519368b8f00658c4f382b5980e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20=D0=9C=D0=B0=D1=80=D0=BA?= Date: Fri, 27 Jan 2012 12:09:26 +0600 Subject: [PATCH] make *_policy static --- include/netlink-tc.h | 2 +- include/netlink/attr.h | 6 +++--- include/netlink/genl/genl.h | 4 ++-- include/netlink/genl/mngt.h | 2 +- include/netlink/msg.h | 4 ++-- lib/attr.c | 10 +++++----- lib/genl/ctrl.c | 6 +++--- lib/genl/genl.c | 4 ++-- lib/msg.c | 4 ++-- lib/netfilter/ct.c | 14 +++++++------- lib/netfilter/log_msg.c | 2 +- lib/netfilter/queue_msg.c | 2 +- lib/route/addr.c | 2 +- lib/route/cls/basic.c | 2 +- lib/route/cls/cgroup.c | 2 +- lib/route/cls/ematch.c | 2 +- lib/route/cls/ematch/meta.c | 2 +- lib/route/cls/fw.c | 2 +- lib/route/cls/u32.c | 2 +- lib/route/link.c | 3 ++- lib/route/link/inet.c | 2 +- lib/route/link/inet6.c | 2 +- lib/route/link/vlan.c | 2 +- lib/route/neigh.c | 2 +- lib/route/neightbl.c | 2 +- lib/route/qdisc/cbq.c | 2 +- lib/route/qdisc/dsmark.c | 2 +- lib/route/qdisc/htb.c | 2 +- lib/route/qdisc/netem.c | 2 +- lib/route/qdisc/red.c | 2 +- lib/route/qdisc/tbf.c | 2 +- lib/route/route_obj.c | 2 +- lib/route/rule.c | 2 +- lib/route/tc.c | 6 +++--- 34 files changed, 55 insertions(+), 54 deletions(-) diff --git a/include/netlink-tc.h b/include/netlink-tc.h index 3e44642..d0f6dab 100644 --- a/include/netlink-tc.h +++ b/include/netlink-tc.h @@ -35,7 +35,7 @@ extern "C" { #define TCA_ATTR_MAX TCA_ATTR_LINKTYPE extern int tca_parse(struct nlattr **, int, struct rtnl_tc *, - struct nla_policy *); + const struct nla_policy *); #define RTNL_TC_RTABLE_SIZE 256 diff --git a/include/netlink/attr.h b/include/netlink/attr.h index 8479c23..4dc01fb 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -80,9 +80,9 @@ extern int nla_len(const struct nlattr *); extern int nla_ok(const struct nlattr *, int); extern struct nlattr * nla_next(const struct nlattr *, int *); extern int nla_parse(struct nlattr **, int, struct nlattr *, - int, struct nla_policy *); + int, const struct nla_policy *); extern int nla_validate(struct nlattr *, int, int, - struct nla_policy *); + const struct nla_policy *); extern struct nlattr * nla_find(struct nlattr *, int, int); /* Helper Functions */ @@ -125,7 +125,7 @@ extern int nla_put_nested(struct nl_msg *, int, struct nl_msg *); extern struct nlattr * nla_nest_start(struct nl_msg *, int); extern int nla_nest_end(struct nl_msg *, struct nlattr *); extern int nla_parse_nested(struct nlattr **, int, struct nlattr *, - struct nla_policy *); + const struct nla_policy *); /** * @name Attribute Construction (Exception Based) diff --git a/include/netlink/genl/genl.h b/include/netlink/genl/genl.h index 364a471..3c70d32 100644 --- a/include/netlink/genl/genl.h +++ b/include/netlink/genl/genl.h @@ -29,9 +29,9 @@ extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t, extern int genlmsg_valid_hdr(struct nlmsghdr *, int); extern int genlmsg_validate(struct nlmsghdr *, int, int, - struct nla_policy *); + const struct nla_policy *); extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **, - int, struct nla_policy *); + int, const struct nla_policy *); extern void * genlmsg_data(const struct genlmsghdr *); extern int genlmsg_len(const struct genlmsghdr *); extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int); diff --git a/include/netlink/genl/mngt.h b/include/netlink/genl/mngt.h index 8b0244f..c454571 100644 --- a/include/netlink/genl/mngt.h +++ b/include/netlink/genl/mngt.h @@ -56,7 +56,7 @@ struct genl_cmd /** * Attribute validation policy (optional) */ - struct nla_policy * c_attr_policy; + const struct nla_policy * c_attr_policy; }; /** diff --git a/include/netlink/msg.h b/include/netlink/msg.h index f3d50ae..bf88db5 100644 --- a/include/netlink/msg.h +++ b/include/netlink/msg.h @@ -64,10 +64,10 @@ extern int nlmsg_valid_hdr(const struct nlmsghdr *, int); extern int nlmsg_ok(const struct nlmsghdr *, int); extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *); extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **, - int, struct nla_policy *); + int, const struct nla_policy *); extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int); extern int nlmsg_validate(struct nlmsghdr *, int, int, - struct nla_policy *); + const struct nla_policy *); extern struct nl_msg * nlmsg_alloc(void); extern struct nl_msg * nlmsg_alloc_size(size_t); diff --git a/lib/attr.c b/lib/attr.c index a045351..4570061 100644 --- a/lib/attr.c +++ b/lib/attr.c @@ -525,9 +525,9 @@ static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = { }; static int validate_nla(struct nlattr *nla, int maxtype, - struct nla_policy *policy) + const struct nla_policy *policy) { - struct nla_policy *pt; + const struct nla_policy *pt; int minlen = 0, type = nla_type(nla); if (type <= 0 || type > maxtype) @@ -581,7 +581,7 @@ static int validate_nla(struct nlattr *nla, int maxtype, * @return 0 on success or a negative error code. */ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, - struct nla_policy *policy) + const struct nla_policy *policy) { struct nlattr *nla; int rem, err; @@ -634,7 +634,7 @@ errout: * @return 0 on success or a negative error code. */ int nla_validate(struct nlattr *head, int len, int maxtype, - struct nla_policy *policy) + const struct nla_policy *policy) { struct nlattr *nla; int rem, err; @@ -1203,7 +1203,7 @@ int nla_nest_end(struct nl_msg *msg, struct nlattr *start) * @return 0 on success or a negative error code. */ int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, - struct nla_policy *policy) + const struct nla_policy *policy) { return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy); } diff --git a/lib/genl/ctrl.c b/lib/genl/ctrl.c index 107a4fa..629a3a3 100644 --- a/lib/genl/ctrl.c +++ b/lib/genl/ctrl.c @@ -37,7 +37,7 @@ static int ctrl_request_update(struct nl_cache *c, struct nl_sock *h) CTRL_VERSION, NLM_F_DUMP); } -static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = { +static const struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = { [CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 }, [CTRL_ATTR_FAMILY_NAME] = { .type = NLA_STRING, .maxlen = GENL_NAMSIZ }, @@ -48,12 +48,12 @@ static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = { [CTRL_ATTR_MCAST_GROUPS] = { .type = NLA_NESTED }, }; -static struct nla_policy family_op_policy[CTRL_ATTR_OP_MAX+1] = { +static const struct nla_policy family_op_policy[CTRL_ATTR_OP_MAX+1] = { [CTRL_ATTR_OP_ID] = { .type = NLA_U32 }, [CTRL_ATTR_OP_FLAGS] = { .type = NLA_U32 }, }; -static struct nla_policy family_grp_policy[CTRL_ATTR_MCAST_GRP_MAX+1] = { +static const struct nla_policy family_grp_policy[CTRL_ATTR_MCAST_GRP_MAX+1] = { [CTRL_ATTR_MCAST_GRP_NAME] = { .type = NLA_STRING }, [CTRL_ATTR_MCAST_GRP_ID] = { .type = NLA_U32 }, }; diff --git a/lib/genl/genl.c b/lib/genl/genl.c index 055be91..2c50e75 100644 --- a/lib/genl/genl.c +++ b/lib/genl/genl.c @@ -158,7 +158,7 @@ int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen) } int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, - struct nla_policy *policy) + const struct nla_policy *policy) { struct genlmsghdr *ghdr; @@ -171,7 +171,7 @@ int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, } int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], - int maxtype, struct nla_policy *policy) + int maxtype, const struct nla_policy *policy) { struct genlmsghdr *ghdr; diff --git a/lib/msg.c b/lib/msg.c index 235ee82..2ecce22 100644 --- a/lib/msg.c +++ b/lib/msg.c @@ -343,7 +343,7 @@ struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining) * See nla_parse() */ int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], - int maxtype, struct nla_policy *policy) + int maxtype, const struct nla_policy *policy) { if (!nlmsg_valid_hdr(nlh, hdrlen)) return -NLE_MSG_TOOSHORT; @@ -374,7 +374,7 @@ struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype) * @arg policy validation policy */ int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, - struct nla_policy *policy) + const struct nla_policy *policy) { if (!nlmsg_valid_hdr(nlh, hdrlen)) return -NLE_MSG_TOOSHORT; diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 9d61b6c..a17b49d 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -42,7 +42,7 @@ static uint64_t ntohll(uint64_t x) } #endif -static struct nla_policy ct_policy[CTA_MAX+1] = { +static const struct nla_policy ct_policy[CTA_MAX+1] = { [CTA_TUPLE_ORIG] = { .type = NLA_NESTED }, [CTA_TUPLE_REPLY] = { .type = NLA_NESTED }, [CTA_STATUS] = { .type = NLA_U32 }, @@ -58,19 +58,19 @@ static struct nla_policy ct_policy[CTA_MAX+1] = { //[CTA_NAT_DST] }; -static struct nla_policy ct_tuple_policy[CTA_TUPLE_MAX+1] = { +static const struct nla_policy ct_tuple_policy[CTA_TUPLE_MAX+1] = { [CTA_TUPLE_IP] = { .type = NLA_NESTED }, [CTA_TUPLE_PROTO] = { .type = NLA_NESTED }, }; -static struct nla_policy ct_ip_policy[CTA_IP_MAX+1] = { +static const struct nla_policy ct_ip_policy[CTA_IP_MAX+1] = { [CTA_IP_V4_SRC] = { .type = NLA_U32 }, [CTA_IP_V4_DST] = { .type = NLA_U32 }, [CTA_IP_V6_SRC] = { .minlen = 16 }, [CTA_IP_V6_DST] = { .minlen = 16 }, }; -static struct nla_policy ct_proto_policy[CTA_PROTO_MAX+1] = { +static const struct nla_policy ct_proto_policy[CTA_PROTO_MAX+1] = { [CTA_PROTO_NUM] = { .type = NLA_U8 }, [CTA_PROTO_SRC_PORT] = { .type = NLA_U16 }, [CTA_PROTO_DST_PORT] = { .type = NLA_U16 }, @@ -82,11 +82,11 @@ static struct nla_policy ct_proto_policy[CTA_PROTO_MAX+1] = { [CTA_PROTO_ICMPV6_CODE] = { .type = NLA_U8 }, }; -static struct nla_policy ct_protoinfo_policy[CTA_PROTOINFO_MAX+1] = { +static const struct nla_policy ct_protoinfo_policy[CTA_PROTOINFO_MAX+1] = { [CTA_PROTOINFO_TCP] = { .type = NLA_NESTED }, }; -static struct nla_policy ct_protoinfo_tcp_policy[CTA_PROTOINFO_TCP_MAX+1] = { +static const struct nla_policy ct_protoinfo_tcp_policy[CTA_PROTOINFO_TCP_MAX+1] = { [CTA_PROTOINFO_TCP_STATE] = { .type = NLA_U8 }, [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL] = { .type = NLA_U8 }, [CTA_PROTOINFO_TCP_WSCALE_REPLY] = { .type = NLA_U8 }, @@ -95,7 +95,7 @@ static struct nla_policy ct_protoinfo_tcp_policy[CTA_PROTOINFO_TCP_MAX+1] = { }; -static struct nla_policy ct_counters_policy[CTA_COUNTERS_MAX+1] = { +static const struct nla_policy ct_counters_policy[CTA_COUNTERS_MAX+1] = { [CTA_COUNTERS_PACKETS] = { .type = NLA_U64 }, [CTA_COUNTERS_BYTES] = { .type = NLA_U64 }, [CTA_COUNTERS32_PACKETS]= { .type = NLA_U32 }, diff --git a/lib/netfilter/log_msg.c b/lib/netfilter/log_msg.c index cad6ddd..8591c84 100644 --- a/lib/netfilter/log_msg.c +++ b/lib/netfilter/log_msg.c @@ -39,7 +39,7 @@ static uint64_t ntohll(uint64_t x) } #endif -static struct nla_policy log_msg_policy[NFULA_MAX+1] = { +static const struct nla_policy log_msg_policy[NFULA_MAX+1] = { [NFULA_PACKET_HDR] = { .minlen = sizeof(struct nfulnl_msg_packet_hdr) }, diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c index c40f8c2..88010e9 100644 --- a/lib/netfilter/queue_msg.c +++ b/lib/netfilter/queue_msg.c @@ -39,7 +39,7 @@ static uint64_t ntohll(uint64_t x) } #endif -static struct nla_policy queue_policy[NFQA_MAX+1] = { +static const struct nla_policy queue_policy[NFQA_MAX+1] = { [NFQA_PACKET_HDR] = { .minlen = sizeof(struct nfqnl_msg_packet_hdr), }, diff --git a/lib/route/addr.c b/lib/route/addr.c index deb88ba..786424b 100644 --- a/lib/route/addr.c +++ b/lib/route/addr.c @@ -187,7 +187,7 @@ static int addr_clone(struct nl_object *_dst, struct nl_object *_src) return 0; } -static struct nla_policy addr_policy[IFA_MAX+1] = { +static const struct nla_policy addr_policy[IFA_MAX+1] = { [IFA_LABEL] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, [IFA_CACHEINFO] = { .minlen = sizeof(struct ifa_cacheinfo) }, diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c index 9d7710a..5f70344 100644 --- a/lib/route/cls/basic.c +++ b/lib/route/cls/basic.c @@ -42,7 +42,7 @@ struct rtnl_basic #define BASIC_ATTR_EMATCH 0x002 /** @endcond */ -static struct nla_policy basic_policy[TCA_BASIC_MAX+1] = { +static const struct nla_policy basic_policy[TCA_BASIC_MAX+1] = { [TCA_BASIC_CLASSID] = { .type = NLA_U32 }, [TCA_BASIC_EMATCHES] = { .type = NLA_NESTED }, }; diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c index 230863b..368d33b 100644 --- a/lib/route/cls/cgroup.c +++ b/lib/route/cls/cgroup.c @@ -30,7 +30,7 @@ #define CGROUP_ATTR_EMATCH 0x001 /** @endcond */ -static struct nla_policy cgroup_policy[TCA_CGROUP_MAX+1] = { +static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX+1] = { [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED }, }; diff --git a/lib/route/cls/ematch.c b/lib/route/cls/ematch.c index 8c9c3dd..62a0462 100644 --- a/lib/route/cls/ematch.c +++ b/lib/route/cls/ematch.c @@ -326,7 +326,7 @@ static int link_tree(struct rtnl_ematch *index[], int nmatches, int pos, return -NLE_INVAL; } -static struct nla_policy tree_policy[TCA_EMATCH_TREE_MAX+1] = { +static const struct nla_policy tree_policy[TCA_EMATCH_TREE_MAX+1] = { [TCA_EMATCH_TREE_HDR] = { .minlen=sizeof(struct tcf_ematch_tree_hdr) }, [TCA_EMATCH_TREE_LIST] = { .type = NLA_NESTED }, }; diff --git a/lib/route/cls/ematch/meta.c b/lib/route/cls/ematch/meta.c index 11f87d6..2fb4185 100644 --- a/lib/route/cls/ematch/meta.c +++ b/lib/route/cls/ematch/meta.c @@ -107,7 +107,7 @@ void rtnl_ematch_meta_set_operand(struct rtnl_ematch *e, uint8_t opnd) m->opnd = opnd; } -static struct nla_policy meta_policy[TCA_EM_META_MAX+1] = { +static const struct nla_policy meta_policy[TCA_EM_META_MAX+1] = { [TCA_EM_META_HDR] = { .minlen = sizeof(struct tcf_meta_hdr) }, [TCA_EM_META_LVALUE] = { .minlen = 1, }, [TCA_EM_META_RVALUE] = { .minlen = 1, }, diff --git a/lib/route/cls/fw.c b/lib/route/cls/fw.c index 11c9c67..719c097 100644 --- a/lib/route/cls/fw.c +++ b/lib/route/cls/fw.c @@ -32,7 +32,7 @@ #define FW_ATTR_INDEV 0x008 /** @endcond */ -static struct nla_policy fw_policy[TCA_FW_MAX+1] = { +static const struct nla_policy fw_policy[TCA_FW_MAX+1] = { [TCA_FW_CLASSID] = { .type = NLA_U32 }, [TCA_FW_INDEV] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index 2016460..b2f1eac 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -52,7 +52,7 @@ static inline struct tc_u32_sel *u32_selector_alloc(struct rtnl_u32 *u) return u32_selector(u); } -static struct nla_policy u32_policy[TCA_U32_MAX+1] = { +static const struct nla_policy u32_policy[TCA_U32_MAX+1] = { [TCA_U32_DIVISOR] = { .type = NLA_U32 }, [TCA_U32_HASH] = { .type = NLA_U32 }, [TCA_U32_CLASSID] = { .type = NLA_U32 }, diff --git a/lib/route/link.c b/lib/route/link.c index 4da40a0..67a38eb 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -235,6 +235,7 @@ static int link_clone(struct nl_object *_dst, struct nl_object *_src) return 0; } +/* IFLA_PROTINFO data type is dynamic and depend on ifi_family */ static struct nla_policy link_policy[IFLA_MAX+1] = { [IFLA_IFNAME] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, @@ -256,7 +257,7 @@ static struct nla_policy link_policy[IFLA_MAX+1] = { [IFLA_AF_SPEC] = { .type = NLA_NESTED }, }; -static struct nla_policy link_info_policy[IFLA_INFO_MAX+1] = { +static const struct nla_policy link_info_policy[IFLA_INFO_MAX+1] = { [IFLA_INFO_KIND] = { .type = NLA_STRING }, [IFLA_INFO_DATA] = { .type = NLA_NESTED }, [IFLA_INFO_XSTATS] = { .type = NLA_NESTED }, diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c index a0e2318..a5ded7d 100644 --- a/lib/route/link/inet.c +++ b/lib/route/link/inet.c @@ -91,7 +91,7 @@ static void inet_free(struct rtnl_link *link, void *data) free(data); } -static struct nla_policy inet_policy[IFLA_INET6_MAX+1] = { +static const struct nla_policy inet_policy[IFLA_INET6_MAX+1] = { [IFLA_INET_CONF] = { .minlen = IPV4_DEVCONF_MAX * 4 }, }; diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c index 5f75342..7181a78 100644 --- a/lib/route/link/inet6.c +++ b/lib/route/link/inet6.c @@ -42,7 +42,7 @@ static void inet6_free(struct rtnl_link *link, void *data) free(data); } -static struct nla_policy inet6_policy[IFLA_INET6_MAX+1] = { +static const struct nla_policy inet6_policy[IFLA_INET6_MAX+1] = { [IFLA_INET6_FLAGS] = { .type = NLA_U32 }, [IFLA_INET6_CACHEINFO] = { .minlen = sizeof(struct ifla_cacheinfo) }, [IFLA_INET6_CONF] = { .minlen = DEVCONF_MAX * 4 }, diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index a30ff77..2a763b1 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -53,7 +53,7 @@ struct vlan_info /** @endcond */ -static struct nla_policy vlan_policy[IFLA_VLAN_MAX+1] = { +static const struct nla_policy vlan_policy[IFLA_VLAN_MAX+1] = { [IFLA_VLAN_ID] = { .type = NLA_U16 }, [IFLA_VLAN_FLAGS] = { .minlen = sizeof(struct ifla_vlan_flags) }, [IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED }, diff --git a/lib/route/neigh.c b/lib/route/neigh.c index 7985d34..200ecc0 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -245,7 +245,7 @@ static char *neigh_attrs2str(int attrs, char *buf, size_t len) ARRAY_SIZE(neigh_attrs)); } -static struct nla_policy neigh_policy[NDA_MAX+1] = { +static const struct nla_policy neigh_policy[NDA_MAX+1] = { [NDA_CACHEINFO] = { .minlen = sizeof(struct nda_cacheinfo) }, [NDA_PROBES] = { .type = NLA_U32 }, }; diff --git a/lib/route/neightbl.c b/lib/route/neightbl.c index 9599faa..0ac7b09 100644 --- a/lib/route/neightbl.c +++ b/lib/route/neightbl.c @@ -106,7 +106,7 @@ static int neightbl_compare(struct nl_object *_a, struct nl_object *_b, } -static struct nla_policy neightbl_policy[NDTA_MAX+1] = { +static const struct nla_policy neightbl_policy[NDTA_MAX+1] = { [NDTA_NAME] = { .type = NLA_STRING, .maxlen = NTBLNAMSIZ }, [NDTA_THRESH1] = { .type = NLA_U32 }, diff --git a/lib/route/qdisc/cbq.c b/lib/route/qdisc/cbq.c index e791a10..45c2856 100644 --- a/lib/route/qdisc/cbq.c +++ b/lib/route/qdisc/cbq.c @@ -63,7 +63,7 @@ int nl_str2ovl_strategy(const char *name) return __str2type(name, ovl_strategies, ARRAY_SIZE(ovl_strategies)); } -static struct nla_policy cbq_policy[TCA_CBQ_MAX+1] = { +static const struct nla_policy cbq_policy[TCA_CBQ_MAX+1] = { [TCA_CBQ_LSSOPT] = { .minlen = sizeof(struct tc_cbq_lssopt) }, [TCA_CBQ_RATE] = { .minlen = sizeof(struct tc_ratespec) }, [TCA_CBQ_WRROPT] = { .minlen = sizeof(struct tc_cbq_wrropt) }, diff --git a/lib/route/qdisc/dsmark.c b/lib/route/qdisc/dsmark.c index b5fd0d6..31fa647 100644 --- a/lib/route/qdisc/dsmark.c +++ b/lib/route/qdisc/dsmark.c @@ -34,7 +34,7 @@ #define SCH_DSMARK_ATTR_VALUE 0x2 /** @endcond */ -static struct nla_policy dsmark_policy[TCA_DSMARK_MAX+1] = { +static const struct nla_policy dsmark_policy[TCA_DSMARK_MAX+1] = { [TCA_DSMARK_INDICES] = { .type = NLA_U16 }, [TCA_DSMARK_DEFAULT_INDEX] = { .type = NLA_U16 }, [TCA_DSMARK_SET_TC_INDEX] = { .type = NLA_FLAG }, diff --git a/lib/route/qdisc/htb.c b/lib/route/qdisc/htb.c index f1d0e75..f380d50 100644 --- a/lib/route/qdisc/htb.c +++ b/lib/route/qdisc/htb.c @@ -42,7 +42,7 @@ #define SCH_HTB_HAS_LEVEL 0x040 /** @endcond */ -static struct nla_policy htb_policy[TCA_HTB_MAX+1] = { +static const struct nla_policy htb_policy[TCA_HTB_MAX+1] = { [TCA_HTB_INIT] = { .minlen = sizeof(struct tc_htb_glob) }, [TCA_HTB_PARMS] = { .minlen = sizeof(struct tc_htb_opt) }, }; diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c index 997a31f..5748b4f 100644 --- a/lib/route/qdisc/netem.c +++ b/lib/route/qdisc/netem.c @@ -43,7 +43,7 @@ #define SCH_NETEM_ATTR_DIST 0x2000 /** @endcond */ -static struct nla_policy netem_policy[TCA_NETEM_MAX+1] = { +static const struct nla_policy netem_policy[TCA_NETEM_MAX+1] = { [TCA_NETEM_CORR] = { .minlen = sizeof(struct tc_netem_corr) }, [TCA_NETEM_REORDER] = { .minlen = sizeof(struct tc_netem_reorder) }, [TCA_NETEM_CORRUPT] = { .minlen = sizeof(struct tc_netem_corrupt) }, diff --git a/lib/route/qdisc/red.c b/lib/route/qdisc/red.c index 0480282..d580c05 100644 --- a/lib/route/qdisc/red.c +++ b/lib/route/qdisc/red.c @@ -34,7 +34,7 @@ #define RED_ATTR_SCELL_LOG 0x40 /** @endcond */ -static struct nla_policy red_policy[TCA_RED_MAX+1] = { +static const struct nla_policy red_policy[TCA_RED_MAX+1] = { [TCA_RED_PARMS] = { .minlen = sizeof(struct tc_red_qopt) }, }; diff --git a/lib/route/qdisc/tbf.c b/lib/route/qdisc/tbf.c index 8a6c400..5e08e43 100644 --- a/lib/route/qdisc/tbf.c +++ b/lib/route/qdisc/tbf.c @@ -32,7 +32,7 @@ #define TBF_ATTR_PEAKRATE 0x10 /** @endcond */ -static struct nla_policy tbf_policy[TCA_TBF_MAX+1] = { +static const struct nla_policy tbf_policy[TCA_TBF_MAX+1] = { [TCA_TBF_PARMS] = { .minlen = sizeof(struct tc_tbf_qopt) }, }; diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index d322633..d2af87f 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -779,7 +779,7 @@ int rtnl_route_guess_scope(struct rtnl_route *route) /** @} */ -static struct nla_policy route_policy[RTA_MAX+1] = { +static const struct nla_policy route_policy[RTA_MAX+1] = { [RTA_IIF] = { .type = NLA_U32 }, [RTA_OIF] = { .type = NLA_U32 }, [RTA_PRIORITY] = { .type = NLA_U32 }, diff --git a/lib/route/rule.c b/lib/route/rule.c index 1a695cd..e2dd854 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -70,7 +70,7 @@ static int rule_clone(struct nl_object *_dst, struct nl_object *_src) return 0; } -static struct nla_policy rule_policy[FRA_MAX+1] = { +static const struct nla_policy rule_policy[FRA_MAX+1] = { [FRA_TABLE] = { .type = NLA_U32 }, [FRA_IIFNAME] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, [FRA_OIFNAME] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, diff --git a/lib/route/tc.c b/lib/route/tc.c index 6826a05..e0eb135 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -29,7 +29,7 @@ static struct nl_list_head tc_ops_list[__RTNL_TC_TYPE_MAX]; static struct rtnl_tc_type_ops *tc_type_ops[__RTNL_TC_TYPE_MAX]; -static struct nla_policy tc_policy[TCA_MAX+1] = { +static const struct nla_policy tc_policy[TCA_MAX+1] = { [TCA_KIND] = { .type = NLA_STRING, .maxlen = TCKINDSIZ }, [TCA_STATS] = { .minlen = sizeof(struct tc_stats) }, @@ -37,7 +37,7 @@ static struct nla_policy tc_policy[TCA_MAX+1] = { }; int tca_parse(struct nlattr **tb, int maxattr, struct rtnl_tc *g, - struct nla_policy *policy) + const struct nla_policy *policy) { if (g->ce_mask & TCA_ATTR_OPTS) @@ -52,7 +52,7 @@ int tca_parse(struct nlattr **tb, int maxattr, struct rtnl_tc *g, } } -static struct nla_policy tc_stats2_policy[TCA_STATS_MAX+1] = { +static const struct nla_policy tc_stats2_policy[TCA_STATS_MAX+1] = { [TCA_STATS_BASIC] = { .minlen = sizeof(struct gnet_stats_basic) }, [TCA_STATS_RATE_EST] = { .minlen = sizeof(struct gnet_stats_rate_est) }, [TCA_STATS_QUEUE] = { .minlen = sizeof(struct gnet_stats_queue) }, -- 1.7.4.1